|
What this is
Other links
The source code// $Id: FileImportSupport.java,v 1.8 2004/08/25 18:51:48 mvw Exp $ // Copyright (c) 1996-2004 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.uml.reveng; import org.argouml.kernel.*; import org.argouml.application.api.*; import org.argouml.util.osdep.OsUtil; import org.argouml.uml.diagram.static_structure.layout.ClassdiagramLayouter; import org.argouml.uml.diagram.ui.UMLDiagram; import org.argouml.util.SuffixFilter; import org.tigris.gef.base.Globals; import java.io.*; import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.util.Vector; /** * This is the base class for import from files. * It provides JFileChooser for file selection * and other methods common to file import. * It assumes that similar classes will be written * for other input sources. * * @author Alexander Lepekhine * @version $Revision: 1.8 $ */ public abstract class FileImportSupport implements PluggableImport { private JPanel configPanel; private JRadioButton attribute; private JRadioButton datatype; private static final String SEPARATOR = "/"; //System.getProperty("file.separator"); /** * Object(s) selected in chooser */ private Object theFile; /** * Get the panel that lets the user set reverse engineering * parameters. * * @see org.argouml.application.api.PluggableImport#getConfigPanel() */ public JComponent getConfigPanel() { if (configPanel == null) { configPanel = new JPanel(); configPanel.setLayout(new GridBagLayout()); JLabel attributeLabel = new JLabel("Attributes modelled as"); configPanel.add(attributeLabel, new GridBagConstraints(GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); ButtonGroup group1 = new ButtonGroup(); attribute = new JRadioButton("UML attributes."); attribute.setSelected(true); group1.add(attribute); configPanel.add(attribute, new GridBagConstraints(GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0)); JRadioButton association = new JRadioButton("UML associations."); group1.add(association); configPanel.add(association, new GridBagConstraints(GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); ButtonGroup group2 = new ButtonGroup(); datatype = new JRadioButton("Arrays modelled as datatypes."); datatype.setSelected(true); group2.add(datatype); configPanel.add(datatype, new GridBagConstraints(GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 5), 0, 0)); JRadioButton multi = new JRadioButton("Arrays modelled with multiplicity 1..n."); group2.add(multi); configPanel.add(multi, new GridBagConstraints(GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, GridBagConstraints.REMAINDER, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0)); } return configPanel; } /** * This method parses 1 file. * Default implementation does nothing. * * @exception Exception Parser exception. * @param p the project * @param o the object * @param diagram the diagram interface * @param theImport the import * * @see org.argouml.application.api.PluggableImport#parseFile( * org.argouml.kernel.Project, java.lang.Object, * org.argouml.uml.reveng.DiagramInterface, org.argouml.uml.reveng.Import) */ public void parseFile(Project p, Object o, DiagramInterface diagram, Import theImport) throws Exception { } /** * Create chooser for objects we are to import. * Default implemented chooser is JFileChooser. * * @see org.argouml.application.api.PluggableImport#getChooser(org.argouml.uml.reveng.Import) */ public JComponent getChooser(Import imp) { String directory = Globals.getLastDirectory(); JFileChooser ch = OsUtil.getFileChooser(directory); if (ch == null) ch = OsUtil.getFileChooser(); final JFileChooser chooser = ch; final Import theIimport = imp; chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); SuffixFilter[] filters = getSuffixFilters(); if (filters != null) { for (int i = 0; i < filters.length; i++) chooser.addChoosableFileFilter(filters[i]); } chooser.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals( JFileChooser.APPROVE_SELECTION)) { theFile = chooser.getSelectedFile(); if (theFile != null) { String path = chooser.getSelectedFile().getParent(); String filename = chooser.getSelectedFile().getName(); filename = path + SEPARATOR + filename; Globals.setLastDirectory(path); if (filename != null) { theIimport.disposeDialog(); theIimport.getUserClasspath(); return; } } } else if (e.getActionCommand().equals( JFileChooser.CANCEL_SELECTION)) { theIimport.disposeDialog(); } } }); return chooser; } /** * This method returns a Vector with objects to import. |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.