svn commit: r14825 - trunk/src/argouml-app/src/org/argouml: i18n notation/ui swingext ui uml/diagram/ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: euluis
Date: 2008-05-28 16:21:50-0700
New Revision: 14825

Added:
   trunk/src/argouml-app/src/org/argouml/swingext/JLinkButton.java   (contents, props changed)
Modified:
   trunk/src/argouml-app/src/org/argouml/i18n/action.properties
   trunk/src/argouml-app/src/org/argouml/i18n/button.properties
   trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties
   trunk/src/argouml-app/src/org/argouml/i18n/label.properties
   trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java
   trunk/src/argouml-app/src/org/argouml/ui/ActionProjectSettings.java
   trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java   (contents, props changed)
   trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SettingsTabDiagramAppearance.java

Log:
issue 5014: patch by Bogdan Szanto that adds links to the Project Settings dialog from the Application Settings dialog for tabs that are repeated between the two dialogs.

Modified: trunk/src/argouml-app/src/org/argouml/i18n/action.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/action.properties?view=diff&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/i18n/action.properties&p2=trunk/src/argouml-app/src/org/argouml/i18n/action.properties&r1=14824&r2=14825
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/action.properties	(original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/action.properties	2008-05-28 16:21:50-0700
@@ -142,7 +142,7 @@
 action.page-setup = Page Setup...
 action.paste = Paste
 action.print = Print...
-action.properties = Properties
+action.properties = Project Properties
 action.properties.mnemonic = P
 action.redo = Redo
 action.remove-from-diagram = Remove From Diagram

Modified: trunk/src/argouml-app/src/org/argouml/i18n/button.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/button.properties?view=diff&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/i18n/button.properties&p2=trunk/src/argouml-app/src/org/argouml/i18n/button.properties&r1=14824&r2=14825
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/button.properties	(original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/button.properties	2008-05-28 16:21:50-0700
@@ -172,6 +172,7 @@
 button.ok = OK
 button.ok.mnemonic = O
 button.open = Open
+button.project-settings = Configure project specific settings...
 button.reason-given-below = Reason given below
 button.reason-given-below.mnemonic = R
 button.remove = Remove

Modified: trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties?view=diff&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties&p2=trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties&r1=14824&r2=14825
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties	(original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/dialog.properties	2008-05-28 16:21:50-0700
@@ -75,7 +75,7 @@
   report an issue at http://argouml.tigris.org
 dialog.exception.title = Error
 dialog.exception.unknown.error = An error has occurred.
-dialog.file.properties = File Properties
+dialog.file.properties = Project Properties
 dialog.find.button.clear-tabs = Clear Tabs
 dialog.find.button.find = Find
 dialog.find.column-name.description = Description

Modified: trunk/src/argouml-app/src/org/argouml/i18n/label.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/label.properties?view=diff&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/i18n/label.properties&p2=trunk/src/argouml-app/src/org/argouml/i18n/label.properties&r1=14824&r2=14825
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/label.properties	(original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/label.properties	2008-05-28 16:21:50-0700
@@ -450,3 +450,4 @@
 label.visibility-protected = protected
 label.visibility-public = public
 label.when = When
+label.warning = These are default settings which are applied to newly created 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&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java&p2=trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java&r1=14824&r2=14825
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/notation/ui/SettingsTabNotation.java	2008-05-28 16:21:50-0700
@@ -25,11 +25,13 @@
 package org.argouml.notation.ui;
 
 import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.FlowLayout;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
 
+import javax.swing.BoxLayout;
 import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JLabel;
@@ -45,6 +47,8 @@
 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.ShadowComboBox;
 
 /**
@@ -90,9 +94,31 @@
         super();
         scope = settingsScope;
         setLayout(new BorderLayout());
+
         JPanel top = new JPanel();
+        top.setLayout(new BorderLayout());
+
+        if (settingsScope == Argo.SCOPE_APPLICATION) {
+            JPanel warning = new JPanel();
+            warning.setLayout(new BoxLayout(warning, BoxLayout.PAGE_AXIS));
+            JLabel warningLabel = new JLabel(Translator
+                    .localize("label.warning"));
+            warningLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
+            warning.add(warningLabel);
+
+            JLinkButton projectSettings = new JLinkButton();
+            projectSettings.setAction(new ActionProjectSettings());
+            projectSettings.setText(Translator
+                    .localize("button.project-settings"));
+            projectSettings.setIcon(null);
+            projectSettings.setAlignmentX(Component.RIGHT_ALIGNMENT);
+            warning.add(projectSettings);
+
+            top.add(warning, BorderLayout.NORTH);
+        }
 
-        top.setLayout(new GridBagLayout());
+        JPanel settings = new JPanel();
+        settings.setLayout(new GridBagLayout());
 
         GridBagConstraints constraints = new GridBagConstraints();
         constraints.anchor = GridBagConstraints.WEST;
@@ -114,53 +140,55 @@
         notationLanguageLabel.setLabelFor(notationLanguage);
         notationLanguagePanel.add(notationLanguageLabel);
         notationLanguagePanel.add(notationLanguage);
-        top.add(notationLanguagePanel, constraints);
+        settings.add(notationLanguagePanel, constraints);
 
         showBoldNames = createCheckBox("label.show-bold-names");
-        top.add(showBoldNames, constraints);
+        settings.add(showBoldNames, constraints);
 
         useGuillemots = createCheckBox("label.use-guillemots");
-        top.add(useGuillemots, constraints);
+        settings.add(useGuillemots, constraints);
 
         // 2002-07-31
         // Jaap Branderhorst
         // from here made visibility etc. configurable
 
         showAssociationNames = createCheckBox("label.show-associationnames");
-        top.add(showAssociationNames, constraints);
+        settings.add(showAssociationNames, constraints);
 
         showVisibility = createCheckBox("label.show-visibility");
-        top.add(showVisibility, constraints);
+        settings.add(showVisibility, constraints);
 
         showMultiplicity = createCheckBox("label.show-multiplicity");
-        top.add(showMultiplicity, constraints);
+        settings.add(showMultiplicity, constraints);
 
         showInitialValue = createCheckBox("label.show-initialvalue");
-        top.add(showInitialValue, constraints);
+        settings.add(showInitialValue, constraints);
 
         showProperties = createCheckBox("label.show-properties");
-        top.add(showProperties, constraints);
+        settings.add(showProperties, constraints);
 
         showTypes = createCheckBox("label.show-types");
-        top.add(showTypes, constraints);
+        settings.add(showTypes, constraints);
 
         showStereotypes = createCheckBox("label.show-stereotypes");
-        top.add(showStereotypes, constraints);
+        settings.add(showStereotypes, constraints);
 
-        showSingularMultiplicities =
+        showSingularMultiplicities = 
             createCheckBox("label.show-singular-multiplicities");
-        top.add(showSingularMultiplicities, constraints);
+        settings.add(showSingularMultiplicities, constraints);
 
         constraints.insets = new Insets(5, 30, 0, 4);
-        JPanel defaultShadowWidthPanel =
-            new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
-        JLabel defaultShadowWidthLabel =
-            createLabel("label.default-shadow-width");
+        JPanel defaultShadowWidthPanel = new JPanel(new FlowLayout(
+            FlowLayout.LEFT, 5, 0));
+        JLabel defaultShadowWidthLabel = createLabel(
+            "label.default-shadow-width");
         defaultShadowWidth = new ShadowComboBox();
         defaultShadowWidthLabel.setLabelFor(defaultShadowWidth);
         defaultShadowWidthPanel.add(defaultShadowWidthLabel);
         defaultShadowWidthPanel.add(defaultShadowWidth);
-        top.add(defaultShadowWidthPanel, constraints);
+        settings.add(defaultShadowWidthPanel, constraints);
+
+        top.add(settings, BorderLayout.CENTER);
 
         add(top, BorderLayout.NORTH);
     }

Added: trunk/src/argouml-app/src/org/argouml/swingext/JLinkButton.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/swingext/JLinkButton.java?view=auto&rev=14825
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/swingext/JLinkButton.java	2008-05-28 16:21:50-0700
@@ -0,0 +1,252 @@
+// $Id$
+// Copyright (c) 2008 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.swingext;
+
+import java.awt.Color;
+import java.awt.Cursor;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.net.URL;
+
+import javax.swing.Action;
+import javax.swing.ButtonModel;
+import javax.swing.Icon;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.metal.MetalButtonUI;
+
+/**
+ * A button with the looks of an hyperlink.
+ * 
+ * Based on 
+ * <a href="http://www.java2s.com/Code/Java/Swing-Components/LinkButton.htm">
+ * JLinkButton</a>.
+ * 
+ * @since 0.25.6
+ */
+public class JLinkButton extends JButton {
+
+    /**
+     * Link behavior - underline always.
+     */
+    public static final int ALWAYS_UNDERLINE = 0;
+
+    /**
+     * Link behavior - underline only when hovering the mouse over the button.
+     */
+    public static final int HOVER_UNDERLINE = 1;
+
+    /**
+     * Link behavior - don't underline.
+     */
+    public static final int NEVER_UNDERLINE = 2;
+
+    /**
+     * Link behavior - use the system default behavior for hyper-links.
+     */
+    public static final int SYSTEM_DEFAULT = 3;
+
+    private int linkBehavior;
+
+    private Color linkColor;
+
+    private Color colorPressed;
+
+    private Color visitedLinkColor;
+
+    private Color disabledLinkColor;
+
+    private URL buttonURL;
+
+    private Action defaultAction;
+
+    private boolean isLinkVisited;
+
+    /**
+     * No arguments constructor.
+     */
+    public JLinkButton() {
+        this(null, null, null);
+    }
+
+    /**
+     * Constructor.
+     * @param action the Action to perform upon the button being hit.
+     */
+    public JLinkButton(Action action) {
+        this();
+        setAction(action);
+    }
+
+    /**
+     * @param text the button label.
+     * @param icon the Icon to be shown in the button.
+     * @param url the URL that will be linked from the button.
+     */
+    public JLinkButton(String text, Icon icon, URL url) {
+        super(text, icon);
+        linkBehavior = SYSTEM_DEFAULT;
+        linkColor = Color.blue;
+        colorPressed = Color.red;
+        visitedLinkColor = new Color(128, 0, 128);
+        if (text == null && url != null) setText(url.toExternalForm());
+        setLinkURL(url);
+        setCursor(Cursor.getPredefinedCursor(12));
+        setBorderPainted(false);
+        setContentAreaFilled(false);
+        setRolloverEnabled(true);
+        addActionListener(defaultAction);
+    }
+
+    @Override
+    public void updateUI() {
+        setUI(BasicLinkButtonUI.createUI(this));
+    }
+
+    @Override
+    public String getUIClassID() {
+        return "LinkButtonUI";
+    }
+
+    protected void setupToolTipText() {
+        String tip = null;
+        if (buttonURL != null) tip = buttonURL.toExternalForm();
+        setToolTipText(tip);
+    }
+
+    int getLinkBehavior() {
+        return linkBehavior;
+    }
+
+    Color getLinkColor() {
+        return linkColor;
+    }
+
+    Color getActiveLinkColor() {
+        return colorPressed;
+    }
+
+    Color getDisabledLinkColor() {
+        return disabledLinkColor;
+    }
+
+    Color getVisitedLinkColor() {
+        return visitedLinkColor;
+    }
+
+    URL getLinkURL() {
+        return buttonURL;
+    }
+
+    void setLinkURL(URL url) {
+        URL urlOld = buttonURL;
+        buttonURL = url;
+        setupToolTipText();
+        firePropertyChange("linkURL", urlOld, url);
+        revalidate();
+        repaint();
+    }
+
+    boolean isLinkVisited() {
+        return isLinkVisited;
+    }
+
+    protected String paramString() {
+        String str;
+        if (linkBehavior == ALWAYS_UNDERLINE)
+            str = "ALWAYS_UNDERLINE";
+        else if (linkBehavior == HOVER_UNDERLINE)
+            str = "HOVER_UNDERLINE";
+        else if (linkBehavior == NEVER_UNDERLINE)
+            str = "NEVER_UNDERLINE";
+        else
+            str = "SYSTEM_DEFAULT";
+        String colorStr = linkColor == null ? "" : linkColor.toString();
+        String colorPressStr = colorPressed == null ? "" : colorPressed
+                .toString();
+        String disabledLinkColorStr = disabledLinkColor == null ? ""
+                : disabledLinkColor.toString();
+        String visitedLinkColorStr = visitedLinkColor == null ? ""
+                : visitedLinkColor.toString();
+        String buttonURLStr = buttonURL == null ? "" : buttonURL.toString();
+        String isLinkVisitedStr = isLinkVisited ? "true" : "false";
+        return super.paramString() + ",linkBehavior=" + str + ",linkURL="
+                + buttonURLStr + ",linkColor=" + colorStr + ",activeLinkColor="
+                + colorPressStr + ",disabledLinkColor=" + disabledLinkColorStr
+                + ",visitedLinkColor=" + visitedLinkColorStr
+                + ",linkvisitedString=" + isLinkVisitedStr;
+    }
+}
+
+class BasicLinkButtonUI extends MetalButtonUI {
+    private static final BasicLinkButtonUI UI = new BasicLinkButtonUI();
+
+    BasicLinkButtonUI() {
+    }
+
+    public static ComponentUI createUI(JComponent jcomponent) {
+        return UI;
+    }
+
+    protected void paintText(Graphics g, JComponent com, Rectangle rect,
+            String s) {
+        JLinkButton bn = (JLinkButton) com;
+        ButtonModel bnModel = bn.getModel();
+        bn.getForeground();
+        if (bnModel.isEnabled()) {
+            if (bnModel.isPressed())
+                bn.setForeground(bn.getActiveLinkColor());
+            else if (bn.isLinkVisited())
+                bn.setForeground(bn.getVisitedLinkColor());
+
+            else
+                bn.setForeground(bn.getLinkColor());
+        } else {
+            if (bn.getDisabledLinkColor() != null)
+                bn.setForeground(bn.getDisabledLinkColor());
+        }
+        super.paintText(g, com, rect, s);
+        int behaviour = bn.getLinkBehavior();
+        boolean drawLine = false;
+        if (behaviour == JLinkButton.HOVER_UNDERLINE) {
+            if (bnModel.isRollover()) drawLine = true;
+        } else if (behaviour == JLinkButton.ALWAYS_UNDERLINE
+                || behaviour == JLinkButton.SYSTEM_DEFAULT) drawLine = true;
+        if (!drawLine) return;
+        FontMetrics fm = g.getFontMetrics();
+        int x = rect.x + getTextShiftOffset();
+        int y = (rect.y + fm.getAscent() + fm.getDescent() 
+                + getTextShiftOffset()) - 1;
+        if (bnModel.isEnabled()) {
+            g.setColor(bn.getForeground());
+            g.drawLine(x, y, (x + rect.width) - 1, y);
+        } else {
+            g.setColor(bn.getBackground().brighter());
+            g.drawLine(x, y, (x + rect.width) - 1, y);
+        }
+    }
+}

Modified: trunk/src/argouml-app/src/org/argouml/ui/ActionProjectSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ActionProjectSettings.java?view=diff&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/ui/ActionProjectSettings.java&p2=trunk/src/argouml-app/src/org/argouml/ui/ActionProjectSettings.java&r1=14824&r2=14825
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ActionProjectSettings.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ActionProjectSettings.java	2008-05-28 16:21:50-0700
@@ -42,7 +42,7 @@
     /**
      * The settings dialog.
      */
-    private ProjectSettingsDialog dialog;
+    private static ProjectSettingsDialog dialog;
 
     /**
      * Constructor.

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&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java&p2=trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java&r1=14824&r2=14825
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java	2008-05-28 16:21:50-0700
@@ -1,498 +1,513 @@
-// $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.ArrayList;

-import java.util.List;

-

-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.JScrollPane;

-import javax.swing.MutableComboBoxModel;

-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.ProfileConfiguration;

-import org.argouml.profile.Profile;

-import org.argouml.profile.ProfileException;

-import org.argouml.profile.ProfileFacade;

-import org.argouml.profile.UserDefinedProfile;

-import org.argouml.uml.diagram.DiagramAppearance;

-

-/**

- * The Tab containing the global settings for profiles

- *

- * @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();

-

-    private JList defaultList = new JList();

-

-    ////////

-    

-    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"));    

-

-    ///////

-

-    private JLabel stereoLabel =

-        new JLabel(Translator.localize("menu.popup.stereotype-view") + ": ");

-

-    private JComboBox stereoField = new JComboBox();

-    

-    /**

-     * 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"));

-        

-        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(

-                            ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,

-                            DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL);

-                        break;

-                    case 1:

-                        Configuration.setInteger(

-                            ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,

-                            DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON);

-                        break;

-                    case 2:

-                        Configuration.setInteger(

-                            ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,

-                            DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON);

-                        break;

-                    }

-                }

-            }

-            

-        });

-

-        add(setDefStereoV);

-                

-        ////////////

-        

-        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(new JScrollPane(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));

-

-        refreshLists();

-        	

-	JPanel leftList = new JPanel();

-	leftList.setLayout(new BorderLayout());

-	leftList.add(new JLabel(Translator

-		.localize("tab.profiles.userdefined.available")),

-		BorderLayout.NORTH);

-	leftList.add(new JScrollPane(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(new JScrollPane(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);                       

-    }

-

-    private void refreshLists() {

-        availableList.setModel(new DefaultComboBoxModel(getAvailableProfiles()

-                .toArray()));

-        defaultList.setModel(new DefaultComboBoxModel(getUsedProfiles()

-                .toArray()));

-        directoryList.setModel(new DefaultComboBoxModel(ProfileFacade

-                .getManager().getSearchPathDirectories().toArray()));

-    }

-

-    private List<Profile> getUsedProfiles() {

-        return new ArrayList<Profile>(ProfileFacade.getManager()

-                .getDefaultProfiles());

-    }

-

-    private List<Profile> getAvailableProfiles() {

-        List<Profile> used = getUsedProfiles();

-        List<Profile> ret = new ArrayList<Profile>();

-        

-        for (Profile profile : ProfileFacade.getManager()

-                .getRegisteredProfiles()) {

-            if (!used.contains(profile)) {

-                ret.add(profile);

-            }

-        }

-        

-        return ret;

-    }

-    

-    /*

-     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)

-     */

-    public void actionPerformed(ActionEvent arg0) {

-        MutableComboBoxModel modelAvl = ((MutableComboBoxModel) availableList

-                .getModel());

-        MutableComboBoxModel modelUsd = ((MutableComboBoxModel) defaultList

-                .getModel());

-

-        if (arg0.getSource() == addButton) {

-            if (availableList.getSelectedIndex() != -1) {

-                Profile selected = (Profile) modelAvl.getElementAt(availableList

-                        .getSelectedIndex());

-                modelUsd.addElement(selected);

-                modelAvl.removeElement(selected);

-            }

-	} else if (arg0.getSource() == removeButton) {

-            if (defaultList.getSelectedIndex() != -1) {

-                Profile selected = (Profile) modelUsd.getElementAt(defaultList

-                        .getSelectedIndex());

-                modelUsd.removeElement(selected);

-                modelAvl.addElement(selected);                        

-            }

-	} else if (arg0.getSource() == unregisterProfile) {

-	    if (availableList.getSelectedIndex() != -1) {

-                Profile selected = (Profile) modelAvl.getElementAt(availableList

-                        .getSelectedIndex());

-                if (selected instanceof UserDefinedProfile) {

-                    ProfileFacade.getManager().removeProfile(selected);

-                    modelAvl.removeElement(selected);

-                } 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().toLowerCase()

-                                    .endsWith(".xml") || file.getName()

-                                        .toLowerCase().endsWith(".xmi")));

-                }

-

-		public String getDescription() {

-		    return "*.XMI";

-		}

-

-	    });

-

-	    int ret = fileChooser.showOpenDialog(this);

-	    if (ret == JFileChooser.APPROVE_OPTION) {

-		File file = fileChooser.getSelectedFile();

-

-                try {

-                    UserDefinedProfile profile = new UserDefinedProfile(file);

-

-                    ProfileFacade.getManager().registerProfile(profile);

-

-                    modelAvl.addElement(profile);

-                } catch (ProfileException e) {

-                    JOptionPane.showMessageDialog(this, Translator

-                            .localize("tab.profiles.userdefined.errorloading"));

-                }

-            }

-

-        } else if (arg0.getSource() == removeDirectory) { 

-            if (directoryList.getSelectedIndex() != -1) {

-                int idx = directoryList.getSelectedIndex();

-                ((MutableComboBoxModel) directoryList.getModel())

-                        .removeElementAt(idx);

-            }

-        } else if (arg0.getSource() == refreshProfiles) { 

-            boolean refresh = (JOptionPane

-                    .showConfirmDialog(

-                            this,

-                            Translator

-                                    .localize("tab.profiles.confirmrefresh"),

-                            Translator

-                                    .localize("tab.profiles.confirmrefresh.title"),

-                            JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION);

-

-            if (refresh) {

-                handleSettingsTabSave();

-                ProfileFacade.getManager().refreshRegisteredProfiles();

-                refreshLists();

-            }            

-        } 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();

-

-                ((MutableComboBoxModel) directoryList.getModel())

-                        .addElement(path);

-            }

-            

-        }

-        

-	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() {

-        refreshLists();

-    }

-

-    public void handleSettingsTabCancel() {

-

-    }

-

-    public void handleSettingsTabRefresh() {

-        refreshLists();

- 

-        switch (Configuration.getInteger(

-                ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,

-                DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL)) {

-        case DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL:

-            stereoField.setSelectedIndex(0);                

-            break;

-        case DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON:

-            stereoField.setSelectedIndex(1);                

-            break;

-        case DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON:

-            stereoField.setSelectedIndex(2);                

-            break;

-        }        

-    }

-

-    public void handleSettingsTabSave() {

-        List<Profile> toRemove = new ArrayList<Profile>();        

-        List<Profile> usedItens = new ArrayList<Profile>();

-

-        MutableComboBoxModel modelUsd = ((MutableComboBoxModel) defaultList

-                .getModel());

-        MutableComboBoxModel modelDir = ((MutableComboBoxModel) directoryList

-                .getModel());

-        

-        for (int i = 0; i < modelUsd.getSize(); ++i) {

-            usedItens.add((Profile) modelUsd.getElementAt(i));

-        }

-

-        for (Profile profile : ProfileFacade.getManager()

-                .getDefaultProfiles()) {

-            if (!usedItens.contains(profile)) {

-                toRemove.add(profile);

-            }

-        }

-

-        for (Profile profile : toRemove) {

-            ProfileFacade.getManager().removeFromDefaultProfiles(profile);

-        }

-

-        for (Profile profile : usedItens) {

-            if (!ProfileFacade.getManager().getDefaultProfiles()

-                    .contains(profile)) {

-                ProfileFacade.getManager().addToDefaultProfiles(profile);

-            }

-        }

-   

-        List<String> toRemoveDir = new ArrayList<String>();        

-        List<String> usedItensDir = new ArrayList<String>();

-        

-        for (int i = 0; i < modelDir.getSize(); ++i) {

-            usedItensDir.add((String) modelDir.getElementAt(i));

-        }

-

-        for (String dirEntry : ProfileFacade.getManager()

-                .getSearchPathDirectories()) {

-            if (!usedItensDir.contains(dirEntry)) {

-                toRemoveDir.add(dirEntry);

-            }

-        }

-

-        for (String dirEntry : toRemoveDir) {

-            ProfileFacade.getManager()

-                    .removeSearchPathDirectory(dirEntry);

-        }

-

-        for (String dirEntry : usedItensDir) {

-            if (!ProfileFacade.getManager().getSearchPathDirectories()

-                    .contains(dirEntry)) {

-                ProfileFacade.getManager().addSearchPathDirectory(

-                        dirEntry);

-            }

-        }

-

-    }

-

-}

+// $Id$
+// 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.Component;
+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.ArrayList;
+import java.util.List;
+
+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.JScrollPane;
+import javax.swing.MutableComboBoxModel;
+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.ProfileConfiguration;
+import org.argouml.profile.Profile;
+import org.argouml.profile.ProfileException;
+import org.argouml.profile.ProfileFacade;
+import org.argouml.profile.UserDefinedProfile;
+import org.argouml.swingext.JLinkButton;
+import org.argouml.uml.diagram.DiagramAppearance;
+
+/**
+ * The Tab containing the global settings for profiles
+ *
+ * @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();
+
+    private JList defaultList = new JList();
+
+    ////////
+    
+    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"));    
+
+    ///////
+
+    private JLabel stereoLabel =
+        new JLabel(Translator.localize("menu.popup.stereotype-view") + ": ");
+
+    private JComboBox stereoField = new JComboBox();
+    
+    /**
+     * The default constructor for this class.
+     */
+    public SettingsTabProfile() {
+        setLayout(new BorderLayout());
+        
+        JPanel warning = new JPanel();
+        warning.setLayout(new BoxLayout(warning, BoxLayout.PAGE_AXIS));
+        JLabel warningLabel = new JLabel(Translator.localize("label.warning"));
+        warningLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
+        warning.add(warningLabel);
+
+        JLinkButton projectSettings = new JLinkButton();
+        projectSettings.setAction(new ActionProjectSettings());
+        projectSettings.setText(Translator.localize("button.project-settings"));
+        projectSettings.setIcon(null);
+        projectSettings.setAlignmentX(Component.RIGHT_ALIGNMENT);
+        warning.add(projectSettings);
+        
+        add(warning, BorderLayout.NORTH);
+ 
+        JPanel profileSettings = new JPanel();
+        profileSettings.setLayout(new BoxLayout(profileSettings,
+                BoxLayout.Y_AXIS));
+
+        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));
+
+        lcb.add(addDirectory);
+        lcb.add(removeDirectory);
+
+        addDirectory.addActionListener(this);
+        removeDirectory.addActionListener(this);
+
+        dlist.add(new JScrollPane(directoryList), BorderLayout.CENTER);
+        dlist.add(lcb, BorderLayout.EAST);
+
+        sdirPanel.add(new JLabel(Translator
+                .localize("tab.profiles.directories.desc")));
+        sdirPanel.add(dlist);
+
+        profileSettings.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));
+
+        refreshLists();
+
+        JPanel leftList = new JPanel();
+        leftList.setLayout(new BorderLayout());
+        leftList.add(new JLabel(Translator
+                .localize("tab.profiles.userdefined.available")),
+                BorderLayout.NORTH);
+        leftList.add(new JScrollPane(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(new JScrollPane(defaultList), BorderLayout.CENTER);
+        configPanel.add(rightList);
+
+        addButton.addActionListener(this);
+        removeButton.addActionListener(this);
+
+        profileSettings.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);
+
+        profileSettings.add(lffPanel);
+
+        add(profileSettings, BorderLayout.CENTER);
+    }
+
+    private JPanel initDefaultStereotypeViewSelector() {
+        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) {
+                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(
+                            ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,
+                            DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL);
+                        break;
+                    case 1:
+                        Configuration.setInteger(
+                            ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,
+                            DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON);
+                        break;
+                    case 2:
+                        Configuration.setInteger(
+                            ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,
+                            DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON);
+                        break;
+                    }
+                }
+            }
+
+        });
+        return setDefStereoV;
+    }
+
+    private void refreshLists() {
+        availableList.setModel(new DefaultComboBoxModel(getAvailableProfiles()
+                .toArray()));
+        defaultList.setModel(new DefaultComboBoxModel(getUsedProfiles()
+                .toArray()));
+        directoryList.setModel(new DefaultComboBoxModel(ProfileFacade
+                .getManager().getSearchPathDirectories().toArray()));
+    }
+
+    private List<Profile> getUsedProfiles() {
+        return new ArrayList<Profile>(ProfileFacade.getManager()
+                .getDefaultProfiles());
+    }
+
+    private List<Profile> getAvailableProfiles() {
+        List<Profile> used = getUsedProfiles();
+        List<Profile> ret = new ArrayList<Profile>();
+        
+        for (Profile profile : ProfileFacade.getManager()
+                .getRegisteredProfiles()) {
+            if (!used.contains(profile)) {
+                ret.add(profile);
+            }
+        }
+        
+        return ret;
+    }
+    
+    /*
+     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+     */
+    public void actionPerformed(ActionEvent arg0) {
+        MutableComboBoxModel modelAvl = ((MutableComboBoxModel) availableList
+                .getModel());
+        MutableComboBoxModel modelUsd = ((MutableComboBoxModel) defaultList
+                .getModel());
+
+        if (arg0.getSource() == addButton) {
+            if (availableList.getSelectedIndex() != -1) {
+                Profile selected = (Profile) modelAvl.getElementAt(availableList
+                        .getSelectedIndex());
+                modelUsd.addElement(selected);
+                modelAvl.removeElement(selected);
+            }
+	} else if (arg0.getSource() == removeButton) {
+            if (defaultList.getSelectedIndex() != -1) {
+                Profile selected = (Profile) modelUsd.getElementAt(defaultList
+                        .getSelectedIndex());
+                modelUsd.removeElement(selected);
+                modelAvl.addElement(selected);                        
+            }
+	} else if (arg0.getSource() == unregisterProfile) {
+	    if (availableList.getSelectedIndex() != -1) {
+                Profile selected = (Profile) modelAvl.getElementAt(availableList
+                        .getSelectedIndex());
+                if (selected instanceof UserDefinedProfile) {
+                    ProfileFacade.getManager().removeProfile(selected);
+                    modelAvl.removeElement(selected);
+                } 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().toLowerCase()
+                                    .endsWith(".xml") || file.getName()
+                                        .toLowerCase().endsWith(".xmi")));
+                }
+
+		public String getDescription() {
+		    return "*.XMI";
+		}
+
+	    });
+
+	    int ret = fileChooser.showOpenDialog(this);
+	    if (ret == JFileChooser.APPROVE_OPTION) {
+		File file = fileChooser.getSelectedFile();
+
+                try {
+                    UserDefinedProfile profile = new UserDefinedProfile(file);
+
+                    ProfileFacade.getManager().registerProfile(profile);
+
+                    modelAvl.addElement(profile);
+                } catch (ProfileException e) {
+                    JOptionPane.showMessageDialog(this, Translator
+                            .localize("tab.profiles.userdefined.errorloading"));
+                }
+            }
+
+        } else if (arg0.getSource() == removeDirectory) { 
+            if (directoryList.getSelectedIndex() != -1) {
+                int idx = directoryList.getSelectedIndex();
+                ((MutableComboBoxModel) directoryList.getModel())
+                        .removeElementAt(idx);
+            }
+        } else if (arg0.getSource() == refreshProfiles) { 
+            boolean refresh = JOptionPane.showConfirmDialog(this,
+                Translator.localize("tab.profiles.confirmrefresh"),
+                Translator.localize("tab.profiles.confirmrefresh.title"),
+                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
+            if (refresh) {
+                handleSettingsTabSave();
+                ProfileFacade.getManager().refreshRegisteredProfiles();
+                refreshLists();
+            }            
+        } 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();
+
+                ((MutableComboBoxModel) directoryList.getModel())
+                        .addElement(path);
+            }
+            
+        }
+        
+	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() {
+        refreshLists();
+    }
+
+    public void handleSettingsTabCancel() {
+
+    }
+
+    public void handleSettingsTabRefresh() {
+        refreshLists();
+ 
+        switch (Configuration.getInteger(
+                ProfileConfiguration.KEY_DEFAULT_STEREOTYPE_VIEW,
+                DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL)) {
+        case DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL:
+            stereoField.setSelectedIndex(0);                
+            break;
+        case DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON:
+            stereoField.setSelectedIndex(1);                
+            break;
+        case DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON:
+            stereoField.setSelectedIndex(2);                
+            break;
+        }        
+    }
+
+    public void handleSettingsTabSave() {
+        List<Profile> toRemove = new ArrayList<Profile>();        
+        List<Profile> usedItens = new ArrayList<Profile>();
+
+        MutableComboBoxModel modelUsd = ((MutableComboBoxModel) defaultList
+                .getModel());
+        MutableComboBoxModel modelDir = ((MutableComboBoxModel) directoryList
+                .getModel());
+        
+        for (int i = 0; i < modelUsd.getSize(); ++i) {
+            usedItens.add((Profile) modelUsd.getElementAt(i));
+        }
+
+        for (Profile profile : ProfileFacade.getManager()
+                .getDefaultProfiles()) {
+            if (!usedItens.contains(profile)) {
+                toRemove.add(profile);
+            }
+        }
+
+        for (Profile profile : toRemove) {
+            ProfileFacade.getManager().removeFromDefaultProfiles(profile);
+        }
+
+        for (Profile profile : usedItens) {
+            if (!ProfileFacade.getManager().getDefaultProfiles()
+                    .contains(profile)) {
+                ProfileFacade.getManager().addToDefaultProfiles(profile);
+            }
+        }
+   
+        List<String> toRemoveDir = new ArrayList<String>();        
+        List<String> usedItensDir = new ArrayList<String>();
+        
+        for (int i = 0; i < modelDir.getSize(); ++i) {
+            usedItensDir.add((String) modelDir.getElementAt(i));
+        }
+
+        for (String dirEntry : ProfileFacade.getManager()
+                .getSearchPathDirectories()) {
+            if (!usedItensDir.contains(dirEntry)) {
+                toRemoveDir.add(dirEntry);
+            }
+        }
+
+        for (String dirEntry : toRemoveDir) {
+            ProfileFacade.getManager()
+                    .removeSearchPathDirectory(dirEntry);
+        }
+
+        for (String dirEntry : usedItensDir) {
+            if (!ProfileFacade.getManager().getSearchPathDirectories()
+                    .contains(dirEntry)) {
+                ProfileFacade.getManager().addSearchPathDirectory(
+                        dirEntry);
+            }
+        }
+
+    }
+
+}

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&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java&p2=trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java&r1=14824&r2=14825
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabUser.java	2008-05-28 16:21:50-0700
@@ -25,10 +25,12 @@
 package org.argouml.ui;
 
 import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
 
+import javax.swing.BoxLayout;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
@@ -37,6 +39,7 @@
 import org.argouml.application.api.GUISettingsTabInterface;
 import org.argouml.configuration.Configuration;
 import org.argouml.i18n.Translator;
+import org.argouml.swingext.JLinkButton;
 
 /**
  * Tab Panel for setting the default user attributes: name and email.
@@ -67,8 +70,27 @@
      */
     SettingsTabUser() {
         setLayout(new BorderLayout());
-	JPanel top = new JPanel();
-    	top.setLayout(new GridBagLayout());
+        
+        JPanel top = new JPanel();
+        top.setLayout(new BorderLayout());
+        
+        JPanel warning = new JPanel();
+        warning.setLayout(new BoxLayout(warning, BoxLayout.PAGE_AXIS));
+        JLabel warningLabel = new JLabel(Translator.localize("label.warning"));
+        warningLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
+        warning.add(warningLabel);
+
+        JLinkButton projectSettings = new JLinkButton();
+        projectSettings.setAction(new ActionProjectSettings());
+        projectSettings.setText(Translator.localize("button.project-settings"));
+        projectSettings.setIcon(null);
+        projectSettings.setAlignmentX(Component.RIGHT_ALIGNMENT);
+        warning.add(projectSettings);
+        
+        top.add(warning, BorderLayout.NORTH);
+        
+	JPanel settings = new JPanel();
+    	settings.setLayout(new GridBagLayout());
 
 	GridBagConstraints labelConstraints = new GridBagConstraints();
 	labelConstraints.anchor = GridBagConstraints.WEST;
@@ -90,20 +112,21 @@
 
 	labelConstraints.gridy = 0;
 	fieldConstraints.gridy = 0;
-	top.add(new JLabel(Translator.localize("label.user")),
+	settings.add(new JLabel(Translator.localize("label.user")),
                 labelConstraints);
 	JTextField j = new JTextField();
         userFullname = j;
-	top.add(userFullname, fieldConstraints);
+	settings.add(userFullname, fieldConstraints);
 
 	labelConstraints.gridy = 1;
 	fieldConstraints.gridy = 1;
- 	top.add(new JLabel(Translator.localize("label.email")),
+ 	settings.add(new JLabel(Translator.localize("label.email")),
                 labelConstraints);
  	JTextField j1 = new JTextField();
         userEmail = j1;
-	top.add(userEmail, fieldConstraints);
-
+	settings.add(userEmail, fieldConstraints);
+	top.add(settings, BorderLayout.CENTER);
+	
 	add(top, BorderLayout.NORTH);
     }
 

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&rev=14825&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SettingsTabDiagramAppearance.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/SettingsTabDiagramAppearance.java&r1=14824&r2=14825
==============================================================================
--- 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	2008-05-28 16:21:50-0700
@@ -23,13 +23,13 @@
 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 package org.argouml.uml.diagram.ui;
 
+import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
+import javax.swing.BoxLayout;
 import javax.swing.JButton;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
@@ -42,6 +42,8 @@
 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.uml.diagram.DiagramAppearance;
 import org.argouml.util.ArgoFrame;
@@ -86,32 +88,40 @@
      * This method initializes this
      */
     private void initialize() {
-        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
-        gridBagConstraints2.gridx = 0;
-        gridBagConstraints2.fill = GridBagConstraints.BOTH;
-        gridBagConstraints2.weightx = 1.0;
-        gridBagConstraints2.weighty = 1.0;
-        gridBagConstraints2.gridy = 2;
-        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
-        gridBagConstraints1.gridx = 0;
-        gridBagConstraints1.anchor = GridBagConstraints.NORTHWEST;
-        gridBagConstraints1.insets = new Insets(5, 5, 0, 0);
-        gridBagConstraints1.gridy = 0;
+        
+        this.setLayout(new BorderLayout());
+        JPanel top = new JPanel();
+        top.setLayout(new BorderLayout());
+        
+        if (scope == Argo.SCOPE_APPLICATION) {
+            JPanel warning = new JPanel();
+            warning.setLayout(new BoxLayout(warning, BoxLayout.PAGE_AXIS));
+            JLabel warningLabel = new JLabel(
+                Translator.localize("label.warning"));
+            warningLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
+            warning.add(warningLabel);
+
+            JLinkButton projectSettings = new JLinkButton();
+            projectSettings.setAction(new ActionProjectSettings());
+            projectSettings.setText(
+                Translator.localize("button.project-settings"));
+            projectSettings.setIcon(null);
+            projectSettings.setAlignmentX(Component.RIGHT_ALIGNMENT);
+            warning.add(projectSettings);
+            
+            top.add(warning, BorderLayout.NORTH);
+        }
+        
+        JPanel settings = new JPanel();
         jlblDiagramFont = new JLabel();
-        jlblDiagramFont.setText(
-                Translator.localize("label.diagramappearance.diagramfont"));
-        GridBagConstraints gridBagConstraints = new GridBagConstraints();
-        gridBagConstraints.gridx = 0;
-        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
-        gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
-        gridBagConstraints.weightx = 1.0;
-        gridBagConstraints.insets = new Insets(5, 5, 0, 5);
-        gridBagConstraints.gridy = 1;
-        this.setLayout(new GridBagLayout());
+        jlblDiagramFont.setText(Translator
+                .localize("label.diagramappearance.diagramfont"));       
+        settings.add(getJbtnDiagramFont());
+        settings.add(jlblDiagramFont);
+        top.add(settings, BorderLayout.CENTER);
+        
+        this.add(top, BorderLayout.NORTH);
         this.setSize(new Dimension(296, 169));
-        this.add(getJbtnDiagramFont(), gridBagConstraints);
-        this.add(jlblDiagramFont, gridBagConstraints1);
-        this.add(new JPanel(), gridBagConstraints2);
 
     }
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.