Author: maurelio1234
Date: 2007-07-17 07:53:52-0700
New Revision: 13093
Added:
branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ActionExportProfileXMI.java
Modified:
branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/action.properties
branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/UmlFilePersister.java
branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ExplorerPopup.java
Log:
implementing action to export a profile's model to XMI
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/action.properties
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/action.properties?view=diff&rev=13093&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/action.properties&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/action.properties&r1=13092&r2=13093
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/action.properties (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/i18n/action.properties 2007-07-17 07:53:52-0700
@@ -77,6 +77,7 @@
action.empty-trash = Empty Trash
action.exit = Exit
action.export-project-as-xmi = Export XMI...
+action.export-profile-as-xmi = Export profile model as XMI...
action.find = Find...
action.generate-all-classes = Generate All Classes...
action.generate-code-for-project = Generate Code for Project...
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/UmlFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/UmlFilePersister.java?view=diff&rev=13093&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/UmlFilePersister.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/UmlFilePersister.java&r1=13092&r2=13093
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/UmlFilePersister.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/persistence/UmlFilePersister.java 2007-07-17 07:53:52-0700
@@ -80,7 +80,7 @@
*
* @author Bob Tarling
*/
-class UmlFilePersister extends AbstractFilePersister {
+public class UmlFilePersister extends AbstractFilePersister {
/**
* The PERSISTENCE_VERSION is increased every time the persistence format
@@ -88,7 +88,7 @@
* This controls conversion of old persistence version files to be
* converted to the current one, keeping ArgoUML backwards compatible.
*/
- protected static final int PERSISTENCE_VERSION = 5;
+ public static final int PERSISTENCE_VERSION = 5;
/**
* The TOTAL_PHASES_LOAD constant is the number of phases used by the load
Added: branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ActionExportProfileXMI.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ActionExportProfileXMI.java?view=auto&rev=13093
==============================================================================
--- (empty file)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ActionExportProfileXMI.java 2007-07-17 07:53:52-0700
@@ -0,0 +1,133 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z 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.explorer;
+
+import java.awt.event.ActionEvent;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import javax.swing.AbstractAction;
+import javax.swing.JFileChooser;
+
+import org.apache.log4j.Logger;
+import org.argouml.application.helpers.ApplicationVersion;
+import org.argouml.configuration.Configuration;
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.model.UmlException;
+import org.argouml.model.XmiWriter;
+import org.argouml.persistence.PersistenceManager;
+import org.argouml.persistence.UmlFilePersister;
+import org.argouml.ui.ArgoFrame;
+import org.argouml.uml.profile.Profile;
+import org.argouml.uml.ui.ProjectFileView;
+
+/**
+ * Exports the model of a selected profile as XMI
+ *
+ * @author Marcos Aurélio
+ */
+public class ActionExportProfileXMI extends AbstractAction {
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = Logger
+ .getLogger(ActionExportProfileXMI.class);
+
+ private Profile selectedProfile;
+
+ /**
+ * Default Constructor
+ *
+ * @param profile the selected profile
+ */
+ public ActionExportProfileXMI(Profile profile) {
+ super(Translator.localize("action.export-profile-as-xmi"));
+ this.selectedProfile = profile;
+ }
+
+ /**
+ * @param arg0
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent arg0) {
+ Object model = selectedProfile.getModel();
+ if (model != null) {
+ File destiny = getTargetFile();
+ if (destiny != null) {
+ try {
+ saveModel(destiny, model);
+ } catch (IOException e) {
+ LOG.error("Exception", e);
+ } catch (UmlException e) {
+ LOG.error("Exception", e);
+ }
+ }
+ }
+ }
+
+ private void saveModel(File destiny, Object model) throws IOException,
+ UmlException {
+ FileWriter w = new FileWriter(destiny);
+
+ XmiWriter xmiWriter = Model.getXmiWriter(model, w, ApplicationVersion
+ .getVersion()
+ + "(" + UmlFilePersister.PERSISTENCE_VERSION + ")");
+ xmiWriter.write();
+ }
+
+ private File getTargetFile() {
+ PersistenceManager pm = PersistenceManager.getInstance();
+ // show a chooser dialog for the file name, only xmi is allowed
+ JFileChooser chooser = new JFileChooser();
+ chooser.setDialogTitle(Translator.localize(
+ "action.export-profile-as-xmi"));
+ chooser.setFileView(ProjectFileView.getInstance());
+ chooser.setApproveButtonText(Translator.localize(
+ "filechooser.export"));
+ chooser.setAcceptAllFileFilterUsed(true);
+
+ String fn =
+ Configuration.getString(
+ PersistenceManager.KEY_PROJECT_NAME_PATH);
+ if (fn.length() > 0) {
+ fn = PersistenceManager.getInstance().getBaseName(fn);
+ chooser.setSelectedFile(new File(fn));
+ }
+
+ int result = chooser.showSaveDialog(ArgoFrame.getInstance());
+ if (result == JFileChooser.APPROVE_OPTION) {
+ File theFile = chooser.getSelectedFile();
+ if (theFile != null) {
+ return theFile;
+ }
+ }
+
+ return null;
+ }
+
+}
Modified: branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ExplorerPopup.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ExplorerPopup.java?view=diff&rev=13093&p1=branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ExplorerPopup.java&p2=branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ExplorerPopup.java&r1=13092&r2=13093
==============================================================================
--- branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ExplorerPopup.java (original)
+++ branches/gsoc2007/maurelio1234/src_new/org/argouml/ui/explorer/ExplorerPopup.java 2007-07-17 07:53:52-0700
@@ -141,6 +141,10 @@
this.add(createDiagrams);
}
+ if (!multiSelect && selectedItem instanceof Profile) {
+ this.add(new ActionExportProfileXMI((Profile)selectedItem));
+ }
+
if (modelElementsOnly) {
initMenuCreateModelElements();
}
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.