001: package net.suberic.util.gui.propedit;
002:
003: import javax.swing.*;
004: import net.suberic.util.*;
005: import java.util.*;
006: import java.awt.Container;
007: import java.awt.Component;
008:
009: /**
010: * A factory which can be used to create PropertyEditorUI's.
011: */
012: public class DesktopPropertyEditorFactory extends PropertyEditorFactory {
013: JDesktopPane desktop;
014:
015: /**
016: * Creates a PropertyEditorFactory using the given VariableBundle as
017: * a source.
018: */
019: public DesktopPropertyEditorFactory(VariableBundle bundle,
020: JDesktopPane newDesktop) {
021: super (bundle);
022: desktop = newDesktop;
023: }
024:
025: /**
026: * Creates a PropertyEditorFactory using the given VariableBundle as
027: * a source.
028: */
029: public DesktopPropertyEditorFactory(VariableBundle bundle) {
030: super (bundle);
031: }
032:
033: /**
034: * Returns the desktop.
035: */
036: public JDesktopPane getDesktop() {
037: return desktop;
038: }
039:
040: /**
041: * Sets the desktop.
042: */
043: public void setDesktop(JDesktopPane newDesktop) {
044: desktop = newDesktop;
045: }
046:
047: /**
048: * Shows an error message.
049: */
050: public void showError(Object component, String errorMessage) {
051: JOptionPane.showInternalMessageDialog(desktop, errorMessage);
052: }
053:
054: /**
055: * Shows an input dialog.
056: */
057: public String showInputDialog(SwingPropertyEditor dpe, String query) {
058: return JOptionPane.showInternalInputDialog(desktop, query);
059: }
060:
061: /**
062: * Creates and displays an editor window.
063: */
064: public void showNewEditorWindow(String title, List properties,
065: List templates, PropertyEditorManager mgr) {
066: JInternalFrame jif = (JInternalFrame) createEditorWindow(title,
067: properties, templates, mgr);
068: desktop.add(jif);
069: jif.setVisible(true);
070: try {
071: jif.setSelected(true);
072: } catch (java.beans.PropertyVetoException pve) {
073: }
074: }
075:
076: /**
077: * Creates and displays an editor window.
078: */
079: public void showNewEditorWindow(String title,
080: PropertyEditorUI editor) {
081: JInternalFrame jif = new JInternalFrame(title, true, false,
082: false, false);
083: jif.getContentPane().add(
084: new PropertyEditorPane(editor.getManager(),
085: (SwingPropertyEditor) editor, jif));
086:
087: jif.pack();
088: desktop.add(jif);
089: jif.setVisible(true);
090: try {
091: jif.setSelected(true);
092: } catch (java.beans.PropertyVetoException pve) {
093: }
094: }
095:
096: /**
097: * This method returns an EditorWindow (a JFrame in this
098: * implementation) which has an editor for each property in the
099: * properties Vector. The title string is the title of the
100: * JInternalFrame.
101: */
102: public Container createEditorWindow(String title, List properties,
103: List templates, PropertyEditorManager mgr) {
104: JInternalFrame jif = new JInternalFrame(title, true, false,
105: false, false);
106: PropertyEditorPane pep = new PropertyEditorPane(mgr,
107: properties, templates, jif);
108: jif.getContentPane().add(pep);
109: jif.setSize(100, 100);
110: jif.pack();
111: return jif;
112: }
113:
114: }
|