1 package net.suberic.util.gui.propedit; 2 import javax.swing.*; 3 import net.suberic.util.*; 4 import net.suberic.util.gui.IconManager; 5 import java.util.*; 6 import java.awt.Container ; 7 import java.awt.Component ; 8 import javax.help.HelpBroker; 9 10 13 public class DesktopPropertyEditorFactory extends PropertyEditorFactory { 14 JDesktopPane desktop; 15 16 20 public DesktopPropertyEditorFactory(VariableBundle bundle, JDesktopPane newDesktop, IconManager manager, HelpBroker broker) { 21 super(bundle, manager, broker); 22 desktop = newDesktop; 23 } 24 25 29 public DesktopPropertyEditorFactory(VariableBundle bundle, IconManager manager, HelpBroker broker) { 30 this(bundle, null, manager, broker); 31 } 32 33 36 public JDesktopPane getDesktop() { 37 return desktop; 38 } 39 40 43 public void setDesktop(JDesktopPane newDesktop) { 44 desktop = newDesktop; 45 } 46 47 50 public void showError(Object component, String errorMessage) { 51 JOptionPane.showInternalMessageDialog(desktop, errorMessage); 52 } 53 54 57 public String showInputDialog(SwingPropertyEditor dpe, String query) { 58 return JOptionPane.showInternalInputDialog(desktop, query); 59 } 60 61 64 public void showNewEditorWindow(String title, PropertyEditorUI editor, Container window) { 65 JInternalFrame jif = (JInternalFrame) createEditorWindow(title, editor, window); 66 67 jif.setSize(jif.getPreferredSize()); 69 if (window != null && window instanceof JInternalFrame) { 70 jif.setLocation(Math.max(0, ((window.getWidth() - jif.getWidth()) / 2) + window.getX()), Math.max(0, ((window.getHeight() - jif.getHeight()) / 2) + window.getY())); 71 } 72 desktop.add(jif); 73 jif.setVisible(true); 74 try { 75 jif.setSelected(true); 76 } catch (java.beans.PropertyVetoException pve) { 77 } 78 } 79 80 public void showNewEditorWindow(String title, String property, String template, String propertyBase, PropertyEditorManager mgr, Container window) { 81 JInternalFrame jif = (JInternalFrame) createEditorWindow(title, property, template, propertyBase, mgr, window); 82 jif.setSize(jif.getPreferredSize()); 84 if (window != null && window instanceof JInternalFrame) { 85 jif.setLocation(Math.max(0, ((window.getWidth() - jif.getWidth()) / 2) + window.getX()), Math.max(0, ((window.getHeight() - jif.getHeight()) / 2) + window.getY())); 86 } 87 desktop.add(jif); 88 jif.setVisible(true); 89 try { 90 jif.setSelected(true); 91 } catch (java.beans.PropertyVetoException pve) { 92 } 93 } 94 95 101 public Container createEditorWindow(String title, PropertyEditorUI editor, Container window) { 102 JInternalFrame jif = new JInternalFrame(title, true, true); 103 PropertyEditorPane pep = createPropertyEditorPane(editor.getManager(), (SwingPropertyEditor) editor, jif); 104 jif.getContentPane().add(pep); 105 jif.pack(); 106 jif.setSize(jif.getPreferredSize()); 107 return jif; 108 } 109 110 } 111 | Popular Tags |