svn commit: r17109 - trunk/src/argouml-app/src/org/argouml: application notation/ui ui

Tom Morris <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2009-04-13 11:44:21-0700
New Revision: 17109

Modified:
   trunk/src/argouml-app/src/org/argouml/application/SubsystemUtility.java
   trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java
   trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java
   trunk/src/argouml-app/src/org/argouml/ui/SettingsDialog.java
   trunk/src/argouml-app/src/org/argouml/ui/SettingsTabAppearance.java
   trunk/src/argouml-app/src/org/argouml/ui/SettingsTabEnvironment.java
   trunk/src/argouml-app/src/org/argouml/ui/SettingsTabPreferences.java
   trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java
   trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java

Log:
Issue 5409: Refactor to defer dialog construction until used

Modified: trunk/src/argouml-app/src/org/argouml/application/SubsystemUtility.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/application/SubsystemUtility.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/application/SubsystemUtility.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/application/SubsystemUtility.java	2009-04-13 11:44:21-0700
@@ -48,9 +48,11 @@
     static void initSubsystem(InitSubsystem subsystem) {
         subsystem.init();
         for (GUISettingsTabInterface tab : subsystem.getSettingsTabs()) {
+            // TODO: This work should be deferred until actually needed for display
             GUI.getInstance().addSettingsTab(tab);
         }
         for (GUISettingsTabInterface tab : subsystem.getProjectSettingsTabs()) {
+            // TODO: This work should be deferred until actually needed for display
             GUI.getInstance().addProjectSettingsTab(tab);
         }
         for (AbstractArgoJPanel tab : subsystem.getDetailsTabs()) {

Modified: trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java	2009-04-13 11:44:21-0700
@@ -67,6 +67,7 @@
     extends JPanel
     implements GUIProjectSettingsTabInterface {
 
+    private JPanel topPanel;
     private JComboBox notationLanguage;
     private JCheckBox useGuillemots;
     private JCheckBox showAssociationNames;
@@ -91,12 +92,15 @@
     public SettingsTabNotation(int settingsScope) {
         super();
         scope = settingsScope;
+    }
+
+    private void buildPanel() {
         setLayout(new BorderLayout());
 
-        JPanel top = new JPanel();
-        top.setLayout(new BorderLayout());
+        topPanel = new JPanel();
+        topPanel.setLayout(new BorderLayout());
 
-        if (settingsScope == Argo.SCOPE_APPLICATION) {
+        if (scope == Argo.SCOPE_APPLICATION) {
             JPanel warning = new JPanel();
             warning.setLayout(new BoxLayout(warning, BoxLayout.PAGE_AXIS));
             JLabel warningLabel = new JLabel(Translator
@@ -112,7 +116,7 @@
             projectSettings.setAlignmentX(Component.RIGHT_ALIGNMENT);
             warning.add(projectSettings);
 
-            top.add(warning, BorderLayout.NORTH);
+            topPanel.add(warning, BorderLayout.NORTH);
         }
 
         JPanel settings = new JPanel();
@@ -172,9 +176,9 @@
             createCheckBox("label.show-singular-multiplicities");
         settings.add(showSingularMultiplicities, constraints);
 
-        top.add(settings, BorderLayout.CENTER);
+        topPanel.add(settings, BorderLayout.CENTER);
 
-        add(top, BorderLayout.NORTH);
+        add(topPanel, BorderLayout.NORTH);
     }
 
     /*
@@ -273,7 +277,9 @@
             ProjectSettings ps = p.getProjectSettings();
             NotationSettings ns = ps.getNotationSettings();
             NotationName nn = (NotationName) notationLanguage.getSelectedItem();
-            if (nn != null) ps.setNotationLanguage(nn.getConfigurationValue());
+            if (nn != null) {
+                ps.setNotationLanguage(nn.getConfigurationValue());
+            }
             ps.setUseGuillemots(useGuillemots.isSelected());
             ns.setShowAssociationNames(showAssociationNames.isSelected());
             ns.setShowVisibilities(showVisibility.isSelected());
@@ -324,12 +330,19 @@
     /*
      * @see org.argouml.ui.GUISettingsTabInterface#getTabKey()
      */
-    public String getTabKey() { return "tab.notation"; }
+    public String getTabKey() {
+        return "tab.notation";
+    }
 
     /*
      * @see org.argouml.ui.GUISettingsTabInterface#getTabPanel()
      */
-    public JPanel getTabPanel() { return this; }
+    public JPanel getTabPanel() {
+        if (topPanel == null) {
+            buildPanel();
+        }
+        return this;
+    }
 
     /**
      * Create a localized JCheckBox.

Modified: trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java	2009-04-13 11:44:21-0700
@@ -70,19 +70,17 @@
 
     private Project p;
 
-    private JButton loadFromFile = new JButton(Translator
-            .localize("tab.profiles.userdefined.load"));
+    private JButton loadFromFile;
 
-    private JButton unregisterProfile = new JButton(Translator
-            .localize("tab.profiles.userdefined.unload"));
+    private JButton unregisterProfile;
 
-    private JButton addButton = new JButton(">>");
+    private JButton addButton;
 
-    private JButton removeButton = new JButton("<<");
+    private JButton removeButton;
 
-    private JList availableList = new JList();
+    private JList availableList;
 
-    private JList usedList = new JList();
+    private JList usedList;
 
     // //////
 
@@ -92,10 +90,18 @@
 
     private JComboBox stereoField = new JComboBox();
 
+    private JFileChooser fileChooser;
+
+    private boolean initialized = false;
+    
     /**
      * The default constructor for this class
      */
     public ProjectSettingsTabProfile() {
+        // Defer all work until we're actually needed
+    }
+
+    private void buildDialog() {
         setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
 
         // ////////////
@@ -159,11 +165,8 @@
         JPanel configPanel = new JPanel();
         configPanel.setLayout(new BoxLayout(configPanel, BoxLayout.X_AXIS));
 
-        availableList.setPrototypeCellValue("12345678901234567890");
-        usedList.setPrototypeCellValue("12345678901234567890");
-
-        availableList.setMinimumSize(new Dimension(50, 50));
-        usedList.setMinimumSize(new Dimension(50, 50));
+        availableList = createProfileList();
+        usedList = createProfileList();
 
         JPanel leftList = new JPanel();
         leftList.setLayout(new BorderLayout());
@@ -175,7 +178,10 @@
 
         JPanel centerButtons = new JPanel();
         centerButtons.setLayout(new BoxLayout(centerButtons, BoxLayout.Y_AXIS));
+
+        addButton = new JButton(">>");
         centerButtons.add(addButton);
+        removeButton = new JButton("<<");
         centerButtons.add(removeButton);
         configPanel.add(centerButtons);
 
@@ -187,6 +193,7 @@
         rightList.add(new JScrollPane(usedList), BorderLayout.CENTER);
         configPanel.add(rightList);
 
+
         addButton.addActionListener(this);
         removeButton.addActionListener(this);
 
@@ -194,15 +201,37 @@
 
         JPanel lffPanel = new JPanel();
         lffPanel.setLayout(new FlowLayout());
-        lffPanel.add(unregisterProfile);
-        lffPanel.add(loadFromFile);
 
+        loadFromFile = new JButton(Translator
+                .localize("tab.profiles.userdefined.load"));
         loadFromFile.addActionListener(this);
+        lffPanel.add(loadFromFile);
+
+        unregisterProfile = new JButton(Translator
+                .localize("tab.profiles.userdefined.unload"));
         unregisterProfile.addActionListener(this);
+        lffPanel.add(unregisterProfile);
 
         add(lffPanel);
+        
+        initialized = true;
+    }
+    
+   
+    @Override
+    public void setVisible(boolean flag) {
+        if (flag && !initialized) {
+            buildDialog();
+        }
+        super.setVisible(flag);
+    }
+    
+    private JList createProfileList() {
+        JList list = new JList();
+        list.setPrototypeCellValue("12345678901234567890");
+        list.setMinimumSize(new Dimension(50, 50));
+        return list;
     }
-
     private void refreshLists() {
         availableList.setModel(new DefaultComboBoxModel(getAvailableProfiles()
                 .toArray()));
@@ -309,29 +338,12 @@
                 }
             }
         } else if (arg0.getSource() == loadFromFile) {
-            JFileChooser fileChooser = new JFileChooser();
-            fileChooser.setFileFilter(new FileFilter() {
-
-                public boolean accept(File file) {
-                    return file.isDirectory()
-                            || (file.isFile() && (file.getName().endsWith(
-                                    ".xmi")
-                                    || file.getName().endsWith(".xml")
-                                    || file.getName().toLowerCase().endsWith(
-                                            ".xmi.zip") 
-                        || file.getName().toLowerCase().endsWith(".xml.zip")));
-                }
+            JFileChooser chooser = getFileChooser();
 
-                public String getDescription() {
-                    return "*.xmi *.xml *.xmi.zip *.xml.zip";
-                }
-
-            });
-
-            int ret = fileChooser.showOpenDialog(this);
+            int ret = chooser.showOpenDialog(this);
             if (ret == JFileChooser.APPROVE_OPTION) {
-                File file = fileChooser.getSelectedFile();
-
+                File file = chooser.getSelectedFile();
+                chooser.setCurrentDirectory(file.getParentFile());
                 try {
                     UserDefinedProfile profile = new UserDefinedProfile(file);
                     ProfileFacade.getManager().registerProfile(profile);
@@ -348,6 +360,14 @@
         usedList.validate();
     }
 
+    private JFileChooser getFileChooser() {
+        if (fileChooser == null) {
+            fileChooser = new JFileChooser();
+            fileChooser.setFileFilter(new ProfileFileFilter());
+        }
+        return fileChooser;
+    }
+
     private List<Profile> getAvailableDependents(Profile selected) {
         MutableComboBoxModel modelAvl = ((MutableComboBoxModel) availableList
                 .getModel());
@@ -356,7 +376,8 @@
         for (int i = 0; i < modelAvl.getSize(); ++i) {
             Profile profile = (Profile) modelAvl.getElementAt(i);
 
-            if (!profile.equals(selected) && selected.getDependencies().contains(profile)) {
+            if (!profile.equals(selected) 
+                    && selected.getDependencies().contains(profile)) {
                 ret.add(profile);
             }
         }
@@ -372,7 +393,8 @@
         for (int i = 0; i < modelUsd.getSize(); ++i) {
             Profile profile = (Profile) modelUsd.getElementAt(i);
 
-            if (!profile.equals(selected) && profile.getDependencies().contains(selected)) {
+            if (!profile.equals(selected) 
+                    && profile.getDependencies().contains(selected)) {
                 ret.add(profile);
             }
         }
@@ -393,10 +415,16 @@
      * @see org.argouml.application.api.GUISettingsTabInterface#getTabPanel()
      */
     public JPanel getTabPanel() {
+        if (!initialized) {
+            buildDialog();
+        }
         return this;
     }
 
     public void handleResetToDefault() {
+        if (!initialized) {
+            buildDialog();
+        }
         refreshLists();
     }
 
@@ -405,6 +433,9 @@
     }
 
     public void handleSettingsTabRefresh() {
+        if (!initialized) {
+            buildDialog();
+        }
         assert p != null;
         ProjectSettings ps = p.getProjectSettings();
         DiagramSettings ds = ps.getDefaultDiagramSettings();
@@ -425,6 +456,9 @@
     }
 
     public void handleSettingsTabSave() {
+        if (!initialized) {
+            return;
+        }
         assert p != null;
         List<Profile> toRemove = new ArrayList<Profile>();
         ProfileConfiguration pc = p.getProfileConfiguration();
@@ -461,4 +495,27 @@
         assert project != null;
         p = project;
     }
+    
+    private class ProfileFileFilter extends FileFilter {
+        public boolean accept(File file) {
+            if (file.isDirectory()) {
+                return true;
+            }
+            if (file.isFile()) {
+                String filename = file.getName().toLowerCase();
+                String[] validEndings = {".xmi", ".xml", ".xmi.zip", 
+                                         ".xml.zip"};
+                for (String ending : validEndings) {
+                    if (filename.endsWith(ending)) {
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
+
+        public String getDescription() {
+            return "*.xmi *.xml *.xmi.zip *.xml.zip";
+        }
+    }
 }

Modified: trunk/src/argouml-app/src/org/argouml/ui/SettingsDialog.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SettingsDialog.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsDialog.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsDialog.java	2009-04-13 11:44:21-0700
@@ -63,7 +63,6 @@
               ArgoDialog.OK_CANCEL_OPTION,
               true);
 
-
         tabs = new JTabbedPane();
 
         applyButton = new JButton(Translator.localize("button.apply"));
@@ -81,13 +80,14 @@
         // Add settings from the settings registry.
         settingsTabs = GUI.getInstance().getSettingsTabs();
         for (GUISettingsTabInterface stp : settingsTabs) {
+            // TODO: Only fetch names and defer fetching panels until needed
             tabs.addTab(
                     Translator.localize(stp.getTabKey()),
                     stp.getTabPanel());
         }
 
         // Increase width to accommodate all tabs on one row.
-        final int minimumWidth = 480;
+        final int minimumWidth = 500;
         tabs.setPreferredSize(new Dimension(Math.max(tabs
                 .getPreferredSize().width, minimumWidth), tabs
                 .getPreferredSize().height));

Modified: trunk/src/argouml-app/src/org/argouml/ui/SettingsTabAppearance.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SettingsTabAppearance.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabAppearance.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabAppearance.java	2009-04-13 11:44:21-0700
@@ -64,16 +64,22 @@
 
     private Locale locale;
 
+    private JPanel topPanel;
+    
     /**
      * The constructor.
      *
      */
     SettingsTabAppearance() {
+        // Defer initialization until we're visible
+    }
+
+    private void buildPanel() {
         setLayout(new BorderLayout());
 
         int labelGap = 10;
         int componentGap = 10;
-        JPanel top = new JPanel(new LabelledLayout(labelGap, componentGap));
+        topPanel = new JPanel(new LabelledLayout(labelGap, componentGap));
 
         JLabel label = new JLabel(Translator.localize("label.look-and-feel"));
         lookAndFeel =
@@ -85,8 +91,8 @@
             }
         });
         label.setLabelFor(lookAndFeel);
-        top.add(label);
-        top.add(lookAndFeel);
+        topPanel.add(label);
+        topPanel.add(lookAndFeel);
 
         metalLabel = new JLabel(Translator.localize("label.metal-theme"));
 
@@ -94,16 +100,16 @@
             new JComboBox(LookAndFeelMgr.getInstance()
                 .getAvailableThemeNames());
         metalLabel.setLabelFor(metalTheme);
-        top.add(metalLabel);
-        top.add(metalTheme);
+        topPanel.add(metalLabel);
+        topPanel.add(metalTheme);
         JCheckBox j = new JCheckBox(Translator.localize("label.smooth-edges"));
 
         smoothEdges = j;
         JLabel emptyLabel = new JLabel();
         emptyLabel.setLabelFor(smoothEdges);
 
-        top.add(emptyLabel);
-        top.add(smoothEdges);
+        topPanel.add(emptyLabel);
+        topPanel.add(smoothEdges);
 
         JLabel languageLabel =
             new JLabel(Translator.localize("label.language"));
@@ -122,11 +128,11 @@
             }
         });
         languageLabel.setLabelFor(language);
-        top.add(languageLabel);
-        top.add(language);
+        topPanel.add(languageLabel);
+        topPanel.add(language);
 
-        top.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-        add(top, BorderLayout.CENTER);
+        topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+        add(topPanel, BorderLayout.CENTER);
 
         JLabel restart =
             new JLabel(Translator.localize("label.restart-application"));
@@ -207,7 +213,12 @@
     /*
      * @see GUISettingsTabInterface#getTabPanel()
      */
-    public JPanel getTabPanel() { return this; }
+    public JPanel getTabPanel() {
+        if (topPanel == null) {
+            buildPanel();
+        }
+        return this;
+    }
 
     /**
      * The UID.

Modified: trunk/src/argouml-app/src/org/argouml/ui/SettingsTabEnvironment.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SettingsTabEnvironment.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabEnvironment.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabEnvironment.java	2009-04-13 11:44:21-0700
@@ -52,6 +52,7 @@
 class SettingsTabEnvironment extends JPanel
     implements GUISettingsTabInterface {
 
+    private JPanel topPanel;
     private JTextField fieldArgoExtDir;
     private JTextField fieldJavaHome;
     private JTextField fieldUserHome;
@@ -66,17 +67,20 @@
      */
     SettingsTabEnvironment() {
         super();
+    }
+
+    private void buildPanel() {
         setLayout(new BorderLayout());
         int labelGap = 10;
         int componentGap = 5;
-        JPanel top = new JPanel(new LabelledLayout(labelGap, componentGap));
+        topPanel = new JPanel(new LabelledLayout(labelGap, componentGap));
 
         JLabel label =
             new JLabel(Translator.localize("label.default.graphics-format"));
         fieldGraphicsFormat = new JComboBox();
         label.setLabelFor(fieldGraphicsFormat);
-        top.add(label);
-        top.add(fieldGraphicsFormat);
+        topPanel.add(label);
+        topPanel.add(fieldGraphicsFormat);
 
         label =
             new JLabel(
@@ -87,8 +91,8 @@
         theResolutions.add(new GResolution(4, "combobox.item.resolution-4"));
         fieldGraphicsResolution = new JComboBox(); //filled in later
         label.setLabelFor(fieldGraphicsResolution);
-        top.add(label);
-        top.add(fieldGraphicsResolution);
+        topPanel.add(label);
+        topPanel.add(fieldGraphicsResolution);
 
  	// This string is NOT to be translated! See issue 2381.
 	label = new JLabel("${argo.ext.dir}");
@@ -96,8 +100,8 @@
         fieldArgoExtDir = j2;
 	fieldArgoExtDir.setEnabled(false);
         label.setLabelFor(fieldArgoExtDir);
-        top.add(label);
-        top.add(fieldArgoExtDir);
+        topPanel.add(label);
+        topPanel.add(fieldArgoExtDir);
 
   	// This string is NOT to be translated! See issue 2381.
 	label = new JLabel("${java.home}");
@@ -105,8 +109,8 @@
         fieldJavaHome = j3;
 	fieldJavaHome.setEnabled(false);
         label.setLabelFor(fieldJavaHome);
-        top.add(label);
-        top.add(fieldJavaHome);
+        topPanel.add(label);
+        topPanel.add(fieldJavaHome);
 
   	// This string is NOT to be translated! See issue 2381.
 	label = new JLabel("${user.home}");
@@ -114,8 +118,8 @@
         fieldUserHome = j4;
 	fieldUserHome.setEnabled(false);
         label.setLabelFor(fieldUserHome);
-        top.add(label);
-        top.add(fieldUserHome);
+        topPanel.add(label);
+        topPanel.add(fieldUserHome);
 
 	// This string is NOT to be translated! See issue 2381.
 	label = new JLabel("${user.dir}");
@@ -123,19 +127,19 @@
         fieldUserDir = j5;
 	fieldUserDir.setEnabled(false);
         label.setLabelFor(fieldUserDir);
-        top.add(label);
-        top.add(fieldUserDir);
+        topPanel.add(label);
+        topPanel.add(fieldUserDir);
 
   	label = new JLabel(Translator.localize("label.startup-directory"));
   	JTextField j6 = new JTextField();
         fieldStartupDir = j6;
 	fieldStartupDir.setEnabled(false);
         label.setLabelFor(fieldStartupDir);
-        top.add(label);
-        top.add(fieldStartupDir);
+        topPanel.add(label);
+        topPanel.add(fieldStartupDir);
 
-        top.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-	add(top, BorderLayout.NORTH);
+        topPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+	add(topPanel, BorderLayout.NORTH);
 	
 	JPanel bottom = new JPanel();
 	bottom.add(new JLabel(
@@ -203,12 +207,19 @@
     /*
      * @see GUISettingsTabInterface#getTabKey()
      */
-    public String getTabKey() { return "tab.environment"; }
+    public String getTabKey() {
+        return "tab.environment";
+    }
 
     /*
      * @see GUISettingsTabInterface#getTabPanel()
      */
-    public JPanel getTabPanel() { return this; }
+    public JPanel getTabPanel() {
+        if (topPanel == null) {
+            buildPanel();
+        }
+        return this;
+    }
 
     /**
      * The UID.

Modified: trunk/src/argouml-app/src/org/argouml/ui/SettingsTabPreferences.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SettingsTabPreferences.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabPreferences.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabPreferences.java	2009-04-13 11:44:21-0700
@@ -46,6 +46,7 @@
 class SettingsTabPreferences extends JPanel
     implements GUISettingsTabInterface {
 
+    private JPanel topPanel;
     private JCheckBox chkSplash;
     private JCheckBox chkReloadRecent;
     private JCheckBox chkStripDiagrams;
@@ -55,9 +56,12 @@
      *
      */
     SettingsTabPreferences() {
+    }
+
+    private void buildPanel() {
         setLayout(new BorderLayout());
-	JPanel top = new JPanel();
-    	top.setLayout(new GridBagLayout());
+	topPanel = new JPanel();
+    	topPanel.setLayout(new GridBagLayout());
 
 	GridBagConstraints checkConstraints = new GridBagConstraints();
 	checkConstraints.anchor = GridBagConstraints.LINE_START;
@@ -70,23 +74,23 @@
 	checkConstraints.gridy = 2;
 	JCheckBox j = new JCheckBox(Translator.localize("label.splash"));
         chkSplash = j;
-	top.add(chkSplash, checkConstraints);
+	topPanel.add(chkSplash, checkConstraints);
 
 	checkConstraints.gridy++;
         JCheckBox j2 =
             new JCheckBox(Translator.localize("label.reload-recent"));
         chkReloadRecent = j2;
- 	top.add(chkReloadRecent, checkConstraints);
+ 	topPanel.add(chkReloadRecent, checkConstraints);
 
         checkConstraints.gridy++;
         JCheckBox j3 =
             new JCheckBox(Translator.localize("label.strip-diagrams"));
         chkStripDiagrams = j3;
-        top.add(chkStripDiagrams, checkConstraints);
+        topPanel.add(chkStripDiagrams, checkConstraints);
 
         checkConstraints.fill = GridBagConstraints.HORIZONTAL;
 
-	add(top, BorderLayout.NORTH);
+	add(topPanel, BorderLayout.NORTH);
     }
 
     /*
@@ -130,12 +134,19 @@
     /*
      * @see GUISettingsTabInterface#getTabPanel()
      */
-    public JPanel getTabPanel() { return this; }
+    public JPanel getTabPanel() {
+        if (topPanel == null) {
+            buildPanel();
+        }
+        return this;
+    }
 
     /*
      * @see GUISettingsTabInterface#getTabKey()
      */
-    public String getTabKey() { return "tab.preferences"; }
+    public String getTabKey() {
+        return "tab.preferences";
+    }
 
     /**
      * The UID.

Modified: trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java	2009-04-13 11:44:21-0700
@@ -69,42 +69,42 @@
 public class SettingsTabProfile extends JPanel implements
         GUISettingsTabInterface, ActionListener {
 
-    private JButton loadFromFile = new JButton(Translator
-            .localize("tab.profiles.userdefined.load"));
+    private JButton loadFromFile;
 
-    private JButton addButton = new JButton(">>");
+    private JButton addButton;
 
-    private JButton removeButton = new JButton("<<");
+    private JButton removeButton;
 
-    private JList availableList = new JList();
+    private JList availableList;
 
-    private JList defaultList = new JList();
+    private JList defaultList;
 
     // //////
 
-    private JList directoryList = new JList();
+    private JList directoryList;
 
-    private JButton addDirectory = new JButton(Translator
-            .localize("tab.profiles.directories.add"));
+    private JButton addDirectory;
 
-    private JButton removeDirectory = new JButton(Translator
-            .localize("tab.profiles.directories.remove"));
+    private JButton removeDirectory;
 
     private JButton refreshProfiles = new JButton(Translator
             .localize("tab.profiles.directories.refresh"));
 
     // /////
 
-    private JLabel stereoLabel = new JLabel(Translator
-            .localize("menu.popup.stereotype-view")
-            + ": ");
+    private JLabel stereoLabel;
 
-    private JComboBox stereoField = new JComboBox();
+    private JComboBox stereoField;
+
+    private boolean initialized = false;
 
     /**
-     * The default constructor for this class.
+     * Construct the Profile settings tab
      */
     public SettingsTabProfile() {
+    }
+
+    private void buildPanel() {
         setLayout(new BorderLayout());
 
         JPanel warning = new JPanel();
@@ -128,25 +128,29 @@
 
         profileSettings.add(initDefaultStereotypeViewSelector());
 
-        directoryList
-                .setPrototypeCellValue("123456789012345678901234567890123456789012345678901234567890");
-        directoryList.setMinimumSize(new Dimension(50, 50));
-
         JPanel sdirPanel = new JPanel();
         sdirPanel.setLayout(new BoxLayout(sdirPanel, BoxLayout.Y_AXIS));
 
-        JPanel dlist = new JPanel();
-        dlist.setLayout(new BorderLayout());
 
         JPanel lcb = new JPanel();
         lcb.setLayout(new BoxLayout(lcb, BoxLayout.Y_AXIS));
 
+        addDirectory = new JButton(Translator
+                .localize("tab.profiles.directories.add"));
+        removeDirectory = new JButton(Translator
+                .localize("tab.profiles.directories.remove"));
+        
         lcb.add(addDirectory);
         lcb.add(removeDirectory);
 
         addDirectory.addActionListener(this);
         removeDirectory.addActionListener(this);
 
+        directoryList = new JList();
+        directoryList.setMinimumSize(new Dimension(50, 50));
+
+        JPanel dlist = new JPanel();
+        dlist.setLayout(new BorderLayout());        
         dlist.add(new JScrollPane(directoryList), BorderLayout.CENTER);
         dlist.add(lcb, BorderLayout.EAST);
 
@@ -159,11 +163,8 @@
         JPanel configPanel = new JPanel();
         configPanel.setLayout(new BoxLayout(configPanel, BoxLayout.X_AXIS));
 
-        availableList.setPrototypeCellValue("12345678901234567890");
-        defaultList.setPrototypeCellValue("12345678901234567890");
-
-        availableList.setMinimumSize(new Dimension(50, 50));
-        defaultList.setMinimumSize(new Dimension(50, 50));
+        availableList = createProfileList();
+        defaultList = createProfileList();
 
         refreshLists();
 
@@ -177,6 +178,8 @@
 
         JPanel centerButtons = new JPanel();
         centerButtons.setLayout(new BoxLayout(centerButtons, BoxLayout.Y_AXIS));
+        addButton = new JButton(">>");
+        removeButton = new JButton("<<");
         centerButtons.add(addButton);
         centerButtons.add(removeButton);
         configPanel.add(centerButtons);
@@ -197,6 +200,8 @@
 
         JPanel lffPanel = new JPanel();
         lffPanel.setLayout(new FlowLayout());
+        loadFromFile = new JButton(Translator
+                .localize("tab.profiles.userdefined.load"));
         lffPanel.add(loadFromFile);
         lffPanel.add(refreshProfiles);
 
@@ -206,12 +211,33 @@
         profileSettings.add(lffPanel);
 
         add(profileSettings, BorderLayout.CENTER);
+
+        initialized = true;
+    }
+
+    
+    @Override
+    public void setVisible(boolean flag) {
+        if (flag && !initialized) {
+            buildPanel();
+        }
+        super.setVisible(flag);
+    }
+    
+    private JList createProfileList() {
+        JList list = new JList();
+        list.setPrototypeCellValue("12345678901234567890");
+        list.setMinimumSize(new Dimension(50, 50));
+        return list;
     }
 
     private JPanel initDefaultStereotypeViewSelector() {
         JPanel setDefStereoV = new JPanel();
         setDefStereoV.setLayout(new FlowLayout());
-
+        stereoField = new JComboBox();
+        stereoLabel = new JLabel(Translator
+                .localize("menu.popup.stereotype-view")
+                + ": ");
         stereoLabel.setLabelFor(stereoField);
         setDefStereoV.add(stereoLabel);
         setDefStereoV.add(stereoField);
@@ -233,8 +259,8 @@
 
                 if (src == stereoField) {
                     Object item = e.getItem();
-                    DefaultComboBoxModel model = (DefaultComboBoxModel) stereoField
-                            .getModel();
+                    DefaultComboBoxModel model = 
+                        (DefaultComboBoxModel) stereoField.getModel();
                     int idx = model.getIndexOf(item);
 
                     switch (idx) {
@@ -409,7 +435,13 @@
         return this;
     }
 
+
+
+
     public void handleResetToDefault() {
+        if (!initialized) {
+            buildPanel();
+        }
         refreshLists();
     }
 
@@ -418,6 +450,9 @@
     }
 
     public void handleSettingsTabRefresh() {
+        if (!initialized) {
+            buildPanel();
+        }
         refreshLists();
 
         switch (Configuration.getInteger(
@@ -491,4 +526,5 @@
         }
 
     }
+
 }

Modified: trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java?view=diff&pathrev=17109&r1=17108&r2=17109
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java	2009-04-13 11:44:21-0700
@@ -50,6 +50,8 @@
 class SettingsTabUser extends JPanel
     implements GUISettingsTabInterface {
 
+    private JPanel topPanel;
+    
     /**
      * This is where the user enters full name in settings tab.
      * This information is stored
@@ -66,13 +68,16 @@
 
     /**
      * The constructor.
-     *
      */
     SettingsTabUser() {
+        // defer work until fetched/visible
+    }
+
+    private void buildPanel() {
         setLayout(new BorderLayout());
         
-        JPanel top = new JPanel();
-        top.setLayout(new BorderLayout());
+        topPanel = new JPanel();
+        topPanel.setLayout(new BorderLayout());
         
         JPanel warning = new JPanel();
         warning.setLayout(new BoxLayout(warning, BoxLayout.PAGE_AXIS));
@@ -87,7 +92,7 @@
         projectSettings.setAlignmentX(Component.RIGHT_ALIGNMENT);
         warning.add(projectSettings);
         
-        top.add(warning, BorderLayout.NORTH);
+        topPanel.add(warning, BorderLayout.NORTH);
         
 	JPanel settings = new JPanel();
     	settings.setLayout(new GridBagLayout());
@@ -125,9 +130,9 @@
  	JTextField j1 = new JTextField();
         userEmail = j1;
 	settings.add(userEmail, fieldConstraints);
-	top.add(settings, BorderLayout.CENTER);
+	topPanel.add(settings, BorderLayout.CENTER);
 	
-	add(top, BorderLayout.NORTH);
+	add(topPanel, BorderLayout.NORTH);
     }
 
     /*
@@ -163,12 +168,19 @@
     /*
      * @see GUISettingsTabInterface#getTabKey()
      */
-    public String getTabKey() { return "tab.user"; }
+    public String getTabKey() {
+        return "tab.user";
+    }
 
     /*
      * @see GUISettingsTabInterface#getTabPanel()
      */
-    public JPanel getTabPanel() { return this; }
+    public JPanel getTabPanel() {
+        if (topPanel == null) {
+            buildPanel();
+        }
+        return this;
+    }
 
     /**
      * The UID.

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1696187

To unsubscribe from this discussion, e-mail: [[email protected]].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.