svn commit: r15394 - trunk/src/argouml-app/src/org/argouml/ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: thn
Date: 2008-07-28 13:10:04-0700
New Revision: 15394

Modified:
   trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java
   trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java

Log:
Issue 5101, part 2/2: All ArgoUML supported XMI file extensions should be allowed

Modified: trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java?view=diff&rev=15394&p1=trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java&p2=trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java&r1=15393&r2=15394
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectSettingsTabProfile.java	2008-07-28 13:10:04-0700
@@ -46,7 +46,6 @@
 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.i18n.Translator;

@@ -57,6 +56,7 @@
 import org.argouml.profile.ProfileException;

 import org.argouml.profile.ProfileFacade;

 import org.argouml.profile.UserDefinedProfile;

+import org.argouml.profile.UserDefinedProfileHelper;

 import org.argouml.uml.diagram.DiagramAppearance;

 

 /**

@@ -255,7 +255,7 @@
                     if (!dependents.isEmpty()) {

                         String message = Translator.localize(

                                 "tab.profiles.confirmdeletewithdependencies",

-                                new Object[] {dependents});

+                                new Object[] { dependents });

                         String title = Translator

                                 .localize("tab.profiles.confirmdeletewithdependencies.title");

                         remove = (JOptionPane.showConfirmDialog(this, message,

@@ -291,37 +291,26 @@
                 }

             }

         } else if (arg0.getSource() == loadFromFile) {

-            JFileChooser fileChooser = new JFileChooser();

-            fileChooser.setFileFilter(new FileFilter() {

-

-                public boolean accept(File file) {

-                    return file.isDirectory()

-                            || (file.isFile() && (file.getName().endsWith(

-                                    ".xmi")

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

-                                    || file.getName().toLowerCase().endsWith(

-                                            ".xmi.zip") || file.getName()

-                                    .toLowerCase().endsWith(".xml.zip")));

-                }

-

-                public String getDescription() {

-                    return "*.xmi *.xml *.xmi.zip *.xml.zip";

-                }

-

-            });

-

+            JFileChooser fileChooser =

+                UserDefinedProfileHelper.createUserDefinedProfileFileChooser();

             int ret = fileChooser.showOpenDialog(this);

+            List<File> files = null;

             if (ret == JFileChooser.APPROVE_OPTION) {

-                File file = fileChooser.getSelectedFile();

-

-                try {

-                    UserDefinedProfile profile = new UserDefinedProfile(file);

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

-

-                    modelAvailable.addElement(profile);

-                } catch (ProfileException e) {

-                    JOptionPane.showMessageDialog(this, Translator

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

+                files = UserDefinedProfileHelper.getFileList(

+                    fileChooser.getSelectedFiles());

+            }

+            if (files != null && files.size() > 0) {

+                for (File file : files) {

+                    try {

+                        UserDefinedProfile profile =

+                            new UserDefinedProfile(file);

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

+                        modelAvailable.addElement(profile);

+                    } catch (ProfileException e) {

+                        JOptionPane.showMessageDialog(this, Translator

+                            .localize("tab.profiles.userdefined.errorloading")

+                            + ": " + file.getAbsolutePath());

+                    }

                 }

             }

         }

@@ -436,5 +425,4 @@
         }

 

     }

-

 }


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=15394&p1=trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java&p2=trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java&r1=15393&r2=15394
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SettingsTabProfile.java	2008-07-28 13:10:04-0700
@@ -57,6 +57,7 @@
 import org.argouml.profile.ProfileException;
 import org.argouml.profile.ProfileFacade;
 import org.argouml.profile.UserDefinedProfile;
+import org.argouml.profile.UserDefinedProfileHelper;
 import org.argouml.swingext.JLinkButton;
 import org.argouml.uml.diagram.DiagramAppearance;
 
@@ -321,39 +322,26 @@
                 }
             }
         } 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(".xmi")
-                                    || file.getName().toLowerCase().endsWith(
-                                            ".xml")
-                                    || file.getName().toLowerCase().endsWith(
-                                            ".xmi.zip") || file.getName()
-                                    .toLowerCase().endsWith(".xml.zip")));
-                }
-
-                public String getDescription() {
-                    return "*.xmi *.xml *.xmi.zip *.xml.zip";
-                }
-
-            });
-
+            JFileChooser fileChooser =
+                UserDefinedProfileHelper.createUserDefinedProfileFileChooser();
             int ret = fileChooser.showOpenDialog(this);
+            List<File> files = null;
             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"));
+                files = UserDefinedProfileHelper.getFileList(
+                    fileChooser.getSelectedFiles());
+            }
+            if (files != null && files.size() > 0) {
+                for (File file : files) {
+                    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")
+                            + ": " + file.getAbsolutePath());
+                    }
                 }
             }
 
@@ -503,5 +491,4 @@
         }
 
     }
-
 }
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.