svn commit: r16986 - trunk/src/argouml-app/src/org/argouml/uml/reveng

Thomas Neustupny <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: thn
Date: 2009-03-28 03:04:18-0700
New Revision: 16986

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java
   trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java

Log:
enable GUI-less usage of the import facility

Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java?view=diff&pathrev=16986&r1=16985&r2=16986
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/reveng/Import.java	2009-03-28 03:04:18-0700
@@ -142,21 +142,27 @@
         super();
         myFrame = frame;
 
-        JComponent chooser = getChooser();
-        dialog =
-            new JDialog(frame,
-                    Translator.localize("action.import-sources"), true);
-
-        dialog.getContentPane().add(chooser, BorderLayout.CENTER);
-        dialog.getContentPane().add(getConfigPanel(), BorderLayout.EAST);
-        dialog.pack();
-        int x = (frame.getSize().width - dialog.getSize().width) / 2;
-        int y = (frame.getSize().height - dialog.getSize().height) / 2;
-        dialog.setLocation(x > 0 ? x : 0, y > 0 ? y : 0);
-
-        UIUtils.loadCommonKeyMap(dialog);
-
-        dialog.setVisible(true);
+        // TODO: this needs to be improved
+        // even for nongui calling, the config panel needs to be initialized:
+        getConfigPanel();
+        
+        if (frame != null) {
+            JComponent chooser = getChooser();
+            dialog =
+                new JDialog(frame,
+                        Translator.localize("action.import-sources"), true);
+    
+            dialog.getContentPane().add(chooser, BorderLayout.CENTER);
+            dialog.getContentPane().add(getConfigPanel(), BorderLayout.EAST);
+            dialog.pack();
+            int x = (frame.getSize().width - dialog.getSize().width) / 2;
+            int y = (frame.getSize().height - dialog.getSize().height) / 2;
+            dialog.setLocation(x > 0 ? x : 0, y > 0 ? y : 0);
+    
+            UIUtils.loadCommonKeyMap(dialog);
+    
+            dialog.setVisible(true);
+        }
     }
 
     /*
@@ -420,8 +426,8 @@
 
 
     /**
-     * Parse all selected files. It calls the actual parser methods depending on
-     * the type of the file.
+     * Parse all selected files in a separate thread. It calls the actual
+     * parser methods depending on the type of the file.
      */
     public void doFile() {
         iss = new ImportStatusScreen(myFrame, "Importing", "Splash");

Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java?view=diff&pathrev=16986&r1=16985&r2=16986
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java	2009-03-28 03:04:18-0700
@@ -258,11 +258,31 @@
      */
     public abstract boolean isChangedOnlySelected();
 
+    /**
+     * Gets the specified import module.
+     * 
+     * @param importerName The import module's name
+     * @return The found import module, otherwise null
+     */
+    public ImportInterface getImporter(String importerName) {
+        return getModules().get(importerName);
+    }
+
+    /**
+     * Sets the files that will be imported.
+     * 
+     * @param files The array of files.
+     */
+    public void setFiles(File[] files) {
+        if (files != null) {
+            setSelectedFiles(files);
+        }
+    }
+
     protected Hashtable<String, ImportInterface> getModules() {
         return modules;
     }
 
-
     protected void setSelectedFiles(final File[] files) {
         selectedFiles = files;
     }
@@ -285,7 +305,12 @@
         //return Arrays.copyOf(selectedFiles, selectedFiles.length);
     }
     
-    protected void setCurrentModule(ImportInterface module) {
+    /**
+     * Sets the current import module.
+     * 
+     * @param module
+     */
+    public void setCurrentModule(ImportInterface module) {
         currentModule = module;
     }
 
@@ -460,13 +485,14 @@
 
 
     /**
-     * Import the selected source modules.
+     * Import the selected source files. It calls the actual
+     * parser methods depending on the type of the file.
      *
      * @param monitor
      *            a ProgressMonitor to both receive progress updates and to be
      *            polled for user requests to cancel.
      */
-    protected void doImport(ProgressMonitor monitor) {
+    public void doImport(ProgressMonitor monitor) {
         // Roughly equivalent to and derived from old Import.doFile()
         monitor.setMaximumProgress(MAX_PROGRESS);
         int progress = 0;

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

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