Author: tfmorris
Date: 2008-05-28 14:30:13-0700
New Revision: 14823
Added:
branches/work_ocl2_tfmorris/src/argouml-app/ocl20-integration-notes.txt (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/README.txt (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/ConstraintRepresentation.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/EditingUtilities.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditor.form
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditor.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorModel.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorPreferences.form
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorPreferences.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLToolbar.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeAdapter.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeEvent.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeListener.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Cancel16.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Delete16.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Edit16.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/New16.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Ok16.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Preferences16.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/RowDelete24.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/RowInsertAfter24.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/empty.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/failed.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/left.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/logo.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/ok.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/question.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/right.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/save_icon.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgdelete.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgleftArrow.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgline.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgline_k.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgrightArrow.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/st.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/tulogo.gif (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/Classes.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/ModelFacade.java (contents, props changed)
branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/OCLChecker.java (contents, props changed)
Modified:
branches/work_ocl2_tfmorris/src/argouml-app/.settings/de.mvmsoft.checkclipse.prefs
Log:
Issue 4676: Initial commit for new files for OCL 2 support
Modified: branches/work_ocl2_tfmorris/src/argouml-app/.settings/de.mvmsoft.checkclipse.prefs
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/.settings/de.mvmsoft.checkclipse.prefs?view=diff&rev=14823&p1=branches/work_ocl2_tfmorris/src/argouml-app/.settings/de.mvmsoft.checkclipse.prefs&p2=branches/work_ocl2_tfmorris/src/argouml-app/.settings/de.mvmsoft.checkclipse.prefs&r1=14822&r2=14823
==============================================================================
--- branches/work_ocl2_tfmorris/src/argouml-app/.settings/de.mvmsoft.checkclipse.prefs (original)
+++ branches/work_ocl2_tfmorris/src/argouml-app/.settings/de.mvmsoft.checkclipse.prefs 2008-05-28 14:30:13-0700
@@ -1,5 +1,5 @@
-#Sun Feb 17 21:07:44 CET 2008
+#Wed May 28 17:07:59 EDT 2008
filenames.properties=/argouml-core-tools/checkstyle/checkstyle.properties
-enabled=true
file_filter=in\:\\.java$\nin\:\\.properties$\nex\:Java(Lexer|Recognizer|TokenTypes)\\.java$\n
+enabled=true
filenames.config=/argouml-core-tools/checkstyle/checkstyle_argouml.xml
Added: branches/work_ocl2_tfmorris/src/argouml-app/ocl20-integration-notes.txt
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/ocl20-integration-notes.txt?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/ocl20-integration-notes.txt 2008-05-28 14:30:13-0700
@@ -0,0 +1,70 @@
+OCL Changes
+
+org.argouml.ocl - unchanged?
+ - regression of changes made to consolidate multiple OCL implementations
+ - regression of deprecation
+ - commenting out of some methods
+
+org.argouml.uml.ui.TabConstraints - minor updates for new code
+
+ch.ethz.infosec.ocl2Argo.ArgoUMLModelFacade - new (updated version of org.argouml.ocl.ArgoFacade?)
+ - introduces direct dependency on JMI and MDR (probably not necessary)
+
+Java & C# generators depend on old OCL parser to generate Javadoc for constraints
+
+
+tudresden.ocl20.gui derived from ocl project's tudresden.ocl.gui
+----------------------------------------------------------------
+SourceForge SVN at https://dresden-ocl.svn.sourceforge.net/svnroot/dresden-ocl/trunk/ocl/src/tudresden/ocl/gui
+
+LGPL licensed, so can't be mingled with ArgoUML sources - need a binary dist.
+
+mostly just changed package names to match new ocl20 names
+
+OCLEditor.java had a revision in 2003 which we apparently never got
+ (also large number of formatting changes)
+
+OCLEditorPreferences - change of string
+
+tudresden.ocl20.images copied unchanged from tudresden.ocl.images
+-----------------------------------------------------------------
+SourceForge SVN at https://dresden-ocl.svn.sourceforge.net/svnroot/dresden-ocl/trunk/ocl/src/tudresden/ocl/images
+
+tudresden.ocl20.integration (no changes from version forked? double check against history)
+---------------------------
+SourceForge SVN at https://dresden-ocl.svn.sourceforge.net/svnroot/dresden-ocl/trunk/ocl20/src/tudresden/ocl20/integration
+
+- doesn't appear to be included in jar ocl20jmiimpl.jar, so perhaps they are modified in some way that we need
+- the following diffs
+
+Classes.java - no changes
+ModelFacade.java - replaceRefProject & getElement methods added
+OCLChecker.java - transaction rollback supported added to SourceForge version
+
+
+
+Changes
+-------
+- removed constraint enriched doc comment generation from Java and C# code generators
+- moved ch.ethz.infsec.ocl2Argo.ArgoUMLModelFacade to org.argouml.ocl where old facade was
+ (no license information for this. Need to get it copyright/license cleared!)
+- changed debugging printlns to use Log4J
+
+Questions
+---------
+- What is compatibility story between old OCL and new OCL constraints?
+
+
+Modified Files for Initial Commit (included during creation of branch)
+
+ G C:/eclipse-workspace-clean2/argouml-app/.classpath
+ G C:/eclipse-workspace-clean2/argouml-app/META-INF/MANIFEST.MF
+ D C:/eclipse-workspace-clean2/argouml-app/lib/ocl-argo-1.1.jar
+ G C:/eclipse-workspace-clean2/argouml-app/ArgoUML DEBUG.launch
+ G C:/eclipse-workspace-clean2/argouml-app/src/org/argouml/language/java/generator/GeneratorJava.java
+ G C:/eclipse-workspace-clean2/argouml-app/src/org/argouml/uml/ui/TabConstraints.java
+ G C:/eclipse-workspace-clean2/argouml-app/src/org/argouml/ocl/OCLEvaluator.java
+ G C:/eclipse-workspace-clean2/argouml-app/src/org/argouml/ocl/OCLExpander.java
+ G C:/eclipse-workspace-clean2/argouml-app/src/org/argouml/ocl/OCLUtil.java
+ G C:/eclipse-workspace-clean2/argouml-app/src/org/argouml/ocl/ArgoFacade.java
+ G C:/eclipse-workspace-clean2/argouml-app/src/org/argouml/ocl/CriticOclEvaluator.java
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/README.txt
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/README.txt?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/README.txt 2008-05-28 14:30:13-0700
@@ -0,0 +1,9 @@
+The sources in this directory are from the TU Dresden OCL1 & OCL2 Toolkits
+which are hosted at http://dresden-ocl.sourceforge.net.
+
+These files are all licensed under LGPL V2, not standard ArgoUML license.
+Original files are by the TU Dresden team with modifications and integration
+work to update ArgoUML integration from OCL1 to OCL2 by Raphael Schmid
+of ETH Zurich.
+
+- Tom Morris 28 May 2008
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/ConstraintRepresentation.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/ConstraintRepresentation.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/ConstraintRepresentation.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,93 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Compiler *
+ * Copyright (C) 2001 Steffen Zschaler ([email protected]). *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * To submit a bug report, send a comment, or get the latest news on *
+ * this project and other projects, please visit the web site: *
+ * http://www-st.inf.tu-dresden.de/ (Chair home page) or *
+ * http://www-st.inf.tu-dresden.de/ocl/ (project home page) *
+ * *
+ * See CREDITS file for further details. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+// ConstraintRepresentation.java -- Representation of an event.
+//
+// 02/15/2001 [sz9 ] Created.
+//
+package tudresden.ocl20.gui;
+
+import java.io.IOException;
+
+import tudresden.ocl20.core.OclModelException;
+import tudresden.ocl20.core.parser.sablecc.analysis.AttrEvalException;
+import tudresden.ocl20.core.parser.sablecc.lexer.LexerException;
+import tudresden.ocl20.core.parser.sablecc.parser.ParserException;
+
+
+/**
+ * A representation of an individual constraint with name and data.
+ *
+ * @author sz9
+ */
+public interface ConstraintRepresentation {
+
+ /**
+ * Get the constraint's name.
+ */
+ public String getName();
+
+ /**
+ * Set the constraint's name. For the exceptions the detailed message must
+ * be human readable.
+ *
+ * @param sName the new name of the constraint
+ * @param euHelper utility that can be used to check for syntactical
+ * correctness etc.
+ *
+ * @exception IllegalStateException if the constraint is not in a state to
+ * accept name changes.
+ * @exception IllegalArgumentException if the specified name is not a legal
+ * name for the constraint.
+ */
+ public void setName (String sName, EditingUtilities euHelper)
+ throws IllegalStateException, IllegalArgumentException;
+
+ /**
+ * Get the constraint's body text.
+ */
+ public String getData();
+
+ /**
+ * Set the constraint's body text. For the exceptions the detailed message must
+ * be human readable.
+ *
+ * @param sData the new body of the constraint
+ * @param euHelper utility that can be used to check for syntactical
+ * correctness etc.
+ *
+ * @exception IllegalStateException if the constraint is not in a state to
+ * accept body changes.
+ * @exception OclModelException thrown by the methods of {@link OclModel OclModel} in case of an error.
+ * @exception ParserException if a syntax error occurred.
+ * @exception LexerException .
+ * @exception AttrEvalException if a type checking error occurred.
+ * @exception IOException if an I/O operation failed.
+ */
+ public void setData (String sData, EditingUtilities euHelper)
+ throws IllegalStateException, OclModelException, LexerException, AttrEvalException, ParserException, IOException;
+}
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/EditingUtilities.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/EditingUtilities.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/EditingUtilities.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,91 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Editor *
+ * Copyright (C) 2001 Steffen Zschaler. *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * See CREDITS file for further details. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+// EditingUtilities.java -- utility interface for parsing and splitting
+// raw constraints
+//
+// 05/04/2001 [sz9 ] Created.
+//
+package tudresden.ocl20.gui;
+
+import java.io.IOException;
+import tudresden.ocl20.core.OclModelException;
+import tudresden.ocl20.core.parser.sablecc.analysis.AttrEvalException;
+import tudresden.ocl20.core.parser.sablecc.lexer.LexerException;
+import tudresden.ocl20.core.parser.sablecc.parser.ParserException;
+
+/**
+ * Utility interface for parsing and splitting raw constraints.
+ *
+ * @author sz9
+ * @author Raphael Schmid
+ */
+public interface EditingUtilities {
+
+ /**
+ * Checks the specified name and returns true if it is a valid OCL name.
+ */
+ public boolean isValidConstraintName (String sName);
+
+ /**
+ * Check the specified constraint.
+ *
+ * @exception OclModelException thrown by the methods of {@link OclModel OclModel} in case of an error.
+ * @exception ParserException if a syntax error occurred.
+ * @exception LexerException .
+ * @exception AttrEvalException if a type checking error occurred.
+ * @exception IOException if an I/O operation failed.
+ */
+ public void parseAndCheckConstraint (final String sConstraint)
+ throws OclModelException, ParserException, LexerException, AttrEvalException, IOException;
+
+ /**
+ * Return whether auto split mode is on. If this returns true, constraint
+ * representations should call {@link #splitConstraint} and create one
+ * constraint representation per actual constraint.
+ */
+ public boolean getDoAutoSplit();
+
+// /**
+// * Split the specified constraint into its constituting constraints. E.g.
+// * <pre>
+// * context Test
+// * inv: a > 0
+// * inv: a < 10
+// * inv: a * 100 = 900
+// * </pre>
+// * would be split into three constraints:
+// * <pre>
+// * context Test
+// * inv: a > 0
+// *
+// * context Test
+// * inv: a < 10
+// *
+// * context Test
+// * inv: a * 100 = 900
+// * </pre>
+// *
+// * @return a list of abstract syntax trees, one per sub-constraint.
+// */
+// public List splitConstraint (OclTree ocltConstraint);
+}
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditor.form
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditor.form?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditor.form 2008-05-28 14:30:13-0700
@@ -0,0 +1,309 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[500, 300]"/>
+ </Property>
+ <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[500, 300]"/>
+ </Property>
+ </Properties>
+ <SyntheticProperties>
+ </SyntheticProperties>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JToolBar" name="m_jtbTools">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="North"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JButton" name="m_jbNew">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
+ <Image iconType="3" name="/tudresden/ocl/images/New16.gif"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Click to create a new constraint"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onNewConstraintButton"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="m_jbRemove">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
+ <Image iconType="3" name="/tudresden/ocl/images/Delete16.gif"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Click to remove the currently selected constraint"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onRemoveConstraintButton"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="m_jbEdit">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
+ <Image iconType="3" name="/tudresden/ocl/images/Edit16.gif"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Click to edit the currently selected constraint"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onEditButton"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="m_jbSaveEditResult">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
+ <Image iconType="3" name="/tudresden/ocl/images/Ok16.gif"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Check OCL syntax and save constraint into model"/>
+ <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
+ <Insets value="[0, 0, 0, 0]"/>
+ </Property>
+ </Properties>
+
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onSubmitConstraintButton"/>
+ </Events>
+
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="m_jbSaveEditResult.setVisible (false);"/>
+ </AuxValues>
+ </Component>
+ <Container class="javax.swing.JPanel" name="pad1">
+ <Properties>
+ <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[10, 10]"/>
+ </Property>
+ </Properties>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ </Container>
+ <Component class="javax.swing.JButton" name="m_jbPreferences">
+ <Properties>
+ <Property name="icon" type="javax.swing.Icon" editor="org.openide.explorer.propertysheet.editors.IconEditor">
+ <Image iconType="3" name="/tudresden/ocl/images/Preferences16.gif"/>
+ </Property>
+ <Property name="toolTipText" type="java.lang.String" value="Click to inspect and modify OCL editor preferences."/>
+ </Properties>
+
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onPreferencesButton"/>
+ </Events>
+ </Component>
+ <Container class="javax.swing.JPanel" name="pad2">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[5, 10]"/>
+ </Property>
+ <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[5, 10]"/>
+ </Property>
+ <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[5, 10]"/>
+ </Property>
+ </Properties>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ </Container>
+ <Component class="javax.swing.JCheckBox" name="m_jcbQuickBar">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" value="Check to see the syntax assistant toolbar"/>
+ <Property name="text" type="java.lang.String" value="Syntax Assistant"/>
+ </Properties>
+
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="onQuickBarButton"/>
+ </Events>
+
+ <AuxValues>
+ <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value="m_jcbQuickBar.setVisible (false);"/>
+ </AuxValues>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="m_jpToolbarWrapper">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+ <SubComponents>
+ <Container class="tudresden.ocl.gui.OCLToolbar" name="m_ocltbQuickBar">
+ <Properties>
+ <Property name="editor" type="tudresden.ocl.gui.OCLEditor" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="this" type="code"/>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="North"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
+ </Container>
+ <Container class="javax.swing.JPanel" name="m_jpEditorPanel">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Edit constraint"/>
+ </Border>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane" name="m_jspConstraintEditorScroller">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="18" fill="1" gridHeight="0" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="10" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextPane" name="m_jtpConstraintEditor">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" value="Edit the constraint expression"/>
+ <Property name="document" type="javax.swing.text.Document" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="new OCLEditorDocument()" type="code"/>
+ </Property>
+ </Properties>
+
+ <Events>
+ <EventHandler event="caretUpdate" listener="javax.swing.event.CaretListener" parameters="javax.swing.event.CaretEvent" handler="onCaretUpdate"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JSplitPane" name="m_jspMainPane">
+ <Properties>
+ <Property name="oneTouchExpandable" type="boolean" value="true"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="m_jpConstraintListPane">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[100, 37]"/>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+ <JSplitPaneConstraints position="left"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane" name="m_jspConstraintListScroller">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="10" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTable" name="m_jtConstraintList">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" value="Lists all constraints. Selecting a constraint, shows its body in the right hand preview pane. Clicking twice on a constraint allows editing the constraint's name."/>
+ <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+ <Connection code="m_ctmTableModel" type="code"/>
+ </Property>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="m_jpPreviewPane">
+ <Properties>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[100, 80]"/>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+ <JSplitPaneConstraints position="right"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="m_jpPreviewGroup">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Preview"/>
+ </Border>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="10" fill="1" gridHeight="0" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="20" insetsLeft="5" insetsRight="5" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JScrollPane" name="m_jspConstraintPreviewScroller">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextPane" name="m_jtpConstraintPreview">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" value="Constraint expression preview"/>
+ <Property name="editable" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditor.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditor.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditor.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,1716 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Editor *
+ * Copyright (C) 2001 Steffen Zschaler. *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * See CREDITS file for further details. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+// OCLEditor.java -- new version of the ocl editor intented for practical use
+//
+// 08/08/2002 [sz9 ] Fixed issue #511143 by hardcoding line breaking at column 50.
+// 10/16/2001 [sz9 ] Added support for editor instances that whish to prevent
+// a constraint's context from being edited.
+// 10/16/2001 [sz9 ] Added support for replacing the table model in subclasses.
+// 10/16/2001 [sz9 ] Added support for deleting unedited, freshly created
+// constraints.
+// 03/12/2001 [sz9 ] Added handling of line and column numbers in parser error
+// messages.
+// 02/23/2001 [sz9 ] Added helper function to syntax check constraints.
+// 02/15/2001 [sz9 ] Created.
+//
+package tudresden.ocl20.gui;
+
+//import tudresden.ocl.OclTree;
+import tudresden.ocl20.core.MetaModelConst;
+import tudresden.ocl20.core.OclModel;
+import tudresden.ocl20.core.OclModelException;
+import tudresden.ocl20.core.parser.astgen.Heritage;
+import tudresden.ocl20.core.parser.astgen.LAttrAstGenerator;
+import tudresden.ocl20.core.parser.sablecc.analysis.AttrEvalException;
+import tudresden.ocl20.core.parser.sablecc.lexer.Lexer;
+import tudresden.ocl20.core.parser.sablecc.lexer.LexerException;
+import tudresden.ocl20.core.parser.sablecc.parser.Parser;
+import tudresden.ocl20.core.parser.sablecc.parser.ParserException;
+import tudresden.ocl20.gui.events.*;
+import tudresden.ocl20.integration.OCLChecker;
+
+import javax.jmi.xmi.XmiWriter;
+import javax.swing.*;
+import javax.swing.text.*;
+import javax.swing.event.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.StringReader;
+import java.util.*;
+
+import org.apache.log4j.Logger;
+import org.argouml.model.Facade;
+import org.argouml.model.Model;
+import org.argouml.model.ModelManagementFactory;
+import org.argouml.model.UmlException;
+import org.argouml.ocl.ArgoUMLModelFacade;
+import org.netbeans.api.xmi.XMIOutputConfig;
+import org.netbeans.api.xmi.XMIWriterFactory;
+import org.netbeans.lib.jmi.xmi.OutputConfig;
+
+
+
+/**
+ * An editor for a list of OCL Constraints. The editor allows editing
+ * of a list of {@link ConstraintRepresentation constraint representations}
+ * as specified by its {@link OCLEditorModel model}.
+ *
+ * @author sz9
+ * @author Raphael Schmid
+ */
+public class OCLEditor extends javax.swing.JPanel
+ implements javax.swing.event.ListSelectionListener,
+ ConstraintChangeListener,
+ EditingUtilities {
+
+ private static final Logger LOG = Logger.getLogger(OCLEditor.class);
+
+ private static final long serialVersionUID = -5645723403437695527L;
+
+ /**
+ * Attributes used to denote fields that need to be replaced.
+ */
+ private static SimpleAttributeSet s_sasField
+ = new SimpleAttributeSet();
+ /**
+ * Attributes used to denote normal OCL constraint text.
+ */
+ private static SimpleAttributeSet s_sasNormalText
+ = new SimpleAttributeSet();
+
+ /**
+ * Attributes used to denote uneditable text.
+ */
+ private static SimpleAttributeSet s_sasNoEditText
+ = new SimpleAttributeSet();
+
+ static {
+ if (StyleConstants.Alignment != null) {
+ // Just a dummy to properly initialize StyleConstants...
+ // for some reason this seems to be necessary...
+ }
+
+ s_sasField.addAttribute (
+ StyleConstants.CharacterConstants.Underline,
+ Boolean.TRUE);
+ s_sasField.addAttribute (
+ "isField",
+ Boolean.TRUE);
+
+ s_sasNoEditText.addAttribute (
+ StyleConstants.CharacterConstants.Italic,
+ Boolean.TRUE);
+ s_sasNoEditText.addAttribute (
+ "allowEdit",
+ Boolean.FALSE);
+ // provoke automatic selection of the whole un-editable text
+ // when the cursor enters it
+ s_sasNoEditText.addAttribute (
+ "isField",
+ Boolean.TRUE);
+ }
+
+ private static String imagePath = "/tudresden/ocl20/images/";
+
+ /**
+ * A specialized styled document that will prevent editing of portions of text
+ * which have been specially marked "allowEdit"==FALSE.
+ */
+ protected static class OCLEditorDocument extends DefaultStyledDocument {
+
+ /**
+ * If >= 0, {@link #checkEditLocation} will throw a
+ * {@link BadLocationException} on attempts to remove or modify elements
+ * which are marked "allowEdit"==FALSE.
+ */
+ private int m_nDoCheckUneditable = 0;
+
+ public void insertString (final int offset,
+ final String str,
+ final AttributeSet a)
+ throws BadLocationException {
+ checkEditLocation (offset, 0);
+
+ super.insertString (offset, str, a);
+ }
+
+ public void remove (int offset,
+ int length)
+ throws BadLocationException {
+ checkEditLocation (offset, length);
+
+ super.remove (offset, length);
+ }
+
+ /**
+ * Stop checking for uneditable elements. Must be paired with calls to
+ * {@link #restartChecking}.
+ */
+ public void stopChecking() {
+ m_nDoCheckUneditable --;
+ }
+
+ /**
+ * Restart checking for uneditable elements. Must be paired with calls to
+ * {@link #stopChecking}.
+ */
+ public void restartChecking() {
+ m_nDoCheckUneditable ++;
+ }
+
+ /**
+ * Check the edit range for intersection with any elements that are marked
+ * uneditable.
+ */
+ protected void checkEditLocation (int offset,
+ int length)
+ throws BadLocationException {
+ if (m_nDoCheckUneditable < 0) {
+ return;
+ }
+
+ //LOG.debug ("OCLEditor$OCLEditorDocument.checkEditLocation: invoked for (" + offset + ", " + length + ")");
+ // Get first affected element
+ Element eAffected = getDefaultRootElement();
+ while (! eAffected.isLeaf()) {
+ eAffected = eAffected.getElement (
+ eAffected.getElementIndex (offset));
+ }
+
+ // check all affected elements
+ while (
+ (eAffected != null) &&
+ (
+ (eAffected.getStartOffset() <= offset) ||
+ (eAffected.getEndOffset() >= offset + length)
+ )
+ ) {
+ if (eAffected.getAttributes().getAttribute ("allowEdit") == Boolean.FALSE) {
+ // do not allow edit
+ //LOG.debug ("OCLEditor$OCLEditorDocument.checkEditLocation: denying edit for (" + offset + ", " + length + ")");
+ throw new BadLocationException (
+ "Editing not allowed.",
+ Math.max (offset, eAffected.getStartOffset())
+ );
+ }
+ else {
+ eAffected = getNeighbouringElement (eAffected);
+ }
+ }
+ }
+
+ protected Element getNeighbouringElement (Element e) {
+ Element eTemp = e.getParentElement();
+
+ // move up in the tree
+ while ((eTemp != null) &&
+ (eTemp.getEndOffset() <= e.getEndOffset())) {
+ e = eTemp;
+ eTemp = eTemp.getParentElement();
+ }
+
+ // and down again
+ while ((eTemp != null) &&
+ (! eTemp.isLeaf())) {
+ eTemp = eTemp.getElement (eTemp.getElementIndex (e.getEndOffset()));
+ }
+
+ return eTemp;
+ }
+ }
+
+ /**
+ * Table model for the table of constraints.
+ *
+ * @author sz9
+ */
+ protected static class ConstraintTableModel extends javax.swing.table.AbstractTableModel
+ implements ConstraintChangeListener {
+ /**
+ * The OCLEditorModel on which this table model is based.
+ */
+ protected OCLEditorModel m_oclemModel;
+
+ /**
+ * The OCLEditor for which this table model is used.
+ */
+ protected java.lang.ref.WeakReference m_wrocle;
+
+ public ConstraintTableModel (OCLEditor ocle) {
+ super();
+
+ m_wrocle = new java.lang.ref.WeakReference (ocle);
+ }
+
+ /**
+ * Set the OCLEditorModel to base this table model on.
+ */
+ public void setOCLModel (OCLEditorModel oclemModel) {
+ if (m_oclemModel != null) {
+ m_oclemModel.removeConstraintChangeListener (this);
+ }
+
+ m_oclemModel = oclemModel;
+
+ if (m_oclemModel != null) {
+ m_oclemModel.addConstraintChangeListener (this);
+ }
+
+ fireTableDataChanged();
+ }
+
+ /**
+ * Return the number of rows in the table. This returns the number of
+ * constraints in the underlying model.
+ */
+ public int getRowCount() {
+ if (m_oclemModel != null) {
+ return m_oclemModel.getConstraintCount();
+ }
+ else {
+ return 0;
+ }
+ }
+
+ /**
+ * This table model has one column.
+ */
+ public int getColumnCount() {
+ return 1;
+ }
+
+ /**
+ * This table model has one column: "Constraint name".
+ */
+ public String getColumnName (int nIdx) {
+ return "Constraint Name";
+ }
+
+ /**
+ * This table model has one column: "String.class".
+ */
+ public Class getColumnClass (int nIdx) {
+ return String.class;
+ }
+
+ /**
+ * Get the constraint name of the specified constraint.
+ */
+ public Object getValueAt (int row, int column) {
+ if (m_oclemModel != null) {
+ ConstraintRepresentation cr = m_oclemModel.getConstraintAt (row);
+
+ if (cr != null) {
+ return cr.getName();
+ }
+ else {
+ return null;
+ }
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Constraint names can be edited.
+ */
+ public boolean isCellEditable (int row, int column) {
+ return column == 0;
+ }
+
+ /**
+ * Set the edited constraint name.
+ */
+ public void setValueAt (Object value, int row, int column) {
+ if (column == 0) {
+ if (m_oclemModel != null) {
+ ConstraintRepresentation cr = m_oclemModel.getConstraintAt (row);
+
+ if (cr != null) {
+ try {
+ cr.setName (value.toString(), (OCLEditor) m_wrocle.get());
+ }
+ catch (IllegalArgumentException iae) {
+ JOptionPane.showMessageDialog (null,
+ "Invalid name: " +
+ iae.getMessage(),
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ catch (IllegalStateException ise) {
+ JOptionPane.showMessageDialog (null,
+ "Couldn't set name: " +
+ ise.getMessage(),
+ "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+ }
+ }
+
+ // ConstraintChangeListener interface methods
+
+ /**
+ * Relay the event to the table indicating a row was added.
+ */
+ public void constraintAdded (ConstraintChangeEvent cce) {
+ fireTableRowsInserted (cce.getIndex(), cce.getIndex());
+ }
+
+ /**
+ * Relay the event to the table indicating a row was deleted.
+ */
+ public void constraintRemoved(ConstraintChangeEvent cce) {
+ fireTableRowsDeleted (cce.getIndex(), cce.getIndex());
+ }
+
+ /**
+ * Relay the event to the table indicating the data in the cell changed.
+ */
+ public void constraintNameChanged(ConstraintChangeEvent cce) {
+ fireTableCellUpdated (cce.getIndex(), 0);
+ }
+
+ /**
+ * Ignored.
+ */
+ public void constraintDataChanged(ConstraintChangeEvent cce) {
+ }
+ }
+
+ /**
+ * The underlying model.
+ */
+ private OCLEditorModel m_oclemModel;
+
+ /**
+ * The currently selected constraint, if any.
+ */
+ private ConstraintRepresentation m_crCurrent;
+
+ /**
+ * The table model used by the list of constraints table.
+ */
+ private ConstraintTableModel m_ctmTableModel;
+
+ /**
+ * Does {@link #parseAndCheckConstraint} perform type checking?
+ */
+ private boolean m_fDoTypeCheck = true;
+
+ /**
+ * Should multi-constraint inputs be automatically split into individual
+ * constraints?
+ */
+ private boolean m_fDoAutoSplit = true;
+
+ /**
+ * Should the constraints context (everything up to the first 'inv', 'pre',
+ * or 'post') be un-editable?
+ */
+ private boolean m_fNoContextEdit = false;
+
+ public static final int OPTIONMASK_TYPECHECK = 1;
+ public static final int OPTIONMASK_AUTOSPLIT = 2;
+
+ /**
+ * The options supported by this instance of the editor. I.e., the options
+ * which will show up in the options dialog.
+ */
+ private int m_nOptionMask = OPTIONMASK_TYPECHECK | OPTIONMASK_AUTOSPLIT;
+
+ /**
+ * If true, we're in edit mode.
+ */
+ private boolean m_fInEditMode = false;
+
+ /**
+ * Set to false when beginning edit mode, evaluated at the end of editing a
+ * newly created constraint to determine whether to remove it again. When a
+ * {@link #constraintDataChanged} event is received for the currently selected
+ * constraint, this is set to true.
+ */
+ private boolean m_fConstraintChanged;
+
+ /**
+ * Indicates the constraint currently being edited is a newly created one.
+ * This means, it will be removed if no changes where made to it.
+ */
+ private boolean m_fCreatedFreshConstraint = false;
+
+ /** Creates new form OCLEditor */
+ public OCLEditor() {
+ m_ctmTableModel = createConstraintTableModel();
+
+ initComponents ();
+
+ /*
+ * Remove editor panel, which was added only to be able to manipulate it
+ * from the IDE.
+ */
+ m_jpToolbarWrapper.remove (m_jpEditorPanel);
+
+ m_jtConstraintList.getSelectionModel()
+ .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m_jtConstraintList.getSelectionModel()
+ .addListSelectionListener (this);
+
+ m_ocltbQuickBar.setVisible (false);
+ }
+
+ /**
+ * Create and return an instance of ConstraintTableModel that will be used
+ * to represent the list of constraints currently being edited.
+ *
+ * <p><strong>Attention!</strong> This method is called from the constructor
+ * and should therefore be overridden with great care. When referencing
+ * <code>this</code> from within this method care must be taken to recognize
+ * that <code>this</code> will not have been fully initialized yet. In
+ * particular, any field introduced by subclasses of {@link OCLEditor}
+ * will not have been initialized, and any code specified in constructors of
+ * subclasses of {@link OCLEditor} will not have been executed.
+ *
+ * @return an instance of ConstraintTableModel to be used to display the list
+ * of constraints being edited
+ */
+ protected ConstraintTableModel createConstraintTableModel() {
+ return new ConstraintTableModel (this);
+ }
+
+ /**
+ * Retrieve the underlying model.
+ */
+ public OCLEditorModel getModel() {
+ return m_oclemModel;
+ }
+
+ /**
+ * Set the underlying model and update the display.
+ */
+ public void setModel (OCLEditorModel oclemModel) {
+ setEditMode (false);
+
+ if (m_oclemModel != null) {
+ m_oclemModel.removeConstraintChangeListener (this);
+ }
+
+ m_oclemModel = oclemModel;
+
+ m_ctmTableModel.setOCLModel (oclemModel);
+
+ if (m_oclemModel != null) {
+ m_oclemModel.addConstraintChangeListener (this);
+ }
+
+ m_jtConstraintList.clearSelection();
+ }
+
+ /**
+ * Return true if the OCL editor is currently in edit mode.
+ */
+ public boolean isInEditMode() {
+ return m_fInEditMode;
+ }
+
+ /**
+ * Set the edit mode of the OCL editor. Setting the edit mode to false cancels
+ * any current edit.
+ */
+ public void setEditMode (boolean fEditMode) {
+ if (fEditMode == m_fInEditMode) {
+ return;
+ }
+
+ // From here it's basically a toggling of edit mode
+ if (! m_fInEditMode) {
+ // Only switch to edit mode if current constraint exists
+ if (m_crCurrent == null) {
+ return;
+ }
+
+ m_fInEditMode = true;
+ m_fConstraintChanged = false;
+
+ m_jpToolbarWrapper.remove (m_jspMainPane);
+ m_jpToolbarWrapper.add (m_jpEditorPanel, java.awt.BorderLayout.CENTER);
+
+ /*m_jbNew.setEnabled (false);
+ m_jbRemove.setEnabled (false);*/
+ m_jbNew.setVisible (false);
+ m_jbRemove.setVisible (false);
+
+ m_jbEdit.setIcon (new javax.swing.ImageIcon (getClass ().getResource (imagePath + "Cancel16.gif")));
+ m_jbEdit.setToolTipText ("Click to cancel editing without saving changes");
+ //m_jbEdit.setText ("Stop Edit");
+
+ /*m_jbSaveEditResult.setEnabled (true);*/
+ m_jbSaveEditResult.setVisible (true);
+
+ m_jtpConstraintEditor.requestFocus();
+
+ m_ocltbQuickBar.setVisible (m_jcbQuickBar.isSelected());
+ /*m_jcbQuickBar.setEnabled (true);*/
+ m_jcbQuickBar.setVisible (true);
+ }
+ else {
+ m_fInEditMode = false;
+
+ if (m_fCreatedFreshConstraint &&
+ ! m_fConstraintChanged) {
+ int nIdx = m_jtConstraintList.getSelectedRow();
+
+ if (nIdx != -1) {
+ m_oclemModel.removeConstraintAt (nIdx);
+ }
+ }
+
+ // reset flags
+ m_fCreatedFreshConstraint = false;
+ m_fConstraintChanged = false;
+
+ m_jpToolbarWrapper.remove (m_jpEditorPanel);
+ m_jpToolbarWrapper.add (m_jspMainPane, java.awt.BorderLayout.CENTER);
+
+ setEditorText (m_crCurrent);
+
+ /*m_jbNew.setEnabled (true);
+ m_jbRemove.setEnabled (true);*/
+ m_jbNew.setVisible (true);
+ m_jbRemove.setVisible (true);
+
+ m_jbEdit.setIcon (new javax.swing.ImageIcon (getClass ().getResource (imagePath + "Edit16.gif")));
+ m_jbEdit.setToolTipText ("Click to edit the currently selected constraint");
+ //m_jbEdit.setText ("Edit");
+
+ /*m_jbSaveEditResult.setEnabled (false);*/
+ m_jbSaveEditResult.setVisible (false);
+
+ m_ocltbQuickBar.setVisible (false);
+ /*m_jcbQuickBar.setEnabled (false);*/
+ m_jcbQuickBar.setVisible (false);
+ }
+
+ m_jpToolbarWrapper.revalidate();
+ m_jpToolbarWrapper.repaint();
+ }
+
+ /**
+ * Checks the specified name and returns true if it is a valid OCL name.
+ */
+ public boolean isValidConstraintName (String sName) {
+ if ((sName == null) ||
+ (sName.length() == 0)) {
+ return false;
+ }
+ if ((! Character.isLetter (sName.charAt (0))) ||
+ (! Character.isLowerCase (sName.charAt (0)))) {
+ return false;
+ }
+ for (int i = 1; i < sName.length(); i++) {
+ if ((! Character.isLetterOrDigit (sName.charAt (i))) &&
+ (sName.charAt (i) != '_')) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Specify which user option check boxes should be displayed.
+ */
+ public void setOptionMask (int nOptionMask) {
+ m_nOptionMask = nOptionMask;
+
+ if (m_nOptionMask == 0) {
+ return;
+ }
+ }
+
+ public int getOptionMask() {
+ return m_nOptionMask;
+ }
+
+ /**
+ * Specify whether or not to allow editing the context of a constraint.
+ */
+ public void setNoContextEdit (boolean fNoContextEdit) {
+ m_fNoContextEdit = fNoContextEdit;
+ }
+
+ /**
+ * Return whether context editing is currently prohibited.
+ */
+ public boolean getNoContextEdit() {
+ return m_fNoContextEdit;
+ }
+
+ /**
+ * Set the type checking mode.
+ */
+ public void setDoTypeCheck (boolean fDoTypeCheck) {
+ m_fDoTypeCheck = fDoTypeCheck;
+ }
+
+ /**
+ * Return whether type checking mode is on. If this returns true,
+ * {@link #parseAndCheckConstraint} will also check type conformance of
+ * constraints.
+ */
+ public boolean getDoTypeCheck() {
+ return m_fDoTypeCheck;
+ }
+
+ /**
+ * Check the specified constraint.
+ *
+ * @exception OclModelException thrown by the methods of {@link OclModel OclModel} in case of an error.
+ * @exception ParserException if a syntax error occurred.
+ * @exception LexerException .
+ * @exception AttrEvalException if a type checking error occurred.
+ * @exception IOException if an I/O operation failed.
+ */
+ public void parseAndCheckConstraint (final String sConstraint)
+ // Updated by Raphael Schmid
+ throws OclModelException, ParserException, LexerException, AttrEvalException, IOException {
+ if (this.getDoTypeCheck()) {
+ String constraint = m_jtpConstraintEditor.getText();
+
+ // Project p = ProjectManager.getManager().getCurrentProject();
+ // Object o = p.getRoot();
+
+ ModelManagementFactory mmf = Model.getModelManagementFactory();
+ Object o = mmf.getRootModel();
+
+ //LOG.debug("Root-package: " + o.getClass().getName());
+ OCLChecker oclChecker = OCLChecker.getInstance(o);
+ try {
+ oclChecker.setModelFacade(new ArgoUMLModelFacade());
+ // oclChecker.initModel(); // not necessary, already called by getInstance()!
+ } catch (Exception e) {
+ // TODO
+ e.printStackTrace();
+ }
+ //LOG.debug("check the following constraint: " + constraint);
+ oclChecker.validate(constraint);
+ } else {
+ // don't perform OCL type checking
+
+ }
+ }
+
+//
+// /**
+// * Check the specified constraint using the specified model facade for model
+// * information. Return the parse tree for the constraint.
+// *
+// * <p>This is a short-cut helper function for editor models that want to parse
+// * constraints before adding them to the model base.</p>
+// *
+// * @exception OclParserException if a syntax error occurred.
+// * @exception IOException if an I/O operation failed.
+// * @exception OclTypeException if a type checking error occurred.
+// */
+// public OclTree parseAndCheckConstraint (final String sConstraint,
+// final ModelFacade mfFacade)
+// throws OclParserException,
+// java.io.IOException,
+// OclTypeException {
+// // Parse and syntax check
+// final OclTree tree = OclTree.createTree (sConstraint,
+// mfFacade);
+//
+// // Type check
+// if ((tree != null) &&
+// (m_fDoTypeCheck)) {
+// DepthFirstAdapter dfaTypeChecker = new DepthFirstAdapter() {
+// private RuntimeException m_rteException = null;
+//
+// public void inStart (Start node) {
+// defaultIn(node);
+// }
+//
+// public void outStart(Start s) {
+// if (m_rteException != null) {
+// throw m_rteException;
+// }
+// }
+//
+// public void defaultIn(Node node) {
+// try {
+// Object o = tree.getNodeType(node);
+// }
+// catch (RuntimeException e) {
+// if (m_rteException == null) {
+// m_rteException = e;
+// }
+// }
+// }
+// };
+//
+// try {
+// tree.apply (dfaTypeChecker);
+//
+// try {
+// tree.applyGeneratedTests();
+// }
+// catch (java.security.AccessControlException ace) {
+// // SecurityManager denies access to non-public fields
+// // Ignore and assume all is correct
+// }
+// }
+// catch (Exception e) {
+// e.printStackTrace();
+// throw new OclTypeException (e.getMessage());
+// }
+// }
+//
+// return tree;
+// }
+
+ /**
+ * Set the auto split mode.
+ */
+ public void setDoAutoSplit (boolean fDoAutoSplit) {
+ m_fDoAutoSplit = fDoAutoSplit;
+ }
+
+ /**
+ * Return whether auto split mode is on. If this returns true, constraint
+ * representations should call {@link #splitConstraint} and create one
+ * constraint representation per actual constraint.
+ */
+ public boolean getDoAutoSplit() {
+ return m_fDoAutoSplit;
+ }
+
+// /**
+// * Split the specified constraint into its constituting constraints. E.g.
+// * <pre>
+// * context Test
+// * inv: a > 0
+// * inv: a < 10
+// * inv: a * 100 = 900
+// * </pre>
+// * would be split into three constraints:
+// * <pre>
+// * context Test
+// * inv: a > 0
+// *
+// * context Test
+// * inv: a < 10
+// *
+// * context Test
+// * inv: a * 100 = 900
+// * </pre>
+// */
+// public List splitConstraint (OclTree ocltConstraint) {
+// final List lResult = new LinkedList();
+//
+// class Splitter extends DepthFirstAdapter {
+// public void caseAConstraint(AConstraint node) {
+// PContextDeclaration pcd = node.getContextDeclaration();
+//
+// for (Iterator i = node.getConstraintBody().iterator(); i.hasNext();) {
+// PConstraintBody pcbCurrent = (PConstraintBody) i.next();
+//
+// List lTempBody = new LinkedList();
+// lTempBody.add (pcbCurrent.clone());
+//
+// lResult.add (new OclTree (
+// new Start (
+// new AConstraint ((PContextDeclaration) pcd.clone(),
+// lTempBody),
+// new EOF()
+// )
+// ));
+// }
+// }
+// }
+//
+// ocltConstraint.apply (new Splitter());
+//
+// return lResult;
+// }
+
+ /**
+ * Add the given text to the edit pane, if a constraint is currently being
+ * edited. The text will replace the current selection. If saBefore/saAfter
+ * are not <code>null</code> and contain elements, these will be added as
+ * items to be replaced. The first such item will be selected.
+ */
+ void addConstraintText (String[] saBefore,
+ String sText,
+ String[] saAfter) {
+ if ((m_crCurrent != null) && isInEditMode()) {
+ int nSelStart = -1;
+ int nSelEnd = -1;
+
+ this.m_fHandleCaretUpdates = false;
+
+ m_jtpConstraintEditor.replaceSelection ("");
+
+ if (saBefore != null) {
+ m_jtpConstraintEditor.setCharacterAttributes (s_sasField, true);
+ for (int i = 0; i < saBefore.length; i++) {
+ if (i == 0) {
+ nSelStart = m_jtpConstraintEditor.getSelectionStart();
+ nSelEnd = nSelStart + saBefore[i].length();
+ }
+
+ m_jtpConstraintEditor.replaceSelection (saBefore[i]);
+ }
+ m_jtpConstraintEditor.setCharacterAttributes (s_sasNormalText, true);
+ }
+
+ m_jtpConstraintEditor.replaceSelection (sText);
+
+ if (saAfter != null) {
+ m_jtpConstraintEditor.setCharacterAttributes (s_sasField, true);
+ for (int i = 0; i < saAfter.length; i++) {
+ if ((i == 0) &&
+ (nSelStart == -1)) {
+ nSelStart = m_jtpConstraintEditor.getSelectionStart();
+ nSelEnd = nSelStart + saAfter[i].length();
+ }
+
+ m_jtpConstraintEditor.replaceSelection (saAfter[i]);
+ }
+ m_jtpConstraintEditor.setCharacterAttributes (s_sasNormalText, true);
+ }
+
+ if (nSelStart != -1) {
+ m_jtpConstraintEditor.paintImmediately (
+ 0, 0,
+ m_jtpConstraintEditor.getWidth(),
+ m_jtpConstraintEditor.getHeight());
+ m_jtpConstraintEditor.setSelectionStart (nSelStart);
+ m_jtpConstraintEditor.setSelectionEnd (nSelEnd);
+ }
+ this.m_fHandleCaretUpdates = true;
+
+/* java.awt.Frame fTop = (java.awt.Frame) getTopLevelAncestor();
+ fTop.toFront();
+ fTop.requestFocus();
+ m_jtpConstraintEditor.requestFocus();*/
+ }
+ }
+
+ /**
+ * Replace the contents of the edior by the data of the specified constraint.
+ */
+ protected void setEditorText (ConstraintRepresentation cr) {
+ m_jtpConstraintEditor.setCharacterAttributes (s_sasNormalText, true);
+
+ if (cr != null) {
+ if (m_fNoContextEdit) {
+ ((OCLEditorDocument) m_jtpConstraintEditor.getDocument()).stopChecking();
+ m_jtpConstraintEditor.setText ("");
+ ((OCLEditorDocument) m_jtpConstraintEditor.getDocument()).restartChecking();
+
+ String s = cr.getData();
+
+ int nInvPos = s.indexOf ("inv"); if (nInvPos == -1) { nInvPos = s.length(); }
+ int nPrePos = s.indexOf ("pre"); if (nPrePos == -1) { nPrePos = s.length(); }
+ int nPostPos = s.indexOf ("post"); if (nPostPos == -1) { nPostPos = s.length(); }
+
+ int nContextEnd =
+ Math.min (
+ Math.min (
+ nInvPos,
+ nPrePos
+ ),
+ nPostPos
+ );
+
+ m_jtpConstraintEditor.setCharacterAttributes (
+ s_sasNoEditText,
+ true
+ );
+ m_jtpConstraintEditor.replaceSelection (s.substring (0, nContextEnd));
+
+ m_jtpConstraintEditor.setCharacterAttributes (
+ s_sasNormalText,
+ true
+ );
+ m_jtpConstraintEditor.replaceSelection (s.substring (nContextEnd));
+ }
+ else {
+ // TODO: Deal with fields.
+ ((OCLEditorDocument) m_jtpConstraintEditor.getDocument()).stopChecking();
+ m_jtpConstraintEditor.setText (cr.getData());
+ ((OCLEditorDocument) m_jtpConstraintEditor.getDocument()).restartChecking();
+ }
+ }
+ else {
+ ((OCLEditorDocument) m_jtpConstraintEditor.getDocument()).stopChecking();
+ m_jtpConstraintEditor.setText ("");
+ ((OCLEditorDocument) m_jtpConstraintEditor.getDocument()).restartChecking();
+ }
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the FormEditor.
+ */
+ private void initComponents () {//GEN-BEGIN:initComponents
+ m_jtbTools = new javax.swing.JToolBar ();
+ m_jbNew = new javax.swing.JButton ();
+ m_jbRemove = new javax.swing.JButton ();
+ m_jbEdit = new javax.swing.JButton ();
+ m_jbSaveEditResult = new javax.swing.JButton ();
+ m_jbSaveEditResult.setVisible (false);
+ pad1 = new javax.swing.JPanel ();
+ m_jbPreferences = new javax.swing.JButton ();
+ xmiExportButton = new javax.swing.JButton();
+ pad2 = new javax.swing.JPanel ();
+ m_jcbQuickBar = new javax.swing.JCheckBox ();
+ m_jcbQuickBar.setVisible (false);
+ m_jpToolbarWrapper = new javax.swing.JPanel ();
+ m_ocltbQuickBar = new tudresden.ocl20.gui.OCLToolbar ();
+ m_jpEditorPanel = new javax.swing.JPanel ();
+ m_jspConstraintEditorScroller = new javax.swing.JScrollPane ();
+ m_jtpConstraintEditor = new javax.swing.JTextPane ();
+ m_jspMainPane = new javax.swing.JSplitPane ();
+ m_jpConstraintListPane = new javax.swing.JPanel ();
+ m_jspConstraintListScroller = new javax.swing.JScrollPane ();
+ m_jtConstraintList = new javax.swing.JTable ();
+ m_jpPreviewPane = new javax.swing.JPanel ();
+ m_jpPreviewGroup = new javax.swing.JPanel ();
+ m_jspConstraintPreviewScroller = new javax.swing.JScrollPane ();
+ m_jtpConstraintPreview = new javax.swing.JTextPane ();
+
+ setLayout (new java.awt.BorderLayout ());
+
+ setPreferredSize (new java.awt.Dimension (500, 300));
+ setMinimumSize (new java.awt.Dimension (500, 300));
+ m_jbNew.setIcon (new javax.swing.ImageIcon (getClass ().getResource (imagePath + "New16.gif")));
+ m_jbNew.setToolTipText ("Click to create a new constraint");
+ m_jbNew.setMargin (new java.awt.Insets (0, 0, 0, 0));
+ m_jbNew.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onNewConstraintButton (evt);
+ }
+ });
+
+ m_jtbTools.add (m_jbNew);
+
+ m_jbRemove.setIcon (new javax.swing.ImageIcon (getClass ().getResource (imagePath + "Delete16.gif")));
+ m_jbRemove.setToolTipText ("Click to remove the currently selected constraint");
+ m_jbRemove.setMargin (new java.awt.Insets (0, 0, 0, 0));
+ m_jbRemove.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onRemoveConstraintButton (evt);
+ }
+ });
+
+ m_jtbTools.add (m_jbRemove);
+
+ m_jbEdit.setIcon (new javax.swing.ImageIcon (getClass ().getResource (imagePath + "Edit16.gif")));
+ m_jbEdit.setToolTipText ("Click to edit the currently selected constraint");
+ m_jbEdit.setMargin (new java.awt.Insets (0, 0, 0, 0));
+ m_jbEdit.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onEditButton (evt);
+ }
+ });
+
+ m_jtbTools.add (m_jbEdit);
+
+ m_jbSaveEditResult.setIcon (new javax.swing.ImageIcon (getClass ().getResource (imagePath + "Ok16.gif")));
+ m_jbSaveEditResult.setToolTipText ("Check OCL syntax and save constraint into model");
+ m_jbSaveEditResult.setMargin (new java.awt.Insets (0, 0, 0, 0));
+ m_jbSaveEditResult.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onSubmitConstraintButton (evt);
+ }
+ });
+
+ m_jtbTools.add (m_jbSaveEditResult);
+
+ pad1.setMaximumSize (new java.awt.Dimension (10, 10));
+ m_jtbTools.add (pad1);
+
+ m_jbPreferences.setIcon (new javax.swing.ImageIcon (getClass ().getResource (imagePath + "Preferences16.gif")));
+ m_jbPreferences.setToolTipText ("Click to inspect and modify OCL editor preferences.");
+ m_jbPreferences.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onPreferencesButton (evt);
+ }
+ });
+
+ m_jtbTools.add (m_jbPreferences);
+
+ xmiExportButton.setIcon (new javax.swing.ImageIcon (getClass ().getResource (imagePath + "save_icon.gif")));
+ xmiExportButton.setToolTipText ("Click to export the model and constraints in XMI.");
+ xmiExportButton.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onXMIExportButton (evt);
+ }
+ });
+
+ m_jtbTools.add (xmiExportButton);
+
+ pad2.setPreferredSize (new java.awt.Dimension (5, 10));
+ pad2.setMinimumSize (new java.awt.Dimension (5, 10));
+ pad2.setMaximumSize (new java.awt.Dimension (5, 10));
+ m_jtbTools.add (pad2);
+
+ m_jcbQuickBar.setToolTipText ("Check to see the syntax assistant toolbar");
+ m_jcbQuickBar.setText ("Syntax Assistant");
+ m_jcbQuickBar.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onQuickBarButton (evt);
+ }
+ });
+
+ m_jtbTools.add (m_jcbQuickBar);
+
+ add (m_jtbTools, java.awt.BorderLayout.NORTH);
+
+ m_jpToolbarWrapper.setLayout (new java.awt.BorderLayout ());
+
+ m_ocltbQuickBar.setEditor (this);
+ m_jpToolbarWrapper.add (m_ocltbQuickBar, java.awt.BorderLayout.NORTH);
+
+ m_jpEditorPanel.setLayout (new java.awt.GridBagLayout ());
+ java.awt.GridBagConstraints gridBagConstraints1;
+
+ m_jpEditorPanel.setBorder (new javax.swing.border.TitledBorder ("Edit constraint"));
+ m_jtpConstraintEditor.setToolTipText ("Edit the constraint expression");
+ m_jtpConstraintEditor.setDocument (new OCLEditorDocument ());
+ m_jtpConstraintEditor.addCaretListener (new javax.swing.event.CaretListener () {
+ public void caretUpdate (javax.swing.event.CaretEvent evt) {
+ onCaretUpdate (evt);
+ }
+ });
+
+ m_jspConstraintEditorScroller.setViewportView (m_jtpConstraintEditor);
+
+ gridBagConstraints1 = new java.awt.GridBagConstraints ();
+ gridBagConstraints1.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints1.gridheight = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints1.insets = new java.awt.Insets (5, 5, 10, 5);
+ gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ gridBagConstraints1.weightx = 1.0;
+ gridBagConstraints1.weighty = 1.0;
+ m_jpEditorPanel.add (m_jspConstraintEditorScroller, gridBagConstraints1);
+
+ m_jpToolbarWrapper.add (m_jpEditorPanel, java.awt.BorderLayout.CENTER);
+
+ m_jspMainPane.setOneTouchExpandable (true);
+ m_jpConstraintListPane.setLayout (new java.awt.GridBagLayout ());
+ java.awt.GridBagConstraints gridBagConstraints2;
+
+ m_jpConstraintListPane.setPreferredSize (new java.awt.Dimension (100, 37));
+ m_jtConstraintList.setToolTipText ("Lists all constraints. Selecting a constraint, shows its body in the right hand preview pane. Clicking twice on a constraint allows editing the constraint's name.");
+ m_jtConstraintList.setModel (m_ctmTableModel);
+ m_jspConstraintListScroller.setViewportView (m_jtConstraintList);
+
+ gridBagConstraints2 = new java.awt.GridBagConstraints ();
+ gridBagConstraints2.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints2.insets = new java.awt.Insets (10, 5, 5, 5);
+ gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ gridBagConstraints2.weightx = 1.0;
+ gridBagConstraints2.weighty = 1.0;
+ m_jpConstraintListPane.add (m_jspConstraintListScroller, gridBagConstraints2);
+
+ m_jspMainPane.setLeftComponent (m_jpConstraintListPane);
+
+ m_jpPreviewPane.setLayout (new java.awt.GridBagLayout ());
+ java.awt.GridBagConstraints gridBagConstraints3;
+
+ m_jpPreviewPane.setPreferredSize (new java.awt.Dimension (100, 80));
+ m_jpPreviewGroup.setLayout (new java.awt.GridBagLayout ());
+ java.awt.GridBagConstraints gridBagConstraints4;
+
+ m_jpPreviewGroup.setBorder (new javax.swing.border.TitledBorder ("Preview"));
+ m_jtpConstraintPreview.setToolTipText ("Constraint expression preview");
+ m_jtpConstraintPreview.setEditable (false);
+ m_jspConstraintPreviewScroller.setViewportView (m_jtpConstraintPreview);
+
+ gridBagConstraints4 = new java.awt.GridBagConstraints ();
+ gridBagConstraints4.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints4.insets = new java.awt.Insets (5, 5, 5, 5);
+ gridBagConstraints4.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ gridBagConstraints4.weightx = 1.0;
+ gridBagConstraints4.weighty = 1.0;
+ m_jpPreviewGroup.add (m_jspConstraintPreviewScroller, gridBagConstraints4);
+
+ gridBagConstraints3 = new java.awt.GridBagConstraints ();
+ gridBagConstraints3.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints3.gridheight = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints3.insets = new java.awt.Insets (0, 5, 20, 5);
+ gridBagConstraints3.weightx = 1.0;
+ gridBagConstraints3.weighty = 1.0;
+ m_jpPreviewPane.add (m_jpPreviewGroup, gridBagConstraints3);
+
+ m_jspMainPane.setRightComponent (m_jpPreviewPane);
+
+ m_jpToolbarWrapper.add (m_jspMainPane, java.awt.BorderLayout.CENTER);
+
+ add (m_jpToolbarWrapper, java.awt.BorderLayout.CENTER);
+
+ }//GEN-END:initComponents
+
+ private void onEditButton (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onEditButton
+ // Toggle edit mode
+ setEditMode (! isInEditMode());
+ }//GEN-LAST:event_onEditButton
+
+ private void onNewConstraintButton (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onNewConstraintButton
+ if (m_oclemModel != null) {
+ int nOldCount = m_oclemModel.getConstraintCount();
+ m_oclemModel.addConstraint();
+
+ if (m_oclemModel.getConstraintCount() > nOldCount) {
+ // New constraint was added, it should now also be selected because of
+ // our reaction to the constraintAdded event.
+ m_fCreatedFreshConstraint = true; // mark as new constraint
+ setEditMode (true);
+ }
+ }
+ }//GEN-LAST:event_onNewConstraintButton
+
+ private void onPreferencesButton (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onPreferencesButton
+ new OCLEditorPreferences (new JFrame(), this).setVisible (true);
+ }//GEN-LAST:event_onPreferencesButton
+
+ private boolean m_fHandleCaretUpdates = true;
+
+ private int m_nOldDot = 0;
+ private int m_nOldMark = 0;
+
+ private void onCaretUpdate (javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_onCaretUpdate
+ if (! m_fHandleCaretUpdates) {
+ return;
+ }
+
+ final CaretEvent e = evt;
+ SwingUtilities.invokeLater(new Runnable () {
+ public void run() {
+ // Get affected element
+ Element eAffected = m_jtpConstraintEditor.
+ getDocument().getDefaultRootElement();
+ while (! eAffected.isLeaf()) {
+ eAffected = eAffected.getElement (
+ eAffected.getElementIndex (e.getDot()));
+ }
+
+ if (eAffected.getAttributes().getAttribute("isField") == Boolean.TRUE) {
+ // enhance selection to end of field
+ int nFieldStart = eAffected.getStartOffset();
+ int nFieldEnd = eAffected.getEndOffset();
+
+ int nMark = e.getMark();
+ int nDot = e.getDot();
+
+ int nSelStart = 0;
+ int nSelEnd = 0;
+
+ if (nMark == nDot) {
+ // Cursor set
+ if (m_nOldDot > nDot) {
+ // coming in from the right
+ nSelStart = nFieldEnd;
+ nSelEnd = nFieldStart;
+ }
+ else {
+ // coming in from the left
+ nSelStart = nFieldStart;
+ nSelEnd = nFieldEnd;
+ }
+ }
+ else if (nMark < nDot) {
+ // Selection spanning toward the right
+ if (m_nOldDot > nDot) {
+ // making selection smaller...
+ nSelStart = Math.min (nMark, nFieldStart);
+ nSelEnd = Math.min (nDot, nFieldStart);
+ }
+ else {
+ if (nMark > nFieldStart) {
+ nSelStart = nFieldStart;
+ }
+ else {
+ nSelStart = nMark;
+ }
+
+ if (nDot <= nFieldEnd) {
+ nSelEnd = nFieldEnd;
+ }
+ else {
+ nSelEnd = nDot;
+ }
+ }
+ }
+ else {
+ if (m_nOldDot < nDot) {
+ // making selection smaller...
+ nSelStart = Math.max (nMark, nFieldEnd);
+ nSelEnd = Math.max (nDot, nFieldEnd);
+ }
+ else {
+ if (nMark < nFieldEnd) {
+ nSelStart = nFieldEnd;
+ }
+ else {
+ nSelStart = nMark;
+ }
+
+ if (nDot >= nFieldStart) {
+ nSelEnd = nFieldStart;
+ }
+ else {
+ nSelEnd = nDot;
+ }
+ }
+ }
+
+ Caret c = m_jtpConstraintEditor.getCaret();
+ m_fHandleCaretUpdates = false;
+ c.setDot (nSelStart);
+ c.moveDot (nSelEnd);
+ m_fHandleCaretUpdates = true;
+
+ m_nOldMark = nSelEnd;
+ m_nOldDot = nSelEnd;
+ }
+ else {
+ m_nOldDot = e.getDot();
+ m_nOldMark = e.getMark();
+ }
+ }
+ });
+ }//GEN-LAST:event_onCaretUpdate
+
+ private ArrayList getConstraints(Object element) {
+ ArrayList constraints = new ArrayList();
+ Facade argoFacade = Model.getFacade();
+
+ // the constraints of the sub-namespaces
+ Collection ownedElements = argoFacade.getOwnedElements(element);
+ Iterator i = ownedElements.iterator();
+ while (i.hasNext()) {
+ Object e = i.next();
+ if (e instanceof org.omg.uml.foundation.core.Namespace) {
+ Collection c = this.getConstraints(e);
+ constraints.addAll(c);
+ }
+ }
+
+ // the constraints of the features
+ if (element instanceof org.omg.uml.foundation.core.Classifier) {
+ Collection features = argoFacade.getFeatures(element);
+ i = features.iterator();
+ while (i.hasNext()) {
+ Object e = i.next();
+ constraints.addAll(argoFacade.getConstraints(e));
+ }
+ }
+
+ // the constraints of the element itself
+ constraints.addAll(argoFacade.getConstraints(element));
+ return constraints;
+ }
+
+ private String convertConstraints(ArrayList constraints) {
+ String constraintsText = new String();
+ for (Object o : constraints) {
+ org.omg.uml.foundation.core.Constraint c = (org.omg.uml.foundation.core.Constraint) o;
+ String text = c.getBody().getBody();
+ constraintsText = constraintsText.concat(text);
+ constraintsText = constraintsText.concat(" "); // to prevent endpackagepackage !
+ }
+ //LOG.debug(constraintsText);
+ return constraintsText;
+ }
+
+ private void onXMIExportButton(java.awt.event.ActionEvent evt) {
+ ModelManagementFactory mmf = Model.getModelManagementFactory();
+ Object argoModel = mmf.getRootModel();
+
+ // gather all constraints
+ ArrayList constraints = this.getConstraints(argoModel);
+ String constraintText = this.convertConstraints(constraints);
+
+ LOG.debug("Exporting the following constraints:");
+ LOG.debug(constraintText);
+
+ try {
+ javax.swing.JFileChooser fileChooser = new javax.swing.JFileChooser();
+ if (fileChooser.showSaveDialog(this) != JFileChooser.CANCEL_OPTION) {
+ // write the xmi model from argoUML
+ String tmppath = fileChooser.getSelectedFile().getParent() + "/tmp.xmi";
+ Model.getXmiWriter(argoModel, new FileWriter(tmppath), "1.4").write();
+
+ // load the xmi model into the dresden ocl2 toolkit
+ String modelUrl = "file:" + tmppath;
+ OclModel oclModel = new OclModel(MetaModelConst.UML15, modelUrl);
+
+ // generate concrete syntax tree
+ // create lexer
+ Lexer lexer = new Lexer (new PushbackReader(new StringReader(constraintText),1024));
+ // parser program
+ Parser parser = new Parser(lexer);
+ tudresden.ocl20.core.parser.sablecc.node.Start cst = parser.parse(); // start symbol of cst
+
+ LAttrAstGenerator astgen = new LAttrAstGenerator(oclModel);
+ //astgen.setMessageSink(this);
+ Heritage hrtg = new Heritage();
+ oclModel.beginTrans(true);
+ cst.apply(astgen, hrtg);
+ oclModel.endTrans(false);
+
+ // write the xmi
+ //oclModel.save(fileChooser.getSelectedFile().getAbsolutePath());
+ //tudresden.ocl20.core.Repository r = RepositoryManager.getRepository();
+ //XmiWriter xmiWriter = r.createXMIWriter();
+ XMIOutputConfig config = new OutputConfig();
+ config.setEncoding("UTF-8");
+ XmiWriter xmiWriter = XMIWriterFactory.getDefault().createXMIWriter(config);
+ xmiWriter.write(new FileOutputStream(fileChooser.getSelectedFile().getAbsolutePath()), oclModel.getModel(), "1.2");
+
+ // delete the tmp file
+ new File(tmppath).delete();
+ }
+ } catch (UmlException e) {
+ String sWrappedMessage = wrapMessage(e.getMessage(), 100);
+ JOptionPane.showMessageDialog(null,
+ "XMI Export failed:\n" + sWrappedMessage,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ e.printStackTrace();
+ } catch (IOException e) {
+ String sWrappedMessage = wrapMessage(e.getMessage(), 100);
+ JOptionPane.showMessageDialog(null,
+ "XMI Export failed:\n" + sWrappedMessage,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ e.printStackTrace();
+ } catch (OclModelException e) {
+ String sWrappedMessage = wrapMessage(e.getMessage(), 100);
+ JOptionPane.showMessageDialog(null,
+ "XMI Export failed:\n" + sWrappedMessage,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ e.printStackTrace();
+ } catch (ParserException e) {
+ String sWrappedMessage = wrapMessage(e.getMessage(), 100);
+ JOptionPane.showMessageDialog(null,
+ "XMI Export failed:\n" + sWrappedMessage,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ e.printStackTrace();
+ } catch (LexerException e) {
+ String sWrappedMessage = wrapMessage(e.getMessage(), 100);
+ JOptionPane.showMessageDialog(null,
+ "XMI Export failed:\n" + sWrappedMessage,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ e.printStackTrace();
+ } catch (AttrEvalException e) {
+ String sWrappedMessage = wrapMessage(e.getMessage(), 100);
+ JOptionPane.showMessageDialog(null,
+ "XMI Export failed:\n" + sWrappedMessage,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ e.printStackTrace();
+ }
+ }
+
+ private void onQuickBarButton (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onQuickBarButton
+ /*if (m_ocltQuickBar == null) {
+ m_ocltQuickBar = new OCLToolbar (this);
+ }
+
+ if (m_jcbQuickBar.isSelected()) {
+ m_ocltQuickBar.setVisible (true);
+ m_ocltQuickBar.toFront();
+ }
+ else {
+ m_ocltQuickBar.setVisible (false);
+ }*/
+
+ m_ocltbQuickBar.setVisible (m_jcbQuickBar.isSelected());
+ revalidate();
+ repaint();
+ }//GEN-LAST:event_onQuickBarButton
+
+ // Updated by Raphael Schmid.
+ protected String wrapMessage(String sMessage, int maxLineLen) {
+ StringBuffer sbResult = new StringBuffer(sMessage.length());
+ int sMessagePointer = 0;
+ int currentLinePointer = 0;
+
+ while (sMessagePointer < sMessage.length()) {
+ int lengthOfNextWord = 0;
+
+ while ((sMessagePointer+lengthOfNextWord < sMessage.length()) && (sMessage.charAt (sMessagePointer+lengthOfNextWord) != ' ')) {
+ lengthOfNextWord++;
+ }
+
+ if (currentLinePointer + lengthOfNextWord < maxLineLen) {
+ sbResult.append(sMessage.substring(sMessagePointer,sMessagePointer + lengthOfNextWord));
+ sbResult.append(' ');
+ currentLinePointer += lengthOfNextWord;
+ } else {
+ sbResult.append('\n');
+ sbResult.append(sMessage.substring(sMessagePointer,sMessagePointer + lengthOfNextWord));
+ sbResult.append(' ');
+ currentLinePointer = lengthOfNextWord;
+ }
+ sMessagePointer++;
+ sMessagePointer += lengthOfNextWord;
+ }
+ return sbResult.toString();
+ }
+
+// protected String wrapMessage (String sMessage,
+// int nMaxLineLen) {
+// StringBuffer sbResult = new StringBuffer (sMessage.length());
+// int i = 0;
+//
+// while (i < sMessage.length()) {
+// int nEndOfLine = i + nMaxLineLen;
+//
+// if (nEndOfLine > sMessage.length()) {
+// nEndOfLine = sMessage.length();
+// }
+//
+// while ((nEndOfLine > i + 1) &&
+// (sMessage.charAt (nEndOfLine - 1) != ' ')) {
+// nEndOfLine--;
+// }
+//
+// sbResult.append (sMessage.substring (i, nEndOfLine - 1))
+// .append ('\n');
+//
+// i = nEndOfLine;
+// }
+//
+// return sbResult.toString();
+// }
+
+
+ /**
+ * React to the submit button.
+ */
+ private void onSubmitConstraintButton(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_onSubmitConstraintButton
+ // Updated by Raphael Schmid
+ if (m_oclemModel != null) {
+ int nIdx = m_jtConstraintList.getSelectedRow();
+
+ if (nIdx != -1) {
+ try {
+ m_oclemModel.getConstraintAt(nIdx).setData(
+ m_jtpConstraintEditor.getText(), this);
+
+ // Stop editing if successful
+ m_fConstraintChanged = true; // somehow wasn't set
+ // correctly before...
+ setEditMode(false);
+ } catch (ParserException ope) {
+ // int nCaretPos = getCaretPositionFromLineAndColumn (
+ // ope.getErrorLine(),
+ // ope.getErrorCol()
+ // );
+
+ String sWrappedMessage = wrapMessage(ope.getMessage(), 100);
+
+ JOptionPane.showMessageDialog(null, "Syntax error:\n"
+ + sWrappedMessage, "Error",
+ JOptionPane.ERROR_MESSAGE);
+
+ // m_jtpConstraintEditor.select (nCaretPos, nCaretPos);
+ m_jtpConstraintEditor.requestFocus();
+
+ LOG.debug(ope);
+
+ } catch (IllegalStateException ise) {
+ String sWrappedMessage = wrapMessage(ise.getMessage(), 50);
+
+ JOptionPane.showMessageDialog(null,
+ "Couldn't set constraint:\n" + sWrappedMessage,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ LOG.debug(ise);
+ } catch (OclModelException e) {
+ // TODO
+ LOG.debug(e);
+ } catch (IOException e) {
+ // TODO
+ LOG.debug(e);
+ } catch (LexerException e) {
+ // TODO
+ LOG.debug(e);
+ } catch (AttrEvalException e) {
+ String sWrappedMessage = wrapMessage(e.getMessage(), 100);
+ JOptionPane.showMessageDialog(null,
+ "Type checking failed:\n" + sWrappedMessage,
+ "Error", JOptionPane.ERROR_MESSAGE);
+ LOG.debug(e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Compute caret position for the given line and column in the editor pane's
+ * text.
+ */
+ protected int getCaretPositionFromLineAndColumn (int nLine, int nCol) {
+ int nCurLine = 1; int nCurCol = 1;
+ String sText = m_jtpConstraintEditor.getText();
+ int nCaret = 0;
+ while ((nCurLine != nLine) || (nCurCol != nCol)) {
+ if (nCaret >= sText.length()) {
+ return 0;
+ }
+
+ if (sText.charAt (nCaret) == '\n') {
+ // new line
+ nCurLine++;
+ nCurCol = 1;
+ }
+ else {
+ nCurCol++;
+ }
+
+ nCaret++;
+ }
+
+ return nCaret;
+ }
+
+ /**
+ * React to the remove button.
+ */
+ private void onRemoveConstraintButton (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onRemoveConstraintButton
+ if (m_oclemModel != null) {
+ int nIdx = m_jtConstraintList.getSelectedRow();
+
+ if (nIdx != -1) {
+ m_oclemModel.removeConstraintAt (nIdx);
+ }
+ }
+ }//GEN-LAST:event_onRemoveConstraintButton
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JToolBar m_jtbTools;
+ private javax.swing.JButton m_jbNew;
+ private javax.swing.JButton m_jbRemove;
+ private javax.swing.JButton m_jbEdit;
+ private javax.swing.JButton m_jbSaveEditResult;
+ private javax.swing.JPanel pad1;
+ private javax.swing.JButton m_jbPreferences;
+ private javax.swing.JButton xmiExportButton;
+ private javax.swing.JPanel pad2;
+ private javax.swing.JCheckBox m_jcbQuickBar;
+ private javax.swing.JPanel m_jpToolbarWrapper;
+ private tudresden.ocl20.gui.OCLToolbar m_ocltbQuickBar;
+ private javax.swing.JPanel m_jpEditorPanel;
+ private javax.swing.JScrollPane m_jspConstraintEditorScroller;
+ private javax.swing.JTextPane m_jtpConstraintEditor;
+ private javax.swing.JSplitPane m_jspMainPane;
+ private javax.swing.JPanel m_jpConstraintListPane;
+ private javax.swing.JScrollPane m_jspConstraintListScroller;
+ private javax.swing.JTable m_jtConstraintList;
+ private javax.swing.JPanel m_jpPreviewPane;
+ private javax.swing.JPanel m_jpPreviewGroup;
+ private javax.swing.JScrollPane m_jspConstraintPreviewScroller;
+ private javax.swing.JTextPane m_jtpConstraintPreview;
+ // End of variables declaration//GEN-END:variables
+
+ // ListSelectionListener interface method
+
+ /**
+ * The selection in the table changed.
+ */
+ public void valueChanged(final javax.swing.event.ListSelectionEvent p1) {
+ // Selected row changed in table.
+ int newIndex = m_jtConstraintList.getSelectedRow();
+
+ if (newIndex != -1) {
+ if (m_oclemModel != null) {
+ m_crCurrent = m_oclemModel.getConstraintAt (newIndex);
+ }
+ else {
+ m_crCurrent = null;
+ }
+ }
+ else {
+ m_crCurrent = null;
+ }
+
+ setEditorText (m_crCurrent);
+ if (m_crCurrent != null) {
+ // TODO: Deal with fields.
+ m_jtpConstraintPreview.setText (m_crCurrent.getData());
+ }
+ else {
+ m_jtpConstraintPreview.setText ("");
+ }
+ }
+
+ // ConstraintChangeListener interface methods
+
+ /**
+ * Select the newly added constraint.
+ */
+ public void constraintAdded(ConstraintChangeEvent cce) {
+ m_jtConstraintList.setRowSelectionInterval (cce.getIndex(),
+ cce.getIndex());
+ }
+
+ /**
+ * If the current constraint was deleted, clear the selection.
+ */
+ public void constraintRemoved(ConstraintChangeEvent cce) {
+ if (cce.getIndex() == m_jtConstraintList.getSelectedRow()) {
+ m_jtConstraintList.clearSelection();
+ }
+ }
+
+ /**
+ * Ignored.
+ */
+ public void constraintNameChanged(ConstraintChangeEvent cce) { }
+
+ /**
+ * Update the editor if the currently selected constraint changed.
+ */
+ public void constraintDataChanged(ConstraintChangeEvent cce) {
+ // TODO: Deal with fields.
+ if (cce.getIndex() == m_jtConstraintList.getSelectedRow()) {
+ m_jtpConstraintEditor.setText (cce.getNew().getData());
+ m_jtpConstraintPreview.setText (cce.getNew().getData());
+
+ m_fConstraintChanged = true;
+ }
+ }
+}
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorModel.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorModel.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,81 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Compiler *
+ * Copyright (C) 2001 Steffen Zschaler ([email protected]). *
+ * All rights reserved. *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * To submit a bug report, send a comment, or get the latest news on *
+ * this project and other projects, please visit the web site: *
+ * http://www-st.inf.tu-dresden.de/ (Chair home page) or *
+ * http://www-st.inf.tu-dresden.de/ocl/ (project home page) *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+// OCLEditorModel.java -- interface declaration for the ocl editor's model.
+//
+// 02/15/2001 [sz9 ] Created.
+//
+package tudresden.ocl20.gui;
+
+import tudresden.ocl20.gui.events.*;
+
+/**
+ * A model for the {@link OCLEditor}. This model represents a list of
+ * {@link ConstraintRepresentation OCL constraints} that can be edited
+ * using the OCLEditor.
+ *
+ * @author sz9
+ */
+public interface OCLEditorModel {
+
+ /**
+ * Return the number of constraints in this model.
+ */
+ public int getConstraintCount();
+
+ /**
+ * Return the constraint with the specified index.
+ *
+ * @param nIdx the index of the constraint to be returned. 0 <= nIdx < {@link #getConstraintCount}
+ */
+ public ConstraintRepresentation getConstraintAt (int nIdx);
+
+ /**
+ * Add a fresh constraint to the model.
+ */
+ public void addConstraint();
+
+ /**
+ * Remove the specified constraint from the model.
+ *
+ * @param nIdx the index of the constraint to be removed. 0 <= nIdx < {@link #getConstraintCount}
+ */
+ public void removeConstraintAt (int nIdx);
+
+ /**
+ * Add a listener to be informed of changes in the model.
+ *
+ * @param ccl the new listener
+ */
+ public void addConstraintChangeListener (ConstraintChangeListener ccl);
+
+ /**
+ * Remove a listener to be informed of changes in the model.
+ *
+ * @param ccl the listener to be removed
+ */
+ public void removeConstraintChangeListener (ConstraintChangeListener ccl);
+}
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorPreferences.form
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorPreferences.form?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorPreferences.form 2008-05-28 14:30:13-0700
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+
+<Form version="1.0" type="com.netbeans.developer.modules.loaders.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="title" type="java.lang.String" editor="com.netbeans.developer.editors.StringEditor" value="OCL Editor Preferences"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="menuBar" type="java.lang.String" value="(No Menu)"/>
+ <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-56,0,0,1,44"/>
+ <SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
+ <SyntheticProperty name="formSizePolicy" type="int" value="0"/>
+ <SyntheticProperty name="generatePosition" type="boolean" value="true"/>
+ <SyntheticProperty name="generateSize" type="boolean" value="false"/>
+ <SyntheticProperty name="generateCenter" type="boolean" value="true"/>
+ <SyntheticProperty name="encoding" type="java.lang.String" value="ISO-8859-1"/>
+ </SyntheticProperties>
+
+ <Events>
+ <EventHandler event="windowClosing" handler="closeDialog"/>
+ </Events>
+
+ <AuxValues>
+ </AuxValues>
+
+ <Layout class="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="m_jpOptionsGroup">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="com.netbeans.developer.explorer.propertysheet.editors.BorderEditor">
+ <Border info="com.netbeans.developerx.loaders.form.formeditor.border.TitledBorderInfo">
+ <TitledBorder title="Options">
+ <Border PropertyName="innerBorder" info="com.netbeans.developerx.loaders.form.formeditor.border.EtchedBorderInfo">
+ <EtchetBorder/>
+ </Border>
+ </TitledBorder>
+ </Border>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="5" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
+ </Constraint>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignBorderLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.support.JSplitPaneSupportLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
+ <JSplitPaneConstraints position="bottom"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JCheckBox" name="m_jcbTypeCheck">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" editor="com.netbeans.developer.editors.StringEditor" value="Check this option to have the editor perform type checks on each constraint you submit."/>
+ <Property name="selected" type="boolean" editor="sun.beans.editors.BoolEditor" value="true"/>
+ <Property name="text" type="java.lang.String" editor="com.netbeans.developer.editors.StringEditor" value="Check type conformance of OCL constraints"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="0" insetsLeft="5" insetsRight="5" insetsTop="5" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
+ </Constraint>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout$FlowConstraintsDescription"/>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="m_jcbAutoSplit">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" editor="com.netbeans.developer.editors.StringEditor" value="Check this option to have the editor automatically split multiple constraints that were entered in one go."/>
+ <Property name="selected" type="boolean" editor="sun.beans.editors.BoolEditor" value="true"/>
+ <Property name="text" type="java.lang.String" editor="com.netbeans.developer.editors.StringEditor" value="AutoSplit: Automatically split apart multiple constraints entered as a single text"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="18" fill="1" gridHeight="1" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="0" insetsLeft="5" insetsRight="5" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
+ </Constraint>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout$FlowConstraintsDescription"/>
+ </Constraints>
+ </Component>
+ <Container class="javax.swing.JPanel" name="jPanel3">
+ <Constraints>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="18" fill="1" gridHeight="0" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="0" insetsLeft="5" insetsRight="5" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="1.0"/>
+ </Constraint>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignBoxLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignBoxLayout$BoxConstraintsDescription"/>
+ </Constraints>
+
+ <Layout class="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout"/>
+ </Container>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="m_jpButtonsGroup">
+ <Constraints>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints anchor="18" fill="1" gridHeight="0" gridWidth="0" gridX="-1" gridY="-1" insetsBottom="10" insetsLeft="0" insetsRight="0" insetsTop="0" ipadX="0" ipadY="0" weightX="1.0" weightY="0.0"/>
+ </Constraint>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignBorderLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="South"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout">
+ <Property name="alignment" type="int" value="2"/>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JButton" name="m_jbOKButton">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="com.netbeans.developer.editors.StringEditor" value="OK"/>
+ </Properties>
+
+ <Events>
+ <EventHandler event="actionPerformed" handler="onOKButton"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout$FlowConstraintsDescription"/>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JButton" name="m_jbCancelButton">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="com.netbeans.developer.editors.StringEditor" value="Cancel"/>
+ </Properties>
+
+ <Events>
+ <EventHandler event="actionPerformed" handler="onCancelButton"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout" value="com.netbeans.developerx.loaders.form.formeditor.layouts.DesignFlowLayout$FlowConstraintsDescription"/>
+ </Constraints>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorPreferences.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorPreferences.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLEditorPreferences.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,205 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Compiler *
+ * Copyright (C) 2001 Steffen Zschaler. *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * See CREDITS file for further details. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+// HISTORY
+//
+// 03/13/2001 [sz9 ] Created.
+
+package tudresden.ocl20.gui;
+
+import javax.swing.*;
+
+/**
+ * OCL editor preference dialog.
+ *
+ * @author sz9
+ */
+public class OCLEditorPreferences extends javax.swing.JDialog {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8238830991495314346L;
+ private OCLEditor m_ocleEditor;
+
+ /** Creates new form OCLEditorPreferences */
+ public OCLEditorPreferences (JFrame parent, OCLEditor ocle) {
+ super (parent, true);
+ m_ocleEditor = ocle;
+
+ initComponents();
+
+ int nOptionMask = m_ocleEditor.getOptionMask();
+
+ m_jcbTypeCheck.setVisible (
+ (nOptionMask & OCLEditor.OPTIONMASK_TYPECHECK) != 0);
+ m_jcbTypeCheck.setSelected (m_ocleEditor.getDoTypeCheck());
+
+ m_jcbAutoSplit.setVisible (
+ (nOptionMask & OCLEditor.OPTIONMASK_AUTOSPLIT) != 0);
+ m_jcbAutoSplit.setSelected (m_ocleEditor.getDoAutoSplit());
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the FormEditor.
+ */
+ private void initComponents () {//GEN-BEGIN:initComponents
+ m_jpOptionsGroup = new javax.swing.JPanel ();
+ m_jcbTypeCheck = new javax.swing.JCheckBox ();
+ m_jcbAutoSplit = new javax.swing.JCheckBox ();
+ jPanel3 = new javax.swing.JPanel ();
+ m_jpButtonsGroup = new javax.swing.JPanel ();
+ m_jbOKButton = new javax.swing.JButton ();
+ m_jbCancelButton = new javax.swing.JButton ();
+ getContentPane ().setLayout (new java.awt.GridBagLayout ());
+ java.awt.GridBagConstraints gridBagConstraints1;
+ setTitle ("OCL Editor Preferences");
+ addWindowListener (new java.awt.event.WindowAdapter () {
+ public void windowClosing (java.awt.event.WindowEvent evt) {
+ closeDialog (evt);
+ }
+ }
+ );
+
+ m_jpOptionsGroup.setLayout (new java.awt.GridBagLayout ());
+ java.awt.GridBagConstraints gridBagConstraints2;
+ m_jpOptionsGroup.setBorder (new javax.swing.border.TitledBorder(
+ new javax.swing.border.EtchedBorder(), "Options"));
+
+ m_jcbTypeCheck.setToolTipText ("Check this option to have the editor perform type checks on each constraint you submit.");
+ m_jcbTypeCheck.setSelected (true);
+// m_jcbTypeCheck.setText ("Check type conformance of OCL constraints");
+ m_jcbTypeCheck.setText ("Check syntax and type conformance of OCL constraints");
+
+ gridBagConstraints2 = new java.awt.GridBagConstraints ();
+ gridBagConstraints2.gridwidth = 0;
+ gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints2.insets = new java.awt.Insets (5, 5, 0, 5);
+ gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ gridBagConstraints2.weightx = 1.0;
+ m_jpOptionsGroup.add (m_jcbTypeCheck, gridBagConstraints2);
+
+ m_jcbAutoSplit.setToolTipText ("Check this option to have the editor automatically split multiple constraints that were entered in one go.");
+ m_jcbAutoSplit.setSelected (true);
+ m_jcbAutoSplit.setText ("AutoSplit: Automatically split apart multiple constraints entered as a single text");
+
+ gridBagConstraints2 = new java.awt.GridBagConstraints ();
+ gridBagConstraints2.gridwidth = 0;
+ gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints2.insets = new java.awt.Insets (0, 5, 0, 5);
+ gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ gridBagConstraints2.weightx = 1.0;
+ m_jpOptionsGroup.add (m_jcbAutoSplit, gridBagConstraints2);
+
+
+ gridBagConstraints2 = new java.awt.GridBagConstraints ();
+ gridBagConstraints2.gridwidth = 0;
+ gridBagConstraints2.gridheight = 0;
+ gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints2.insets = new java.awt.Insets (0, 5, 0, 5);
+ gridBagConstraints2.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ gridBagConstraints2.weightx = 1.0;
+ gridBagConstraints2.weighty = 1.0;
+ m_jpOptionsGroup.add (jPanel3, gridBagConstraints2);
+
+
+ gridBagConstraints1 = new java.awt.GridBagConstraints ();
+ gridBagConstraints1.gridwidth = 0;
+ gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints1.insets = new java.awt.Insets (5, 5, 5, 5);
+ gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ gridBagConstraints1.weightx = 1.0;
+ gridBagConstraints1.weighty = 1.0;
+ getContentPane ().add (m_jpOptionsGroup, gridBagConstraints1);
+
+ m_jpButtonsGroup.setLayout (new java.awt.FlowLayout (2, 5, 5));
+
+ m_jbOKButton.setText ("OK");
+ m_jbOKButton.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onOKButton (evt);
+ }
+ }
+ );
+
+ m_jpButtonsGroup.add (m_jbOKButton);
+
+ m_jbCancelButton.setText ("Cancel");
+ m_jbCancelButton.addActionListener (new java.awt.event.ActionListener () {
+ public void actionPerformed (java.awt.event.ActionEvent evt) {
+ onCancelButton (evt);
+ }
+ }
+ );
+
+ m_jpButtonsGroup.add (m_jbCancelButton);
+
+
+ gridBagConstraints1 = new java.awt.GridBagConstraints ();
+ gridBagConstraints1.gridwidth = 0;
+ gridBagConstraints1.gridheight = 0;
+ gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints1.insets = new java.awt.Insets (0, 0, 10, 0);
+ gridBagConstraints1.anchor = java.awt.GridBagConstraints.NORTHWEST;
+ gridBagConstraints1.weightx = 1.0;
+ getContentPane ().add (m_jpButtonsGroup, gridBagConstraints1);
+
+ pack ();
+ java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
+ java.awt.Dimension dialogSize = getSize();
+ setLocation((screenSize.width-dialogSize.width)/2, (screenSize.height-dialogSize.height)/2);
+ }//GEN-END:initComponents
+
+ private void onOKButton (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onOKButton
+ m_ocleEditor.setDoAutoSplit (m_jcbAutoSplit.isSelected());
+ m_ocleEditor.setDoTypeCheck (m_jcbTypeCheck.isSelected());
+
+ closeDialog();
+ }//GEN-LAST:event_onOKButton
+
+ private void onCancelButton (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_onCancelButton
+ closeDialog();
+ }//GEN-LAST:event_onCancelButton
+
+ /** Closes the dialog */
+ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+ closeDialog();
+ }//GEN-LAST:event_closeDialog
+
+ private void closeDialog() {
+ setVisible (false);
+ dispose ();
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel m_jpOptionsGroup;
+ private javax.swing.JCheckBox m_jcbTypeCheck;
+ private javax.swing.JCheckBox m_jcbAutoSplit;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel m_jpButtonsGroup;
+ private javax.swing.JButton m_jbOKButton;
+ private javax.swing.JButton m_jbCancelButton;
+ // End of variables declaration//GEN-END:variables
+
+}
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLToolbar.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLToolbar.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/OCLToolbar.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,622 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Compiler *
+ * Copyright (C) 2001 Steffen Zschaler ([email protected]). *
+ * All rights reserved. *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * To submit a bug report, send a comment, or get the latest news on *
+ * this project and other projects, please visit the web site: *
+ * http://www-st.inf.tu-dresden.de/ (Chair home page) or *
+ * http://www-st.inf.tu-dresden.de/ocl/ (project home page) *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+package tudresden.ocl20.gui;
+
+import javax.swing.*;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import java.lang.ref.WeakReference;
+
+import java.util.ArrayList;
+
+/**
+ * A quick bar for the {@link OCLEditor}
+ *
+ * @author sz9
+ */
+public class OCLToolbar extends JToolBar implements ActionListener {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -4484972493951577184L;
+
+/**
+ * The frame used for floating the tool bar.
+ */
+ private JFrame m_jfFloatFrame;
+
+ /**
+ * The OCLEditor for which this is the quick bar.
+ */
+ private WeakReference m_wrocleEditor;
+
+ /** Creates new OCLToolbar */
+ public OCLToolbar() {
+ super();
+
+ initComponents();
+ }
+
+ /**
+ * Set the editor owning this tool bar.
+ */
+ public void setEditor (OCLEditor ocle) {
+ m_wrocleEditor = new WeakReference (ocle);
+ }
+
+ public OCLEditor getEditor() {
+ if (m_wrocleEditor == null) {
+ return null;
+ }
+ else {
+ return (OCLEditor) m_wrocleEditor.get();
+ }
+ }
+
+ /**
+ * Overridden to correctly hide the float frame, if it was open.
+ */
+ public void setVisible (boolean fVisible) {
+ if (m_jfFloatFrame != null) {
+ if (getUI() instanceof javax.swing.plaf.basic.BasicToolBarUI) {
+ if (((javax.swing.plaf.basic.BasicToolBarUI) getUI()).isFloating()) {
+ m_jfFloatFrame.setVisible (fVisible);
+ }
+ }
+ }
+
+ super.setVisible (fVisible);
+ }
+
+ /**
+ * Overridden to allow access to the free float frame.
+ */
+ public void setUI (javax.swing.plaf.ToolBarUI tbui) {
+ if (tbui instanceof javax.swing.plaf.metal.MetalToolBarUI) {
+ super.setUI (new javax.swing.plaf.metal.MetalToolBarUI() {
+ protected JFrame createFloatingFrame (JToolBar jtb) {
+ if (jtb == OCLToolbar.this) {
+ if (m_jfFloatFrame == null) {
+ m_jfFloatFrame = super.createFloatingFrame (jtb);
+ m_jfFloatFrame.setTitle ("Syntax Assistant");
+ }
+
+ return m_jfFloatFrame;
+ }
+ else {
+ return super.createFloatingFrame (jtb);
+ }
+ }
+ });
+ }
+ else if (tbui instanceof javax.swing.plaf.basic.BasicToolBarUI) {
+ super.setUI (new javax.swing.plaf.basic.BasicToolBarUI() {
+ protected JFrame createFloatingFrame (JToolBar jtb) {
+ if (jtb == OCLToolbar.this) {
+ if (m_jfFloatFrame == null) {
+ m_jfFloatFrame = super.createFloatingFrame (jtb);
+ m_jfFloatFrame.setTitle ("Syntax Assistant");
+ }
+
+ return m_jfFloatFrame;
+ }
+ else {
+ return super.createFloatingFrame (jtb);
+ }
+ }
+ });
+ }
+ else {
+ throw new IllegalArgumentException ("L&F not valid with OCLToolbar: " + tbui);
+ }
+ }
+
+ private void initComponents() {
+ setFloatable (true);
+
+ JComboBox jcb = new JComboBox (new ActionItem[] {
+ new ActionItem ("General", -1),
+ new ActionItem ("inv", 0),
+ new ActionItem ("pre", 0),
+ new ActionItem ("post", 0),
+ new ActionItem ("self", 1),
+ new ActionItem ("@pre", 2),
+ new ActionItem ("result", 3)
+ });
+ jcb.addActionListener (this);
+ add (jcb);
+
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // Inv, Pre, Post
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ null,
+ "\n" + sOCLText + " ",
+ new String[] {"tmp"});
+ ocle.addConstraintText (
+ new String[] {"constraint name"},
+ ": ",
+ new String[] {"constraint expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // Self
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ null,
+ "self.",
+ new String[] {"attribute, association or query method"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // @pre
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"attribute or association"},
+ "@pre ",
+ null);
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // result
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ null,
+ "result ",
+ null);
+ }
+ });
+
+ jcb = new JComboBox (new ActionItem[] {
+ new ActionItem ("Basic Operators", -1),
+ new ActionItem ("=", 4),
+ new ActionItem ("<>", 4),
+ new ActionItem ("<", 4),
+ new ActionItem (">", 4),
+ new ActionItem ("<=", 4),
+ new ActionItem (">=", 4),
+ new ActionItem ("()", 5)
+ });
+ jcb.addActionListener (this);
+ add (jcb);
+
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // simple ops
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"expression"},
+ " " + sOCLText + " ",
+ new String[] {"expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // parens
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ null,
+ "(",
+ new String[] {"expression"});
+ }
+ });
+
+ jcb = new JComboBox (new ActionItem[] {
+ new ActionItem ("Numbers", -1),
+ new ActionItem ("+", 6),
+ new ActionItem ("-", 6),
+ new ActionItem ("*", 6),
+ new ActionItem ("/", 6),
+ new ActionItem ("mod", 7),
+ new ActionItem ("div", 7),
+ new ActionItem ("abs", 8),
+ new ActionItem ("max", 7),
+ new ActionItem ("min", 7),
+ new ActionItem ("round", 8),
+ new ActionItem ("floor", 8)
+ });
+ jcb.addActionListener (this);
+ add (jcb);
+
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // numeric ops
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"numeric expression"},
+ " " + sOCLText + " ",
+ new String[] {"numeric expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // mod, div, max, min
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"numeric expression"},
+ "." + sOCLText + " (",
+ new String[] {"numeric expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // abs, round, floor
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"numeric expression"},
+ "." + sOCLText + " ",
+ null);
+ }
+ });
+
+ jcb = new JComboBox (new ActionItem[] {
+ new ActionItem ("Strings", -1),
+ new ActionItem ("concat", 9),
+ new ActionItem ("size", 10),
+ new ActionItem ("toLower", 10),
+ new ActionItem ("toUpper", 10),
+ new ActionItem ("substring", 11)
+ });
+ jcb.addActionListener (this);
+ add (jcb);
+
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // concat
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"string expression"},
+ "." + sOCLText + " (",
+ new String[] {"string expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // size, toLower, toUpper
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"string expression"},
+ "." + sOCLText + " ",
+ null);
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // substring
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ", ",
+ new String[] {"integer expression"});
+ ocle.addConstraintText (
+ new String[] {"string expression"},
+ "." + sOCLText + " (",
+ new String[] {"integer expression"});
+ }
+ });
+
+ jcb = new JComboBox (new ActionItem[] {
+ new ActionItem ("Booleans", -1),
+ new ActionItem ("or", 12),
+ new ActionItem ("and", 12),
+ new ActionItem ("xor", 12),
+ new ActionItem ("not", 13),
+ new ActionItem ("implies", 12),
+ new ActionItem ("if then else", 14)
+ });
+ jcb.addActionListener (this);
+ add (jcb);
+
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // basic ops
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"boolean expression"},
+ " " + sOCLText + " ",
+ new String[] {"boolean expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // not
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ null,
+ sOCLText + " ",
+ new String[] {"boolean expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // if then else
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ " endif",
+ null);
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ " else ",
+ new String[] {"expression"});
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ " then ",
+ new String[] {"expression"});
+ ocle.addConstraintText (
+ null,
+ "if ",
+ new String[] {"boolean expression"});
+ }
+ });
+
+ jcb = new JComboBox (new ActionItem[] {
+ new ActionItem ("Collections", -1),
+ new ActionItem ("-----------", ActionItem.DUMMY_ACTION),
+ new ActionItem ("General", ActionItem.DUMMY_ACTION),
+ new ActionItem ("-----------", ActionItem.DUMMY_ACTION),
+ new ActionItem ("Collection {}", "Collection", 15),
+ new ActionItem ("Set {}", "Set", 15),
+ new ActionItem ("Bag {}", "Bag", 15),
+ new ActionItem ("Sequence {}", "Sequence", 15),
+ new ActionItem ("size", 16),
+ new ActionItem ("count", 17),
+ new ActionItem ("isEmpty", 16),
+ new ActionItem ("notEmpty", 16),
+ new ActionItem ("includes", 17),
+ new ActionItem ("includesAll", 18),
+ new ActionItem ("iterate", 19),
+ new ActionItem ("exists", 19),
+ new ActionItem ("forAll", 19),
+ new ActionItem ("collect", 19),
+ new ActionItem ("select", 19),
+ new ActionItem ("reject", 19),
+ new ActionItem ("union", 18),
+ new ActionItem ("intersection", 18),
+ new ActionItem ("including", 17),
+ new ActionItem ("excluding", 17),
+ new ActionItem ("sum", 20),
+ new ActionItem ("-----------", ActionItem.DUMMY_ACTION),
+ new ActionItem ("Sets", ActionItem.DUMMY_ACTION),
+ new ActionItem ("-----------", ActionItem.DUMMY_ACTION),
+ new ActionItem ("-", 21),
+ new ActionItem ("symmetricDifference", 22),
+ new ActionItem ("-----------", ActionItem.DUMMY_ACTION),
+ new ActionItem ("Sequences", ActionItem.DUMMY_ACTION),
+ new ActionItem ("-----------", ActionItem.DUMMY_ACTION),
+ new ActionItem ("first", 23),
+ new ActionItem ("last", 23),
+ new ActionItem ("at", 24),
+ new ActionItem ("append", 25),
+ new ActionItem ("prepend", 25),
+ new ActionItem ("subSequence", 26)
+ });
+ jcb.addActionListener (this);
+ add (jcb);
+
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // collection constructors
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ "}",
+ null);
+ ocle.addConstraintText (
+ null,
+ sOCLText + " {",
+ new String[] {"element list"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // size, isEmpty, notEmpty
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"collection expression"},
+ "->" + sOCLText,
+ null);
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // count, includes, including, excluding
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"collection expression"},
+ "->" + sOCLText + " (",
+ new String[] {"element expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // includesAll, union, intersection
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"collection expression"},
+ "->" + sOCLText + " (",
+ new String[] {"collection expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // iterate etc
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ " | ",
+ new String[] {"expression"});
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ " : ",
+ new String[] {"type"});
+ ocle.addConstraintText (
+ new String[] {"collection expression "},
+ "->" + sOCLText + " (",
+ new String[] {"element variable"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // sum
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"collection expression"},
+ "->" + sOCLText + "()",
+ null);
+ }
+ });
+
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // set minus
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"set expression"},
+ " " + sOCLText + " ",
+ new String[] {"set expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // symmetricDifference
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"set expression"},
+ "->" + sOCLText + " (",
+ new String[] {"set expression"});
+ }
+ });
+
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // first, last
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"sequence expression"},
+ "->" + sOCLText,
+ null);
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // at
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"sequence expression"},
+ "->" + sOCLText + " (",
+ new String[] {"integer expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // append, prepend
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"sequence expression"},
+ "->" + sOCLText + " (",
+ new String[] {"element expression"});
+ }
+ });
+ ActionItem.addShortCut (new ActionItem.ShortCutAction() { // subSequence
+ public void performShortCut (String sOCLText, OCLEditor ocle) {
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ")",
+ null);
+ ocle.addConstraintText (
+ new String[] {"tmp"},
+ ", ",
+ new String[] {"integer expression"});
+ ocle.addConstraintText (
+ new String[] {"sequence expression"},
+ "->" + sOCLText + " (",
+ new String[] {"integer expression"});
+ }
+ });
+ }
+
+ public void actionPerformed(final ActionEvent e) {
+ JComboBox jcb = (JComboBox) e.getSource();
+ ActionItem ai = (ActionItem) jcb.getSelectedItem();
+
+ if (ai != null) {
+ ai.perform (jcb, getEditor());
+ }
+ }
+
+ private static final class ActionItem {
+ public static final int DUMMY_ACTION = Integer.MAX_VALUE;
+
+ public static interface ShortCutAction {
+ public void performShortCut (String sOCLText, OCLEditor ocle);
+ }
+
+ private static ArrayList s_aalActions = new ArrayList();
+
+ private String m_sCaption;
+ private String m_sOCLText;
+ private int m_nActionIdx;
+
+ public ActionItem (String sCaption, String sOCLText, int nActionIdx) {
+ super();
+
+ m_sCaption = sCaption;
+ m_sOCLText = sOCLText;
+ m_nActionIdx = nActionIdx;
+ }
+
+ public ActionItem (String sOCLText, int nActionID) {
+ this (sOCLText, sOCLText, nActionID);
+ }
+
+ public String toString() {
+ return getCaption();
+ }
+
+ public String getCaption() {
+ return m_sCaption;
+ }
+
+ public String getOCLText() {
+ return m_sOCLText;
+ }
+
+ public void perform (JComboBox jcb, OCLEditor ocle) {
+ if (m_nActionIdx >= 0) {
+ // React
+ if ((m_nActionIdx != DUMMY_ACTION) &&
+ (ocle != null)) {
+ ShortCutAction sca = (ShortCutAction) s_aalActions.get (m_nActionIdx);
+
+ sca.performShortCut (getOCLText(), ocle);
+ }
+
+ // Reset combo box, assuming that 0 is the index with no associated action
+ jcb.setSelectedIndex (0);
+ }
+ }
+
+ public static void addShortCut (ShortCutAction sca) {
+ s_aalActions.add (sca);
+ }
+ }
+}
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeAdapter.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeAdapter.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeAdapter.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,42 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Compiler *
+ * Copyright (C) 2001 Steffen Zschaler ([email protected]). *
+ * All rights reserved. *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * To submit a bug report, send a comment, or get the latest news on *
+ * this project and other projects, please visit the web site: *
+ * http://www-st.inf.tu-dresden.de/ (Chair home page) or *
+ * http://www-st.inf.tu-dresden.de/ocl/ (project home page) *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+// ConstraintChangeAdapter.java -- Adapter for ConstraintChangeListener
+//
+// 02/15/2001 [sz9 ] Created.
+//
+package tudresden.ocl20.gui.events;
+
+/**
+ *
+ * @author sz9
+ */
+public class ConstraintChangeAdapter implements ConstraintChangeListener {
+ public void constraintAdded(ConstraintChangeEvent cce) { }
+ public void constraintRemoved(ConstraintChangeEvent cce) { }
+ public void constraintNameChanged(ConstraintChangeEvent cce) { }
+ public void constraintDataChanged(ConstraintChangeEvent cce) { }
+}
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeEvent.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeEvent.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeEvent.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,77 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Compiler *
+ * Copyright (C) 2001 Steffen Zschaler ([email protected]). *
+ * All rights reserved. *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * To submit a bug report, send a comment, or get the latest news on *
+ * this project and other projects, please visit the web site: *
+ * http://www-st.inf.tu-dresden.de/ (Chair home page) or *
+ * http://www-st.inf.tu-dresden.de/ocl/ (project home page) *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+// ConstraintChangeEvent.java -- Event to be sent when constraints change
+//
+// 02/15/2001 [sz9 ] Created.
+//
+package tudresden.ocl20.gui.events;
+
+import java.util.EventObject;
+
+import tudresden.ocl20.gui.ConstraintRepresentation;
+
+/**
+ *
+ * @author sz9
+ */
+public class ConstraintChangeEvent extends EventObject {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6853487958825581720L;
+
+ private int m_nIdx;
+
+ private ConstraintRepresentation m_crOld;
+
+ private ConstraintRepresentation m_crNew;
+
+ /** Creates new ConstraintChangeEvent */
+ public ConstraintChangeEvent (Object source,
+ int nIdx,
+ ConstraintRepresentation crOld,
+ ConstraintRepresentation crNew) {
+ super (source);
+
+ m_nIdx = nIdx;
+ m_crOld = crOld;
+ m_crNew = crNew;
+ }
+
+ public int getIndex() {
+ return m_nIdx;
+ }
+
+ public ConstraintRepresentation getOld() {
+ return m_crOld;
+ }
+
+ public ConstraintRepresentation getNew() {
+ return m_crNew;
+ }
+}
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeListener.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeListener.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/gui/events/ConstraintChangeListener.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,46 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * OCL Compiler *
+ * Copyright (C) 2001 Steffen Zschaler ([email protected]). *
+ * All rights reserved. *
+ * *
+ * This work is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Library General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2 of the License, or (at your option) any later version. *
+ * *
+ * This work is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Library General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Library General Public *
+ * License along with this library; if not, write to the *
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, *
+ * Boston, MA 02111-1307, USA. *
+ * *
+ * To submit a bug report, send a comment, or get the latest news on *
+ * this project and other projects, please visit the web site: *
+ * http://www-st.inf.tu-dresden.de/ (Chair home page) or *
+ * http://www-st.inf.tu-dresden.de/ocl/ (project home page) *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+// ConstraintChangeListener.java -- Listener to be informed about changes in an OCLEditorModel
+//
+// 02/15/2001 [sz9 ] Created.
+//
+package tudresden.ocl20.gui.events;
+
+import java.util.EventListener;
+
+/**
+ * Listener to be informed about changes in an
+ * {@link tudresden.ocl20.gui.OCLEditorModel}.
+ *
+ * @author sz9
+ */
+public interface ConstraintChangeListener extends EventListener {
+ public void constraintAdded (ConstraintChangeEvent cce);
+ public void constraintRemoved (ConstraintChangeEvent cce);
+ public void constraintNameChanged (ConstraintChangeEvent cce);
+ public void constraintDataChanged (ConstraintChangeEvent cce);
+}
\ No newline at end of file
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Cancel16.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Cancel16.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Delete16.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Delete16.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Edit16.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Edit16.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/New16.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/New16.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Ok16.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Ok16.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Preferences16.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/Preferences16.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/RowDelete24.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/RowDelete24.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/RowInsertAfter24.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/RowInsertAfter24.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/empty.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/empty.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/failed.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/failed.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/left.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/left.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/logo.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/logo.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/ok.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/ok.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/question.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/question.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/right.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/right.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/save_icon.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/save_icon.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgdelete.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgdelete.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgleftArrow.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgleftArrow.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgline.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgline.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgline_k.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgline_k.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgrightArrow.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/sgrightArrow.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/st.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/st.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/tulogo.gif
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/images/tulogo.gif?view=auto&rev=14823
==============================================================================
Binary file. No diff available.
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/Classes.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/Classes.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/Classes.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,178 @@
+/*
+ * Created on 23.10.2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package tudresden.ocl20.integration;
+
+import tudresden.ocl20.core.jmi.uml15.core.Association;
+import tudresden.ocl20.core.jmi.uml15.core.AssociationEnd;
+import tudresden.ocl20.core.jmi.uml15.core.Attribute;
+import tudresden.ocl20.core.jmi.uml15.core.Classifier;
+import tudresden.ocl20.core.jmi.uml15.core.DataType;
+import tudresden.ocl20.core.jmi.uml15.core.Enumeration;
+import tudresden.ocl20.core.jmi.uml15.core.EnumerationLiteral;
+import tudresden.ocl20.core.jmi.uml15.core.Generalization;
+import tudresden.ocl20.core.jmi.uml15.core.Interface;
+import tudresden.ocl20.core.jmi.uml15.core.Operation;
+import tudresden.ocl20.core.jmi.uml15.core.Parameter;
+import tudresden.ocl20.core.jmi.uml15.core.UmlClass;
+import tudresden.ocl20.core.jmi.uml15.datatypes.Multiplicity;
+import tudresden.ocl20.core.jmi.uml15.datatypes.MultiplicityRange;
+import tudresden.ocl20.core.jmi.uml15.datatypes.OrderingKindEnum;
+import tudresden.ocl20.core.jmi.uml15.datatypes.ParameterDirectionKindEnum;
+import tudresden.ocl20.core.jmi.uml15.datatypes.ScopeKindEnum;
+
+/**
+ * An enumeration of all classes of elements in the MDR created by the class ModelFacade.
+ * @author Mirko
+ */
+public enum Classes
+{
+ multiplicity(0),
+ attribute(1),
+ parameter(2),
+ association(3),
+ associationend(4),
+ range(5),
+ method(6),
+ umlClass(7),
+ umlPackage(8),
+ dataType(9),
+ scopeKind_classifier(10),
+ scopeKind_instance(11),
+ orderingKind_ordered(12),
+ orderingKind_unordered(13),
+ parameterDirectionKind_Return(14),
+ parameterDirectionKind_InOut(15),
+ parameterDirectionKind_In(16),
+ parameterDirectionKind_Out(17),
+ generalization(18),
+ enumeration(19),
+ enumerationLiteral(20),
+ umlinterface(21);
+
+ private Class value = null;
+ Classes (int i)
+ {
+ switch (i)
+ {
+ case 0:
+ {
+ this.value = Multiplicity.class;
+ break;
+ }
+ case 1:
+ {
+ this.value = Attribute.class;
+ break;
+ }
+ case 2:
+ {
+ this.value = Parameter.class;
+ break;
+ }
+ case 3:
+ {
+ this.value = Association.class;
+ break;
+ }
+ case 4:
+ {
+ this.value = AssociationEnd.class;
+ break;
+ }
+ case 5:
+ {
+ this.value = MultiplicityRange.class;
+ break;
+ }
+ case 6:
+ {
+ this.value = Operation.class;
+ break;
+ }
+ case 7:
+ {
+ this.value = UmlClass.class;
+ break;
+ }
+ case 8:
+ {
+ this.value = tudresden.ocl20.core.jmi.uml15.modelmanagement.Package.class;
+ break;
+ }
+ case 9:
+ {
+ this.value = DataType.class;
+ break;
+ }
+ case 10:
+ {
+ this.value = ScopeKindEnum.SK_CLASSIFIER.getClass();
+ break;
+ }
+ case 11:
+ {
+ this.value = ScopeKindEnum.SK_INSTANCE.getClass();
+ break;
+ }
+ case 12:
+ {
+ this.value = OrderingKindEnum.OK_ORDERED.getClass();
+ break;
+ }
+ case 13:
+ {
+ this.value = OrderingKindEnum.OK_UNORDERED.getClass();
+ break;
+ }
+ case 14:
+ {
+ this.value = ParameterDirectionKindEnum.PDK_RETURN.getClass();
+ break;
+ }
+ case 15:
+ {
+ this.value = ParameterDirectionKindEnum.PDK_INOUT.getClass();
+ break;
+ }
+ case 16:
+ {
+ this.value = ParameterDirectionKindEnum.PDK_IN.getClass();
+ break;
+ }
+ case 17:
+ {
+ this.value = ParameterDirectionKindEnum.PDK_OUT.getClass();
+ break;
+ }
+ case 18:
+ {
+ this.value = Generalization.class;
+ break;
+ }
+ case 19:
+ {
+ this.value = Enumeration.class;
+ break;
+ }
+ case 20:
+ {
+ this.value = EnumerationLiteral.class;
+ break;
+ }
+ case 21:
+ {
+ this.value = Interface.class;
+ break;
+ }
+ }
+ }
+
+ public Class getValue()
+ {
+ return this.value;
+ }
+}
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/ModelFacade.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/ModelFacade.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/ModelFacade.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,365 @@
+/*
+ * Created on 25.08.2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package tudresden.ocl20.integration;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.WeakHashMap;
+
+import javax.jmi.reflect.RefObject;
+
+import tudresden.ocl20.core.RepositoryManager;
+import javax.jmi.reflect.RefBaseObject;
+import tudresden.ocl20.core.jmi.uml15.core.Association;
+import tudresden.ocl20.core.jmi.uml15.core.AssociationEnd;
+import tudresden.ocl20.core.jmi.uml15.core.DataType;
+import tudresden.ocl20.core.jmi.uml15.core.Enumeration;
+import tudresden.ocl20.core.jmi.uml15.core.Operation;
+import tudresden.ocl20.core.jmi.uml15.core.UmlClass;
+import tudresden.ocl20.core.jmi.uml15.core.Classifier;
+import tudresden.ocl20.core.jmi.uml15.core.CorePackage;
+import tudresden.ocl20.core.jmi.uml15.core.Generalization;
+import tudresden.ocl20.core.jmi.uml15.core.ModelElement;
+import tudresden.ocl20.core.jmi.uml15.core.Namespace;
+import tudresden.ocl20.core.jmi.uml15.datatypes.Multiplicity;
+import tudresden.ocl20.core.jmi.uml15.datatypes.MultiplicityRange;
+import tudresden.ocl20.core.jmi.uml15.datatypes.OrderingKind;
+import tudresden.ocl20.core.jmi.uml15.datatypes.OrderingKindEnum;
+import tudresden.ocl20.core.jmi.uml15.datatypes.ParameterDirectionKind;
+import tudresden.ocl20.core.jmi.uml15.datatypes.ParameterDirectionKindEnum;
+import tudresden.ocl20.core.jmi.uml15.datatypes.ScopeKind;
+import tudresden.ocl20.core.jmi.uml15.datatypes.ScopeKindEnum;
+import tudresden.ocl20.core.jmi.uml15.impl.uml15ocl.types.OclLibraryHelper;
+import tudresden.ocl20.core.jmi.uml15.uml15.Uml15Package;
+
+/**
+ * Implementations of this class are used to access the repository of the CASE-Tools.
+ * @author Mirko
+ */
+public abstract class ModelFacade
+{
+ /**
+ * All instances of the class ModelFacade which are associated to an UML-Model in the MDR.
+ */
+ private static HashMap<String, ModelFacade> instances = new HashMap<String, ModelFacade>();
+
+ /**
+ * All associations between the elements in the MDR and the objects in the repository of a CASE-Tool.
+ */
+ private static HashMap<String, Object> refObjects = new HashMap<String, Object>();
+
+ /**
+ * Returns the UML-Model in the MDR which is associated to the given ModelFacade.
+ */
+ private Uml15Package getModel(ModelFacade facade)
+ {
+ Iterator<String> it = instances.keySet().iterator();
+ Uml15Package model = null;
+ while (it.hasNext())
+ {
+ String mofID = it.next().toString();
+ if (instances.get(mofID) != null)
+ if (instances.get(mofID).equals(facade))
+ model = (Uml15Package) RepositoryManager.getRepository().getElementByMofID(mofID);
+ }
+ return model;
+ }
+
+ /**
+ * Generates the association between an element in the MDR and object in the repository of a CASE-Tool.
+ */
+ public void addRefObject(String mofID, Object refObject)
+ {
+ refObjects.put(mofID, refObject);
+ }
+
+ /**
+ * Returns all element in the MDR which are associated to the given object.
+ */
+ private static List<RefBaseObject> getAllElement(Object refObject)
+ {
+ ArrayList<RefBaseObject> result = new ArrayList<RefBaseObject>();
+ Iterator<String> it = refObjects.keySet().iterator();
+ while (it.hasNext())
+ {
+ String mofID = it.next().toString();
+ if (refObjects.get(mofID) != null)
+ if (refObjects.get(mofID).equals(refObject))
+ result.add(RepositoryManager.getRepository().getElementByMofID(mofID));
+ }
+ return result;
+ }
+
+ /**
+ * Deletes all collection types of an classifier in the OCL Standard Library.
+ */
+ private static void deleteCollectionTypes(Classifier c)
+ {
+ Object[] types = OclLibraryHelper.getInstance(c.refOutermostPackage()).findCollectionTypes(c).toArray();
+ for (int i = 0; i < types.length; i++)
+ {
+ RefObject object = (RefObject) types[i];
+ object.refDelete();
+ }
+ }
+
+ /**
+ * Returns true if an object in the repository of the CASE-Tool is associated to the element in the MDR with the given mofID.
+ */
+ public static boolean isRepresentative(String mofID)
+ {
+ return refObjects.containsKey(mofID);
+ }
+
+ /**
+ * Returns the object which is association to the element in the MDR with the given mofID.
+ */
+ public Object getRefObject(String mofID)
+ {
+ return refObjects.get(mofID);
+ }
+
+ /**
+ * Returns the existing element in the MDR which is associated to the given object. If no instance
+ * of the given class exists a new element will be created.
+ */
+ protected Object getElement(Classes elementClass, Object refObject)
+ {
+ Collection elements = getAllElement(refObject);
+ Iterator it = elements.iterator();
+ Object existingElement = null;
+ while (it.hasNext())
+ {
+ existingElement = it.next();
+ if (elementClass.getValue().isAssignableFrom(existingElement.getClass()))
+ {
+ return existingElement;
+ }
+ }
+
+ Uml15Package model = this.getModel(this);
+ RefBaseObject newElement = null;
+
+ if (elementClass.equals(Classes.umlClass))
+ newElement = model.getCore().getUmlClass().createUmlClass();
+
+ if (elementClass.equals(Classes.multiplicity))
+ newElement = model.getDataTypes().getMultiplicity().createMultiplicity();
+
+ if (elementClass.equals(Classes.method))
+ newElement = model.getCore().getOperation().createOperation();
+
+ if (elementClass.equals(Classes.association))
+ newElement = model.getCore().getAssociation().createAssociation();
+
+ if (elementClass.equals(Classes.associationend))
+ newElement = model.getCore().getAssociationEnd().createAssociationEnd();
+
+ if (elementClass.equals(Classes.attribute))
+ newElement = model.getCore().getAttribute().createAttribute();
+
+ if (elementClass.equals(Classes.parameter))
+ newElement = model.getCore().getParameter().createParameter();
+
+ if (elementClass.equals(Classes.range))
+ newElement = model.getDataTypes().getMultiplicityRange().createMultiplicityRange();
+
+ if (elementClass.equals(Classes.umlPackage))
+ newElement = model.getModelManagement().getPackage().createPackage();
+
+ if (elementClass.equals(Classes.dataType))
+ newElement = model.getCore().getDataType().createDataType();
+
+ if (elementClass.equals(Classes.scopeKind_classifier))
+ return ScopeKindEnum.SK_CLASSIFIER;
+
+ if (elementClass.equals(Classes.scopeKind_instance))
+ return ScopeKindEnum.SK_INSTANCE;
+
+ if (elementClass.equals(Classes.orderingKind_ordered))
+ return OrderingKindEnum.OK_ORDERED;
+
+ if (elementClass.equals(Classes.orderingKind_unordered))
+ return OrderingKindEnum.OK_UNORDERED;
+
+ if (elementClass.equals(Classes.parameterDirectionKind_Return))
+ return ParameterDirectionKindEnum.PDK_RETURN;
+
+ if (elementClass.equals(Classes.parameterDirectionKind_In))
+ return ParameterDirectionKindEnum.PDK_IN;
+
+ if (elementClass.equals(Classes.parameterDirectionKind_Out))
+ return ParameterDirectionKindEnum.PDK_OUT;
+
+ if (elementClass.equals(Classes.parameterDirectionKind_InOut))
+ return ParameterDirectionKindEnum.PDK_INOUT;
+
+ if (elementClass.equals(Classes.generalization))
+ newElement = model.getCore().getGeneralization().createGeneralization();
+
+ if (elementClass.equals(Classes.enumeration))
+ newElement = model.getCore().getEnumeration().createEnumeration();
+
+ if (elementClass.equals(Classes.enumerationLiteral))
+ newElement = model.getCore().getEnumerationLiteral().createEnumerationLiteral();
+
+ if (elementClass.equals(Classes.umlinterface))
+ newElement = model.getCore().getInterface().createInterface();
+
+ this.addRefObject(newElement.refMofId(), refObject);
+ return newElement;
+ }
+
+ /**
+ * Deletes all elements in the MDR which are associated to the given object.
+ */
+ public void deleteElements(Object refObject)
+ {
+ ArrayList elements = (ArrayList) getAllElement(refObject);
+ for (int i = 0; i < elements.size(); i++)
+ {
+ RefObject object = (RefObject) elements.get(i);
+ if (object instanceof Classifier)
+ {
+ this.deleteCollectionTypes((Classifier) object);
+ }
+ object.refDelete();
+ }
+
+ }
+
+ /**
+ * Sets the ModelFacade instance for the UML-Model with the given mofID.
+ */
+ public static void addModelFacade(String mofID, ModelFacade facade) throws Exception
+ {
+ Object obj = RepositoryManager.getRepository().getElementByMofID(mofID);
+ if (obj != null)
+ if (obj instanceof Uml15Package) //TODO test for MOF
+ if (facade != null)
+ {
+ instances.put(mofID, facade);
+ }
+ else
+ throw new NullPointerException();
+ else
+ throw new Exception("Uml15Package excepted");
+ else
+ throw new NullPointerException("Model with MOFID: " + mofID + " doesn't exist!");
+ }
+
+ public static ModelFacade getInstance(String mofID)
+ {
+ if (instances != null && instances.get(mofID) != null)
+ return instances.get(mofID);
+ return null;
+ }
+
+ /**
+ * Returns true if an element in the mdr has a valid element in the repository of the CASE-Tool
+ */
+ public abstract boolean hasRefObject(String mofID);
+ /**
+ * Returns all elements within a namespace.
+ */
+ public abstract Collection getOwnedElements(String mofID);
+ /**
+ * Returns all features of a classifier.
+ */
+ public abstract java.util.List getFeature(String mofID);
+ /**
+ * Returns the name of a modelelement.
+ */
+ public abstract String getName(String mofID);
+ /**
+ * Returns the multiplicity of an association end or of an attribute.
+ */
+ public abstract Multiplicity getMultiplicity(String mofID);
+ /**
+ * Returns the ordering kind of an association end or of an attribute.
+ */
+ public abstract OrderingKind getOrdering(String mofID);
+ /**
+ * Returns the classifier which is connected to an association end.
+ */
+ public abstract Classifier getParticipant(String mofID);
+ /**
+ * Returns the association of an association end.
+ */
+ public abstract Association getAssociation(String mofID);
+ /**
+ * Returns all association ends and the association class of an association.
+ */
+ public abstract java.util.Collection getAssociationEnds(String mofID);
+ /**
+ * Returns the qualifiers of an association end.
+ */
+ public abstract List getQualifier(String mofID);
+ /**
+ * Returns the parameter direction kind of a parameter.
+ */
+ public abstract ParameterDirectionKind getKind(String mofID);
+ /**
+ * Returns the type of parameters and attributes.
+ */
+ public abstract Classifier getType(String mofID);
+ /**
+ * Returns the owner of features.
+ */
+ public abstract Classifier getOwner(String mofID);
+ /**
+ * Returns the namespace of modelelements.
+ */
+ public abstract Namespace getNamespace(String mofID);
+ /**
+ * Returns the generalization where a classifier is the superclass.
+ */
+ public abstract Collection getGeneralization(String mofID);
+ /**
+ * Returns the generalization where a classifier is the subclass.
+ */
+ public abstract Collection getSpecialization(String mofID);
+ /**
+ * Returns the association ends of an association.
+ */
+ public abstract List getConnection(String mofID);
+ /**
+ * Returns the parameters of an operation.
+ */
+ public abstract List getParameter(String mofID);
+ /**
+ * Returns the owner scope of features.
+ */
+ public abstract ScopeKind getOwnerScope(String mofID);
+ /**
+ * Returns the multiplicity range of attributes and association ends.
+ */
+ public abstract java.util.Collection getRange(String mofID);
+ /**
+ * Returns the upper bound of the multiplicity range of attributes and association ends.
+ */
+ public abstract int getUpper(String mofID);
+ /**
+ * Returns the superclass of a generalization.
+ */
+ public abstract tudresden.ocl20.core.jmi.uml15.core.GeneralizableElement getParent(String mofID);
+ /**
+ * Returns subclass of a generalization.
+ */
+ public abstract tudresden.ocl20.core.jmi.uml15.core.GeneralizableElement getChild(String mofID);
+ /**
+ * Returns all enumeration literals of an enumeration.
+ */
+ public abstract java.util.List getLiteral(String mofID);
+ /**
+ * Returns the enumeration of an enumeration literal.
+ */
+ public abstract Enumeration getEnumeration(String mofID);
+}
Added: branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/OCLChecker.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/OCLChecker.java?view=auto&rev=14823
==============================================================================
--- (empty file)
+++ branches/work_ocl2_tfmorris/src/argouml-app/src/tudresden/ocl20/integration/OCLChecker.java 2008-05-28 14:30:13-0700
@@ -0,0 +1,219 @@
+/*
+ * Created on 25.08.2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package tudresden.ocl20.integration;
+
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.jmi.model.ModelPackage;
+import javax.jmi.model.MofPackage;
+import javax.jmi.reflect.RefPackage;
+
+import tudresden.ocl20.core.MetaModelConst;
+import tudresden.ocl20.core.MetaModelIntegrator;
+import tudresden.ocl20.core.MetaModelUtil;
+import tudresden.ocl20.core.ModelManager;
+import tudresden.ocl20.core.ModelManagerException;
+import tudresden.ocl20.core.OclModel;
+import tudresden.ocl20.core.OclModelException;
+import tudresden.ocl20.core.Repository;
+import tudresden.ocl20.core.RepositoryManager;
+import tudresden.ocl20.core.MetaModelConst.MetaModelInfo;
+import tudresden.ocl20.core.jmi.uml15.core.Association;
+import tudresden.ocl20.core.jmi.uml15.core.AssociationEnd;
+import tudresden.ocl20.core.jmi.uml15.core.CorePackage;
+import tudresden.ocl20.core.jmi.uml15.core.Namespace;
+import tudresden.ocl20.core.jmi.uml15.core.UmlClass;
+import tudresden.ocl20.core.jmi.uml15.datatypes.Multiplicity;
+import tudresden.ocl20.core.jmi.uml15.datatypes.MultiplicityRange;
+import tudresden.ocl20.core.jmi.uml15.impl.core.ModelElementImpl;
+import tudresden.ocl20.core.jmi.uml15.impl.modelmanagement.ModelHelper;
+import tudresden.ocl20.core.jmi.uml15.impl.modelmanagement.PackageImpl;
+import tudresden.ocl20.core.jmi.uml15.modelmanagement.Model;
+import tudresden.ocl20.core.jmi.uml15.modelmanagement.Package;
+import tudresden.ocl20.core.jmi.uml15.uml15.Uml15Package;
+import tudresden.ocl20.core.parser.astgen.Heritage;
+import tudresden.ocl20.core.parser.astgen.LAttrAstGenerator;
+import tudresden.ocl20.core.parser.sablecc.analysis.AttrEvalException;
+import tudresden.ocl20.core.parser.sablecc.lexer.Lexer;
+import tudresden.ocl20.core.parser.sablecc.lexer.LexerException;
+import tudresden.ocl20.core.parser.sablecc.node.Start;
+import tudresden.ocl20.core.parser.sablecc.parser.Parser;
+import tudresden.ocl20.core.parser.sablecc.parser.ParserException;
+
+/**
+ * This class can be use to start the validation of a constraint.
+ * @author Mirko
+ */
+public class OCLChecker
+{
+ public static HashMap instances = new HashMap();
+
+ /**
+ * Returns the existing OCLChecker instance for the given object or creates a new instance.
+ */
+ public static OCLChecker getInstance(Object rootPackage)
+ {
+ if (instances.get(rootPackage) == null)
+ {
+ try
+ {
+ OCLChecker instance = new OCLChecker();
+ instance.initModel();
+ instances.put(rootPackage, instance);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return (OCLChecker) instances.get(rootPackage);
+ }
+
+ /**
+ * Deletes all models in the MDR.
+ *
+ */
+ private static void deleteModels()
+ {
+ for (int i = 0; i < instances.size(); i++)
+ {
+ ((OCLChecker)instances.get(i)).deleteModel();
+ }
+ }
+
+ private static ModelManager mm = ModelManager.getInstance();
+ private Uml15Package model = null;
+
+ private OCLChecker()
+ {
+
+ }
+
+ /**
+ * Creates a new UML model in the MDR with one Model instance.
+ */
+ public void initModel() throws Exception
+ {
+ //deleteModel();
+ System.out.println("Initialize Model");
+ mm.beginTrans(true);
+ model = (Uml15Package) mm.createOclModel(MetaModelConst.UML15, this.getUniqueName());
+ Model rootModel = model.getModelManagement().getModel().createModel();
+ rootModel.setNameA("rootPackage");
+
+ mm.endTrans(false);
+ }
+
+ /**
+ * Sets the ModelFacade for the model of the OCLChecker instance.
+ */
+ public void setModelFacade(ModelFacade facade) throws Exception
+ {
+ ModelFacade.addModelFacade(this.model.refMofId(), facade);
+ ModelFacade instance = ModelFacade.getInstance(this.model.refMofId());
+ Model topPackage = ModelHelper.getInstance(this.model).getTopPackage();
+
+ ArrayList result = new ArrayList();
+ Iterator it = this.instances.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object caseTop = it.next();
+ if (this.instances.get(caseTop) != null)
+ if (this.instances.get(caseTop).equals(this))
+ instance.addRefObject(topPackage.refMofId(), caseTop);
+ }
+ }
+
+ /**
+ * Validates the given constraint.
+ */
+ public void validate(String constraint) throws OclModelException, ParserException, LexerException, IOException, AttrEvalException
+ {
+ if (this.model != null)
+ {
+ OclModel oclModel = new OclModel(MetaModelConst.UML15, model);
+ System.out.println("Syntaxprüfung");
+ Lexer lexer = new Lexer (new PushbackReader(new StringReader(constraint)));
+ System.out.println("CSTErstellung");
+ Parser parser = new Parser(lexer);
+ Start cst = parser.parse();
+ System.out.println("Konsistenzprüfung");
+ LAttrAstGenerator astgen = new LAttrAstGenerator(oclModel);
+ Heritage hrtg = new Heritage();
+ oclModel.beginTrans(true);
+ cst.apply(astgen, hrtg);
+ oclModel.endTrans(false);
+ }
+ else
+ System.out.println("Please initialize the model first!");
+ }
+
+ /**
+ * Deletes the models of all OCLChecker instances.
+ */
+ protected void finalize()
+ {
+ Iterator it = instances.values().iterator();
+ while (it.hasNext())
+ ((OCLChecker)it.next()).deleteModel();
+ }
+
+ /**
+ * Deletes the element in the MDR assoziated to the given object.
+ */
+ public void deleteElements(Object refObject)
+ {
+ ModelFacade instance = ModelFacade.getInstance(this.model.refMofId());
+ instance.deleteElements(refObject);
+ }
+
+ /**
+ * Deletes the model of the OCLChecker instance.
+ */
+ private void deleteModel()
+ {
+ mm.beginTrans(true);
+ if (this.model != null)
+ mm.deleteModel(model);
+ mm.endTrans(false);
+ }
+
+ /**
+ * Returns an unique name for a new model.
+ */
+ private String getUniqueName()
+ {
+ try
+ {
+ boolean found = false;
+ Collection col = mm.getAllModelNames();
+ String name = "WorkingModel";
+ int i = col.size()+1;
+ while (true)
+ {
+ name = "WorkingModel" + i;
+ if (!col.contains(name))
+ return name;
+ i++;
+ }
+ }
+ catch (ModelManagerException e)
+ {
+ e.printStackTrace();
+ return "";
+ }
+
+ }
+}
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.