Author: maurelio1234
Date: 2007-07-16 05:37:40-0700
New Revision: 13090
Added:
branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/ProjectSettingsTabProfile.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/SettingsTabProfile.java
Modified:
branches/gsoc2007/maurelio1234/src_new/ext/javabeans.jar
branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/tab.properties
branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/Project.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/ProjectSettings.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/argo.tee
branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/GUI.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/StylePanelFig.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileConfiguration.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManager.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManagerImpl.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/UserDefinedProfile.java
Log:
implementing modifications from the community feedback
- global settings for profile
- stereotype view in style tab
Modified: branches/gsoc2007/maurelio1234/src_new/ext/javabeans.jar
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/ext/javabeans.jar?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/ext/javabeans.jar&p2=branches/gsoc2007/maurelio1234/src_new/ext/javabeans.jar&r1=13089&r2=13090
==============================================================================
Binary files. No diff available.
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/tab.properties
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/tab.properties?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/tab.properties&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/tab.properties&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/tab.properties (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/tab.properties 2007-07-16 05:37:40-0700
@@ -47,8 +47,15 @@
tab.modules = Modules
tab.profiles = Profiles
tab.profiles.userdefined.load = Load profile from file...
-tab.profiles.userdefined.unload = Unregister Profile loaded from file
+tab.profiles.userdefined.unload = Unload
tab.profiles.userdefined.available = Available Profiles:
tab.profiles.userdefined.active = Active Profiles:
+tab.profiles.userdefined.default = Default Profiles:
tab.profiles.userdefined.errorloading = Error opening profile!
-tab.profiles.cannotdelete = Only user defined profiles can be removed
\ No newline at end of file
+
+tab.profiles.directories.desc = Default XMI directories:
+tab.profiles.directories.add = Add
+tab.profiles.directories.remove = Remove
+tab.profiles.directories.refresh = Refresh
+
+tab.profiles.cannotdelete = Only user defined profiles can be unregistered!
\ No newline at end of file
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/Project.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/Project.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/Project.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/Project.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/Project.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/Project.java 2007-07-16 05:37:40-0700
@@ -61,6 +61,7 @@
import org.argouml.uml.generator.GenerationPreferences;
import org.argouml.uml.profile.Profile;
import org.argouml.uml.profile.ProfileConfiguration;
+import org.argouml.uml.profile.ProfileManagerImpl;
import org.tigris.gef.base.Diagram;
import org.tigris.gef.presentation.Fig;
import org.tigris.gef.undo.Memento;
@@ -170,6 +171,12 @@
public Project() {
setProfileConfiguration(new ProfileConfiguration(this));
+ Iterator it = ProfileManagerImpl.getInstance().getDefaultProfiles().iterator();
+
+ while (it.hasNext()) {
+ getProfileConfiguration().addProfile((Profile) it.next());
+ }
+
projectSettings = new ProjectSettings();
Model.getModelManagementFactory().setRootModel(null);
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/ProjectSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/ProjectSettings.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/ProjectSettings.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/ProjectSettings.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/ProjectSettings.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/kernel/ProjectSettings.java 2007-07-16 05:37:40-0700
@@ -34,6 +34,8 @@
import org.argouml.notation.Notation;
import org.argouml.notation.NotationName;
import org.argouml.notation.NotationProviderFactory2;
+import org.argouml.ui.SettingsTabProfile;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
import org.tigris.gef.undo.Memento;
import org.tigris.gef.undo.UndoManager;
@@ -60,7 +62,8 @@
private boolean showStereotypes;
private boolean showSingularMultiplicities;
private int defaultShadowWidth;
-
+ private int defaultStereotypeView;
+
/**
* Create a new set of project settings,
@@ -104,6 +107,9 @@
Notation.KEY_SHOW_SINGULAR_MULTIPLICITIES, true);
defaultShadowWidth = Configuration.getInteger(
Notation.KEY_DEFAULT_SHADOW_WIDTH, 1);
+ defaultStereotypeView = Configuration.getInteger(
+ SettingsTabProfile.KEY_DEFAULT_STEREOTYPE_VIEW,
+ FigNodeModelElement.STEREOTYPE_VIEW_TEXTUAL);
}
@@ -666,6 +672,53 @@
}
/**
+ * Used by "argo.tee".
+ *
+ * @return Returns the default stereotype view
+ */
+ public String getDefaultStereotypeView() {
+ return new Integer(defaultStereotypeView).toString();
+ }
+
+ /**
+ * @return Returns the default stereotype view
+ */
+ public int getDefaultStereotypeViewValue() {
+ return defaultStereotypeView;
+ }
+
+ /**
+ * @param defaultStereotypeView the default stereotype view
+ */
+ public void setDefaultStereotypeView(final int newView) {
+ this.defaultStereotypeView = defaultStereotypeView;
+
+ if (defaultStereotypeView == newView) return;
+
+ final int oldValue = defaultStereotypeView;
+
+ Memento memento = new Memento() {
+ private final ConfigurationKey key =
+ SettingsTabProfile.KEY_DEFAULT_STEREOTYPE_VIEW;
+
+ public void redo() {
+ defaultStereotypeView = newView;
+ fireEvent(key, oldValue, newView);
+ }
+
+ public void undo() {
+ defaultStereotypeView = oldValue;
+ fireEvent(key, newView, oldValue);
+ }
+ };
+ if (UndoManager.getInstance().isGenerateMementos()) {
+ UndoManager.getInstance().addMemento(memento);
+ }
+ memento.redo();
+ ProjectManager.getManager().setSaveEnabled(true);
+ }
+
+ /**
* @param width The shadow width to set.
*/
public void setDefaultShadowWidth(String width) {
@@ -709,4 +762,5 @@
ArgoEventTypes.NOTATION_CHANGED, new PropertyChangeEvent(this,
key.getKey(), oldValue, newValue)));
}
+
}
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/argo.tee
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/argo.tee?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/argo.tee&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/argo.tee&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/argo.tee (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/argo.tee 2007-07-16 05:37:40-0700
@@ -41,6 +41,7 @@
<showstereotypes><ocl>self.projectSettings.showStereotypes</ocl></showstereotypes>
<showsingularmultiplicities><ocl>self.projectSettings.showSingularMultiplicities</ocl></showsingularmultiplicities>
<defaultshadowwidth><ocl>self.projectSettings.defaultShadowWidth</ocl></defaultshadowwidth>
+ <defaultstereotypeview><ocl>self.projectSettings.defaultStereotypeView</ocl></defaultstereotypeview>
</settings>
<searchpath href="<ocl>self.searchPath</ocl>" />
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/GUI.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/GUI.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/GUI.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/GUI.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/GUI.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/GUI.java 2007-07-16 05:37:40-0700
@@ -59,9 +59,10 @@
addSettingsTab(new SettingsTabEnvironment());
addSettingsTab(new SettingsTabUser());
addSettingsTab(new SettingsTabAppearance());
+ addSettingsTab(new SettingsTabProfile());
addProjectSettingsTab(new ProjectSettingsTabProperties());
- addProjectSettingsTab(new ProfileSelectionTab());
+ addProjectSettingsTab(new ProjectSettingsTabProfile());
}
/**
Added: branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/ProjectSettingsTabProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/ProjectSettingsTabProfile.java?view=auto&rev=13090
==============================================================================
--- (empty file)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/ProjectSettingsTabProfile.java 2007-07-16 05:37:40-0700
@@ -0,0 +1,506 @@
+// $Id: ProfileSelectionTab.java 13040 2007-07-10 20:00:25Z linus $
+// Copyright (c) 2007 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 java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.File;
+import java.util.Vector;
+
+import javax.swing.BoxLayout;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.ListModel;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.filechooser.FileFilter;
+
+import org.argouml.application.api.GUISettingsTabInterface;
+import org.argouml.configuration.Configuration;
+import org.argouml.i18n.Translator;
+import org.argouml.kernel.ProjectManager;
+import org.argouml.kernel.ProjectSettings;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.uml.profile.Profile;
+import org.argouml.uml.profile.ProfileConfiguration;
+import org.argouml.uml.profile.ProfileManager;
+import org.argouml.uml.profile.ProfileManagerImpl;
+import org.argouml.uml.profile.UserDefinedProfile;
+
+/**
+ * The Tab where new profiles can be added and the registered
+ * ones can be activated or deactivated on current project
+ *
+ * @author Marcos Aurélio
+ */
+public class ProjectSettingsTabProfile extends JPanel implements
+ GUISettingsTabInterface, ActionListener {
+
+ private JButton loadFromFile = new JButton(Translator
+ .localize("tab.profiles.userdefined.load"));
+
+ private JButton unregisterProfile = new JButton(Translator
+ .localize("tab.profiles.userdefined.unload"));
+
+ private JButton addButton = new JButton(">>");
+
+ private JButton removeButton = new JButton("<<");
+
+ private JList availableList = new JList(new AvailableProfilesListModel());
+
+ private JList usedList = new JList(new UsedProfilesListModel());
+
+ ////////
+
+ private JLabel stereoLabel =
+ new JLabel(Translator.localize("menu.popup.stereotype-view") + ": ");
+
+ private JComboBox stereoField = new JComboBox();
+
+
+ /**
+ * This List contains the registered profiles that have not been applied
+ * to the current project
+ *
+ * @author maurelio1234
+ */
+ private class AvailableProfilesListModel implements ListModel {
+ private ProfileManager profileManager = ProfileManagerImpl
+ .getInstance();
+
+ private Vector listeners = new Vector();
+
+ /**
+ * @param arg0
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void addListDataListener(ListDataListener arg0) {
+ listeners.add(arg0);
+ }
+
+ /**
+ * Fire listeners
+ */
+ public void fireListeners() {
+ ListDataEvent evt = new ListDataEvent(this,
+ ListDataEvent.CONTENTS_CHANGED, 0, getSize());
+ for (int i = 0; i < listeners.size(); ++i) {
+ ((ListDataListener) listeners.elementAt(i))
+ .contentsChanged(evt);
+ }
+ }
+
+ /**
+ * @param n the profile to be returned
+ * @return the n-th profile at the registered profiles list
+ */
+ public Profile getProfileAt(int n) {
+ ProfileConfiguration config = ProjectManager.getManager()
+ .getCurrentProject().getProfileConfiguration();
+ Vector registeredProfiles = profileManager.getRegisteredProfiles();
+ int count = 0;
+ for (int i = 0; i < registeredProfiles.size(); ++i) {
+ if (!config.getProfiles().contains(
+ registeredProfiles.elementAt(i))) {
+
+ if (count == n) {
+ return ((Profile) registeredProfiles.elementAt(i));
+ }
+ ++count;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param arg0
+ * @return the arg0-th element of this list
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ public Object getElementAt(int arg0) {
+ Profile p = getProfileAt(arg0);
+ if (p != null) {
+ return p.getDisplayName();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the amount of registered profiles not applied to current
+ * project
+ * @see javax.swing.ListModel#getSize()
+ */
+ public int getSize() {
+ ProfileConfiguration config = ProjectManager.getManager()
+ .getCurrentProject().getProfileConfiguration();
+ Vector registeredProfiles = profileManager.getRegisteredProfiles();
+ int count = 0;
+ for (int i = 0; i < registeredProfiles.size(); ++i) {
+ if (!config.getProfiles().contains(
+ registeredProfiles.elementAt(i))) {
+ ++count;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * @param arg0
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void removeListDataListener(ListDataListener arg0) {
+ listeners.remove(arg0);
+ }
+ }
+
+ /**
+ * This list contains the profiles that are applied to the current project
+ *
+ * @author maurelio1234
+ */
+ private class UsedProfilesListModel implements ListModel {
+ private Vector listeners = new Vector();
+
+ /**
+ * @param arg0
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void addListDataListener(ListDataListener arg0) {
+ listeners.add(arg0);
+ }
+
+ /**
+ * Fires listeners
+ */
+ public void fireListeners() {
+ ListDataEvent evt = new ListDataEvent(this,
+ ListDataEvent.CONTENTS_CHANGED, 0, getSize());
+ for (int i = 0; i < listeners.size(); ++i) {
+ ((ListDataListener) listeners.elementAt(i))
+ .contentsChanged(evt);
+ }
+ }
+
+ /**
+ * @param n
+ * @return the n-th profile on this list
+ */
+ public Profile getProfileAt(int n) {
+ ProfileConfiguration config = ProjectManager.getManager()
+ .getCurrentProject().getProfileConfiguration();
+ return ((Profile) config.getProfiles().elementAt(n));
+ }
+
+ /**
+ * @param n
+ * @return the n-th profile on this list
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ public Object getElementAt(int n) {
+ ProfileConfiguration config = ProjectManager.getManager()
+ .getCurrentProject().getProfileConfiguration();
+ if (n >= 0 && n < config.getProfiles().size()) {
+ return ((Profile) config.getProfiles().elementAt(n))
+ .getDisplayName();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the amount of elements in the list
+ * @see javax.swing.ListModel#getSize()
+ */
+ public int getSize() {
+ ProfileConfiguration config = ProjectManager.getManager()
+ .getCurrentProject().getProfileConfiguration();
+ return config.getProfiles().size();
+ }
+
+ /**
+ * @param arg0
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void removeListDataListener(ListDataListener arg0) {
+ listeners.remove(arg0);
+ }
+ }
+
+ /**
+ * The default constructor for this class
+ */
+ public ProjectSettingsTabProfile() {
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+
+ //////////////
+
+ JPanel setDefStereoV = new JPanel();
+ setDefStereoV.setLayout(new FlowLayout());
+
+ stereoLabel.setLabelFor(stereoField);
+ setDefStereoV.add(stereoLabel);
+ setDefStereoV.add(stereoField);
+
+ DefaultComboBoxModel cmodel = new DefaultComboBoxModel();
+ stereoField.setModel(cmodel);
+
+ cmodel.addElement(Translator.localize("menu.popup.stereotype-view.textual"));
+ cmodel.addElement(Translator.localize("menu.popup.stereotype-view.big-icon"));
+ cmodel.addElement(Translator.localize("menu.popup.stereotype-view.small-icon"));
+
+ stereoField.addItemListener(new ItemListener() {
+
+ public void itemStateChanged(ItemEvent e) {
+ ProjectSettings ps = ProjectManager.getManager().getCurrentProject().getProjectSettings();
+ Object src = e.getSource();
+
+ if (src == stereoField) {
+ Object item = e.getItem();
+ DefaultComboBoxModel model = (DefaultComboBoxModel) stereoField
+ .getModel();
+ int idx = model.getIndexOf(item);
+
+ switch (idx) {
+ case 0:
+ ps.setDefaultStereotypeView(FigNodeModelElement.STEREOTYPE_VIEW_TEXTUAL);
+ break;
+ case 1:
+ ps.setDefaultStereotypeView(FigNodeModelElement.STEREOTYPE_VIEW_BIG_ICON);
+ break;
+ case 2:
+ ps.setDefaultStereotypeView(FigNodeModelElement.STEREOTYPE_VIEW_SMALL_ICON);
+ break;
+ }
+ }
+ }
+
+ });
+
+ add(setDefStereoV);
+
+ ////////////
+
+
+ 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));
+
+ JPanel leftList = new JPanel();
+ leftList.setLayout(new BorderLayout());
+ leftList.add(new JLabel(Translator
+ .localize("tab.profiles.userdefined.available")),
+ BorderLayout.NORTH);
+ leftList.add(availableList, BorderLayout.CENTER);
+ configPanel.add(leftList);
+
+ JPanel centerButtons = new JPanel();
+ centerButtons.setLayout(new BoxLayout(centerButtons, BoxLayout.Y_AXIS));
+ centerButtons.add(addButton);
+ centerButtons.add(removeButton);
+ configPanel.add(centerButtons);
+
+ JPanel rightList = new JPanel();
+ rightList.setLayout(new BorderLayout());
+ rightList.add(new JLabel(Translator
+ .localize("tab.profiles.userdefined.active")),
+ BorderLayout.NORTH);
+ rightList.add(usedList, BorderLayout.CENTER);
+ configPanel.add(rightList);
+
+ addButton.addActionListener(this);
+ removeButton.addActionListener(this);
+
+ add(configPanel);
+
+ JPanel lffPanel = new JPanel();
+ lffPanel.setLayout(new FlowLayout());
+ lffPanel.add(loadFromFile);
+ lffPanel.add(unregisterProfile);
+
+ loadFromFile.addActionListener(this);
+ unregisterProfile.addActionListener(this);
+
+ add(lffPanel);
+ }
+
+ /**
+ * @param arg0
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ AvailableProfilesListModel modelAvl = ((AvailableProfilesListModel) availableList
+ .getModel());
+ UsedProfilesListModel modelUsd = ((UsedProfilesListModel) usedList
+ .getModel());
+
+ if (arg0.getSource() == addButton) {
+ if (availableList.getSelectedIndex() != -1) {
+ Profile selected = modelAvl.getProfileAt(availableList
+ .getSelectedIndex());
+ ProjectManager.getManager().getCurrentProject()
+ .getProfileConfiguration().addProfile(selected);
+
+ modelAvl.fireListeners();
+ modelUsd.fireListeners();
+ }
+ } else if (arg0.getSource() == removeButton) {
+ if (usedList.getSelectedIndex() != -1) {
+ Profile selected = modelUsd.getProfileAt(usedList
+ .getSelectedIndex());
+ ProjectManager.getManager().getCurrentProject()
+ .getProfileConfiguration().removeProfile(selected);
+
+ modelAvl.fireListeners();
+ modelUsd.fireListeners();
+ }
+ } else if (arg0.getSource() == unregisterProfile) {
+ if (availableList.getSelectedIndex() != -1) {
+ Profile selected = modelAvl.getProfileAt(availableList
+ .getSelectedIndex());
+ if (selected instanceof UserDefinedProfile) {
+ ProfileManagerImpl.getInstance().removeProfile(selected);
+
+ modelAvl.fireListeners();
+ modelUsd.fireListeners();
+ } else {
+ JOptionPane.showMessageDialog(this,Translator.localize("tab.profiles.cannotdelete"));
+ }
+ }
+ } 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(".xml")
+ || file.getName().endsWith(".xmi")));
+ }
+
+ public String getDescription() {
+ return "XMI Files";
+ }
+
+ });
+
+ int ret = fileChooser.showOpenDialog(this);
+ if (ret == JFileChooser.APPROVE_OPTION) {
+ File file = fileChooser.getSelectedFile();
+
+ Profile profile = new UserDefinedProfile(file);
+
+ if (profile.getModel() != null) {
+ ProfileManagerImpl.getInstance().registerProfile(profile);
+
+ ProjectManager.getManager().getCurrentProject()
+ .getProfileConfiguration().addProfile(profile);
+
+ UsedProfilesListModel model =
+ ((UsedProfilesListModel) usedList.getModel());
+ model.fireListeners();
+ } else {
+ JOptionPane.showMessageDialog(this,
+ Translator.localize("tab.profiles.userdefined.errorloading"));
+ }
+ }
+ }
+
+ availableList.validate();
+ usedList.validate();
+ }
+
+ /**
+ * @return the internationalization key that containing the name of this tab
+ * @see org.argouml.application.api.GUISettingsTabInterface#getTabKey()
+ */
+ public String getTabKey() {
+ return "tab.profiles";
+ }
+
+ /**
+ * @return the panel containing this tab
+ * @see org.argouml.application.api.GUISettingsTabInterface#getTabPanel()
+ */
+ public JPanel getTabPanel() {
+ return this;
+ }
+
+ public void handleResetToDefault() {
+ // TODO: Auto-generated method stub
+
+ }
+
+ public void handleSettingsTabCancel() {
+ // TODO: Auto-generated method stub
+
+ }
+
+ public void handleSettingsTabRefresh() {
+ ProjectSettings ps = ProjectManager.getManager().getCurrentProject().getProjectSettings();
+
+ switch (ps.getDefaultStereotypeViewValue()) {
+ case FigNodeModelElement.STEREOTYPE_VIEW_TEXTUAL:
+ stereoField.setSelectedIndex(0);
+ break;
+ case FigNodeModelElement.STEREOTYPE_VIEW_BIG_ICON:
+ stereoField.setSelectedIndex(1);
+ break;
+ case FigNodeModelElement.STEREOTYPE_VIEW_SMALL_ICON:
+ stereoField.setSelectedIndex(2);
+ break;
+ }
+
+ AvailableProfilesListModel modelAvl = ((AvailableProfilesListModel) availableList
+ .getModel());
+ UsedProfilesListModel modelUsd = ((UsedProfilesListModel) usedList
+ .getModel());
+
+ modelAvl.fireListeners();
+ modelUsd.fireListeners();
+ }
+
+ public void handleSettingsTabSave() {
+ // TODO: Auto-generated method stub
+
+ }
+
+}
Added: branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/SettingsTabProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/SettingsTabProfile.java?view=auto&rev=13090
==============================================================================
--- (empty file)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/SettingsTabProfile.java 2007-07-16 05:37:40-0700
@@ -0,0 +1,591 @@
+// $Id: ProfileSelectionTab.java 13040 2007-07-10 20:00:25Z linus $
+// Copyright (c) 2007 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 java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.File;
+import java.util.Iterator;
+import java.util.Vector;
+
+import javax.swing.BoxLayout;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.ListModel;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+import javax.swing.filechooser.FileFilter;
+
+import org.argouml.application.api.GUISettingsTabInterface;
+import org.argouml.configuration.Configuration;
+import org.argouml.configuration.ConfigurationKey;
+import org.argouml.i18n.Translator;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.uml.profile.Profile;
+import org.argouml.uml.profile.ProfileManager;
+import org.argouml.uml.profile.ProfileManagerImpl;
+import org.argouml.uml.profile.UserDefinedProfile;
+
+/**
+ * The Tab containing the global settings for proifiles
+ *
+ * @author Marcos Aurélio
+ */
+public class SettingsTabProfile extends JPanel implements
+ GUISettingsTabInterface, ActionListener {
+
+ private JButton loadFromFile = new JButton(Translator
+ .localize("tab.profiles.userdefined.load"));
+
+ private JButton unregisterProfile = new JButton(Translator
+ .localize("tab.profiles.userdefined.unload"));
+
+ private JButton addButton = new JButton(">>");
+
+ private JButton removeButton = new JButton("<<");
+
+ private JList availableList = new JList(new AvailableProfilesListModel());
+
+ private JList defaultList = new JList(new DefaultProfilesListModel());
+
+ ////////
+
+ private JList directoryList = new JList();
+
+ private JButton addDirectory = new JButton(Translator
+ .localize("tab.profiles.directories.add"));
+
+ private JButton removeDirectory = new JButton(Translator
+ .localize("tab.profiles.directories.remove"));
+
+ private JButton refreshProfiles = new JButton(Translator
+ .localize("tab.profiles.directories.refresh"));
+
+ ///////
+
+ /**
+ * The configuration key for the default stereotype view.
+ */
+ public static final ConfigurationKey KEY_DEFAULT_STEREOTYPE_VIEW = Configuration
+ .makeKey("profiles", "stereotypeView");
+
+ private JLabel stereoLabel =
+ new JLabel(Translator.localize("menu.popup.stereotype-view") + ": ");
+
+ private JComboBox stereoField = new JComboBox();
+
+ /**
+ * This List contains the registered profiles that have not been applied
+ * to the current project
+ *
+ * @author maurelio1234
+ */
+ private class AvailableProfilesListModel implements ListModel {
+ private ProfileManager profileManager = ProfileManagerImpl
+ .getInstance();
+
+ private Vector listeners = new Vector();
+
+ /**
+ * @param arg0
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void addListDataListener(ListDataListener arg0) {
+ listeners.add(arg0);
+ }
+
+ /**
+ * Fire listeners
+ */
+ public void fireListeners() {
+ ListDataEvent evt = new ListDataEvent(this,
+ ListDataEvent.CONTENTS_CHANGED, 0, getSize());
+ for (int i = 0; i < listeners.size(); ++i) {
+ ((ListDataListener) listeners.elementAt(i))
+ .contentsChanged(evt);
+ }
+ }
+
+ /**
+ * @param n the profile to be returned
+ * @return the n-th profile at the registered profiles list
+ */
+ public Profile getProfileAt(int n) {
+ Vector list = ProfileManagerImpl.getInstance().getDefaultProfiles();
+
+ Vector registeredProfiles = profileManager.getRegisteredProfiles();
+ int count = 0;
+ for (int i = 0; i < registeredProfiles.size(); ++i) {
+ if (!list.contains(
+ registeredProfiles.elementAt(i))) {
+
+ if (count == n) {
+ return ((Profile) registeredProfiles.elementAt(i));
+ }
+ ++count;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param arg0
+ * @return the arg0-th element of this list
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ public Object getElementAt(int arg0) {
+ Profile p = getProfileAt(arg0);
+ if (p != null) {
+ return p.getDisplayName();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the amount of registered profiles not applied to current
+ * project
+ * @see javax.swing.ListModel#getSize()
+ */
+ public int getSize() {
+ Vector list = ProfileManagerImpl.getInstance().getDefaultProfiles();
+ Vector registeredProfiles = profileManager.getRegisteredProfiles();
+ int count = 0;
+ for (int i = 0; i < registeredProfiles.size(); ++i) {
+ if (!list.contains(
+ registeredProfiles.elementAt(i))) {
+ ++count;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * @param arg0
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void removeListDataListener(ListDataListener arg0) {
+ listeners.remove(arg0);
+ }
+ }
+
+ /**
+ * This list contains the profiles that are applied by default
+ *
+ * @author maurelio1234
+ */
+ private class DefaultProfilesListModel implements ListModel {
+ private Vector listeners = new Vector();
+
+ /**
+ * @param arg0
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void addListDataListener(ListDataListener arg0) {
+ listeners.add(arg0);
+ }
+
+ /**
+ * Fires listeners
+ */
+ public void fireListeners() {
+ ListDataEvent evt = new ListDataEvent(this,
+ ListDataEvent.CONTENTS_CHANGED, 0, getSize());
+ for (int i = 0; i < listeners.size(); ++i) {
+ ((ListDataListener) listeners.elementAt(i))
+ .contentsChanged(evt);
+ }
+ }
+
+ /**
+ * @param n
+ * @return the n-th profile on this list
+ */
+ public Profile getProfileAt(int n) {
+ return ((Profile) ProfileManagerImpl.getInstance().getDefaultProfiles().elementAt(n));
+ }
+
+ /**
+ * @param n
+ * @return the n-th profile on this list
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ public Object getElementAt(int n) {
+ Vector list = ProfileManagerImpl.getInstance().getDefaultProfiles();
+ if (n >= 0 && n < list.size()) {
+ return ((Profile) list.elementAt(n))
+ .getDisplayName();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the amount of elements in the list
+ * @see javax.swing.ListModel#getSize()
+ */
+ public int getSize() {
+ return ProfileManagerImpl.getInstance().getDefaultProfiles().size();
+ }
+
+ /**
+ * @param arg0
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void removeListDataListener(ListDataListener arg0) {
+ listeners.remove(arg0);
+ }
+ }
+
+ /**
+ * The default constructor for this class
+ */
+ public SettingsTabProfile() {
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+
+ //////////////
+
+ JPanel setDefStereoV = new JPanel();
+ setDefStereoV.setLayout(new FlowLayout());
+
+ stereoLabel.setLabelFor(stereoField);
+ setDefStereoV.add(stereoLabel);
+ setDefStereoV.add(stereoField);
+
+ DefaultComboBoxModel cmodel = new DefaultComboBoxModel();
+ stereoField.setModel(cmodel);
+
+ cmodel.addElement(Translator.localize("menu.popup.stereotype-view.textual"));
+ cmodel.addElement(Translator.localize("menu.popup.stereotype-view.big-icon"));
+ cmodel.addElement(Translator.localize("menu.popup.stereotype-view.small-icon"));
+
+ switch (Configuration.getInteger(KEY_DEFAULT_STEREOTYPE_VIEW,
+ FigNodeModelElement.STEREOTYPE_VIEW_TEXTUAL)) {
+ case FigNodeModelElement.STEREOTYPE_VIEW_TEXTUAL:
+ stereoField.setSelectedIndex(0);
+ break;
+ case FigNodeModelElement.STEREOTYPE_VIEW_BIG_ICON:
+ stereoField.setSelectedIndex(1);
+ break;
+ case FigNodeModelElement.STEREOTYPE_VIEW_SMALL_ICON:
+ stereoField.setSelectedIndex(2);
+ break;
+ }
+
+ stereoField.addItemListener(new ItemListener() {
+
+ public void itemStateChanged(ItemEvent e) {
+ Object src = e.getSource();
+
+ if (src == stereoField) {
+ Object item = e.getItem();
+ DefaultComboBoxModel model = (DefaultComboBoxModel) stereoField
+ .getModel();
+ int idx = model.getIndexOf(item);
+
+ switch (idx) {
+ case 0:
+ Configuration.setInteger(KEY_DEFAULT_STEREOTYPE_VIEW,
+ FigNodeModelElement.STEREOTYPE_VIEW_TEXTUAL);
+ break;
+ case 1:
+ Configuration.setInteger(KEY_DEFAULT_STEREOTYPE_VIEW,
+ FigNodeModelElement.STEREOTYPE_VIEW_BIG_ICON);
+ break;
+ case 2:
+ Configuration.setInteger(KEY_DEFAULT_STEREOTYPE_VIEW,
+ FigNodeModelElement.STEREOTYPE_VIEW_SMALL_ICON);
+ break;
+ }
+ }
+ }
+
+ });
+
+ add(setDefStereoV);
+
+ ////////////
+
+ DefaultListModel model = new DefaultListModel();
+ directoryList.setModel(model);
+ Iterator it = ProfileManagerImpl.getInstance().getSearchPathDirectories().iterator();
+
+ while(it.hasNext()) {
+ String dir = (String) it.next();
+ model.addElement(dir);
+ }
+
+ 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));
+
+ lcb.add(addDirectory);
+ lcb.add(removeDirectory);
+
+ addDirectory.addActionListener(this);
+ removeDirectory.addActionListener(this);
+
+ dlist.add(directoryList, BorderLayout.CENTER);
+ dlist.add(lcb, BorderLayout.EAST);
+
+ sdirPanel.add(new JLabel(Translator
+ .localize("tab.profiles.directories.desc")));
+ sdirPanel.add(dlist);
+
+ add(sdirPanel);
+
+ /////
+
+ 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));
+
+ JPanel leftList = new JPanel();
+ leftList.setLayout(new BorderLayout());
+ leftList.add(new JLabel(Translator
+ .localize("tab.profiles.userdefined.available")),
+ BorderLayout.NORTH);
+ leftList.add(availableList, BorderLayout.CENTER);
+ configPanel.add(leftList);
+
+ JPanel centerButtons = new JPanel();
+ centerButtons.setLayout(new BoxLayout(centerButtons, BoxLayout.Y_AXIS));
+ centerButtons.add(addButton);
+ centerButtons.add(removeButton);
+ configPanel.add(centerButtons);
+
+ JPanel rightList = new JPanel();
+ rightList.setLayout(new BorderLayout());
+ rightList.add(new JLabel(Translator
+ .localize("tab.profiles.userdefined.default")),
+ BorderLayout.NORTH);
+
+ rightList.add(defaultList, BorderLayout.CENTER);
+ configPanel.add(rightList);
+
+ addButton.addActionListener(this);
+ removeButton.addActionListener(this);
+
+ add(configPanel);
+
+ JPanel lffPanel = new JPanel();
+ lffPanel.setLayout(new FlowLayout());
+ lffPanel.add(loadFromFile);
+ lffPanel.add(unregisterProfile);
+ lffPanel.add(refreshProfiles);
+
+ loadFromFile.addActionListener(this);
+ unregisterProfile.addActionListener(this);
+ refreshProfiles.addActionListener(this); //ADDED
+
+ add(lffPanel);
+ }
+
+ /**
+ * @param arg0
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ AvailableProfilesListModel modelAvl = ((AvailableProfilesListModel) availableList
+ .getModel());
+ DefaultProfilesListModel modelUsd = ((DefaultProfilesListModel) defaultList
+ .getModel());
+
+ if (arg0.getSource() == addButton) {
+ if (availableList.getSelectedIndex() != -1) {
+ Profile selected = modelAvl.getProfileAt(availableList
+ .getSelectedIndex());
+ ProfileManagerImpl.getInstance().addToDefaultProfiles(selected);
+
+ modelAvl.fireListeners();
+ modelUsd.fireListeners();
+ }
+ } else if (arg0.getSource() == removeButton) {
+ if (defaultList.getSelectedIndex() != -1) {
+ Profile selected = modelUsd.getProfileAt(defaultList
+ .getSelectedIndex());
+ ProfileManagerImpl.getInstance().removeFromDefaultProfiles(
+ selected);
+
+ modelAvl.fireListeners();
+ modelUsd.fireListeners();
+ }
+ } else if (arg0.getSource() == unregisterProfile) {
+ if (availableList.getSelectedIndex() != -1) {
+ Profile selected = modelAvl.getProfileAt(availableList
+ .getSelectedIndex());
+ if (selected instanceof UserDefinedProfile) {
+ ProfileManagerImpl.getInstance().removeProfile(selected);
+
+ modelAvl.fireListeners();
+ modelUsd.fireListeners();
+ } else {
+ JOptionPane.showMessageDialog(this, Translator
+ .localize("tab.profiles.cannotdelete"));
+ }
+ }
+ } 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(".xml")
+ || file.getName().endsWith(".xmi")));
+ }
+
+ public String getDescription() {
+ return "XMI Files";
+ }
+
+ });
+
+ int ret = fileChooser.showOpenDialog(this);
+ if (ret == JFileChooser.APPROVE_OPTION) {
+ File file = fileChooser.getSelectedFile();
+
+ Profile profile = new UserDefinedProfile(file);
+
+ if (profile.getModel() != null) {
+ ProfileManagerImpl.getInstance().registerProfile(profile);
+
+ DefaultProfilesListModel model =
+ ((DefaultProfilesListModel) defaultList.getModel());
+ model.fireListeners();
+ } else {
+ JOptionPane.showMessageDialog(this,
+ Translator.localize("tab.profiles.userdefined.errorloading"));
+ }
+ }
+
+ ///
+ } else if (arg0.getSource() == removeDirectory) {
+ if (directoryList.getSelectedIndex() != -1) {
+ int idx = directoryList.getSelectedIndex();
+ String item = (String) directoryList.getSelectedValue();
+ ProfileManagerImpl.getInstance().removeSearchPathDirectory(item);
+
+ ((DefaultListModel)directoryList.getModel()).remove(idx);
+ }
+ } else if (arg0.getSource() == refreshProfiles) {
+ ProfileManagerImpl.getInstance().refreshRegisteredProfiles();
+ modelAvl.fireListeners();
+ } else if (arg0.getSource() == addDirectory) {
+ JFileChooser fileChooser = new JFileChooser();
+ fileChooser.setFileFilter(new FileFilter() {
+
+ public boolean accept(File file) {
+ return file.isDirectory();
+ }
+
+ public String getDescription() {
+ return "Directories";
+ }
+
+ });
+
+ fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+
+ int ret = fileChooser.showOpenDialog(this);
+ if (ret == JFileChooser.APPROVE_OPTION) {
+ File file = fileChooser.getSelectedFile();
+
+ String path = file.getAbsolutePath();
+
+ ProfileManagerImpl.getInstance().addSearchPathDirectory(path);
+ ((DefaultListModel)directoryList.getModel()).addElement(path);
+
+ ProfileManagerImpl.getInstance().refreshRegisteredProfiles();
+ }
+
+ }
+
+ availableList.validate();
+ defaultList.validate();
+ }
+
+ /**
+ * @return the internationalization key that containing the name of this tab
+ * @see org.argouml.application.api.GUISettingsTabInterface#getTabKey()
+ */
+ public String getTabKey() {
+ return "tab.profiles";
+ }
+
+ /**
+ * @return the panel containing this tab
+ * @see org.argouml.application.api.GUISettingsTabInterface#getTabPanel()
+ */
+ public JPanel getTabPanel() {
+ return this;
+ }
+
+ public void handleResetToDefault() {
+ // TODO: Auto-generated method stub
+
+ }
+
+ public void handleSettingsTabCancel() {
+ // TODO: Auto-generated method stub
+
+ }
+
+ public void handleSettingsTabRefresh() {
+ // TODO: Auto-generated method stub
+
+ }
+
+ public void handleSettingsTabSave() {
+ // TODO: Auto-generated method stub
+
+ }
+
+}
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/StylePanelFig.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/StylePanelFig.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/StylePanelFig.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/StylePanelFig.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/StylePanelFig.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/StylePanelFig.java 2007-07-16 05:37:40-0700
@@ -33,6 +33,8 @@
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultListModel;
import javax.swing.JColorChooser;
import javax.swing.JComboBox;
import javax.swing.JLabel;
@@ -42,12 +44,13 @@
import org.argouml.i18n.Translator;
import org.argouml.swingext.SpacerPanel;
import org.argouml.uml.diagram.ui.FigEdgeModelElement;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
import org.tigris.gef.presentation.Fig;
import org.tigris.gef.ui.ColorRenderer;
/**
* The basic stylepanel which provides the boundaries box,
- * line and fill color information.
+ * line and fill color information and the stereotype view combo box.
*
*/
public class StylePanelFig
@@ -72,6 +75,11 @@
private JComboBox lineField = new JComboBox();
+ private JLabel stereoLabel =
+ new JLabel(Translator.localize("menu.popup.stereotype-view") + ": ");
+
+ private JComboBox stereoField = new JComboBox();
+
private SpacerPanel spacer = new SpacerPanel();
private SpacerPanel spacer2 = new SpacerPanel();
@@ -102,6 +110,7 @@
bboxField.addFocusListener(this);
fillField.addItemListener(this);
lineField.addItemListener(this);
+ stereoField.addItemListener(this);
fillField.setRenderer(new ColorRenderer());
lineField.setRenderer(new ColorRenderer());
@@ -117,6 +126,10 @@
lineLabel.setLabelFor(lineField);
add(lineLabel);
add(lineField);
+
+ stereoLabel.setLabelFor(stereoField);
+ add(stereoLabel);
+ add(stereoField);
}
/**
@@ -164,6 +177,13 @@
lineField.addItem(Color.orange);
lineField.addItem(Color.pink);
lineField.addItem(CUSTOM_ITEM);
+
+ DefaultComboBoxModel model = new DefaultComboBoxModel();
+ stereoField.setModel(model);
+
+ model.addElement(Translator.localize("menu.popup.stereotype-view.textual"));
+ model.addElement(Translator.localize("menu.popup.stereotype-view.big-icon"));
+ model.addElement(Translator.localize("menu.popup.stereotype-view.small-icon"));
}
/**
@@ -248,6 +268,24 @@
lineField.setSelectedIndex(0);
}
+ stereoField.setEnabled(target instanceof FigNodeModelElement);
+ stereoLabel.setEnabled(target instanceof FigNodeModelElement);
+
+ if (target instanceof FigNodeModelElement) {
+ FigNodeModelElement fig = (FigNodeModelElement) target;
+
+ switch (fig.getStereotypeView()) {
+ case FigNodeModelElement.STEREOTYPE_VIEW_TEXTUAL:
+ stereoField.setSelectedIndex(0);
+ break;
+ case FigNodeModelElement.STEREOTYPE_VIEW_BIG_ICON:
+ stereoField.setSelectedIndex(1);
+ break;
+ case FigNodeModelElement.STEREOTYPE_VIEW_SMALL_ICON:
+ stereoField.setSelectedIndex(2);
+ break;
+ }
+ }
}
/**
@@ -441,6 +479,26 @@
target.getLineColor());
}
setTargetLine();
+ } else if (src == stereoField) {
+ if (target instanceof FigNodeModelElement) {
+ Object item = e.getItem();
+ DefaultComboBoxModel model = (DefaultComboBoxModel) stereoField
+ .getModel();
+ int idx = model.getIndexOf(item);
+ FigNodeModelElement fig = (FigNodeModelElement) target;
+
+ switch (idx) {
+ case 0:
+ fig.setStereotypeView(FigNodeModelElement.STEREOTYPE_VIEW_TEXTUAL);
+ break;
+ case 1:
+ fig.setStereotypeView(FigNodeModelElement.STEREOTYPE_VIEW_BIG_ICON);
+ break;
+ case 2:
+ fig.setStereotypeView(FigNodeModelElement.STEREOTYPE_VIEW_SMALL_ICON);
+ break;
+ }
+ }
}
}
}
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/diagram/ui/FigNodeModelElement.java 2007-07-16 05:37:40-0700
@@ -360,6 +360,8 @@
setShadowSize(ps.getDefaultShadowWidthValue());
/* TODO: how to handle changes in shadowsize
* from the project properties? */
+
+ stereotypeView = ps.getDefaultStereotypeViewValue();
}
/**
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileConfiguration.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileConfiguration.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileConfiguration.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileConfiguration.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileConfiguration.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileConfiguration.java 2007-07-16 05:37:40-0700
@@ -68,14 +68,8 @@
defaultProfile = ProfileUML.getInstance();
- Profile cppProfile = ProfileCpp.getInstance();
- Profile javaProfile = ProfileJava.getInstance();
-
- ProfileManagerImpl.getInstance().registerProfile(cppProfile);
- ProfileManagerImpl.getInstance().registerProfile(javaProfile);
+ addProfile(defaultProfile);
- addProfile(defaultProfile);
- addProfile(javaProfile);
activateFormatingStrategy(defaultProfile);
}
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManager.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManager.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManager.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManager.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManager.java 2007-07-16 05:37:40-0700
@@ -54,4 +54,48 @@
* @return the profile instance for the class
*/
Profile getProfileForClass(String className);
+
+ /**
+ * @return the default set of profiles
+ */
+ Vector getDefaultProfiles();
+
+ /**
+ * Adds a profile to the default list.
+ *
+ * @param p profile to add
+ */
+ void addToDefaultProfiles(Profile p);
+
+ /**
+ * Remove a profile from the default list
+ *
+ * @param p the profile to be removed
+ */
+ void removeFromDefaultProfiles(Profile p);
+
+ /**
+ * Adds a new directory to the directory list
+ *
+ * @param path user defined directory
+ */
+ void addSearchPathDirectory(String path);
+
+ /**
+ * Removes a directory from the directory list
+ *
+ * @param path
+ */
+ void removeSearchPathDirectory(String path);
+
+ /**
+ * @return the current directory list
+ */
+ Vector getSearchPathDirectories();
+
+ /**
+ * Looks for XMI files at the current directory list and registers
+ * them as user defined profiles.
+ */
+ void refreshRegisteredProfiles();
}
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManagerImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManagerImpl.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManagerImpl.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManagerImpl.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManagerImpl.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/ProfileManagerImpl.java 2007-07-16 05:37:40-0700
@@ -24,9 +24,14 @@
package org.argouml.uml.profile;
+import java.io.File;
import java.util.Iterator;
+import java.util.StringTokenizer;
import java.util.Vector;
+import org.argouml.configuration.Configuration;
+import org.argouml.configuration.ConfigurationKey;
+
/**
* Default <code>ProfileManager</code> implementation
*
@@ -34,28 +39,139 @@
*/
public class ProfileManagerImpl implements ProfileManager {
+ /**
+ * The configuration key for the default profiles.
+ */
+ public static final ConfigurationKey KEY_DEFAULT_PROFILES = Configuration
+ .makeKey("profiles", "default");
+
+ /**
+ * The configuration key for the search directories.
+ */
+ public static final ConfigurationKey KEY_DEFAULT_DIRECTORIES = Configuration
+ .makeKey("profiles", "directories");
+
private static ProfileManager instance = null;
- private Vector profiles = new Vector();
+
+ /**
+ * Avoids recursive configuration update when loading configuration
+ */
+ private boolean disableConfigurationUpdate = false;
+ private Vector profiles = new Vector();
+
+ private Vector defaultProfiles = new Vector();
+
+ private Vector searchDirectories = new Vector();
+
private ProfileManagerImpl() {
+ registerProfile(ProfileJava.getInstance());
+ registerProfile(ProfileCpp.getInstance());
+
+ loadDirectoriesFromConfiguration();
+
+ refreshRegisteredProfiles();
+
+ loadDefaultProfilesfromConfiguration();
}
-
+
+ private void loadDefaultProfilesfromConfiguration() {
+ disableConfigurationUpdate = true;
+
+ StringTokenizer tokenizer = new StringTokenizer(Configuration
+ .getString(KEY_DEFAULT_PROFILES), "*", false);
+
+ while (tokenizer.hasMoreTokens()) {
+ String desc = tokenizer.nextToken();
+
+ if (desc.charAt(0) == 'U') {
+ String fileName = desc.substring(1);
+ Profile p = findUserDefinedProfile(new File(fileName));
+
+ if (p != null) {
+ addToDefaultProfiles(p);
+ }
+ } else if (desc.charAt(0) == 'C') {
+ String className = desc.substring(1);
+ Profile p = getProfileForClass(className);
+
+ if (p != null) {
+ addToDefaultProfiles(p);
+ }
+ }
+ }
+
+ disableConfigurationUpdate = false;
+ }
+
+ private void updateDefaultProfilesConfiguration() {
+ if (!disableConfigurationUpdate) {
+ StringBuffer buf = new StringBuffer();
+
+ Iterator it = defaultProfiles.iterator();
+
+ while (it.hasNext()) {
+ Profile p = (Profile) it.next();
+
+ if (p instanceof UserDefinedProfile) {
+ buf.append("U"
+ + ((UserDefinedProfile) p).getModelFile()
+ .getAbsolutePath());
+ } else {
+ buf.append("C" + p.getClass().getName());
+ }
+
+ buf.append("*");
+ }
+
+ Configuration.setString(KEY_DEFAULT_PROFILES, buf.toString());
+ }
+ }
+
+ private void loadDirectoriesFromConfiguration() {
+ disableConfigurationUpdate = true;
+
+ StringTokenizer tokenizer = new StringTokenizer(Configuration
+ .getString(KEY_DEFAULT_DIRECTORIES), "*", false);
+
+ while (tokenizer.hasMoreTokens()) {
+ searchDirectories.add(tokenizer.nextToken());
+ }
+
+ disableConfigurationUpdate = false;
+ }
+
+ private void updateSearchDirectoriesConfiguration() {
+ if (!disableConfigurationUpdate) {
+ StringBuffer buf = new StringBuffer();
+
+ Iterator it = searchDirectories.iterator();
+
+ while (it.hasNext()) {
+ String s = (String) it.next();
+ buf.append(s + "*");
+ }
+
+ Configuration.setString(KEY_DEFAULT_DIRECTORIES, buf.toString());
+ }
+ }
+
/**
* @return the unique instance for this class
*/
public static ProfileManager getInstance() {
- if (instance == null) {
- instance = new ProfileManagerImpl();
- }
- return instance;
+ if (instance == null) {
+ instance = new ProfileManagerImpl();
+ }
+ return instance;
}
-
+
/**
* @return the list of profiles
* @see org.argouml.uml.profile.ProfileManager#getRegisteredProfiles()
*/
public Vector getRegisteredProfiles() {
- return profiles;
+ return profiles;
}
/**
@@ -64,7 +180,8 @@
*/
public void registerProfile(Profile p) {
if (!profiles.contains(p)) {
- if (getProfileForClass(p.getClass().getName()) == null) {
+ if (p instanceof UserDefinedProfile
+ || getProfileForClass(p.getClass().getName()) == null) {
profiles.add(p);
}
}
@@ -75,7 +192,8 @@
* @see org.argouml.uml.profile.ProfileManager#removeProfile(org.argouml.uml.profile.Profile)
*/
public void removeProfile(Profile p) {
- profiles.remove(p);
+ profiles.remove(p);
+ defaultProfiles.remove(p);
}
/**
@@ -86,16 +204,117 @@
public Profile getProfileForClass(String profileClass) {
Iterator it = profiles.iterator();
Profile found = null;
-
- while(it.hasNext()) {
+
+ while (it.hasNext()) {
Profile p = (Profile) it.next();
if (p.getClass().getName().equals(profileClass)) {
found = p;
break;
}
}
-
+
return found;
}
+ /**
+ * @param p th profile
+ * @see org.argouml.uml.profile.ProfileManager#addToDefaultProfiles(org.argouml.uml.profile.Profile)
+ */
+ public void addToDefaultProfiles(Profile p) {
+ if (p != null && profiles.contains(p)) {
+ defaultProfiles.add(p);
+ updateDefaultProfilesConfiguration();
+ }
+ }
+
+ /**
+ * @return the list
+ * @see org.argouml.uml.profile.ProfileManager#getDefaultProfiles()
+ */
+ public Vector getDefaultProfiles() {
+ return defaultProfiles;
+ }
+
+ /**
+ * @param p the profile
+ * @see org.argouml.uml.profile.ProfileManager#removeFromDefaultProfiles(org.argouml.uml.profile.Profile)
+ */
+ public void removeFromDefaultProfiles(Profile p) {
+ if (p != null && profiles.contains(p)) {
+ defaultProfiles.remove(p);
+ updateDefaultProfilesConfiguration();
+ }
+ }
+
+ public void addSearchPathDirectory(String path) {
+ if (!searchDirectories.contains(path)) {
+ searchDirectories.add(path);
+ updateSearchDirectoriesConfiguration();
+ }
+ }
+
+ /**
+ * @return the directory list
+ * @see org.argouml.uml.profile.ProfileManager#getSearchPathDirectories()
+ */
+ public Vector getSearchPathDirectories() {
+ return searchDirectories;
+ }
+
+ /**
+ * @param path the directory to remove
+ * @see org.argouml.uml.profile.ProfileManager#removeSearchPathDirectory(java.lang.String)
+ */
+ public void removeSearchPathDirectory(String path) {
+ if (path != null) {
+ searchDirectories.remove(path);
+ updateSearchDirectoriesConfiguration();
+ }
+ }
+
+ /**
+ * @see org.argouml.uml.profile.ProfileManager#refreshRegisteredProfiles()
+ */
+ public void refreshRegisteredProfiles() {
+ Iterator it = searchDirectories.iterator();
+
+ while (it.hasNext()) {
+ File dir = new File((String) it.next());
+
+ if (dir.exists()) {
+ File[] files = dir.listFiles();
+
+ for (int i = 0; i < files.length; ++i) {
+ if (files[i].getName().toLowerCase().endsWith(".xmi")) {
+
+ boolean found = findUserDefinedProfile(files[i]) != null;
+
+ if (!found) {
+ UserDefinedProfile udp = new UserDefinedProfile(
+ files[i]);
+ registerProfile(udp);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private Profile findUserDefinedProfile(File file) {
+ Iterator it2 = profiles.iterator();
+
+ while (it2.hasNext()) {
+ Profile p = (Profile) it2.next();
+
+ if (p instanceof UserDefinedProfile) {
+ UserDefinedProfile udp = (UserDefinedProfile) p;
+
+ if (udp.getModelFile().equals(file)) {
+ return udp;
+ }
+ }
+ }
+ return null;
+ }
+
}
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/UserDefinedProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/UserDefinedProfile.java?view=diff&rev=13090&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/UserDefinedProfile.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/UserDefinedProfile.java&r1=13089&r2=13090
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/UserDefinedProfile.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/uml/profile/UserDefinedProfile.java 2007-07-16 05:37:40-0700
@@ -87,4 +87,8 @@
public File getModelFile() {
return modelFile;
}
+
+ public String toString() {
+ return super.toString() + " [" + getModelFile() + "]";
+ }
}
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.