001: /*
002: * $RCSfile: PreferencesAction.java,v $
003: * @modification $Date: 2002/12/16 13:23:45 $
004: * @version $Id: PreferencesAction.java,v 1.2 2002/12/16 13:23:45 deniger Exp $
005: *
006: */
007:
008: package com.memoire.vainstall.builder.action;
009:
010: import com.memoire.vainstall.builder.gui.PreferencesFrame;
011: import com.memoire.vainstall.builder.util.*;
012:
013: import java.awt.Rectangle;
014: import java.awt.event.*;
015:
016: import javax.swing.*;
017:
018: /**
019: * This action shows a preferences dialog.
020: *
021: * @see com.memoire.vainstall.builder.util.AbstractVAIBuilderAction
022: * @see java.awt.event.WindowListener
023: *
024: * @author Henrik Falk
025: * @version $Id: PreferencesAction.java,v 1.2 2002/12/16 13:23:45 deniger Exp $
026: */
027: public class PreferencesAction extends AbstractVAIBuilderAction
028: implements WindowListener {
029:
030: /**
031: * We keep a reference to the window to have only one opened window
032: * and keep track of the window bounds
033: */
034: PreferencesFrame preferences;
035:
036: /**
037: * Default constructor
038: */
039: public PreferencesAction() {
040: super ();
041: }
042:
043: /**
044: * Implements the runnit method which show the Preferences window
045: */
046: public void runnit() {
047:
048: // if show before then restore window and show it
049: if (preferences != null) {
050: // preferences.setExtendedState(JFrame.NORMAL);
051: preferences.setVisible(true);
052: return;
053: }
054:
055: // create window and listen to windowDeactivated()
056: preferences = new PreferencesFrame();
057: preferences.addWindowListener(this );
058:
059: // set bounds from properties
060: if (getModel().getWindowList().get("PreferencesFrame") == null) {
061: preferences.center();
062: } else {
063: preferences.setBounds((Rectangle) getModel()
064: .getWindowList().get("PreferencesFrame"));
065: }
066:
067: // create nodes for tree in window
068: PreferencesBaseNode root = new PreferencesBaseNode();
069: root.initialize(getController());
070:
071: PreferencesProjectNode preferencesProjectNode = new PreferencesProjectNode();
072: preferencesProjectNode.initialize(getController());
073: root.add(preferencesProjectNode);
074:
075: preferences.setNode(root);
076:
077: preferences.setVisible(true);
078:
079: }
080:
081: /**
082: * Method to handle events for the WindowListener interface.
083: * @param e java.awt.event.WindowEvent
084: */
085: public void windowActivated(java.awt.event.WindowEvent e) {
086: }
087:
088: /**
089: * Method to handle events for the WindowListener interface.
090: * @param e java.awt.event.WindowEvent
091: */
092: public void windowClosed(java.awt.event.WindowEvent e) {
093: }
094:
095: /**
096: * Method to handle events for the WindowListener interface.
097: * @param e java.awt.event.WindowEvent
098: */
099: public void windowClosing(java.awt.event.WindowEvent e) {
100: }
101:
102: /**
103: * Method to handle events for the WindowListener interface.
104: * @param e java.awt.event.WindowEvent
105: */
106: public void windowDeactivated(java.awt.event.WindowEvent e) {
107: getModel().getWindowList().put("PreferencesFrame",
108: preferences.getBounds());
109: }
110:
111: /**
112: * Method to handle events for the WindowListener interface.
113: * @param e java.awt.event.WindowEvent
114: */
115: public void windowDeiconified(java.awt.event.WindowEvent e) {
116: }
117:
118: /**
119: * Method to handle events for the WindowListener interface.
120: * @param e java.awt.event.WindowEvent
121: */
122: public void windowIconified(java.awt.event.WindowEvent e) {
123: }
124:
125: /**
126: * Method to handle events for the WindowListener interface.
127: * @param e java.awt.event.WindowEvent
128: */
129: public void windowOpened(java.awt.event.WindowEvent e) {
130: }
131:
132: }
|