ConflictsPreventer.java 1.54 KB
package osp.ui;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
 * Enabling / Disabling menu options or components 
 * @author JMG
 *
 */
public class ConflictsPreventer extends WindowAdapter {


	private OSPE_VisuPanel visuPanel;
	private OSPE_SelectPanel selectPanel;
	private OspeMenuBar menuBar;
	private OSPE_BrowserToolBar toolBar;

	public ConflictsPreventer(OSPE_VisuPanel visuPanel, OSPE_SelectPanel selectPanel,
			OspeMenuBar menuBar, OSPE_BrowserToolBar toolBar) {
		this.visuPanel = visuPanel;
		this.selectPanel = selectPanel;
		this.menuBar = menuBar;
		this.toolBar = toolBar;
		
	}
	
	@Override
	public void windowOpened(WindowEvent e) {
		visuPanel.searchButton.setEnabled(false);
		visuPanel.validateButton.setEnabled(false);
		visuPanel.writeButton.setEnabled(false);

		for (int i = 0; i < toolBar.getComponentCount() - 1; i++)
			toolBar.getComponent(i).setEnabled(false);
		for (int i = 0; i < menuBar.getComponentCount() - 1; i++)
			menuBar.getComponent(i).setEnabled(false);
		selectPanel.getFovTree().setEnabled(false);
		visuPanel.updateByHand();
	}

	@Override
	public void windowClosed(WindowEvent e) {
		visuPanel.searchButton.setEnabled(true);
		visuPanel.validateButton.setEnabled(true);
		visuPanel.writeButton.setEnabled(true);

		for (int i = 0; i < toolBar.getComponentCount() - 1; i++)
			toolBar.getComponent(i).setEnabled(true);
		for (int i = 0; i < menuBar.getComponentCount() - 1; i++)
			menuBar.getComponent(i).setEnabled(true);
		selectPanel.getFovTree().setEnabled(true);
		visuPanel.updateByHand();
	}
}