All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hjug.dtangler.swingui.textinput.impl.TextInputGlue Maven / Gradle / Ivy

The newest version!
//This product is provided under the terms of EPL (Eclipse Public License) 
//version 2.0.
//
//The full license text can be read from: https://www.eclipse.org/legal/epl-2.0/

package org.hjug.dtangler.swingui.textinput.impl;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.hjug.dtangler.swingui.actionfactory.ActionFactory;
import org.hjug.dtangler.swingui.textinput.impl.TextInputView.Actions;
import org.hjug.dtangler.swingui.windowmanager.SwingView;
import org.hjug.dtangler.swingui.windowmanager.WindowManager;

public class TextInputGlue {

	private final TextInputPresenter presenter;
	private final ActionFactory actionFactory;

	public TextInputGlue(ActionFactory actionFactory,
			final TextInputPresenter presenter, final SwingView view,
			final WindowManager windowManager) {
		this.actionFactory = actionFactory;
		this.presenter = presenter;
		updateActionStates();

		actionFactory.setImplementation(Actions.ok, e -> {
            presenter.onOk();
            windowManager.close(view);
        });

		actionFactory.setImplementation(Actions.cancel, e -> windowManager.close(view));

		actionFactory.setImplementation(Actions.updateActionStates,
				e -> updateActionStates());

	}

	private void updateActionStates() {
		actionFactory.setEnabled(Actions.ok, presenter.canOk());
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy