svn commit: r16999 - trunk/src/argouml-app/src/org/argouml: notation/ui ui uml/diagram/ui

Michiel van der Wulp <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2009-03-29 23:01:01-0700
New Revision: 16999

Added:
   trunk/src/argouml-app/src/org/argouml/ui/GUIProjectSettingsTabInterface.java
Modified:
   trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java
   trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsDialog.java
   trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java
   trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProperties.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SettingsTabDiagramAppearance.java

Log:
Centralize the use of a deprecated method to the ProjectSettingDialog class.
Now the project related settings tab classes will even work with multiple projects.

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=16999&r1=16998&r2=16999
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java	2009-03-29 23:01:01-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Copyright (c) 1996-2009 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -38,17 +38,16 @@
 import javax.swing.JPanel;
 
 import org.argouml.application.api.Argo;
-import org.argouml.application.api.GUISettingsTabInterface;
 import org.argouml.configuration.Configuration;
 import org.argouml.configuration.ConfigurationKey;
 import org.argouml.i18n.Translator;
 import org.argouml.kernel.Project;
-import org.argouml.kernel.ProjectManager;
 import org.argouml.kernel.ProjectSettings;
 import org.argouml.notation.Notation;
 import org.argouml.notation.NotationName;
 import org.argouml.swingext.JLinkButton;
 import org.argouml.ui.ActionProjectSettings;
+import org.argouml.ui.GUIProjectSettingsTabInterface;
 import org.argouml.ui.ShadowComboBox;
 
 /**
@@ -66,7 +65,7 @@
  */
 public class SettingsTabNotation
     extends JPanel
-    implements GUISettingsTabInterface {
+    implements GUIProjectSettingsTabInterface {
 
     private JComboBox notationLanguage;
     private JCheckBox showBoldNames;
@@ -83,6 +82,7 @@
     private ShadowComboBox defaultShadowWidth;
 
     private int scope;
+    private Project p;
 
     /**
      * The constructor.
@@ -246,7 +246,7 @@
                     Notation.KEY_DEFAULT_SHADOW_WIDTH, 1));
         }
         if (scope == Argo.SCOPE_PROJECT) {
-            Project p = ProjectManager.getManager().getCurrentProject();
+            assert p != null;
             ProjectSettings ps = p.getProjectSettings();
 
             notationLanguage.setSelectedItem(Notation.findNotation(
@@ -312,7 +312,7 @@
                     defaultShadowWidth.getSelectedIndex());
         }
         if (scope == Argo.SCOPE_PROJECT) {
-            Project p = ProjectManager.getManager().getCurrentProject();
+            assert p != null;
             ProjectSettings ps = p.getProjectSettings();
             NotationName nn = (NotationName) notationLanguage.getSelectedItem();
             if (nn != null) ps.setNotationLanguage(nn.getConfigurationValue());
@@ -412,4 +412,9 @@
             handleSettingsTabRefresh();
         }
     }
+
+    public void setProject(Project project) {
+        assert p != null;
+        p = project;
+    }
 }

Added: trunk/src/argouml-app/src/org/argouml/ui/GUIProjectSettingsTabInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/GUIProjectSettingsTabInterface.java?view=markup&pathrev=16999
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/ui/GUIProjectSettingsTabInterface.java	2009-03-29 23:01:01-0700
@@ -0,0 +1,48 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $
+// Copyright (c) 2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.ui;
+
+import org.argouml.application.api.GUISettingsTabInterface;
+import org.argouml.kernel.Project;
+
+/**
+ * An interface for UI tabs on the settings panel that
+ * adjust project related settings. <p>
+ * 
+ * The system shall guarantee that the function 
+ * {@link #setProject(Project)} will be called BEFORE
+ * one of the data related functions are called.
+ *
+ * @author michiel
+ */
+public interface GUIProjectSettingsTabInterface 
+    extends GUISettingsTabInterface {
+
+    /**
+     * @param project the project to change settings for
+     * This p shall never be null.
+     */
+    void setProject(Project project);
+}

Modified: trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsDialog.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsDialog.java?view=diff&pathrev=16999&r1=16998&r2=16999
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsDialog.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsDialog.java	2009-03-29 23:01:01-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2006 The Regents of the University of California. All
+// Copyright (c) 2006-2009 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -38,6 +38,8 @@
 
 import org.argouml.application.api.GUISettingsTabInterface;
 import org.argouml.i18n.Translator;
+import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
 import org.argouml.util.ArgoDialog;
 
 /**
@@ -178,6 +180,12 @@
         for (int i = 0; i < tabs.getComponentCount(); i++) {
             Object o = tabs.getComponent(i);
             if (o instanceof GUISettingsTabInterface) {
+                if (o instanceof GUIProjectSettingsTabInterface) {
+                    /* We have to tell the settings tab in which project
+                     * the settings reside: */
+                    Project p = ProjectManager.getManager().getCurrentProject();
+                    ((GUIProjectSettingsTabInterface) o).setProject(p);
+                }
                 ((GUISettingsTabInterface) o).handleSettingsTabRefresh();
             }
         }

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=16999&r1=16998&r2=16999
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java	2009-03-29 23:01:01-0700
@@ -1,5 +1,5 @@
 // $Id: ProfileSelectionTab.java 13040 2007-07-10 20:00:25Z linus $
-// Copyright (c) 2007 The Regents of the University of California. All
+// Copyright (c) 2007-2009 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -48,11 +48,9 @@
 import javax.swing.MutableComboBoxModel;
 import javax.swing.filechooser.FileFilter;
 
-import org.argouml.application.api.GUISettingsTabInterface;
 import org.argouml.i18n.Translator;
 import org.argouml.kernel.ProfileConfiguration;
 import org.argouml.kernel.Project;
-import org.argouml.kernel.ProjectManager;
 import org.argouml.kernel.ProjectSettings;
 import org.argouml.profile.Profile;
 import org.argouml.profile.ProfileException;
@@ -67,7 +65,9 @@
  * @author Marcos Aurelio
  */
 public class ProjectSettingsTabProfile extends JPanel implements
-        GUISettingsTabInterface, ActionListener {
+        GUIProjectSettingsTabInterface, ActionListener {
+
+    private Project p;
 
     private JButton loadFromFile = new JButton(Translator
             .localize("tab.profiles.userdefined.load"));
@@ -119,8 +119,10 @@
         stereoField.addItemListener(new ItemListener() {
 
             public void itemStateChanged(ItemEvent e) {
-                ProjectSettings ps = ProjectManager.getManager()
-                        .getCurrentProject().getProjectSettings();
+                if (p == null) {
+                    return;
+                }
+                ProjectSettings ps = p.getProjectSettings();
                 Object src = e.getSource();
 
                 if (src == stereoField) {
@@ -207,8 +209,8 @@
     }
 
     private List<Profile> getUsedProfiles() {
-        return new ArrayList<Profile>(ProjectManager.getManager()
-                .getCurrentProject().getProfileConfiguration().getProfiles());
+        return new ArrayList<Profile>(
+                p.getProfileConfiguration().getProfiles());
     }
 
     private List<Profile> getAvailableProfiles() {
@@ -401,8 +403,8 @@
     }
 
     public void handleSettingsTabRefresh() {
-        ProjectSettings ps = ProjectManager.getManager().getCurrentProject()
-                .getProjectSettings();
+        assert p != null;
+        ProjectSettings ps = p.getProjectSettings();
 
         switch (ps.getDefaultStereotypeViewValue()) {
         case DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL:
@@ -420,9 +422,9 @@
     }
 
     public void handleSettingsTabSave() {
+        assert p != null;
         List<Profile> toRemove = new ArrayList<Profile>();
-        Project proj = ProjectManager.getManager().getCurrentProject();
-        ProfileConfiguration pc = proj.getProfileConfiguration();
+        ProfileConfiguration pc = p.getProfileConfiguration();
 
         List<Profile> usedItens = new ArrayList<Profile>();
 
@@ -449,7 +451,11 @@
             }
         }
 
-        proj.setProfileConfiguration(pc);
+        p.setProfileConfiguration(pc);
     }
 
+    public void setProject(Project project) {
+        assert p != null;
+        p = project;
+    }
 }

Modified: trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProperties.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProperties.java?view=diff&pathrev=16999&r1=16998&r2=16999
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProperties.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProperties.java	2009-03-29 23:01:01-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2006-2008 The Regents of the University of California. All
+// Copyright (c) 2006-2009 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -37,11 +37,9 @@
 import javax.swing.SwingConstants;
 
 import org.argouml.application.api.Argo;
-import org.argouml.application.api.GUISettingsTabInterface;
 import org.argouml.configuration.Configuration;
 import org.argouml.i18n.Translator;
 import org.argouml.kernel.Project;
-import org.argouml.kernel.ProjectManager;
 
 /**
  * Tab Panel for setting the project attributes: 
@@ -51,7 +49,10 @@
  * @author Michiel
  */
 public class ProjectSettingsTabProperties extends JPanel implements
-        GUISettingsTabInterface {
+        GUIProjectSettingsTabInterface {
+
+    private Project p;
+    
     /**
      * This is where the user enters full name in settings tab.
      * This information is stored in the zargo file.
@@ -166,7 +167,7 @@
      * @see org.argouml.ui.GUISettingsTabInterface#handleSettingsTabRefresh()
      */
     public void handleSettingsTabRefresh() {
-        Project p = ProjectManager.getManager().getCurrentProject();
+        assert p != null;
         userFullname.setText(p.getAuthorname());
         userEmail.setText(p.getAuthoremail());
         description.setText(p.getDescription());
@@ -178,7 +179,7 @@
      * @see org.argouml.ui.GUISettingsTabInterface#handleSettingsTabSave()
      */
     public void handleSettingsTabSave() {
-        Project p = ProjectManager.getManager().getCurrentProject();
+        assert p != null;
         p.setAuthorname(userFullname.getText());
         p.setAuthoremail(userEmail.getText());
         p.setDescription(description.getText());
@@ -210,4 +211,8 @@
      */
     public JPanel getTabPanel() { return this; }
 
+    public void setProject(Project project) {
+        assert p != null;
+        p = project;
+    }
 }

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SettingsTabDiagramAppearance.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SettingsTabDiagramAppearance.java?view=diff&pathrev=16999&r1=16998&r2=16999
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SettingsTabDiagramAppearance.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SettingsTabDiagramAppearance.java	2009-03-29 23:01:01-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2007 The Regents of the University of California. All
+// Copyright (c) 2007-2009 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -35,16 +35,15 @@
 import javax.swing.JPanel;
 
 import org.argouml.application.api.Argo;
-import org.argouml.application.api.GUISettingsTabInterface;
 import org.argouml.configuration.Configuration;
 import org.argouml.configuration.ConfigurationKey;
 import org.argouml.i18n.Translator;
 import org.argouml.kernel.Project;
-import org.argouml.kernel.ProjectManager;
 import org.argouml.kernel.ProjectSettings;
 import org.argouml.swingext.JLinkButton;
 import org.argouml.ui.ActionProjectSettings;
 import org.argouml.ui.ArgoJFontChooser;
+import org.argouml.ui.GUIProjectSettingsTabInterface;
 import org.argouml.uml.diagram.DiagramAppearance;
 import org.argouml.util.ArgoFrame;
 
@@ -60,8 +59,10 @@
  * @author Aleksandar
  */
 public class SettingsTabDiagramAppearance extends JPanel implements
-        GUISettingsTabInterface {
+        GUIProjectSettingsTabInterface {
 
+    private Project p;
+    
     private JButton jbtnDiagramFont;
 
     private String selectedDiagramFontName;
@@ -159,7 +160,7 @@
                     .getInteger(DiagramAppearance.KEY_FONT_SIZE);
         }
         if (scope == Argo.SCOPE_PROJECT) {
-            Project p = ProjectManager.getManager().getCurrentProject();
+            assert p != null;
             ProjectSettings ps = p.getProjectSettings();
 
             selectedDiagramFontName = ps.getFontName();
@@ -188,7 +189,7 @@
                     selectedDiagramFontSize);
         }
         if (scope == Argo.SCOPE_PROJECT) {
-            Project p = ProjectManager.getManager().getCurrentProject();
+            assert p != null;
             ProjectSettings ps = p.getProjectSettings();
 
             ps.setFontName(selectedDiagramFontName);
@@ -267,4 +268,9 @@
         super.setVisible(arg0);
         if (arg0) handleSettingsTabRefresh();
     }
+
+    public void setProject(Project project) {
+        assert p != null;
+        p = project;
+    }
 } // @jve:decl-index=0:visual-constraint="10,10"

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

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.