|
What this is
This file is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn
Java by Example" TM.
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.core.windows;
import org.netbeans.core.IDESettings;
import org.openide.util.WeakListeners;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
/** XXX This class is a bridge to manage consistent value for uiMode
* property in older core settings IDESettings .
* If possible, remove the dependency, i.e. provide another way of UI to set the
* ui mode, not dependent on core module.
*
* @author Peter Zavadsky
*/
final class UIModeHandler implements PropertyChangeListener {
/** Flag to ignore the event changes. Those are caused by our changes. */
private boolean ignore;
/** Creates a new instance of UIModeHandler */
public UIModeHandler() {
IDESettings ideSettings = (IDESettings)IDESettings.findObject(IDESettings.class, true);
ideSettings.addPropertyChangeListener(WeakListeners.propertyChange(this, ideSettings));
}
public void propertyChange(PropertyChangeEvent evt) {
if(ignore) {
return;
}
if(IDESettings.PROP_UIMODE.equals(evt.getPropertyName())) {
IDESettings ideSettings = (IDESettings)IDESettings.findObject(IDESettings.class, true);
int uiMode = ideSettings.getUIMode();
final int editorAreaState;
// Translate the older values.
if(uiMode == 1) {
editorAreaState = Constants.EDITOR_AREA_SEPARATED;
} else if(uiMode == 2) {
editorAreaState = Constants.EDITOR_AREA_JOINED;
} else {
return;
}
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
WindowManagerImpl.getInstance().setEditorAreaStateImpl(editorAreaState);
}
});
}
}
public void setUIMode(int editorAreaState) {
int uiMode;
// Translate editorAreaState to uiMode.
if(editorAreaState == Constants.EDITOR_AREA_JOINED) {
uiMode = 2;
} else if(editorAreaState == Constants.EDITOR_AREA_SEPARATED) {
uiMode = 1;
} else {
return;
}
IDESettings ideSettings = (IDESettings)IDESettings.findObject(IDESettings.class, true);
try {
ignore = true;
ideSettings.setUIMode(uiMode);
} finally {
ignore = false;
}
}
}
|