summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Wouters2014-04-04 10:15:46 (EDT)
committerLaurent Wouters2014-04-04 10:15:46 (EDT)
commit9fc1721b92623b68a9880dd862b91fc9f3bd26cf (patch)
tree277abd26769475421b80d770a94486b86f7d2521
parentf0b4cf2222ba251a7d3349f37f586b52f5056585 (diff)
downloadorg.eclipse.papyrus-9fc1721b92623b68a9880dd862b91fc9f3bd26cf.zip
org.eclipse.papyrus-9fc1721b92623b68a9880dd862b91fc9f3bd26cf.tar.gz
org.eclipse.papyrus-9fc1721b92623b68a9880dd862b91fc9f3bd26cf.tar.bz2
[clean] Retiring org.eclipse.papyrus.uml.table.commonlast/org.eclipse.papyrus.uml.table.common
Signed-off-by: Laurent Wouters <laurent.wouters@cea.fr>
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/.classpath7
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/.project28
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/META-INF/MANIFEST.MF34
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/OSGI-INF/l10n/bundle.properties3
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/about.html28
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/build.properties9
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/plugin.pdoc4
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/plugin.xml61
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/Activator.java67
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/dialog/ColumnsToShowDialog.java558
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/editor/AbstractUMLTableEditor.java38
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/factory/PapyrusTableInstanceCommandFactory.java58
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/PasteInTableHandler.java326
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/SelectAdditionColumnsPopupUpHandler.java206
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/SelectColumnsHandler.java1038
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/listener/ApplyProfileTriggerListener.java36
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/menu/ContributionFactory.java77
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/messages/Messages.java90
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/messages/messages.properties32
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/AbstractAdditionalContentsProvider.java56
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/AbstractPasteInTableCommandProvider.java187
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/EMFFacetColumnsProvider.java65
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/IPasteInTableCommandProvider.java83
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/PasteInPapyrusTableCommandProvider.java720
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/ProfileFacetSetProvider.java158
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/SortedFeaturesContentProvider.java209
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/UMLTablePropertyTester.java43
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/AbstractWarningPasteResultStatus.java172
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/PasteWarningStatus.java42
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/StereotypeApplicationErrorStatus.java52
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/UnresolvedReferenceErrorInPasteStatus.java61
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/utils/MultiValueContainer.java57
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/utils/ValueContainer.java99
-rw-r--r--deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/widget/FilteredCheckboxTree.java456
35 files changed, 0 insertions, 5167 deletions
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/.classpath b/deprecated/org.eclipse.papyrus.uml.table.common/.classpath
deleted file mode 100644
index 058117a..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry excluding="org/eclipse/papyrus/uml/table/common/factory/CustomizationUtils.java|org/eclipse/papyrus/uml/table/common/factory/ITableCommandFactory.java|org/eclipse/papyrus/uml/table/common/factory/TableCommandFactory.java|org/eclipse/papyrus/uml/table/common/factory/TableInstanceCommandFactory.java|org/eclipse/papyrus/uml/table/common/factory/TableInstanceUtils.java" kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/.project b/deprecated/org.eclipse.papyrus.uml.table.common/.project
deleted file mode 100644
index 7fee890..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.uml.table.common</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/.settings/org.eclipse.jdt.core.prefs b/deprecated/org.eclipse.papyrus.uml.table.common/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 44217f8..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,7 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/META-INF/MANIFEST.MF b/deprecated/org.eclipse.papyrus.uml.table.common/META-INF/MANIFEST.MF
deleted file mode 100644
index 8082aab..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,34 +0,0 @@
-Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.uml.table.common.editor
-Require-Bundle: org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
- org.eclipse.papyrus.uml.profilefacet.generation;bundle-version="1.0.0",
- org.eclipse.papyrus.uml.profilefacet.metamodel;bundle-version="1.0.0",
- org.eclipse.uml2.uml,
- org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.table.common;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.table.instance;bundle-version="1.0.0",
- org.eclipse.emf.facet.widgets.nattable.instance;bundle-version="0.2.1",
- org.eclipse.emf.facet.widgets.nattable;bundle-version="0.2.1",
- org.eclipse.papyrus.uml.tools.utils;bundle-version="1.0.0",
- org.eclipse.gmf.runtime.emf.type.core,
- org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.tools;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.0.0",
- org.eclipse.core.expressions,
- org.eclipse.emf.facet.infra.facet.core;bundle-version="0.2.1",
- org.eclipse.papyrus.uml.profilefacet;bundle-version="1.0.0",
- org.eclipse.emf.edit.ui,
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
- org.eclipse.emf.facet.util.emf.core;bundle-version="0.2.1"
-Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.0.qualifier
-Bundle-Name: %Bundle-Name
-Bundle-Activator: org.eclipse.papyrus.uml.table.common.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.uml.table.common;singleton:=t
- rue
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/OSGI-INF/l10n/bundle.properties b/deprecated/org.eclipse.papyrus.uml.table.common/OSGI-INF/l10n/bundle.properties
deleted file mode 100644
index f207b1e..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/OSGI-INF/l10n/bundle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#Properties file for org.eclipse.papyrus.uml.table.common
-Bundle-Vendor = Eclipse Modeling Project
-Bundle-Name = UML Table Common (Incubation) \ No newline at end of file
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/about.html b/deprecated/org.eclipse.papyrus.uml.table.common/about.html
deleted file mode 100644
index 82d49bf..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/about.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 5, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
-
-</body>
-</html>
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/build.properties b/deprecated/org.eclipse.papyrus.uml.table.common/build.properties
deleted file mode 100644
index 7602c3a..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/build.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- about.html,\
- OSGI-INF/,\
- plugin.pdoc
-src.includes = about.html
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/plugin.pdoc b/deprecated/org.eclipse.papyrus.uml.table.common/plugin.pdoc
deleted file mode 100644
index 6a720e9..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/plugin.pdoc
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<doc:Documentation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:doc="http://www.eclipse.org/papyrus/documentation/plugin/documentation" description="This plugin provides classes, handlers, ... for all UML Table Editor">
- <referent firstName="vincent" lastName="lorenzo" eMail="vincent.lorenzo@cea.fr" currentCompany="CEA-LIST"/>
-</doc:Documentation>
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/plugin.xml b/deprecated/org.eclipse.papyrus.uml.table.common/plugin.xml
deleted file mode 100644
index 0491e4d..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/plugin.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.eclipse.papyrus.uml.table.common.provider.UMLTablePropertyTester"
- id="org.eclipse.papyrus.uml.table.common.provider"
- namespace="org.eclipse.papyrus.uml.table.common.provider"
- properties="isUMLTable"
- type="org.eclipse.jface.viewers.IStructuredSelection">
- </propertyTester>
- </extension>
- <!--extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.papyrus.uml.table.common.handler.SelectColumnsHandler"
- commandId="org.eclipse.papyrus.infra.table.common.selectvisiblecolumns">
- <activeWhen>
- <and>
- <with
- variable="activeEditorId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- <with
- variable="selection">
- <test
- forcePluginActivation="true"
- property="org.eclipse.papyrus.uml.table.common.provider.isUMLTable"
- value="true">
- </test>
- </with>
- </and>
- </activeWhen>
- </handler>
- <handler
- class="org.eclipse.papyrus.uml.table.common.handler.PasteInTableHandler"
- commandId="org.eclipse.ui.edit.paste">
- <activeWhen>
- <with
- variable="selection">
- <test
- forcePluginActivation="true"
- property="org.eclipse.papyrus.uml.table.common.provider.isUMLTable"
- value="true">
- </test>
- </with>
- </activeWhen>
- </handler>
- </extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="true"
- class="org.eclipse.papyrus.uml.table.common.menu.ContributionFactory"
- locationURI="popup:org.eclipse.ui.popup.any">
- </menuContribution>
- </extension-->
-</plugin>
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/Activator.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/Activator.java
deleted file mode 100644
index 314bcc1..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/Activator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common;
-
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.papyrus.uml.table.common"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- public static LogHelper log;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- log = new LogHelper(this);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/dialog/ColumnsToShowDialog.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/dialog/ColumnsToShowDialog.java
deleted file mode 100644
index 07c1126..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/dialog/ColumnsToShowDialog.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.dialog;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.facet.infra.facet.Facet;
-import org.eclipse.emf.facet.infra.facet.FacetSet;
-import org.eclipse.emf.facet.infra.facet.FacetStructuralFeature;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Column;
-import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidgetInternalUtils;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypeFacet;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypePropertyElement;
-import org.eclipse.papyrus.uml.table.common.messages.Messages;
-import org.eclipse.papyrus.uml.table.common.provider.SortedFeaturesContentProvider;
-import org.eclipse.papyrus.uml.table.common.widget.FilteredCheckboxTree;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
-import org.eclipse.ui.dialogs.FilteredTree;
-import org.eclipse.ui.dialogs.PatternFilter;
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-
-public class ColumnsToShowDialog extends SelectionDialog {
-
- /** the label provider used by the tree viewer */
- private final ILabelProvider labelProvider;
-
- /** the content provider used by the tree viewer */
- private final SortedFeaturesContentProvider contentProvider;
-
- /** the with of the dialog */
- private static final int DIALOG_WIDTH = 1000;
-
- /** the height of the dialog */
- private static final int DIALOG_HEIGHT = 600;
-
- /** the direct features */
- private final Collection<ETypedElement> directFeatures;
-
- /** the additional features */
- private final Collection<ENamedElement> additionalFeatures;
-
- /** the initial selection */
- private final Collection<ETypedElement> initialSelection;
-
- /** the tree used to display the direct features */
- private FilteredTree directFeaturesTree;
-
- /** the tree used to display the additional features */
- private FilteredTree additionnalFeaturesTree;
-
- /** This filter is used to filter additional content */
- private ViewerFilter additionalContentFilter;
-
- /** this map provides all the default columns and their current visibility */
- final private Map<Column, Boolean> defaultColumnsAndVisiblity;
-
- /**
- *
- * Constructor.
- *
- * @param parentShell
- * the parent shell
- * @param defaultColumnsAndVisibility
- * the visibility of the default columns
- * @param features
- * the direct features
- * @param additionalFeatures
- * the additional features (FacetSet, Facets or ETypedElement)
- * @param initialSelection
- * the initial selection
- * @param labelProvider
- * the label provider used by the viewers
- * @param contentProvider
- * the content provider used by the viewers
- */
- public ColumnsToShowDialog(final Shell parentShell, final Map<Column, Boolean> defaultColumnsAndVisibility, final Collection<ETypedElement> features, final Collection<ENamedElement> additionalFeatures, final Collection<ETypedElement> initialSelection, final ILabelProvider labelProvider, final IContentProvider contentProvider) {
- super(parentShell);
- setTitle(Messages.ColumnsToShowDialog_SelecColumnsToShow);
- this.directFeatures = features;
- this.additionalFeatures = additionalFeatures;
- this.labelProvider = labelProvider;
- this.contentProvider = (SortedFeaturesContentProvider)contentProvider;
- this.initialSelection = initialSelection;
- this.additionalContentFilter = new AdditionalContentsFilter(initialSelection);
- this.defaultColumnsAndVisiblity = defaultColumnsAndVisibility;
- }
-
- @Override
- public void create() {
- super.create();
-
- final Composite parent = new Composite((Composite)getDialogArea(), SWT.NONE);
- final GridLayout layout = new GridLayout(2, true);
- parent.setLayout(layout);
- parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- final Composite defaultColumnPane = new Composite(parent, SWT.NONE);
- defaultColumnPane.setLayout(new GridLayout(1, false));
- final GridData data = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- data.horizontalSpan = 2;
- defaultColumnPane.setLayoutData(data);
-
- final Composite selectorPane = new Composite(parent, SWT.NONE);
- selectorPane.setLayout(new GridLayout(2, false));
- selectorPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- final Composite selectedPane = new Composite(parent, SWT.NONE);
- selectedPane.setLayout(new GridLayout(2, false));
- selectedPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- createDefaultColumnsSection(defaultColumnPane);
- createDirectFeaturesSection(selectorPane);
- createAdditionalFeaturesSection(selectedPane);
-
- getShell().pack();
-
- //TODO
- // super.getShell().setImage(Activator.getDefault().getImage("/icons/papyrus.png")); //$NON-NLS-1$
- }
-
-
- protected void createDefaultColumnsSection(final Composite selectorPane) {
- final Composite featureComposite = new Composite(selectorPane, SWT.BORDER);
- featureComposite.setLayout(new GridLayout(3, false));
- featureComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- final Label label = new Label(featureComposite, SWT.NONE);
- label.setText("Default Columns");
- final GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
- data.horizontalSpan = 3;
- label.setLayoutData(data);
-
- for(final Column current : defaultColumnsAndVisiblity.keySet()) {
- Button button = new Button(featureComposite, SWT.CHECK);
- button.setText(NatTableWidgetInternalUtils.getColumnName(current));
- button.setSelection(defaultColumnsAndVisiblity.get(current));
- button.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- ColumnsToShowDialog.this.defaultColumnsAndVisiblity.put(current, !ColumnsToShowDialog.this.defaultColumnsAndVisiblity.get(current));
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- //nothing to do
- }
- });
- }
- }
-
- /**
- *
- * @param parent
- * the parent of the button panel
- * @return
- * the composite used as parent for the buttons
- */
- protected Composite createButtonPanel(final Composite parent) {
- final Composite buttonsPanel = new Composite(parent, SWT.NONE);
- final GridLayout buttonPanelLayout = new GridLayout(2, true);
- buttonPanelLayout.marginWidth = 0;
- buttonPanelLayout.marginHeight = 0;
- buttonsPanel.setLayout(buttonPanelLayout);
- buttonsPanel.setLayoutData(new GridData(SWT.END, SWT.FILL, false, false));
- return buttonsPanel;
- }
-
- /**
- * Create the direct features section
- *
- * @param parent
- * crate the feature section
- *
- */
- protected void createDirectFeaturesSection(final Composite parent) {
- //1. create the composite used for this section
- final Composite featureComposite = new Composite(parent, SWT.BORDER);
- featureComposite.setLayout(new GridLayout(1, false));
- featureComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- //2. create the label of the section
- final Label label = new Label(featureComposite, SWT.NONE);
- label.setText(Messages.ColumnsToShowDialog_DirectFeatures);
-
- //3. create the tree
- this.directFeaturesTree = new FilteredCheckboxTree(featureComposite, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK, new PatternFilter());
- GridDataFactory.fillDefaults().grab(true, true).applyTo(this.directFeaturesTree);
-
- this.directFeaturesTree.getViewer().setLabelProvider(this.labelProvider);
- this.directFeaturesTree.getViewer().setContentProvider(this.contentProvider);
- this.directFeaturesTree.getViewer().setInput(this.directFeatures);
-
- //3.bis set the initial selection
- ((ContainerCheckedTreeViewer)this.directFeaturesTree.getViewer()).setCheckedElements(this.initialSelection.toArray());
-
- //4. create the buttons select all and deselect all
- final Composite buttonsPanel = createButtonPanel(featureComposite);
- final Button selectAllFeaturesButton = new Button(buttonsPanel, SWT.NONE);
- selectAllFeaturesButton.setText(Messages.ColumnsToShowDialog_SelectAll);
- selectAllFeaturesButton.setToolTipText(Messages.ColumnsToShowDialog_SelectAllAvailablesFeatures);
- selectAllFeaturesButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- selectAllFeaturesButton.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(final SelectionEvent e) {
- selectAllDirectFeatures();
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- //nothing to do
- }
- });
-
- final Button deselectAllFeaturesButton = new Button(buttonsPanel, SWT.NONE);
- deselectAllFeaturesButton.setText(Messages.ColumnsToShowDialog_DeselectedAll);
- deselectAllFeaturesButton.setToolTipText(Messages.ColumnsToShowDialog_DeselecteAllAvailableFeatures);
- deselectAllFeaturesButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- deselectAllFeaturesButton.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(final SelectionEvent e) {
- deselectAllDirectFeatures();
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- //nothing to do
- }
- });
-
- }
-
-
-
- protected void createAdditionalFeaturesSection(final Composite facetPane) {
- //1. create the composite used for this section
- final Composite facetComposite = new Composite(facetPane, SWT.BORDER);
- facetComposite.setLayout(new GridLayout(1, true));
- facetComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- //2. create the label for this section
- final Label label = new Label(facetComposite, SWT.NONE);
- label.setText(Messages.ColumnsToShowDialog_AdditionalFeatures);
-
- //3. create the tree for this section
- this.additionnalFeaturesTree = new FilteredCheckboxTree(facetComposite, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK, new PatternFilter());//, true);
- // GridDataFactory.fillDefaults().grab(true, true).applyTo(this.additionnalFeaturesTree);
- this.additionnalFeaturesTree.getViewer().expandAll();
- this.additionnalFeaturesTree.getViewer().addFilter(this.additionalContentFilter);
- this.additionnalFeaturesTree.getViewer().setLabelProvider(this.labelProvider);
- this.additionnalFeaturesTree.getViewer().setContentProvider(this.contentProvider);
- this.additionnalFeaturesTree.getViewer().setInput(this.additionalFeatures);
- ((ContainerCheckedTreeViewer)this.additionnalFeaturesTree.getViewer()).setCheckedElements(this.initialSelection.toArray());
-
- //4. create the buttons select all , deselect all and Show Advanced Contents
- final Composite allButtonsPanel = new Composite(facetComposite, SWT.NONE);
- final GridLayout buttonPanelLayout = new GridLayout(2, true);
- buttonPanelLayout.marginWidth = 0;
- buttonPanelLayout.marginHeight = 0;
- allButtonsPanel.setLayout(buttonPanelLayout);
- allButtonsPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-
- final Button showAdvancedContents = new Button(allButtonsPanel, SWT.CHECK);
- showAdvancedContents.setText(Messages.ColumnsToShowDialog_AdvancedMode);
- showAdvancedContents.setToolTipText(Messages.ColumnsToShowDialog_ShowAllPossibilities);
- showAdvancedContents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- showAdvancedContents.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- TreePath[] treePaths = additionnalFeaturesTree.getViewer().getExpandedTreePaths();
- if(showAdvancedContents.getSelection()) {
- additionnalFeaturesTree.getViewer().removeFilter(additionalContentFilter);
- } else {
- additionnalFeaturesTree.getViewer().addFilter(additionalContentFilter);
- }
- additionnalFeaturesTree.getViewer().setExpandedTreePaths(treePaths);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- //nothing to do
- }
- });
-
- final Composite buttonsPanel = createButtonPanel(allButtonsPanel);
- final Button selectAllAdditionalFeaturesButton = new Button(buttonsPanel, SWT.NONE);
- selectAllAdditionalFeaturesButton.setText(Messages.ColumnsToShowDialog_SelectAll);
- selectAllAdditionalFeaturesButton.setToolTipText(Messages.ColumnsToShowDialog_SelectAllAvailableAdditionalFeatures);
- selectAllAdditionalFeaturesButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- selectAllAdditionalFeaturesButton.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(final SelectionEvent e) {
- selectAllAdditionalFeatures();
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- //nothing to do
- }
- });
-
- final Button deselectAllAdditionalFeaturesButton = new Button(buttonsPanel, SWT.NONE);
- deselectAllAdditionalFeaturesButton.setText(Messages.ColumnsToShowDialog_DeselectAll);
- deselectAllAdditionalFeaturesButton.setToolTipText(Messages.ColumnsToShowDialog_DeselectAllAvailableAdditionalFeatures);
- deselectAllAdditionalFeaturesButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- deselectAllAdditionalFeaturesButton.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(final SelectionEvent e) {
- deselectAllAdditionalFeatures();
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- //nothing to do
- }
- });
- }
-
-
-
- /**
- * select all additional features
- */
- protected void selectAllAdditionalFeatures() {
- final ContainerCheckedTreeViewer viewer = (ContainerCheckedTreeViewer)this.additionnalFeaturesTree.getViewer();
- for(final Object current : this.additionalFeatures) {
- viewer.setSubtreeChecked(current, true);
- }
- }
-
- /**
- * deselect all additional features
- */
- protected void deselectAllAdditionalFeatures() {
- final ContainerCheckedTreeViewer viewer = (ContainerCheckedTreeViewer)this.additionnalFeaturesTree.getViewer();
- for(final Object current : this.additionalFeatures) {
- viewer.setSubtreeChecked(current, false);
- }
- }
-
- /**
- * select all direct features
- */
- protected void selectAllDirectFeatures() {
- final ContainerCheckedTreeViewer viewer = (ContainerCheckedTreeViewer)this.directFeaturesTree.getViewer();
- for(final Object current : this.directFeatures) {
- viewer.setSubtreeChecked(current, true);
- }
- }
-
- /**
- * deselect all direct features
- */
- protected void deselectAllDirectFeatures() {
- final ContainerCheckedTreeViewer viewer = (ContainerCheckedTreeViewer)this.directFeaturesTree.getViewer();
- for(final Object current : this.directFeatures) {
- viewer.setSubtreeChecked(current, false);
- }
- }
-
- public void pressOk() {
- okPressed();
- }
-
- /**
- * The <code>ListSelectionDialog</code> implementation of this <code>Dialog</code> method builds a list of the selected elements for
- * later retrieval by the client and closes this dialog.
- */
- @Override
- protected void okPressed() {
- final Collection<ETypedElement> selectedFeatures = getAllChechedElements(this.directFeaturesTree);
- final Collection<ETypedElement> selectedAdditionalFeatures = getAllChechedElements(this.additionnalFeaturesTree);
-
- final List<Collection<ETypedElement>> result = new ArrayList<Collection<ETypedElement>>();
- result.add(selectedFeatures);
- result.add(selectedAdditionalFeatures);
- setResult(result);
- super.okPressed();
- }
-
- /**
- *
- * @param tree
- * a tree
- * @return
- * all items checked ignoring grayed elements
- */
- protected Collection<ETypedElement> getAllChechedElements(final FilteredTree tree) {
- final Collection<ETypedElement> checkedElements = new HashSet<ETypedElement>();
- final TreeViewer viewer = tree.getViewer();
- final TreeItem[] items = viewer.getTree().getItems();
- for(final TreeItem treeItem : items) {
- if(treeItem.getChecked()) {
- final Object data = treeItem.getData();
- if(data instanceof ETypedElement) {
- checkedElements.add((ETypedElement)data);
- }
- }
- if(treeItem.getChecked() || treeItem.getGrayed()) {
- checkedElements.addAll(getAllCheckedSubItems(treeItem));
- }
- }
- return checkedElements;
- }
-
- /**
- *
- * @param item
- * a item
- * @return
- * all sub items checked ignoring grayed items
- */
- protected Collection<ETypedElement> getAllCheckedSubItems(final TreeItem item) {
- final Collection<ETypedElement> checkedElements = new HashSet<ETypedElement>();
- for(final TreeItem current : item.getItems()) {
- if(current.getGrayed()) {
-
- } else if(current.getChecked()) {
- final Object data = current.getData();
- if(data instanceof ETypedElement) {
- checkedElements.add((ETypedElement)data);
- }
- }
- checkedElements.addAll(getAllCheckedSubItems(current));
- }
-
- return checkedElements;
- }
-
- /**
- *
- *
- * @return
- * the result of the dialog :
- * an array of 2 List<ETypeElement> : the first list contains the direct features selected and the second one contains the additional
- * features
- */
- @Override
- public Object[] getResult() {
- //overriden only for the documentation of the methods
- return super.getResult();
- }
-
-
- /**
- *
- * This class allows to filter easily the required additional contents
- *
- */
- public class AdditionalContentsFilter extends ViewerFilter {
-
- /**
- * the initial selection
- */
- final private Collection<?> initialSelection;
-
- /**
- *
- * Constructor.
- *
- * @param iniCollection
- * the initial selection
- */
- public AdditionalContentsFilter(final Collection<?> iniCollection) {
- this.initialSelection = iniCollection;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param parentElement
- * @param element
- * @return
- * <code>true</code> when the element is owned by {@link #initialSelection} or when it contains element which are instance of
- * StereotypePropertyElement
- */
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if(element instanceof StereotypeFacet) {
- final StereotypeFacet facet = (StereotypeFacet)element;
- for(final StereotypePropertyElement el : facet.getStereotypePropertyElements()) {
- if(initialSelection.contains(el)) {
- return true;
- }
- }
- }
-
- if(element instanceof StereotypePropertyElement) {
- if(initialSelection.contains(element)) {
- return true;
- }
- }
-
- if(element instanceof FacetSet || element instanceof Facet || element instanceof FacetStructuralFeature) {
- if(element instanceof FacetSet) {
- FacetSet set = (FacetSet)element;
- TreeIterator<EObject> iter = set.eAllContents();
- while(iter.hasNext()) {
- Object current = iter.next();
- if(current instanceof FacetSet || current instanceof Facet || current instanceof FacetStructuralFeature) {
- if(select(viewer, null, current)) {
- return true;
- }
- }
- }
- } else if(element instanceof Facet) {
- Facet facet = (Facet)element;
- //FIXME
- for(final EStructuralFeature el : facet.getEStructuralFeatures()) {
- if(initialSelection.contains(el) || el instanceof StereotypePropertyElement) {
- return true;
- }
- }
- } else if(element instanceof FacetStructuralFeature) {
- if(initialSelection.contains(element) || element instanceof StereotypePropertyElement) {
- return true;
- }
- }
- return false;
- }
- return false;
- }
-
-
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/editor/AbstractUMLTableEditor.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/editor/AbstractUMLTableEditor.java
deleted file mode 100644
index a979e9f..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/editor/AbstractUMLTableEditor.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.editor;
-
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.table.common.editor.AbstractNattableEditor;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.uml.table.common.messages.Messages;
-import org.eclipse.uml2.uml.Element;
-
-
-public abstract class AbstractUMLTableEditor extends AbstractNattableEditor {
-
- /**
- * @param servicesRegistry
- * @param rawModel
- *
- */
- public AbstractUMLTableEditor(final ServicesRegistry servicesRegistry, final PapyrusTableInstance rawModel) {
- super(servicesRegistry, rawModel);
- if(!(rawModel.getTable().getContext() instanceof Element)) {
- throw new UnsupportedOperationException(NLS.bind(Messages.AbstractUMLTableEFacetEditor_UMLTableCreationErrorMessage, rawModel.getTable().getContext()));
- }
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/factory/PapyrusTableInstanceCommandFactory.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/factory/PapyrusTableInstanceCommandFactory.java
deleted file mode 100644
index f82beb8..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/factory/PapyrusTableInstanceCommandFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.factory;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
-import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidget;
-
-
-public class PapyrusTableInstanceCommandFactory {
-
- private PapyrusTableInstanceCommandFactory(){
- //to prevent instanciation
- }
-
-
- //adapted code from NattableWidget#addRows
- public static Command getAddRowCommand(final List<EObject> newElements, final TableInstance tableInstance, final NatTableWidget widget){
- CompoundCommand addRowCommand = org.eclipse.emf.facet.widgets.nattable.internal.TableInstanceCommandFactory.createAddRowsCommand(newElements, widget);
- //to avoid the creation of facet columns (see bug 397849: [Table]Hidden Facets Columns become visible after drop, creation of paste into the table)
-// if (tableInstance instanceof TableInstance2) {
-// TableInstance2 tableInstance2 = (TableInstance2) tableInstance;
-// try {
-// widget.getFacetContext().clear();
-// widget.getFacetContext().addFacets(tableInstance2.getFacets2());
-// Command setFacetsCommand = org.eclipse.emf.facet.widgets.nattable.internal.TableInstanceCommandFactory.createSetFacetsCommand(
-// tableInstance2.getFacets2(), newElements, widget);
-// if (setFacetsCommand != null && setFacetsCommand.canExecute()) {
-// addRowCommand.append(setFacetsCommand);
-// }
-// } catch (CoreException e) {
-// throw new RuntimeException(e);
-// }
-// }
- Command loadCustomizationCommand = org.eclipse.emf.facet.widgets.nattable.internal.TableInstanceCommandFactory.createLoadCustomizationsCommand(tableInstance.getCustomizations(), widget);
- if (loadCustomizationCommand != null && loadCustomizationCommand.canExecute()) {
- addRowCommand.append(loadCustomizationCommand);
- }
- return addRowCommand;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/PasteInTableHandler.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/PasteInTableHandler.java
deleted file mode 100644
index 5f8c4cd..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/PasteInTableHandler.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.handler;
-
-import java.awt.Toolkit;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.UnsupportedFlavorException;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.facet.widgets.nattable.INatTableWidget;
-import org.eclipse.emf.facet.widgets.nattable.INatTableWidgetProvider;
-import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidget;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
-import org.eclipse.papyrus.infra.emf.dialog.CommandCreationProgressMonitorDialog;
-import org.eclipse.papyrus.infra.table.common.editor.AbstractNattableEditor;
-import org.eclipse.papyrus.infra.table.common.exceptions.ErrorInPastePreparationException;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
-import org.eclipse.papyrus.uml.table.common.Activator;
-import org.eclipse.papyrus.uml.table.common.messages.Messages;
-import org.eclipse.papyrus.uml.table.common.provider.IPasteInTableCommandProvider;
-import org.eclipse.papyrus.uml.table.common.provider.PasteInPapyrusTableCommandProvider;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-
-public class PasteInTableHandler extends AbstractHandler {
-
- /**
- * this field is used to determine if we want open a dialog to prevent the user that the command creation and the command execution can take a
- * long time
- */
- private boolean useProgressMonitorDialog = true;
-
- private final IPasteInTableCommandProvider provider = new PasteInPapyrusTableCommandProvider();
-
- private NatTableWidget widget = null;
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return
- * @throws ExecutionException
- */
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- widget = (NatTableWidget)getITableWidget();
- final PapyrusTableInstance papyrusTable = getPapyrusTable();
- if(papyrusTable != null) {
- final String contents = getClipboardContents();
- if(this.useProgressMonitorDialog) {//we create the command using a progress monitor
- return executeWithProgressMonitorDialog(papyrusTable, contents);
- } else {
- return executeWithoutProgressMonitorDialog(papyrusTable, contents);
- }
- }
- return null;
- }
-
- protected Object executeWithProgressMonitorDialog(final PapyrusTableInstance pTable, final String contents) {
- Command createdCommand;
- int returnCode = Window.OK;
-
- final CommandCreationProgressMonitorDialog commandCreationDialog = new CommandCreationProgressMonitorDialog(Display.getCurrent().getActiveShell());
- final ProgressMonitorDialog commandExecutionProgressMonitor = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
- commandCreationDialog.getProgressMonitor().setTaskName(Messages.PasteInTableHandler_PasteCreation);
- try {
- commandCreationDialog.run(true, true, new IRunnableWithProgress() {
-
- public void run(final IProgressMonitor cancelProvider) throws InvocationTargetException, InterruptedException {
- Command cmd;
- try {
- cmd = PasteInTableHandler.this.provider.getPasteFromFromStringCommand(pTable, cancelProvider, commandExecutionProgressMonitor, contents, widget);
- commandCreationDialog.setCreatedCommand(cmd);
- } catch (ErrorInPastePreparationException e) {
- commandCreationDialog.setCaughtException(e);
- commandCreationDialog.setCreatedCommand(null);
- }
- }
- });
- } catch (final InvocationTargetException e) {
- Activator.log.error(e);
- } catch (final InterruptedException e) {
- Activator.log.error(e);
- }
- final Exception e = commandCreationDialog.getCaughtException();
- if(e != null) {
- if(e instanceof ErrorInPastePreparationException)
- NotificationBuilder.createErrorPopup(e.getMessage()).run();
- return null;
- }
-
- returnCode = commandCreationDialog.getReturnCode();
- createdCommand = commandCreationDialog.getCreatedCommand();
-
-
- if(returnCode == Window.OK) {
- if(createdCommand != null) {
- if(createdCommand.canExecute()) {
- getEditingDomain().getCommandStack().execute(createdCommand);
- manageCommandResult(createdCommand.getResult());
- } else {
- NotificationBuilder.createErrorPopup(Messages.PasteInTableHandler_ThePasteCommandCantBeExecuted);
- }
- } else {
- //an error occured during the command creation, nothing to do
- }
- //we don't use dialogs to do the paste
- } else if(returnCode == Window.CANCEL) {
- NotificationBuilder.createInfoPopup(Messages.PasteInTableHandler_PasteCancelled).run();
- }
- return null;
- }
-
- protected Object executeWithoutProgressMonitorDialog(final PapyrusTableInstance pTable, final String clipboardContents) {
- Command createdCommand;
- try {
- createdCommand = this.provider.getPasteFromFromStringCommand(pTable, null, null, clipboardContents, this.widget);
- } catch (ErrorInPastePreparationException e) {
- System.out.println(e.getMessage());
- return null;
- }
-
- getEditingDomain().getCommandStack().execute(createdCommand);
- manageCommandResult(createdCommand.getResult());
- return null;
- }
-
- /**
- *
- * @return
- * the current table editor, or <code>null</code> if not found
- */
- private AbstractNattableEditor getCurrentTableEditor() {
- /*
- final IStructuredSelection selection = (IStructuredSelection)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
- final Object current = selection.getFirstElement();
- if (current instanceof EObject) {
-
- IEditorPart part = null;
- try {
- part = ServiceUtilsForResource.getInstance().getNestedActiveIEditorPart(((EObject)current).eResource());
- } catch (final ServiceException e) {
- Activator.log.error(e);
- }
- if(part instanceof AbstractNattableEditor) {
- return (AbstractNattableEditor)part;
- }
-
- } else*/ {//there is not select when click on a gray part of the table
- IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
- if (part instanceof IMultiDiagramEditor) {
- part = ((IMultiDiagramEditor)part).getActiveEditor();
- }
- if (part instanceof AbstractNattableEditor) {
- return (AbstractNattableEditor)part;
- }
- }
- return null;
- }
-
- /**
- *
- * @return
- * the papyrus table
- */
- protected PapyrusTableInstance getPapyrusTable() {
- final IEditorPart part = getCurrentTableEditor();
- if(part != null) {
- return (PapyrusTableInstance)part.getAdapter(PapyrusTableInstance.class);
- }
- return null;
- }
-
- private INatTableWidget getITableWidget() {
- final IAdaptable editor = getCurrentTableEditor();
- if(editor != null) {
- final INatTableWidgetProvider provider = (INatTableWidgetProvider)editor.getAdapter(INatTableWidgetProvider.class);
- if(provider != null) {
- return provider.getNatTableWidget();
- }
- }
- return null;
- }
-
- /**
- *
- * @return
- * the clipboard contents used to build the command
- */
- private String getClipboardContents() {
- // examine system clipboard
- String bufferSystem = null;
-
- //using AWT
- /*
- final DataFlavor[] dataFlavors = Toolkit.getDefaultToolkit().getSystemClipboard().getAvailableDataFlavors();
- for(final DataFlavor dataFlavor : dataFlavors) {
- try {
- if(dataFlavor.isFlavorTextType() && dataFlavor.isMimeTypeEqual(DataFlavor.stringFlavor)) {
- bufferSystem = Toolkit.getDefaultToolkit().getSystemClipboard().getData(dataFlavor).toString();
- }
- } catch (final Exception e) {
- Activator.log.error(e);
- }
- }
- */
- java.awt.datatransfer.Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
- if (clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
- try {
- bufferSystem = clipboard.getData(DataFlavor.stringFlavor).toString();
- } catch (UnsupportedFlavorException e) {
- Activator.log.error(e);
- } catch (IOException e) {
- Activator.log.error(e);
- }
- }
- //using SWT
- // final Display display = Display.getCurrent();
- // final Clipboard cb = new Clipboard(display);
- // //we use the text transfert
- // final TextTransfer transfer = TextTransfer.getInstance();
- //
- // final Clipboard cb = new Clipboard(clipboard);
- // final String contents = (String)cb.getContents(transfer);
-
-
- return bufferSystem;
- }
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
- *
- * @return
- */
- @Override
- public boolean isEnabled() {
- return this.provider.isPasteEnabled(getPapyrusTable(), getClipboardContents(), getITableWidget());
- }
-
- /**
- *
- * @return
- * the editing domain to use to execute the command
- */
- private TransactionalEditingDomain getEditingDomain() {
- TransactionalEditingDomain domain = null;
- ServicesRegistry serviceRegistry = null;
- try {
- serviceRegistry = ServiceUtilsForActionHandlers.getInstance().getServiceRegistry();
- } catch (final ServiceException e) {
- Activator.log.error("ServicesRegistry not found", e); //$NON-NLS-1$
- }
- try {
- domain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
- } catch (final ServiceException e) {
- Activator.log.error("Editing Domain not found", e); //$NON-NLS-1$
- }
- return domain;
- }
-
- /**
- * allows to define if we want use dialog to prevent the user that the command creation and the command execution can take a long time
- *
- */
- public void setWithProgressMonitorDialog(final boolean useProgressMonitorDialog) {
- this.useProgressMonitorDialog = useProgressMonitorDialog;
- }
-
- private Collection<IStatus> getInterestingIStatus(final Collection<?> result) {
- final Collection<IStatus> status = new ArrayList<IStatus>();
- for(final Object current : result) {
- if(current instanceof IStatus) {
- status.add((IStatus)current);
- }
- }
- return status;
- }
-
- /**
- *
- * @param commandResult
- * the result of the executed command
- */
- private void manageCommandResult(final Collection<?> commandResult) {
- final Collection<IStatus> status = getInterestingIStatus(commandResult);
- for(IStatus iStatus : status) {
- final int severity = iStatus.getSeverity();
- if(severity == IStatus.ERROR || severity == IStatus.WARNING) {
- Activator.getDefault().getLog().log(iStatus);
- }
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/SelectAdditionColumnsPopupUpHandler.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/SelectAdditionColumnsPopupUpHandler.java
deleted file mode 100644
index 47f269c..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/SelectAdditionColumnsPopupUpHandler.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.handler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.TreeSet;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.facet.infra.facet.FacetStructuralFeature;
-import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidget;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.papyrus.infra.emf.utils.ENamedElementComparator;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.ProfileFacetSet;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypeFacet;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypePropertyElement;
-import org.eclipse.papyrus.uml.table.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Stereotype;
-
-
-public class SelectAdditionColumnsPopupUpHandler extends SelectColumnsHandler {
-
-
- private Collection<ETypedElement> newAdditionalContentsSelection;
-
-
- /**
- *
- * Constructor.
- *
- */
- public SelectAdditionColumnsPopupUpHandler() {
- final NatTableWidget widget = getTableWidget();
- final PapyrusTableInstance papyrusTable = getPapyrusTable();
- if(widget != null && papyrusTable != null) {
- super.initField(widget, papyrusTable);
- }
- }
-
- /**
- * Setter for the field newAdditionalContentsSelection
- *
- * @param newSelection
- */
- public void setNewSelectedAdditionalFeature(final Collection<ETypedElement> newSelection) {
- this.newAdditionalContentsSelection = newSelection;
- }
-
- /**
- *
- * @return
- * the list of the stereotype properties elements which can be used in the table
- */
- public final Collection<FacetStructuralFeature> getApplicableStereotypePropertyElements() {
- final PapyrusTableInstance pTable = getPapyrusTable();
- final Collection<ENamedElement> allFacetSets = new TreeSet<ENamedElement>(new ENamedElementComparator());
- allFacetSets.addAll(getFacetSetsUsedInTheTable());
- allFacetSets.addAll(getAllAdditionalContents());
-
-
- //1. get all applied stereotypes
- final Collection<Stereotype> stes = new HashSet<Stereotype>();
- for(final EObject current : pTable.getTable().getElements()) {
- if(current instanceof Element) {
- stes.addAll(((Element)current).getAppliedStereotypes());
- }
- }
-
- //2. get all extended stereotypes
- final Collection<Stereotype> allStereotypes = new HashSet<Stereotype>();
- for(final Stereotype current : stes) {
- allStereotypes.add(current);
- allStereotypes.addAll(StereotypeUtil.getAllSuperStereotypes(current));
- }
-
- //3. build the list of the qualified stereotype name
- final Collection<String> steQN = new TreeSet<String>();
- for(final Stereotype ste : stes) {
- steQN.add(ste.getQualifiedName());
- }
-
- //4. create the list of the possible features
- final Collection<FacetStructuralFeature> features = new ArrayList<FacetStructuralFeature>();
- for(final ENamedElement set : allFacetSets) {
- if(set instanceof ProfileFacetSet) {
- final TreeIterator<EObject> iter = set.eAllContents();
- while(iter.hasNext()) {
- final EObject current = iter.next();
- if(current instanceof StereotypeFacet) {
- final String QN = ((StereotypeFacet)current).getStereotypeQualifiedName();
- if(steQN.contains(QN)) {
- features.addAll(((StereotypeFacet)current).getStereotypePropertyElements());
- }
- }
- }
- }
- }
- return features;
- }
-
-
- /**
- *
- * @see org.eclipse.papyrus.uml.table.common.handler.SelectColumnsHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return
- * @throws ExecutionException
- */
- @Override
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- final TransactionalEditingDomain domain = getEditingDomain();
- final Command cmd = getCreateDestroyAdditonalFeatureColumnsCommand(getPapyrusTable(), getTableWidget(), this.newAdditionalContentsSelection);
- domain.getCommandStack().execute(cmd);
- return null;
- }
-
- /**
- * This method allows to contribute to a menu. Its adds check menu to show hide stereotypes properties columns
- *
- * @param manager
- * the menu manager
- */
- public void addContributionItems(final MenuManager manager) {
- IContributionItem item = new ContributionItem() {
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void fill(final Menu menu, int index) {
- final Collection<ETypedElement> initialSelection = getInitialAdditionalFeatureSelected();
- final Iterator<FacetStructuralFeature> iter = getApplicableStereotypePropertyElements().iterator();
- while(iter.hasNext()) {
- final StereotypePropertyElement el = (StereotypePropertyElement)iter.next();
-
- final MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
- menuItem.setText(el.getPropertyQualifiedName()); //$NON-NLS-1$
- if(initialSelection.contains(el)) {
- menuItem.setSelection(true);
- }
- menuItem.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(final SelectionEvent e) {
- final boolean toAdd = menuItem.getSelection();
- final Collection<ETypedElement> newSelection = new ArrayList<ETypedElement>();
- newSelection.addAll(initialSelection);
- if(toAdd) {
- newSelection.add((ETypedElement)el);
- } else {
- newSelection.remove(el);
- }
- setNewSelectedAdditionalFeature(newSelection);
- try {
- execute(new ExecutionEvent());
- } catch (final ExecutionException e1) {
- Activator.log.error(e1);
- }
- }
- });
- }
- boolean enabled = menu.getItemCount() != 0;
- menu.setEnabled(enabled);
- }
- };
-
- Menu menu = manager.getMenu();
- if(menu != null) {
- menu.setEnabled(false);
- }
- manager.add(item);
-
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/SelectColumnsHandler.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/SelectColumnsHandler.java
deleted file mode 100644
index 9a8ced5..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/handler/SelectColumnsHandler.java
+++ /dev/null
@@ -1,1038 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.handler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EStructuralFeature.Setting;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.emf.facet.infra.facet.Facet;
-import org.eclipse.emf.facet.infra.facet.FacetAttribute;
-import org.eclipse.emf.facet.infra.facet.FacetReference;
-import org.eclipse.emf.facet.infra.facet.FacetSet;
-import org.eclipse.emf.facet.infra.facet.FacetStructuralFeature;
-import org.eclipse.emf.facet.infra.query.ModelQuery;
-import org.eclipse.emf.facet.infra.query.ModelQuerySet;
-import org.eclipse.emf.facet.infra.query.QueryFactory;
-import org.eclipse.emf.facet.widgets.celleditors.ICommandFactoriesRegistry;
-import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory;
-import org.eclipse.emf.facet.widgets.nattable.INatTableWidgetProvider;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.AttributeColumn;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Column;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.DefaultLabelColumn;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.EContainerColumn;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.FacetAttributeColumn;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.FacetReferenceColumn;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.FeatureColumn;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.MetaClassColumn;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.ReferenceColumn;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstanceFactory;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableinstancePackage;
-import org.eclipse.emf.facet.widgets.nattable.internal.ColumnComparator;
-import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidget;
-import org.eclipse.emf.facet.widgets.nattable.internal.TableInstanceCommandFactory;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.emf.utils.ENamedElementComparator;
-import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
-import org.eclipse.papyrus.infra.table.common.editor.AbstractNattableEditor;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.ProfileFacetSet;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypeFacet;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypePropertyElement;
-import org.eclipse.papyrus.uml.profilefacet.utils.AdditionalContentsUtils;
-import org.eclipse.papyrus.uml.table.common.dialog.ColumnsToShowDialog;
-import org.eclipse.papyrus.uml.table.common.editor.AbstractUMLTableEditor;
-import org.eclipse.papyrus.uml.table.common.provider.AbstractAdditionalContentsProvider;
-import org.eclipse.papyrus.uml.table.common.provider.EMFFacetColumnsProvider;
-import org.eclipse.papyrus.uml.table.common.provider.ProfileFacetSetProvider;
-import org.eclipse.papyrus.uml.table.common.provider.SortedFeaturesContentProvider;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- *
- * Handler for the Show/Hide columns Papyrus version
- * A FacetSet called in this class AdditionContentsFacetSet is registered in the .notation. It is used to store created facet sets to display
- * additional columns
- *
- * FIXME : the show/hide additional contents should be tested
- * in the facetset AdditionContentsFacetSet :
- * - the facetset used by any table should be remove from it and destroyed
- * - the facetset created should be registered in it
- * - this facetset should be created if needed
- * - this facetset should be destroyed if it is not used
- * - facetset not used should be removed from the table#getFacetSets referencesS
- *
- */
-public class SelectColumnsHandler extends AbstractHandler {
-
- /** all direct features available in the table */
- final private SortedSet<ETypedElement> allDirectFeatures = new TreeSet<ETypedElement>(new ENamedElementComparator());
-
- /** all additional possible contents */
- final private Collection<FacetSet> allAdditionalContents = new HashSet<FacetSet>();
-
- /** the initial direct features visibles in the table */
- final private Collection<ETypedElement> initialDirectFeatureSelected = new HashSet<ETypedElement>();
-
- /** the initial additional features visibles in the table */
- final private Collection<ETypedElement> initialAdditionalFeatureSelected = new HashSet<ETypedElement>();
-
- /** the list of the facetSet used in the current table */
- final private Collection<FacetSet> facetSetsUsedInTheTable = new HashSet<FacetSet>();
-
- /** the map between existing columns (visible or not) and the feature */
- final private Map<ETypedElement, Column> columnsFeatureMap = new HashMap<ETypedElement, Column>();
-
- final private Map<Column, Boolean> defaultColumnsAndVisibility = new TreeMap<Column, Boolean>(new ColumnComparator());
-
- /**
- * clear the fields
- */
- protected void clearFields() {
- this.allDirectFeatures.clear();
- this.initialDirectFeatureSelected.clear();
- this.initialAdditionalFeatureSelected.clear();
- this.facetSetsUsedInTheTable.clear();
- this.columnsFeatureMap.clear();
- this.allAdditionalContents.clear();
- this.defaultColumnsAndVisibility.clear();
- // this.additionalContentProviders.clear();
- }
-
-
- private FacetSet getRootFacetSet(final EObject facetElement) {
-
- EObject container = facetElement;
- while(container.eContainer() != null) {
- container = container.eContainer();
- }
- if(container instanceof FacetSet) {
- return (FacetSet)container;
- }
-
- if(facetElement instanceof FacetStructuralFeature) {
- container = facetElement.eContainer().eContainer();
- }
- if(facetElement instanceof Facet) {
- container = facetElement.eContainer();
- }
- if(facetElement instanceof FacetSet) {
- container = facetElement;
- }
- assert container instanceof FacetSet;
- while(container.eContainer() != null && container.eContainer() instanceof FacetSet) {
- container = container.eContainer();
- }
-
- return (FacetSet)container;
- }
-
- /**
- * Inits the fields of this class
- *
- * @param widget
- * the table widget
- * @param papyrusTable
- * the papyrus table
- */
- protected void initField(final NatTableWidget widget, final PapyrusTableInstance papyrusTable) {
- clearFields();
- //the contents of the table
- final List<EObject> contents = papyrusTable.getTable().getElements();
-
- //1. Get all direct features
- for(final EObject current : contents) {
- this.allDirectFeatures.addAll(current.eClass().getEAllStructuralFeatures());
- }
-
- //2. we build the list of the initialSelection
- final List<Column> visibleColumns = widget.getVisibleColumns(false);
- final Set<ETypedElement> visibleFeatures = new HashSet<ETypedElement>();
- for(final Column current : visibleColumns) {
- if(current instanceof AttributeColumn) {
- this.initialDirectFeatureSelected.add(((AttributeColumn)current).getFeature());
- } else if(current instanceof ReferenceColumn) {
- this.initialDirectFeatureSelected.add(((ReferenceColumn)current).getFeature());
- } else if(current instanceof FacetAttributeColumn) {
- this.initialAdditionalFeatureSelected.add(((FacetAttributeColumn)current).getAttribute());
- } else if(current instanceof FacetReferenceColumn) {
- this.initialAdditionalFeatureSelected.add(((FacetReferenceColumn)current).getReference());
- }
- }
-
- //FIXME : query columns are not yet managed
- for(final Column current : papyrusTable.getTable().getColumns()) {
- if(current instanceof DefaultLabelColumn) {
- this.defaultColumnsAndVisibility.put(current, !current.isIsHidden());
- } else if(current instanceof MetaClassColumn) {
- this.defaultColumnsAndVisibility.put(current, !current.isIsHidden());
- } else if(current instanceof EContainerColumn) {
- this.defaultColumnsAndVisibility.put(current, !current.isIsHidden());
- }
- }
-
- for(final Column current : papyrusTable.getTable().getColumns()) {
- if(current instanceof FeatureColumn) { //FIXME and other columns ?
- final EStructuralFeature feature = ((FeatureColumn)current).getFeature();
- //3. we associate each features to each columns
- assert feature != null;
- this.columnsFeatureMap.put(feature, current);
-
- //3 bis. we build the list of the initialSelection
- if(feature instanceof FacetStructuralFeature) {
- final FacetSet set = getRootFacetSet(feature);
- this.facetSetsUsedInTheTable.add(set);
- }
- }
- }
-
- //4. get the additional features
- final EPackage additionalContentsPackageRoot = AdditionalContentsUtils.getAdditionalContentsEPackage(papyrusTable);
- if(additionalContentsPackageRoot != null) {
- final List<EPackage> sets = additionalContentsPackageRoot.getESubpackages();
- for(final EPackage ePackage : sets) {
- if(ePackage instanceof FacetSet) {
- this.allAdditionalContents.add((FacetSet)ePackage);
- }
- }
- }
- this.allAdditionalContents.addAll(this.facetSetsUsedInTheTable);
-
- AbstractAdditionalContentsProvider provider = new EMFFacetColumnsProvider();
- provider.setPapyrusTable(papyrusTable);
- this.allAdditionalContents.addAll(provider.getAdditionalFeatures());
-
- provider = new ProfileFacetSetProvider();
- provider.setPapyrusTable(papyrusTable);
- this.allAdditionalContents.addAll(provider.getAdditionalFeatures());
-
- }
-
- /**
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- *
- * @param event
- * @return
- * @throws ExecutionException
- */
- public Object execute(final ExecutionEvent event) throws ExecutionException {
-
- final CompoundCommand compoundCmd = new CompoundCommand("Papyrus Show/Hide columns command"); //$NON-NLS-1$
- final PapyrusTableInstance papyrusTable = getPapyrusTable();
- final NatTableWidget widget = getTableWidget();
- final TransactionalEditingDomain domain = getEditingDomain();
- if(papyrusTable != null && widget != null) {
- initField(widget, papyrusTable);
- final Collection<ETypedElement> initialSelection = new ArrayList<ETypedElement>();
- initialSelection.addAll(this.initialDirectFeatureSelected);
- initialSelection.addAll(this.initialAdditionalFeatureSelected);
- final Collection<ENamedElement> allFacetSets = new TreeSet<ENamedElement>(new ENamedElementComparator());
- allFacetSets.addAll(this.facetSetsUsedInTheTable);
- allFacetSets.addAll(this.allAdditionalContents);
-
- SortedFeaturesContentProvider contentProvider = new SortedFeaturesContentProvider();
- // contentProvider.setInitialSelection((Collection<?>)initialSelection);
- final ColumnsToShowDialog dialog = new ColumnsToShowDialog(Display.getCurrent().getActiveShell(), defaultColumnsAndVisibility, this.allDirectFeatures, allFacetSets, initialSelection, getLabelProvider(), contentProvider);
- if(dialog.open() == Window.OK) {
- final Object[] result = dialog.getResult();
- final Set<ETypedElement> directFeatures = (Set<ETypedElement>)result[0];
- final Set<ETypedElement> additionalFeatures = (Set<ETypedElement>)result[1];
-
- //0. update the visibility for the default columns
- for(final Column col : this.defaultColumnsAndVisibility.keySet()) {
- final Command cmd = SetCommand.create(getEditingDomain(), col, TableinstancePackage.eINSTANCE.getColumn_IsHidden(), !this.defaultColumnsAndVisibility.get(col));
- compoundCmd.append(cmd);
- }
-
-
- if(!directFeatures.equals(this.initialDirectFeatureSelected)) {
- //1. get command to show/hide direct features
- final Command cmd = getShowHideDirectFeatureColumnsCommand(papyrusTable, (NatTableWidget)widget, directFeatures);
- if(cmd != null) {
- compoundCmd.append(cmd);
- }
- }
-
- if(!additionalFeatures.equals(this.initialAdditionalFeatureSelected)) {
- // 2. get the command to show/hide additional contents
- final Command cmd2 = getCreateDestroyAdditonalFeatureColumnsCommand(papyrusTable, (NatTableWidget)widget, additionalFeatures);
- if(cmd2 != null) {
- compoundCmd.append(cmd2);
- }
- }
- if(!compoundCmd.isEmpty()) {
- domain.getCommandStack().execute(compoundCmd);
- }
-
- }
- }
- //we clear the fields
- clearFields();
- return null;
- }
-
-
- /**
- *
- * @param papyrusTable
- * the papyrus table
- * @param widget
- * the widget
- * @param selectedFeatures
- * the direct features selected
- * @return
- * the command to show/hide the required columns (we doesn't destroy columns, because EMF-Facet will cerate it, if they are required, for
- * the next added element in the table)
- */
- protected Command getShowHideDirectFeatureColumnsCommand(final PapyrusTableInstance papyrusTable, final NatTableWidget widget, final Collection<ETypedElement> selectedFeatures) {
- final CompoundCommand compoundCmd = new CompoundCommand("Show/Hide direct features command"); //$NON-NLS-1$
-
- //1. calculus of the columns to show/add
- final List<ETypedElement> featuresToAdd = new ArrayList<ETypedElement>(selectedFeatures);
- featuresToAdd.removeAll(this.initialDirectFeatureSelected);
- //these columns should be set To Visible OR created
-
- //2. calculus of the columns to hide
- final List<Object> directFeaturesToHide = new ArrayList<Object>(this.initialDirectFeatureSelected);
- directFeaturesToHide.removeAll(selectedFeatures);
-
- //these columns should be hidden
- final List<Column> columnsToHide = new ArrayList<Column>();
- for(final Object current : directFeaturesToHide) {
- final Column toHide = this.columnsFeatureMap.get(current);
- if(toHide != null) {
- columnsToHide.add(toHide);
- }
- }
-
- final List<Column> columnsToShow = new ArrayList<Column>();
-
- //not useful for direct features
- final List<ETypedElement> columnsToCreate = new ArrayList<ETypedElement>();
-
- for(final Object currentColumn : featuresToAdd) {
- if(this.columnsFeatureMap.containsKey(currentColumn)) {
- columnsToShow.add(this.columnsFeatureMap.get(currentColumn));
- } else {
- columnsToCreate.add((ETypedElement)currentColumn);
- }
- }
-
- final TransactionalEditingDomain domain = getEditingDomain();
-
- Command showHideColumnsCommand = TableInstanceCommandFactory.createShowHideColumnCommand(widget, columnsToShow, columnsToHide, false);
- if(showHideColumnsCommand != null && showHideColumnsCommand.canExecute()) {
- compoundCmd.append(showHideColumnsCommand);
- }
-
- //columns to create should always be null with direct features!
- assert columnsToCreate.isEmpty();
- if(!compoundCmd.isEmpty() && compoundCmd.canExecute()) {
- return compoundCmd;
- }
- return null;
-
- }
-
- /**
- *
- * - when the AddtionalContentsfacetSet is empty -> it should be removed from the resource
- * - when the AddtionalContentsfacetSet is not required by a table -> it should be remove of the facetSet referenced by the table
- * - when a subfacetset is required by any table -> it should be removed of the list of the subfacetset owned by the AddtionalContentsFacetSet
- *
- * /!\We assume that the facet used for columns are not used in the same time for others things!
- *
- *
- * This method is complex because, we should manage :
- * <ul>
- * <li>the new-selected facet feature used to create new columns</li>
- * <li>the non-selected facet feature used to remove new columns</li>
- * <li>the facets of the selected facet features to apply them to the table</li>
- * <li>the facets of the non-selected facet features to unapply them to the table</li>
- * <li>the facetset useful to store them in the additional contents EPcakge</li>
- * <li>the facetset useless to unstore them in the additional contents EPcakge</li>
- * <li>the creation/destruction of the additional contents EPackage</li>
- * </ul>
- *
- *
- *
- * @param papyrusTable
- * the papyrus table
- * @param widget
- * the widget
- * @param selectedAdditionalFeatures
- * the addtional features selected
- * @return
- * the command to create and destroy the required columns (can be <code>null</code>)
- * /!\ EMF-Facet allows to hide EMF-Facet columns, so if such column already exists but are not visible, we show them
- */
- protected Command getCreateDestroyAdditonalFeatureColumnsCommand(final PapyrusTableInstance papyrusTable, final NatTableWidget widget, final Collection<ETypedElement> selectedAdditionalFeatures) {
-
- final CompoundCommand compoundCmd = new CompoundCommand("Show/Hide additional features command"); //$NON-NLS-1$
- final ModelSet resourceSet = (ModelSet)papyrusTable.eResource().getResourceSet();
- final Resource notationResource = resourceSet.getAssociatedResource(papyrusTable.eResource(), NotationModel.NOTATION_FILE_EXTENSION);
- final TransactionalEditingDomain domain = getEditingDomain();
- EPackage additionFeatureRootEPackage = AdditionalContentsUtils.getAdditionalContentsEPackage(papyrusTable);
-
- //1. calculus of the columns to show/add
- //these columns should be set to visible or created
- final List<ETypedElement> featuresToAdd = new ArrayList<ETypedElement>(selectedAdditionalFeatures);
- featuresToAdd.removeAll(this.initialAdditionalFeatureSelected);
-
- //we should take into account that EMF-Facet allows to destroy AND hide columns, so some columns can already exists but are currently not visible
- final List<ETypedElement> columnsToCreate = new ArrayList<ETypedElement>();
- columnsToCreate.addAll(featuresToAdd);
- final List<Column> existingColumnsToShow = new ArrayList<Column>();
-
- final ListIterator<ETypedElement> iter = columnsToCreate.listIterator();
- while(iter.hasNext()) {
- final ETypedElement current = iter.next();
- if(this.columnsFeatureMap.containsKey(current)) {
- existingColumnsToShow.add(this.columnsFeatureMap.get(current));
- //the current column already exists, so we should not create it
- iter.remove();
- }
- }
-
- //2. calculus of the columns to hide/destroy
- final List<ETypedElement> additionalFeaturesToHide = new ArrayList<ETypedElement>(this.initialAdditionalFeatureSelected);
- additionalFeaturesToHide.removeAll(selectedAdditionalFeatures);
-
-
- //3. determine which subfacet and subfacetset for additional contents are useful
- final Set<FacetSet> requiredSubFacetSets = new HashSet<FacetSet>();
- final Set<Facet> requiredFacets = new HashSet<Facet>();
- final Set<FacetSet> requiredRootFacetSet = new HashSet<FacetSet>();
- for(final ETypedElement current : selectedAdditionalFeatures) {
- if(current instanceof FacetStructuralFeature) {
- final Facet facet = (Facet)current.eContainer();
- requiredFacets.add(facet);
- requiredSubFacetSets.add((FacetSet)facet.eContainer());
- requiredRootFacetSet.add(getRootFacetSet(current));
- }
- }
-
- //4. determine which subfacet set for additional contents should be added to the additionalcontents epackage
- final Collection<FacetSet> facetSetsToStore = getFacetSetToStore(requiredSubFacetSets);
-
-
- //5. determine which subfacetset for additional contents are not useful in the current table
- //5 bis. determine which subfacetset for additional contents are never used in the whole model.
- final Set<FacetSet> uselessRootFacetSetsInAllExistingTable = new HashSet<FacetSet>();
- final Set<FacetSet> uselessRootFacetSetsInCurrentTable = new HashSet<FacetSet>();
- if(additionFeatureRootEPackage != null) {
- for(final EPackage set : additionFeatureRootEPackage.getESubpackages()) {
- if(set instanceof FacetSet && !requiredRootFacetSet.contains(set)) {
- uselessRootFacetSetsInCurrentTable.add((FacetSet)set);
- final TreeIterator<EObject> it = set.eAllContents();
- boolean useless = true;
- while(it.hasNext() && useless) {
- final EObject value = it.next();
- if(value instanceof FacetStructuralFeature) {
- final ECrossReferenceAdapter eCrossReference = CrossReferenceAdapter.getCrossReferenceAdapter(papyrusTable.eResource().getResourceSet());
- final Collection<Setting> references = eCrossReference.getInverseReferences(value, false);
- final Iterator<Setting> settingIter = references.iterator();
- while(settingIter.hasNext() && useless) {
- final EObject ref = settingIter.next().getEObject();
- //TODO check with memory analyzer! because we can found existing columns with no resources and no container
- if(ref instanceof Column && ref.eContainer() != null && ref.eResource() != null) {
- useless = papyrusTable.getTable().getColumns().contains(ref);
- }
- }
- }
- }
- if(useless) {
- uselessRootFacetSetsInAllExistingTable.add((FacetSet)set);
- }
- }
- }
- }
-
- // 6.we calculate the new registered FacetSet for the addition contents facetset
- final Collection<FacetSet> newRegisteredRootFacetSetValue = new HashSet<FacetSet>();
- final Collection<FacetSet> oldRegisteredRootFacetSetValue = new HashSet<FacetSet>();
- if(additionFeatureRootEPackage != null) {
- for(final EPackage current : additionFeatureRootEPackage.getESubpackages()) {
- if(current instanceof FacetSet) {
- oldRegisteredRootFacetSetValue.add((FacetSet)current);
- }
- }
- }
- newRegisteredRootFacetSetValue.addAll(oldRegisteredRootFacetSetValue);
- newRegisteredRootFacetSetValue.addAll(facetSetsToStore);
- newRegisteredRootFacetSetValue.removeAll(uselessRootFacetSetsInAllExistingTable);
-
-
- // 7.store/unstore the generated facetsets used by columns
- if(additionFeatureRootEPackage == null && newRegisteredRootFacetSetValue.size() != 0) {
- additionFeatureRootEPackage = AdditionalContentsUtils.createAdditionalContentsEPackage();
- compoundCmd.append(addToResourceAdditionalContentsEPackage(domain, notationResource, additionFeatureRootEPackage));
- compoundCmd.append(storeProfileFacetSet(domain, notationResource, additionFeatureRootEPackage, facetSetsToStore));
- } else if(additionFeatureRootEPackage != null && !newRegisteredRootFacetSetValue.equals(oldRegisteredRootFacetSetValue)) {
- compoundCmd.append(storeProfileFacetSet(domain, notationResource, additionFeatureRootEPackage, facetSetsToStore));
- compoundCmd.append(unstoreProfileFacetSet(domain, notationResource, additionFeatureRootEPackage, uselessRootFacetSetsInAllExistingTable));
- }
-
-
- //8. get the command to create columns
- if(columnsToCreate.size() != 0) {
- final Command createColumns = createAddColumnsCommand(domain, papyrusTable, columnsToCreate);
- if(createColumns != null && createColumns.canExecute()) {
- compoundCmd.append(createColumns);
- }
- }
-
- //9. get the command to destroy columns (only if the AdditionContentsFacetSet continues to be referenced by the current table. If not, the columns will be automatically destroyed
- if(additionalFeaturesToHide.size() != 0) {//&& !removeAdditionalContentsFacetSetFromTheCurrentTable) {
- final Command removeColumns = createRemoveColumnsCommand(domain, papyrusTable, additionalFeaturesToHide);
- if(removeColumns != null && removeColumns.canExecute()) {
- compoundCmd.append(removeColumns);
- }
- }
-
-
- //10. if the addition contents epackage is useless, we destroy it
- if(newRegisteredRootFacetSetValue.size() == 0 && additionFeatureRootEPackage != null) {
- compoundCmd.append(removeFromNotationResourceAdditionalContentsEPackage(domain, notationResource, additionFeatureRootEPackage));
- }
-
-
- //11. we add the command to apply the required facet to the table
- final Collection<Facet> facetsToSetInTableContext = getFacetsToApplyOnTheTable(papyrusTable, requiredFacets);
- compoundCmd.append(updateFacetsAppliedToTheTable(domain, papyrusTable, facetsToSetInTableContext));//the selected facets
-
- if(!compoundCmd.isEmpty()) {
- return compoundCmd;
- }
- return null;
- }
-
- private Collection<Facet> getFacetsToApplyOnTheTable(final PapyrusTableInstance papyrusTable, final Collection<Facet> requiredFacets) {
- final Collection<Facet> facetsForOtherThings = getFacetUsedForOtherThingsThanColumns(papyrusTable);
- final Collection<Facet> facetsToSetInTableContext = new ArrayList<Facet>();
- facetsToSetInTableContext.addAll(facetsForOtherThings);
- facetsToSetInTableContext.addAll(requiredFacets);
- return facetsToSetInTableContext;
- }
-
- private Collection<FacetSet> getFacetSetToStore(Set<FacetSet> requiredSubFacetSets) {
- final Set<FacetSet> toAddToResource = new HashSet<FacetSet>();
- for(final FacetSet set : requiredSubFacetSets) {
- if(set.eResource() == null) {
- toAddToResource.add(getRootFacetSet(set));
- }
- }
- return toAddToResource;
- }
-
- private Collection<FacetSet> getAllOwnedFacetSet(final FacetSet set) {
- final Collection<FacetSet> coll = new ArrayList<FacetSet>();
- if(set instanceof ProfileFacetSet) {
- for(final ProfileFacetSet profileSet : ((ProfileFacetSet)set).getSubProfileFacetSet()) {
- coll.add(profileSet);
- coll.addAll(getAllOwnedFacetSet(profileSet));
- }
- }
- return coll;
- }
-
- private Collection<FacetSet> getOwnedFacetSets(EPackage additionFeatureRootFacetSet) {
- final Collection<FacetSet> ownedFacetSets = new ArrayList<FacetSet>();
- for(final EPackage pack : additionFeatureRootFacetSet.getESubpackages()) {
- if(pack instanceof FacetSet) {
- ownedFacetSets.add((FacetSet)pack);
- }
- }
- return ownedFacetSets;
- }
-
-
-
-
- /**
- *
- * @return
- * the editing domain used by this handler or <code>null</code> if not found
- */
- protected TransactionalEditingDomain getEditingDomain() {
- TransactionalEditingDomain domain = null;
- domain = TransactionUtil.getEditingDomain(getPapyrusTable());
- return domain;
- }
-
- /**
- *
- * @return
- * the current table editor, or <code>null</code> if not found
- */
- private AbstractNattableEditor getCurrentTableEditor() {
- IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
- if (part instanceof IMultiDiagramEditor) {
- part = ((IMultiDiagramEditor)part).getActiveEditor();
- }
- if (part instanceof AbstractNattableEditor) {
- return (AbstractNattableEditor)part;
- }
- return null;
- }
-
- /**
- *
- * @return
- * the papyrus table
- */
- protected PapyrusTableInstance getPapyrusTable() {
- final IEditorPart part = getCurrentTableEditor();
- if(part != null) {
- return (PapyrusTableInstance)part.getAdapter(PapyrusTableInstance.class);
- }
- return null;
- }
-
- /**
- *
- * @return
- * the table widget
- */
- protected NatTableWidget getTableWidget() {
- final IAdaptable editor = getCurrentTableEditor();
- if(editor != null) {
- final INatTableWidgetProvider provider = (INatTableWidgetProvider)editor.getAdapter(INatTableWidgetProvider.class);
- if(provider != null) {
- return (NatTableWidget)provider.getNatTableWidget();
- }
- }
- return null;
- }
-
- /**
- *
- * @return
- * the label provider by for the dialog
- */
- private ILabelProvider getLabelProvider() {
- final AdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
- final ILabelProvider labelProvider = new AdapterFactoryLabelProvider(factory);
- return labelProvider;
- }
-
-
-
- private Command createAddColumnsCommand(final TransactionalEditingDomain domain, final PapyrusTableInstance pTable, final Collection<ETypedElement> columnsToAdd) {
- final CompoundCommand cmd = new CompoundCommand("Create New Columns");
- final ICommandFactory factory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(domain);
- final int width = 100;
- for(final ETypedElement current : columnsToAdd) {
- if(current instanceof FacetAttribute) {
- FacetAttributeColumn col = TableinstanceFactory.eINSTANCE.createFacetAttributeColumn();
- col.setAttribute((FacetAttribute)current);
- col.setWidth(width);
- Command addCommand = factory.createAddCommand(domain, pTable.getTable(), TableinstancePackage.eINSTANCE.getTableInstance_Columns(), col);
- if(addCommand.canExecute()) {
- cmd.append(addCommand);
- }
- } else if(current instanceof FacetReference) {
- FacetReferenceColumn col = TableinstanceFactory.eINSTANCE.createFacetReferenceColumn();
- col.setReference((FacetReference)current);
- col.setWidth(width);
- Command addCommand = factory.createAddCommand(domain, pTable.getTable(), TableinstancePackage.eINSTANCE.getTableInstance_Columns(), col);
- if(addCommand.canExecute()) {
- cmd.append(addCommand);
- }
- }
- //FIXME : and others kind of columns?
- }
- if(cmd.canExecute()) {
- return cmd;
- }
- return null;
- }
-
- private Command createRemoveColumnsCommand(final TransactionalEditingDomain domain, final PapyrusTableInstance pTable, final Collection<ETypedElement> columnsToDestroy) {
- final CompoundCommand cmd = new CompoundCommand("Destroy existing Columns");
- final ICommandFactory factory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(domain);
- for(final ETypedElement current : columnsToDestroy) {
- if(current instanceof EStructuralFeature) {
- Column column = columnsFeatureMap.get(current);
- Command rmColumnCmd = factory.createRemoveCommand(domain, pTable.getTable(), TableinstancePackage.eINSTANCE.getTableInstance_Columns(), column);
- if(rmColumnCmd.canExecute()) {
- cmd.append(rmColumnCmd);
- }
- }
- }
- if(cmd.canExecute()) {
- return cmd;
- }
- return null;
- }
-
-
- /**
- *
- * @param papyrusTable
- * the papyrus table
- * @return
- * the collection of FacetSet which are not used for columns, but for other stuff
- */
- private Collection<Facet> getFacetUsedForOtherThingsThanColumns(final PapyrusTableInstance papyrusTable) {
- final Set<Facet> setForOtherThings = new HashSet<Facet>();
- for(final Facet current : papyrusTable.getTable().getFacets2()) {
- //setForOtherThings.add(getRootFacetSet(current));
- setForOtherThings.add(current);
- }
- for(final Column current : papyrusTable.getTable().getColumns()) {
- if(current instanceof FeatureColumn) {
- final ETypedElement element = ((FeatureColumn)current).getFeature();
- if(element instanceof FacetStructuralFeature) {
- setForOtherThings.remove(((FacetStructuralFeature)element).eContainer());
- }
- }
- }
- return setForOtherThings;
- }
-
- /**
- *
- * @param domain
- * the editing domain
- * @param res
- * a resource
- * @param pack
- * the package to remove from resource
- * @return
- * the command to remove the packge from the resource
- */
- public static final Command removeFromNotationResourceAdditionalContentsEPackage(final TransactionalEditingDomain domain, final Resource resource, final EPackage pack) {
- final ICommand removeFacetSet = new AbstractTransactionalCommand(domain, "Remove FacetSet from the resource", null) { //$NON-NLS-1$
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- resource.getContents().remove(pack);
- return CommandResult.newOKCommandResult();
- }
- };
- return new GMFtoEMFCommandWrapper(removeFacetSet);
- }
-
- /**
- *
- * @param domain
- * the editing domain
- * @param resource
- * the resource
- * @param ePackage
- * the package to add to the resource
- * @return
- * the command to add the package from the resource
- */
- public static final Command addToResourceAdditionalContentsEPackage(final TransactionalEditingDomain domain, final Resource resource, final EPackage ePackage) {
- final ICommand removeFacetSet = new AbstractTransactionalCommand(domain, "Add FacetSet from the resource", null) { //$NON-NLS-1$
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- resource.getContents().add(ePackage);
- return CommandResult.newOKCommandResult();
- }
- };
- return new GMFtoEMFCommandWrapper(removeFacetSet);
- }
-
- /**
- *
- * @param domain
- * the editing domain
- * @param resource
- * the resource
- * @param additionFeatureRootEPackage
- * the package container for the facetsets
- * @param newRegisteredSubFacetSet
- * the facetsets to register
- * @return
- * tehc command to register the facetset AND register their associated queries
- */
- public static final Command storeProfileFacetSet(final TransactionalEditingDomain domain, final Resource resource, final EPackage additionFeatureRootEPackage, final Collection<FacetSet> newRegisteredSubFacetSet) {
- final CompoundCommand cc = new CompoundCommand("Store Generated facetSet and Queries");
- final ModelSet modelSet = (ModelSet)resource.getResourceSet();
- final Resource notationResource = modelSet.getAssociatedResource(resource, NotationModel.NOTATION_FILE_EXTENSION);
- for(final FacetSet set : newRegisteredSubFacetSet) {
- final Collection<ModelQuery> queriesToSave = getAllUnregisteredQueries(set);
- if(!queriesToSave.isEmpty()) {
- final ModelQuerySet querySet = QueryFactory.eINSTANCE.createModelQuerySet();
- querySet.setName("QueriesFor_" + set.getName());
- querySet.setDescription(NLS.bind("Queries used by the generated facetset {0}", set.getName()));
- querySet.getAssociatedMetamodels().add(UMLPackage.eINSTANCE);
- querySet.getAssociatedMetamodels().add(EcorePackage.eINSTANCE);
- querySet.getQueries().addAll(queriesToSave);
- final ICommand addQuerySet = new AbstractTransactionalCommand(domain, "Add QuerySetToResource", null) { //$NON-NLS-1$
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- notationResource.getContents().add(querySet);
- return CommandResult.newOKCommandResult();
- }
- };
- cc.append(new GMFtoEMFCommandWrapper(addQuerySet));
- }
-
- }
-
- final ICommand cmd = new AbstractTransactionalCommand(domain, null, null) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- additionFeatureRootEPackage.getESubpackages().addAll(newRegisteredSubFacetSet);
- return CommandResult.newOKCommandResult();
- }
- };
- cc.append(new GMFtoEMFCommandWrapper(cmd));
- return cc;
- }
-
- /**
- *
- * @param eobject
- * an eobject
- * @return
- * the list of the unregistered queries referenced by the eobject
- */
- public static final Collection<ModelQuery> getAllUnregisteredQueries(final EObject eobject) {
- final Collection<ModelQuery> allQueries = getAllQueries(eobject);
- final Collection<ModelQuery> notYetRegistered = new ArrayList<ModelQuery>();
- for(ModelQuery modelQuery : allQueries) {
- if(modelQuery.eResource() == null) {
- notYetRegistered.add(modelQuery);
- }
- }
- return notYetRegistered;
- }
-
- /**
- *
- * @param eobject
- * an eobject
- * @return
- * the list owning all the queries referenced by the eobject
- */
- public static final Collection<ModelQuery> getAllQueries(final EObject eobject) {
- final Collection<ModelQuery> queries = new HashSet<ModelQuery>();
- if(eobject instanceof ProfileFacetSet) {
- for(final FacetSet set : ((ProfileFacetSet)eobject).getSubProfileFacetSet()) {
- queries.addAll(getAllQueries(set));
- }
- for(final Facet facet : ((ProfileFacetSet)eobject).getStereotypeFacets()) {
- queries.addAll(getAllQueries(facet));
- }
- } else if(eobject instanceof StereotypeFacet) {
- for(final StereotypePropertyElement feature : ((StereotypeFacet)eobject).getStereotypePropertyElements()) {
- queries.addAll(getAllQueries(feature));
- }
- queries.add(((StereotypeFacet)eobject).getConditionQuery());
- } else if(eobject instanceof FacetStructuralFeature) {
- final FacetStructuralFeature feature = (FacetStructuralFeature)eobject;
- final ModelQuery setQuery = feature.getSetQuery();
- final ModelQuery getQuery = feature.getValueQuery();
- if(setQuery != null) {
- queries.add(setQuery);
- }
- if(getQuery != null) {
- queries.add(getQuery);
- }
- }
- return queries;
- }
-
- /**
- *
- * @param domain
- * the domain
- * @param resource
- * the resource where the the epackage is stored
- * @param additionFeatureRootEPackage
- * the epackage owning the facetset
- * @param toRemove
- * the facetset to remove
- * @return
- * the command to remove the facetset from the epackage AND to remove the associated queries from the resource
- */
- public static final Command unstoreProfileFacetSet(final TransactionalEditingDomain domain, final Resource resource, final EPackage additionFeatureRootEPackage, final Collection<FacetSet> toRemove) {
- final CompoundCommand cc = new CompoundCommand("Unstore Generated facetSet and Queries");
-
- for(final FacetSet set : toRemove) {
- final Collection<ModelQuery> allQueries = getAllQueries(set);
- final Collection<ModelQuerySet> querySets = new ArrayList<ModelQuerySet>();
- for(final ModelQuery modelQuery : allQueries) {
- querySets.add(modelQuery.getModelQuerySet());
- final ICommand removeQuerySet = new AbstractTransactionalCommand(domain, "Add QuerySetToResource", null) { //$NON-NLS-1$
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- resource.getContents().removeAll(querySets);
- return CommandResult.newOKCommandResult();
- }
- };
- cc.append(new GMFtoEMFCommandWrapper(removeQuerySet));
- }
- }
-
-
- final ICommand cmd = new AbstractTransactionalCommand(domain, null, null) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- additionFeatureRootEPackage.getESubpackages().removeAll(toRemove);
- return CommandResult.newOKCommandResult();
- }
- };
- cc.append(new GMFtoEMFCommandWrapper(cmd));
-
- return cc;
- }
-
- /**
- *
- * @param domain
- * the editing domain
- * @param pTable
- * the papyrus table
- * @param facets
- * the facets to set to the table context
- * @return
- * // * the command to update (clear, then addAll) the facets referenced by the table
- */
- public static final Command updateFacetsAppliedToTheTable(final TransactionalEditingDomain domain, final PapyrusTableInstance pTable, final Collection<Facet> facets) {
- ICommand updateContext = new AbstractTransactionalCommand(domain, null, null) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- EList<Facet> currentFacets = pTable.getTable().getFacets2();
- currentFacets.clear();
- currentFacets.addAll(facets);
- return CommandResult.newOKCommandResult();
- }
- };
-
- return new GMFtoEMFCommandWrapper(updateContext);
- }
-
- @Override
- public boolean isEnabled() {
- if(getPapyrusTable() != null) {
- if(getCurrentTableEditor() instanceof AbstractUMLTableEditor) {
- return true;
- }
- }
- return false;
- }
-
-
-
- /**
- * @return the allDirectFeatures
- */
- public final SortedSet<ETypedElement> getAllDirectFeatures() {
- return allDirectFeatures;
- }
-
-
-
- /**
- * @return the allAdditionalContents
- */
- public final Collection<FacetSet> getAllAdditionalContents() {
- return allAdditionalContents;
- }
-
-
-
- /**
- * @return the initialDirectFeatureSelected
- */
- public final Collection<ETypedElement> getInitialDirectFeatureSelected() {
- return initialDirectFeatureSelected;
- }
-
-
-
- /**
- * @return the initialAdditionalFeatureSelected
- */
- public final Collection<ETypedElement> getInitialAdditionalFeatureSelected() {
- return initialAdditionalFeatureSelected;
- }
-
-
-
- /**
- * @return the facetSetsUsedInTheTable
- */
- public final Collection<FacetSet> getFacetSetsUsedInTheTable() {
- return facetSetsUsedInTheTable;
- }
-
-
-
- /**
- * @return the columnsFeatureMap
- */
- public final Map<ETypedElement, Column> getColumnsFeatureMap() {
- return columnsFeatureMap;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/listener/ApplyProfileTriggerListener.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/listener/ApplyProfileTriggerListener.java
deleted file mode 100644
index 1ce7d79..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/listener/ApplyProfileTriggerListener.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.listener;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.TriggerListener;
-import org.eclipse.uml2.uml.UMLPackage;
-
-/**
- *
- * This listener allows us to update the ProfileFacetSet when a profile has changes
- *
- */
-public class ApplyProfileTriggerListener extends TriggerListener {
-
- @Override
- protected Command trigger(TransactionalEditingDomain domain, Notification notification) {
- if(notification.getFeature() == UMLPackage.eINSTANCE.getProfileApplication_AppliedProfile()) {
- //TODO
- }
- return null;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/menu/ContributionFactory.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/menu/ContributionFactory.java
deleted file mode 100644
index 66f424f..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/menu/ContributionFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.menu;
-
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.papyrus.uml.table.common.handler.SelectAdditionColumnsPopupUpHandler;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.menus.ExtensionContributionFactory;
-import org.eclipse.ui.menus.IContributionRoot;
-import org.eclipse.ui.services.IServiceLocator;
-
-
-public class ContributionFactory extends ExtensionContributionFactory {
-
-
- /**
- *
- * {@inheritDoc}
- */
- public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
-
- final SelectAdditionColumnsPopupUpHandler handler = new SelectAdditionColumnsPopupUpHandler();
- if(handler.isEnabled()) {
- MenuManager manager = new MenuManager("Select Additional Columns") {
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void fill(Menu parent, int index) {
- super.fill(parent, index);
- getMenu().getParentItem().setEnabled(true);
- //FIXME : set the image
- //Image image = Activator.getImage("IMG_OBJ_ADD"); //$NON-NLS-1$
- //getMenu().getParentItem().setImage(image);
- }
-
-
- };
-
- manager.setVisible(true);
-
- //we delegate to the handler the menu item creation and their management
- handler.addContributionItems(manager);
-
- Expression visibleWhen = new Expression() {
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public EvaluationResult evaluate(IEvaluationContext context) throws CoreException {
- return EvaluationResult.TRUE;
- }
- };
-
- additions.addContributionItem(manager, visibleWhen);
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/messages/Messages.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/messages/Messages.java
deleted file mode 100644
index 42eb095..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/messages/Messages.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.messages;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.papyrus.uml.table.common.messages.messages"; //$NON-NLS-1$
-
- public static String AbstractUMLTableEFacetEditor_UMLTableCreationErrorMessage;
-
- public static String ColumnsToShowDialog_AdditionalFeatures;
-
- public static String ColumnsToShowDialog_AdvancedMode;
-
- public static String ColumnsToShowDialog_default_columns;
-
- public static String ColumnsToShowDialog_DeselectAll;
-
- public static String ColumnsToShowDialog_DeselectAllAvailableAdditionalFeatures;
-
- public static String ColumnsToShowDialog_DeselecteAllAvailableFeatures;
-
- public static String ColumnsToShowDialog_DeselectedAll;
-
- public static String ColumnsToShowDialog_DirectFeatures;
-
- public static String ColumnsToShowDialog_SelecColumnsToShow;
-
- public static String ColumnsToShowDialog_SelectAll;
-
- public static String ColumnsToShowDialog_SelectAllAvailableAdditionalFeatures;
-
- public static String ColumnsToShowDialog_SelectAllAvailablesFeatures;
-
- public static String ColumnsToShowDialog_ShowAllPossibilities;
-
- public static String PasteInPapyrusTableCommandProvider_0;
-
- public static String PasteInPapyrusTableCommandProvider_1;
-
- public static String PasteInPapyrusTableCommandProvider_2;
-
- public static String PasteInPapyrusTableCommandProvider_3;
- public static String PasteInPapyrusTableCommandProvider_Pasting;
-
- public static String PasteInPapyrusTableCommandProvider_PastingInTable;
-
- public static String PasteInPapyrusTableCommandProvider_ProblemsToSetPropertyValue;
-
- public static String PasteInPapyrusTableCommandProvider_ProblemToApplyStereotype;
-
- public static String PasteInPapyrusTableCommandProvider_ProblemToSetStereotypeValue;
-
- public static String PasteInPapyrusTableCommandProvider_RequiredStereotypeCantBeFound;
-
- public static String PasteInPapyrusTableCommandProvider_RequiredStereotypeNotApplied;
-
- public static String PasteInPapyrusTableCommandProvider_StereotypePropertyCantBeResolved;
-
- public static String PasteInPapyrusTableCommandProvider_TheEnumerationLiteralCantBeFound;
-
- public static String PasteInPapyrusTableCommandProvider_TheStereotypeCantBeApplied;
-
- public static String PasteInPapyrusTableCommandProvider_TheTextCantBeMappedOnAnExistingElement;
- public static String PasteInTableHandler_PasteCancelled;
-
- public static String PasteInTableHandler_PasteCreation;
-
- public static String PasteInTableHandler_ThePasteCommandCantBeExecuted;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/messages/messages.properties b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/messages/messages.properties
deleted file mode 100644
index 957725b..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/messages/messages.properties
+++ /dev/null
@@ -1,32 +0,0 @@
-AbstractUMLTableEFacetEditor_UMLTableCreationErrorMessage=A UML Table can't be created with a non-UML element as context ({0})
-ColumnsToShowDialog_AdditionalFeatures=Additional Features
-ColumnsToShowDialog_AdvancedMode=Advanced Mode
-ColumnsToShowDialog_default_columns=Default Columns
-ColumnsToShowDialog_DeselectAll=Deselect All
-ColumnsToShowDialog_DeselectAllAvailableAdditionalFeatures=Deselect all available additional features.
-ColumnsToShowDialog_DeselecteAllAvailableFeatures=Deselect all available features.
-ColumnsToShowDialog_DeselectedAll=Deselect All
-ColumnsToShowDialog_DirectFeatures=Direct Features
-ColumnsToShowDialog_SelecColumnsToShow=Select the columns to show
-ColumnsToShowDialog_SelectAll=Select All
-ColumnsToShowDialog_SelectAllAvailableAdditionalFeatures=Select all available additional features.
-ColumnsToShowDialog_SelectAllAvailablesFeatures=Select all available features.
-ColumnsToShowDialog_ShowAllPossibilities=Show all possibilities
-PasteInPapyrusTableCommandProvider_0=The String {0} is not valid to create a {1}.
-PasteInPapyrusTableCommandProvider_1=Paste Command In FlowPort Table
-PasteInPapyrusTableCommandProvider_2=Create Paste Action
-PasteInPapyrusTableCommandProvider_3=Launch Progress Monitor Dialog
-PasteInPapyrusTableCommandProvider_Pasting=Pasting
-PasteInPapyrusTableCommandProvider_PastingInTable=Pasting in Table
-PasteInPapyrusTableCommandProvider_ProblemsToSetPropertyValue=Problems to set properties value
-PasteInPapyrusTableCommandProvider_ProblemToApplyStereotype=Problems to apply stereotype
-PasteInPapyrusTableCommandProvider_ProblemToSetStereotypeValue=Problems to set stereotype properties value
-PasteInPapyrusTableCommandProvider_RequiredStereotypeCantBeFound=Stereotype {0} required by the column can' be found
-PasteInPapyrusTableCommandProvider_RequiredStereotypeNotApplied=The required stereotype {0} is not applied on the element {1}.
-PasteInPapyrusTableCommandProvider_StereotypePropertyCantBeResolved=The stereotype property called by {0} can't be resolved
-PasteInPapyrusTableCommandProvider_TheEnumerationLiteralCantBeFound=The enumeration literal {0} can't be found
-PasteInPapyrusTableCommandProvider_TheStereotypeCantBeApplied=The stereotype {0} can' be applied on {1}
-PasteInPapyrusTableCommandProvider_TheTextCantBeMappedOnAnExistingElement=The text {0} can't be mapped to an existing element
-PasteInTableHandler_PasteCancelled=Paste Action Canceled
-PasteInTableHandler_PasteCreation=Paste creation...
-PasteInTableHandler_ThePasteCommandCantBeExecuted=The paste command can't be executed
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/AbstractAdditionalContentsProvider.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/AbstractAdditionalContentsProvider.java
deleted file mode 100644
index d5b5d47..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/AbstractAdditionalContentsProvider.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.provider;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.facet.infra.facet.FacetSet;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.infra.table.instance.util.TableContentsUtils;
-
-
-/**
- *
- * This class is used for additional contents providers
- *
- */
-public abstract class AbstractAdditionalContentsProvider {
-
- /**
- * The managed Papyrus Table
- */
- protected PapyrusTableInstance pTable;
-
- /**
- * the contents of the table
- */
- protected Collection<EObject> tableContents;
-
- /**
- *
- * the managed Papyrus Table
- */
- public void setPapyrusTable(final PapyrusTableInstance table) {
- this.pTable = table;
- this.tableContents = TableContentsUtils.getTableContents(table, table.getTable().getContext(), false);
- }
-
- /**
- *
- * @return
- * the available facet set to display additional contents/columns
- */
- public abstract Collection<FacetSet> getAdditionalFeatures();
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/AbstractPasteInTableCommandProvider.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/AbstractPasteInTableCommandProvider.java
deleted file mode 100644
index 9db7cde..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/AbstractPasteInTableCommandProvider.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.provider;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.facet.widgets.nattable.INatTableWidget;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Column;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
-import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidget;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.uml.table.common.Activator;
-
-
-
-/**
- *
- * Abstract class for PasteInTableCommandProvider
- *
- */
-public abstract class AbstractPasteInTableCommandProvider implements IPasteInTableCommandProvider {
-
- //FIXME : we can't get the visible command when a dialog is open during the command creation
- protected List<Column> visibleColumns;
-
- /**
- * the error message for the command
- */
- protected String pasteErrorMessage = null;
-
-
- /**
- *
- * @see org.eclipse.papyrus.uml.table.efacet.common.provider.sysml.table.efacet.flowport.provider.internal.provider.IPasteInTableCommandProvider#getPasteErrorMessage()
- *
- * @return
- */
- public final String getPasteErrorMessage() {
- return this.pasteErrorMessage;
- }
-
- /**
- *
- * @param papyrusTable
- * the papyrus table
- * @return
- * the editing domain to use for the PapyrusTable
- */
- protected TransactionalEditingDomain getEditingDomain(final PapyrusTableInstance papyrusTable) {
- TransactionalEditingDomain domain = null;
- ServicesRegistry serviceRegistry = null;
- try {
- serviceRegistry = ServiceUtilsForResource.getInstance().getServiceRegistry(papyrusTable.eResource());
- } catch (final ServiceException e) {
- Activator.log.error("ServicesRegistry not found", e); //$NON-NLS-1$
- }
- try {
- domain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
- } catch (final ServiceException e) {
- Activator.log.error("EdtingDomain not found", e); //$NON-NLS-1$
- }
- return domain;
- }
-
- /**
- *
- * @param papyrusTable
- * the papyrus table
- * @return
- * the containement feature for the created element
- */
- protected EReference getContainementFeature(final PapyrusTableInstance papyrusTable) {
- return papyrusTable.getPastedElementContainmentFeature();
- }
-
- /**
- *
- * @param clipboardContents
- * @see org.eclipse.papyrus.infra.table.efacet.common.editor.AbstractTableEditor#isPasteEnabled(java.lang.String)
- *
- * @return
- */
- public boolean isPasteEnabled(final PapyrusTableInstance papyrusTable, final String clipboardContents, final INatTableWidget iTableWidget) {
- if((clipboardContents != null) && !"".equals(clipboardContents)) { //$NON-NLS-1$
- final String[] rows = getRows(clipboardContents);
- if(rows != null && rows.length != 0) {
- final String[] cells = getCells(rows[0]);
-
- /*
- * we verify that we know :
- * - the type to create
- * - the containment feature for the created type
- * - the correct number of cells according to the number of managed columns for the paste
- * - we don't do other test, because we need to provide error message to the user when the paste is not possible
- */
- if((getIElementTypeToCreateElement(papyrusTable) != null) && (getContainementFeature(papyrusTable) != null) && (cells.length == getVisibleColumns(iTableWidget).size())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- *
- * @param table
- * a table represented by a String
- * @return the rows for this table
- */
- protected String[] getRows(final String table) {
- final String[] rows = table.split(ROW_SEPARATOR);
- return rows;
- }
-
- /**
- *
- * @param row
- * a row represented by a String
- * @return the cells for this row
- */
- protected String[] getCells(final String row) {
- return row.split(COLUMN_SEPARATOR);
- }
-
- /**
- *
- * @param pTable
- * the papyrus table
- * @return
- * the type of element to create for a paste action
- */
- protected IElementType getIElementTypeToCreateElement(final PapyrusTableInstance pTable) {
- final String id = pTable.getPastedElementId();
- return ElementTypeRegistry.getInstance().getType(id);
- }
-
-
- /**
- *
- * @param widget
- * the table widget
- * @return
- * the visible columns for the widget
- */
- protected List<Column> getVisibleColumns(final INatTableWidget widget) {
- return ((NatTableWidget)widget).getVisibleColumnsUsingCustomizationEngine((TableInstance2)widget.getTableInstance());
- }
-
- /**
- *
- * @param iTableWidget
- * the table widget
- * @return
- * the list of the managed features
- */
- /*
- protected List<EStructuralFeature> getManagedFeatures(final INatTableWidget iTableWidget) {
- final List<EStructuralFeature> features = new ArrayList<EStructuralFeature>();
- // for(final Column col : getManagedColumns(iTableWidget)) {
- for(final Column col : visibleColumns) {
- features.add((EStructuralFeature)((FeatureColumn)col).getFeature());
- }
- return features;
- }
-
- protected abstract Collection<Column> getManagedColumns(INatTableWidget iTableWidget);
- */
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/EMFFacetColumnsProvider.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/EMFFacetColumnsProvider.java
deleted file mode 100644
index 6486489..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/EMFFacetColumnsProvider.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.provider;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.facet.infra.facet.Facet;
-import org.eclipse.emf.facet.infra.facet.FacetSet;
-import org.eclipse.emf.facet.infra.facet.core.FacetSetCatalog;
-
-
-/**
- *
- * This providers provides the list of the registered FacetSet available to display new columns in the table
- *
- */
-public class EMFFacetColumnsProvider extends AbstractAdditionalContentsProvider {
-
- @Override
- public Collection<FacetSet> getAdditionalFeatures() {
- final HashSet<FacetSet> availableFacetSets = new HashSet<FacetSet>();
- availableFacetSets.addAll(FacetSetCatalog.getSingleton().getAllFacetSets());
- if(pTable.getTable().getTableConfiguration() != null) {
- //FIXME
-// for(Facet facet : pTable.getTable().getTableConfiguration().getDefaultFacets()) {
-// availableFacetSets.add(FacetUtils.getRootFacetSet(facet));
-// }
- }
- for(Facet facet : pTable.getTable().getFacets2()) {
- availableFacetSets.add(getRootFacetSet(facet));
- }
- return availableFacetSets;
- }
-
- private FacetSet getRootFacetSet(final Facet facet){
- final EObject container = facet.eContainer();
- assert container instanceof FacetSet;
- return getRootFacetSet((FacetSet)container);
- }
-
- private FacetSet getRootFacetSet(final FacetSet set){
- final EObject container = set.eContainer();
- if(container!=null){
- if(container instanceof FacetSet){
- return getRootFacetSet((FacetSet)container);
- }else{
- return set;
- }
- }
- return set;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/IPasteInTableCommandProvider.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/IPasteInTableCommandProvider.java
deleted file mode 100644
index c32b98e..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/IPasteInTableCommandProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.provider;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.facet.widgets.nattable.INatTableWidget;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.papyrus.infra.table.common.exceptions.ErrorInPastePreparationException;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-
-/**
- *
- * Interface for paste in table command provider
- *
- */
-public interface IPasteInTableCommandProvider {
-
- /**
- * row separator in the clipboard contents
- */
- public static final String ROW_SEPARATOR = "\n"; //$NON-NLS-1$
-
- /**
- * column separator in the clipboard contents
- */
- public static final String COLUMN_SEPARATOR = "\t"; //$NON-NLS-1$
-
- /**
- * the separator used for multivalue
- */
- public static final String MULTI_VALUE_SEPARATOR = ","; //$NON-NLS-1$
-
- /**
- *
- * @param table
- * the table where the clipboard contents is pasted
- * @param commandCreationCancelProvider
- * a progress monitor enabled to provide a cancel during the command creation (can be <code>null</code>)
- * @param commandExecutionProgressMonitor
- * the progress monitor used during the command execution (can be <code>null</code>)
- * @param clipboardContents
- * the clipboard contents
- *
- * @return
- * the command to create the paste in the table command
- * @throws ErrorInPastePreparationException
- */
- public Command getPasteFromFromStringCommand(final PapyrusTableInstance table, final IProgressMonitor commandCreationCancelProvider, final ProgressMonitorDialog commandExecutionProgressMonitor, final String clipboardContents, INatTableWidget iTableWidget) throws ErrorInPastePreparationException;
-
- /**
- *
- * @param papyrusTable
- * the paste table where the paste is done
- * @param clipboardContents
- * the clipboard contents
- * @param iTableWidget
- * the nattable widget
- * @return
- * <code>true</code> if the paste is allowed in the table
- */
- public boolean isPasteEnabled(final PapyrusTableInstance papyrusTable, final String clipboardContents, final INatTableWidget iTableWidget);
-
- /**
- *
- * @return
- * a string represented an error message. This message will be displayed to the user
- */
- public String getPasteErrorMessage();
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/PasteInPapyrusTableCommandProvider.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/PasteInPapyrusTableCommandProvider.java
deleted file mode 100644
index 2e41ae2..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/PasteInPapyrusTableCommandProvider.java
+++ /dev/null
@@ -1,720 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.provider;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.facet.widgets.nattable.INatTableWidget;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.Column;
-import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.FeatureColumn;
-import org.eclipse.emf.facet.widgets.nattable.internal.NatTableWidget;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
-import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
-import org.eclipse.papyrus.infra.table.common.exceptions.ErrorInPastePreparationException;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.infra.tools.util.BooleanHelper;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypeFacet;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypePropertyElement;
-import org.eclipse.papyrus.uml.profilefacet.utils.StereotypePropertyUtils;
-import org.eclipse.papyrus.uml.table.common.factory.PapyrusTableInstanceCommandFactory;
-import org.eclipse.papyrus.uml.table.common.messages.Messages;
-import org.eclipse.papyrus.uml.table.common.status.PasteWarningStatus;
-import org.eclipse.papyrus.uml.table.common.status.StereotypeApplicationErrorStatus;
-import org.eclipse.papyrus.uml.table.common.status.UnresolvedReferenceErrorInPasteStatus;
-import org.eclipse.papyrus.uml.table.common.utils.MultiValueContainer;
-import org.eclipse.papyrus.uml.table.common.utils.ValueContainer;
-import org.eclipse.papyrus.uml.tools.utils.NameResolutionHelper;
-import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
-import org.eclipse.uml2.uml.DataType;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Enumeration;
-import org.eclipse.uml2.uml.EnumerationLiteral;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.PrimitiveType;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLPackage;
-
-
-/**
- *
- * This class allows to get the paste command for the FlowPortTable.
- * This paste used the visible columns to execute the paste action.
- * The columns representing direct features AND stereotype properties are used. Ohters visible columns (like self) are ignored.
- *
- *
- */
-public class PasteInPapyrusTableCommandProvider extends AbstractPasteInTableCommandProvider {
-
- /** the string used for UML boolean */
- private static final String UML_BOOLEAN = "Boolean"; //$NON-NLS-1$
-
- /** the string used for UML integer */
- private static final String UML_INTEGER = "Integer"; //$NON-NLS-1$
-
- /** the string used for UML string */
- private static final String UML_STRING = "String"; //$NON-NLS-1$
-
- /** the string used for uml real */
- private static final String UML_REAL = "Real"; //$NON-NLS-1$
-
- /** the string used for uml unlimited natural */
- private static final String UML_UNLIMITED_NATURAL = "UnlimitedNatural"; //$NON-NLS-1$
-
-
-
- private static final int MIN_ROWS_FOR_PROGRESS_MONITOR = 5;
-
- private static final String TYPE_FORMAT_ERROR_MESSAGE = Messages.PasteInPapyrusTableCommandProvider_0;
-
- /**
- * this map associates EClass to their nameResolutionHelper
- */
- final protected Map<EClass, NameResolutionHelper> nameResolutionHelpers = new HashMap<EClass, NameResolutionHelper>();
-
- /** this map associates profile qualified name, with name resolution helper */
- final protected Map<String, NameResolutionHelper> stereotypesHelper = new HashMap<String, NameResolutionHelper>();
-
- final protected Map<StereotypePropertyElement, Property> stereotypePropertiesMap = new HashMap<StereotypePropertyElement, Property>();
-
- public Command getPasteFromFromStringCommand(final PapyrusTableInstance papyrusTable, final IProgressMonitor commandCreationCancelProvider, final ProgressMonitorDialog commandExecutionProgressMonitor, final String clipboardContents, final INatTableWidget iTableWidget) throws ErrorInPastePreparationException {
- final CompoundCommand cmd = new CompoundCommand(Messages.PasteInPapyrusTableCommandProvider_1);
- final TransactionalEditingDomain editingDomain = getEditingDomain(papyrusTable);
- final Element tableContext = (Element)papyrusTable.getTable().getContext();
-
- //0. we reset the paste error message
- this.pasteErrorMessage = null;
-
- //1. we clear the map of the NameResolutionHelpers
- this.nameResolutionHelpers.clear();
- this.stereotypesHelper.clear();
- this.stereotypePropertiesMap.clear();
- final Collection<Stereotype> stereotypeToApply = getStereotypesToApply(papyrusTable, iTableWidget);
-
- //3. we get the managed features
- //final List<EStructuralFeature> features = getManagedFeatures(iTableWidget);
-
- //4. we determine if we should add a command to add the pasted elements in the table
- // final boolean addToTable = FillMode.USER == papyrusTable.getFillMode();
- //FIXME
- final boolean addToTable = true;
- //5. get the rows to create
- final String[] rows = getRows(clipboardContents);
-
- //6. this list will be used to add the created elements to the table
- final List<ICommand> createCommands = new ArrayList<ICommand>();
-
- //7. we launch the dialog used for the command creation
- if(commandCreationCancelProvider != null) {
- commandCreationCancelProvider.beginTask(Messages.PasteInPapyrusTableCommandProvider_2, rows.length + 1);
- }
-
- //8. we build the command itself
- final boolean useDialog = (commandExecutionProgressMonitor != null) && (rows.length > MIN_ROWS_FOR_PROGRESS_MONITOR);
- //8.1 create the command to open the progress monitor dialog during the command execution
- if(useDialog) {
- final AbstractTransactionalCommand beginMonitor = new AbstractTransactionalCommand(editingDomain, Messages.PasteInPapyrusTableCommandProvider_3, Collections.emptyList()) {
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- commandExecutionProgressMonitor.open();
- commandExecutionProgressMonitor.getProgressMonitor().setTaskName(Messages.PasteInPapyrusTableCommandProvider_PastingInTable);
- commandExecutionProgressMonitor.getProgressMonitor().beginTask(Messages.PasteInPapyrusTableCommandProvider_PastingInTable, rows.length);
- return CommandResult.newOKCommandResult();
- }
- };
- cmd.append(new GMFtoEMFCommandWrapper(beginMonitor));
- }
-
-
- //8.2 we iterate on the rows
- for(final String row : rows) {
- if(useDialog) {
- commandCreationCancelProvider.worked(1);
- }
- if((commandCreationCancelProvider != null) && commandCreationCancelProvider.isCanceled()) {
- //the user click on the cancel button
- return null;
- }
-
- //8.3 we get the string values of the cells
- final String[] cells = getCells(row);
-
- //8.4 we get the containement feature for the created object
- final EReference containementfeature = getContainementFeature(papyrusTable);
-
- //8.4 bis : update the paste execution dialog
- if(useDialog) {
- final ICommand dialogCommand = new AbstractTransactionalCommand(editingDomain, null, null) {
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- commandExecutionProgressMonitor.getProgressMonitor().subTask(Messages.PasteInPapyrusTableCommandProvider_Pasting + row);
- return CommandResult.newOKCommandResult();
- }
- };
- cmd.append(new GMFtoEMFCommandWrapper(dialogCommand));
- }
-
- //8.5 we create the element itself
- //FIXME : we ignore the case where an element with the same name and type already exists
- final CreateElementRequest createRequest = new CreateElementRequest(editingDomain, tableContext, getIElementTypeToCreateElement(papyrusTable), containementfeature);
- final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(tableContext);
- final ICommand commandCreation = provider.getEditCommand(createRequest);
- createCommands.add(commandCreation);
- cmd.append(new GMFtoEMFCommandWrapper(commandCreation));
-
- //8.6 we apply the required stereotypes on it
- if(stereotypeToApply.size() != 0) {
- final ICommand applyStereotypesCmd = new AbstractTransactionalCommand(editingDomain, "Apply Required Stereotype", null) { //$NON-NLS-1$
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- final Element el = (Element)commandCreation.getCommandResult().getReturnValue();
- final PasteWarningStatus rootStatus = new PasteWarningStatus(Messages.PasteInPapyrusTableCommandProvider_ProblemToApplyStereotype, el);
- for(final Stereotype ste : stereotypeToApply) {
- if(el.getApplicableStereotype(ste.getQualifiedName()) == null) {
- final IStatus status = new StereotypeApplicationErrorStatus(NLS.bind(Messages.PasteInPapyrusTableCommandProvider_TheStereotypeCantBeApplied, ste.getQualifiedName(), el), el, ste.getQualifiedName());
- rootStatus.addChildren(status);
- }
- if(el.getAppliedStereotype(ste.getQualifiedName()) == null) {
- el.applyStereotype(ste);
- }
- }
- if(rootStatus.isMultiStatus()) {
- return new CommandResult(rootStatus, rootStatus);
- }
- return CommandResult.newOKCommandResult();
- }
- };
- cmd.append(new GMFtoEMFCommandWrapper(applyStereotypesCmd));
- }
-
- //8.7 we set these properties values
- for(int i = 0; i < java.lang.Math.min(cells.length, visibleColumns.size()); i++) {
- Column column = visibleColumns.get(i);
- if (!(column instanceof FeatureColumn)) continue;
- final EStructuralFeature feature = ((FeatureColumn)column).getFeature();
- if(feature.isChangeable()) {
- final String valueAsString = cells[i];
-
- if(valueAsString != null && !"".equals(valueAsString) && !"null".equals(valueAsString)) { //$NON-NLS-1$ //$NON-NLS-2$
- final ValueContainer<?> realValue = deduceValueFromString((Namespace)tableContext, feature, valueAsString);
-
- if(realValue != null) {
- //it is a property of stereotype
- if(feature instanceof StereotypePropertyElement) {
- final String steQN = ((StereotypeFacet)feature.eContainer()).getStereotypeQualifiedName();
- final String propertyQN = ((StereotypePropertyElement)feature).getPropertyQualifiedName();
- final String propertyName = NamedElementUtil.getNameFromQualifiedName(propertyQN);
-
- final String cmdName = NLS.bind("Set value for the property {0} of the stereotype {1}.", new String[]{ propertyName, steQN }); //$NON-NLS-1$
- final ICommand setStereotypePropertyValue = new AbstractTransactionalCommand(editingDomain, cmdName, null) {
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- //FIXME : streotype inheritance not managed
- final Element createdElement = (Element)commandCreation.getCommandResult().getReturnValue();
- final Stereotype stereotype = createdElement.getAppliedStereotype(steQN);
- final Object valueToSet = realValue.getValue();
- if(stereotype == null) {
- final IStatus status = new StereotypeApplicationErrorStatus(NLS.bind("The required stereotype {0} is not applied on the element", steQN), createdElement, steQN);
- return CommandResult.newOKCommandResult(status);//FIXME : OK command result ?
- }
- createdElement.setValue(stereotype, propertyName, valueToSet);
- return CommandResult.newOKCommandResult(realValue.getStatus(createdElement));
- }
- };
-
- cmd.append(new GMFtoEMFCommandWrapper(setStereotypePropertyValue));
- } else {//it is a direct feature
- final String label = NLS.bind("Set the value for the feature {0}.", feature.getName()); //$NON-NLS-1$
- final ICommand setValueCommand = new AbstractTransactionalCommand(editingDomain, label, null) {
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- final EObject createdElement = (EObject)commandCreation.getCommandResult().getReturnValue();
- final IElementEditService provider = ElementEditServiceUtils.getCommandProvider(createdElement);
- final Object valueToSet = realValue.getValue();
- final SetRequest request = new SetRequest(getEditingDomain(), createdElement, feature, valueToSet);
- final ICommand localSetValueCommand = provider.getEditCommand(request);
- localSetValueCommand.execute(monitor, info);
- return CommandResult.newOKCommandResult(realValue.getStatus(createdElement));
- }
- };
- cmd.append(new GMFtoEMFCommandWrapper(setValueCommand));
- }
- }
- }
- }
- }
-
- //8.8 update the command paste dialog
- if(useDialog) {
- final ICommand dialogCommand = new AbstractTransactionalCommand(editingDomain, null, null) {
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- commandExecutionProgressMonitor.getProgressMonitor().worked(1);
- return CommandResult.newOKCommandResult();
- }
- };
- cmd.append(new GMFtoEMFCommandWrapper(dialogCommand));
- }
-
- }
-
- //add the created element to the table
- if(addToTable) {
- final AbstractTransactionalCommand addToTableCMD = new AbstractTransactionalCommand(editingDomain, "Launch Progress Monitor Dialog", Collections.emptyList()) { //$NON-NLS-1$
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- final List<EObject> toAdd = new ArrayList<EObject>();
- for(final ICommand current : createCommands) {
- final EObject createdElement = (EObject)current.getCommandResult().getReturnValue();
- toAdd.add(createdElement);
- }
-
- //FIXME : we don't test if the created element are allowed in the table
- //I don't know how to do it easily here!
- if(!toAdd.isEmpty()) {
-
- final CompoundCommand cmd2 = new CompoundCommand("Add pasted FlowPort to the table"); //$NON-NLS-1$
- cmd2.append(PapyrusTableInstanceCommandFactory.getAddRowCommand(toAdd, papyrusTable.getTable(), (NatTableWidget)iTableWidget));
- //not required?
- //cmd2.append(factory.createSetFacetSetsCommand(papyrusTable.getTable().getFacetSets()));
- cmd2.execute();
- }
- return CommandResult.newOKCommandResult();
- }
- };
- cmd.append(new GMFtoEMFCommandWrapper(addToTableCMD));
-
- }
-
- //close the dialog used during the paste command execution
- if(useDialog) {
- final AbstractTransactionalCommand endMonitor = new AbstractTransactionalCommand(editingDomain, "Close Progress Monitor Dialog", Collections.emptyList()) { //$NON-NLS-1$
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- commandExecutionProgressMonitor.getProgressMonitor().done();
- commandExecutionProgressMonitor.close();
- return CommandResult.newOKCommandResult();
- }
- };
- cmd.append(new GMFtoEMFCommandWrapper(endMonitor));
- }
-
- if(!cmd.isEmpty()) {
- if(cmd.canExecute()) {
- return cmd;
- }
- }
- return UnexecutableCommand.INSTANCE;
- }
-
-
- /**
- *
- * @param iTableWidget
- * the table widget
- * @return
- * the list of the managed columns. Managed columns are : <li>direct feature columns</li> <li>StereotypeFacetElement columns</li>
- */
- /*
- protected Collection<Column> getManagedColumns(final INatTableWidget iTableWidget) {
- final List<Column> visibleColumns = (List<Column>)getVisibleColumns(iTableWidget);
- final ListIterator<Column> iter = visibleColumns.listIterator();
- while(iter.hasNext()) {
- final Column current = iter.next();
- if(!(current instanceof FeatureColumn)) {
- iter.remove();
- } else {
- final EStructuralFeature feature = (EStructuralFeature)((FeatureColumn)current).getFeature();
- if(feature instanceof StereotypePropertyElement) {
- //it is OK
- }
- //FIXME
-// else if(feature instanceof FacetElement) {
-// iter.remove();
-// }
- }
- }
- return visibleColumns;
- }
- */
-
-
-
-
- /**
- *
- *
- * @param pTable
- * the PapyrusTable
- * @param iTableWidget
- * the tableWidget
- * @return
- * the list of the stereotypes to apply on the table. This method can contribute to the
- * {@link AbstractPasteInTableCommandProvider#pasteErrorMessage}
- */
- protected Collection<Stereotype> getStereotypesToApply(final PapyrusTableInstance pTable, final INatTableWidget iTableWidget) throws ErrorInPastePreparationException {
- final Collection<String> stereotypeQualifiedName = new ArrayList<String>();
- //for(final Column col : getManagedColumns(iTableWidget)) {
- for(final Column col : this.visibleColumns) {
- if(col instanceof FeatureColumn) {
- final ETypedElement feature = ((FeatureColumn)col).getFeature();
- if(feature instanceof StereotypePropertyElement) {
- StereotypeFacet facet = (StereotypeFacet)feature.eContainer();
- stereotypeQualifiedName.add(facet.getStereotypeQualifiedName());
- }
- }
- }
-
-
- final List<Profile> appliedProfiles = ((Element)pTable.getTable().getContext()).getNearestPackage().getAllAppliedProfiles();
- final Collection<Stereotype> toApply = new HashSet<Stereotype>();
- for(final String steQN : stereotypeQualifiedName) {
- final String stereotypeName = NamedElementUtil.getNameFromQualifiedName(steQN);
- final String profileQN = NamedElementUtil.getParentQualifiedName(steQN);
- NameResolutionHelper helper = stereotypesHelper.get(profileQN);
- if(helper == null) {
- for(final Profile prof : appliedProfiles) {
- if(prof.getQualifiedName().equals(profileQN)) {
- helper = new NameResolutionHelper(prof, UMLPackage.eINSTANCE.getStereotype());
- final List<NamedElement> foundElement = helper.getNamedElements(stereotypeName);
- if(foundElement.size() == 1) {
- final Stereotype ste = (Stereotype)foundElement.get(0);
- toApply.add(ste);
- } else {
- throw new ErrorInPastePreparationException(NLS.bind(Messages.PasteInPapyrusTableCommandProvider_RequiredStereotypeCantBeFound, stereotypeName));
- }
- break;
- }
- }
-
- }
- }
- return toApply;
- }
-
-
- //FIXME? use the UML Type Factory?
- protected ValueContainer<?> deduceBooleanValue(final boolean isMany, final String valueAsString) throws ErrorInPastePreparationException {
- ValueContainer<?> returnedValue = null;
- if(isMany) {
- final Collection<Boolean> values = new ArrayList<Boolean>();
- for(final String str : valueAsString.split(MULTI_VALUE_SEPARATOR)) {
- if(BooleanHelper.isBoolean(str)) {
- values.add(Boolean.valueOf(valueAsString));
- } else {
- throw new ErrorInPastePreparationException(NLS.bind(TYPE_FORMAT_ERROR_MESSAGE, str, UML_BOOLEAN));
- }
- }
- returnedValue = new MultiValueContainer<Boolean>(values);
- } else {
- if(BooleanHelper.isBoolean(valueAsString)) {
- returnedValue = new ValueContainer<Boolean>(Boolean.valueOf(valueAsString));
- } else {
- throw new ErrorInPastePreparationException(NLS.bind(TYPE_FORMAT_ERROR_MESSAGE, valueAsString, UML_BOOLEAN));
- }
- }
- return returnedValue;
- }
-
-
- protected ValueContainer<?> deduceDoubleValue(final boolean isMany, final String valueAsString) throws ErrorInPastePreparationException {
- ValueContainer<?> returnedValue = null;
- if(isMany) {
- final Collection<Double> values = new ArrayList<Double>();
- for(final String str : valueAsString.split(MULTI_VALUE_SEPARATOR)) {
- final Double value = Double.valueOf(str);
- if(value != null) {
- values.add(value);
- } else {
- throw new ErrorInPastePreparationException(NLS.bind(TYPE_FORMAT_ERROR_MESSAGE, str, "Double")); //$NON-NLS-1$
- }
- }
- returnedValue = new MultiValueContainer<Double>(values);
- } else {
- try {
- returnedValue = new ValueContainer<Double>(Double.valueOf(valueAsString));
- } catch (final NumberFormatException e) {
- throw new ErrorInPastePreparationException(NLS.bind(TYPE_FORMAT_ERROR_MESSAGE, valueAsString, "Double")); //$NON-NLS-1$
- }
- }
- return returnedValue;
- }
-
-
- protected ValueContainer<?> deduceEnumerationLiteralValue(final boolean isMany, final String valueAsString, final Enumeration enumeration) throws ErrorInPastePreparationException {
- ValueContainer<?> returnedValue = null;
- if(isMany) {
- final Collection<EnumerationLiteral> values = new ArrayList<EnumerationLiteral>();
- for(final String str : valueAsString.split(MULTI_VALUE_SEPARATOR)) {
- final EnumerationLiteral lit = (EnumerationLiteral)enumeration.getMember(str);
- if(lit != null) {
- values.add(lit);
- } else {
- throw new ErrorInPastePreparationException(NLS.bind(Messages.PasteInPapyrusTableCommandProvider_TheEnumerationLiteralCantBeFound, str));
- }
- }
- returnedValue = new MultiValueContainer<EnumerationLiteral>(values);
- } else {
- final EnumerationLiteral lit = (EnumerationLiteral)enumeration.getMember(valueAsString);
- if(lit == null) {
- throw new ErrorInPastePreparationException(NLS.bind(Messages.PasteInPapyrusTableCommandProvider_TheEnumerationLiteralCantBeFound, valueAsString));
- }
- returnedValue = new ValueContainer<EnumerationLiteral>(lit);
- }
- return returnedValue;
- }
-
-
- /**
- *
- * @param namespace
- * the namespace used to look for the pasted eobejct
- * @param feature
- * the feature concerned by this paste
- * @param eClass
- * the type of the wanted element
- * @param isMany
- * <code>true</code> if the property is multivalued
- * @param valueAsString
- * the pasted string
- * @return
- * <ul>
- * <li>if the property is monovalued, we return
- * <ul>
- * <li>the eobject if we found it</li>
- * <li>the pasted string if we ddidn't find it</li>
- * </ul>
- * </li>
- * <li>if the property is multivalued, we return
- * <ul>
- * <li>a list containing the founded element and string for unresolved element</li>
- *
- * </ul>
- *
- * @warning : the property ErrorInPasteStatus#element has not been setted in the returned status (because we don't know it here, it have not been
- * yet created.
- */
- protected ValueContainer<?> deduceEObjectValue(final Namespace namespace, final EStructuralFeature feature, final EClass eClass, final boolean isMany, final String valueAsString) {
- ValueContainer<?> returnedValue = null;
- NameResolutionHelper helper = this.nameResolutionHelpers.get(eClass);
- if(helper == null) {
- helper = new NameResolutionHelper(namespace, eClass);
- this.nameResolutionHelpers.put(eClass, helper);
- }
- if(isMany) {
- final PasteWarningStatus root = new PasteWarningStatus("Problem to find some references", null);
- final Collection<EObject> values = new HashSet<EObject>();
- for(final String str : valueAsString.split(MULTI_VALUE_SEPARATOR)) {
- final List<NamedElement> elements = helper.getNamedElements(str);
- if(elements.size() == 1) {
- values.add(elements.get(0));
- } else {
- root.addChildren(new UnresolvedReferenceErrorInPasteStatus(NLS.bind(Messages.PasteInPapyrusTableCommandProvider_TheTextCantBeMappedOnAnExistingElement, valueAsString), null, feature, str));
- }
- if(root.isMultiStatus()) {
- returnedValue = new MultiValueContainer<EObject>(values, root);
- }
- returnedValue = new MultiValueContainer<EObject>(values);
- }
- } else {
- final List<NamedElement> elements = helper.getNamedElements(valueAsString);
- if(elements.size() == 1) {
- //it is OK
- returnedValue = new ValueContainer<EObject>(elements.get(0));
- } else {
- returnedValue = new ValueContainer<EObject>(null, new UnresolvedReferenceErrorInPasteStatus(NLS.bind(Messages.PasteInPapyrusTableCommandProvider_TheTextCantBeMappedOnAnExistingElement, valueAsString), null, feature, valueAsString));
- }
- }
- return returnedValue;
- }
-
-
- protected ValueContainer<?> deduceIntValue(final boolean isMany, final String valueAsString) throws ErrorInPastePreparationException {
- ValueContainer<?> returnedValue = null;
- if(isMany) {
- final Collection<Integer> values = new ArrayList<Integer>();
- for(final String str : valueAsString.split(MULTI_VALUE_SEPARATOR)) {
- try {
- values.add(Integer.valueOf(str));
- } catch (final NumberFormatException e) {
- throw new ErrorInPastePreparationException(NLS.bind(TYPE_FORMAT_ERROR_MESSAGE, str, UML_INTEGER));
- }
- }
- returnedValue = new MultiValueContainer<Integer>(values);
- } else {
- try {
- returnedValue = new ValueContainer<Integer>(Integer.valueOf(valueAsString));
- } catch (final NumberFormatException e) {
- throw new ErrorInPastePreparationException(NLS.bind(TYPE_FORMAT_ERROR_MESSAGE, valueAsString, UML_INTEGER));
- }
- }
- return returnedValue;
- }
-
-
- protected ValueContainer<?> deduceStringValue(final boolean isMany, final String valueAsString) {
- ValueContainer<?> returnedValue = null;
- if(isMany) {
- final Collection<String> values = new ArrayList<String>();
- for(final String str : valueAsString.split(MULTI_VALUE_SEPARATOR)) {
- values.add(str);
- }
- returnedValue = new MultiValueContainer<String>(values);
- } else {
- returnedValue = new ValueContainer<String>(valueAsString);
- }
- return returnedValue;
- }
-
-
- /**
- *
- * @param tableContext
- * the table context
- * @param feature
- * the feature
- * @param valueAsString
- * the pasted string for this feature
- * @return
- * the value for the pasted string or <code>null</code> if not found
- */
- protected ValueContainer<?> deduceValueFromString(final Namespace tableContext, final EStructuralFeature feature, final String valueAsString) throws ErrorInPastePreparationException {
- ValueContainer<?> realValue = null;
- final int upperbound = feature.getUpperBound();
- boolean isMany = (upperbound > 1 || upperbound == -1);
- EClassifier featureType = null;
- Type type = null;
-
- //the feature can't be edited
- if(!feature.isChangeable()) {
- return null;
- }
- //we look for the real property
- if(feature instanceof StereotypePropertyElement) {
- Property realFeature = stereotypePropertiesMap.get(feature);
- if(realFeature == null) {
- realFeature = StereotypePropertyUtils.findRealStereotypeProperty(tableContext, (StereotypePropertyElement)feature);
- if(realFeature != null) {
- stereotypePropertiesMap.put((StereotypePropertyElement)feature, realFeature);
- }
- }
-
- if(realFeature == null) {
- throw new ErrorInPastePreparationException(NLS.bind(Messages.PasteInPapyrusTableCommandProvider_StereotypePropertyCantBeResolved, ((StereotypePropertyElement)feature).getPropertyQualifiedName()));
- }
- //the real property is read only -> we return null;
- if(realFeature.isReadOnly()) {
- return null;
- }
-
- //we determine feature type for the real property
-
- type = realFeature.getType();
- if(type instanceof PrimitiveType) {
- final PrimitiveType pType = (PrimitiveType)type;
- final String name = pType.getName();
- if(UML_BOOLEAN.equals(name)) {
- featureType = EcorePackage.eINSTANCE.getEBoolean();
- } else if(UML_INTEGER.equals(name)) {
- featureType = EcorePackage.eINSTANCE.getEInt();
- } else if(UML_REAL.equals(name)) {
- featureType = EcorePackage.eINSTANCE.getEDouble();
- } else if(UML_STRING.equals(name)) {
- featureType = EcorePackage.eINSTANCE.getEString();
- } else if(UML_UNLIMITED_NATURAL.equals(name)) {
- featureType = EcorePackage.eINSTANCE.getEInt();
- } else { //custom PrimitiveType
- featureType = EcorePackage.eINSTANCE.getEString();
- }
- } else if(type instanceof Enumeration) {
- featureType = UMLPackage.eINSTANCE.getEnumeration();
- } else if(type instanceof DataType) {
- featureType = EcorePackage.eINSTANCE.getEString();
- } else {
- featureType = type.eClass();
- }
- } else {
- featureType = feature.getEType();
- }
-
- if(featureType instanceof EDataType) {
- final String typeName = featureType.getName();
- if("String".equals(typeName) || "EString".equals(typeName)) { //$NON-NLS-1$ //$NON-NLS-2$
- realValue = deduceStringValue(isMany, valueAsString);
- } else if("EBoolean".equals(typeName) || "Boolean".equals(typeName)) { //$NON-NLS-1$ //$NON-NLS-2$
- realValue = deduceBooleanValue(isMany, valueAsString);
- } else if("EInt".equals(typeName) || "Integer".equals(typeName)) { //$NON-NLS-1$ //$NON-NLS-2$
- realValue = deduceIntValue(isMany, valueAsString);
- } else if("EDouble".equals(typeName)) { //$NON-NLS-1$
- realValue = deduceDoubleValue(isMany, valueAsString);
- }
- } else if(featureType instanceof EClass) {
- if("Enumeration".equals(featureType.getName())) { //$NON-NLS-1$
- realValue = deduceEnumerationLiteralValue(isMany, valueAsString, (Enumeration)type);
- } else {
- realValue = deduceEObjectValue(tableContext, feature, (EClass)featureType, isMany, valueAsString);
- }
- }
- return realValue;
- }
-
-
- @Override
- public boolean isPasteEnabled(PapyrusTableInstance papyrusTable, String clipboardContents, INatTableWidget iTableWidget) {
- this.visibleColumns = getVisibleColumns(iTableWidget);
- return super.isPasteEnabled(papyrusTable, clipboardContents, iTableWidget);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/ProfileFacetSetProvider.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/ProfileFacetSetProvider.java
deleted file mode 100644
index 8bf2cee..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/ProfileFacetSetProvider.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.provider;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.facet.infra.facet.FacetSet;
-import org.eclipse.emf.facet.infra.facet.core.FacetSetCatalog;
-import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
-import org.eclipse.papyrus.uml.profilefacet.generation.factory.ProfileFacetGenericFactory;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.ProfileFacetSet;
-import org.eclipse.papyrus.uml.profilefacet.utils.AdditionalContentsUtils;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.Stereotype;
-
-public class ProfileFacetSetProvider extends AbstractAdditionalContentsProvider {
-
- /**
- *
- * @see org.eclipse.papyrus.uml.table.common.provider.AbstractAdditionalContentsProvider#setPapyrusTable(org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance)
- *
- * @param table
- */
- @Override
- public void setPapyrusTable(final PapyrusTableInstance table) {
- super.setPapyrusTable(table);
- }
-
- /**
- *
- * @see org.eclipse.papyrus.uml.table.common.provider.AbstractAdditionalContentsProvider#getAdditionalFeatures()
- *
- * @return
- */
- @Override
- public Collection<FacetSet> getAdditionalFeatures() {
- final Set<Stereotype> appliedStereotypes = new HashSet<Stereotype>();
- for(final EObject current : this.tableContents) {
- if(current instanceof Element) {
- appliedStereotypes.addAll(((Element)current).getAppliedStereotypes());
- }
- }
-
- final Set<Profile> usedProfile = new HashSet<Profile>();
- for(final Stereotype current : appliedStereotypes) {
- usedProfile.add((Profile)PackageUtil.getRootPackage(current));
- }
-
- final EPackage additionalContentsFacetSet = AdditionalContentsUtils.getAdditionalContentsEPackage(pTable);
-
- final Map<String, ProfileFacetSet> mapProfileQNameFacetSet = new HashMap<String, ProfileFacetSet>();
- if(additionalContentsFacetSet != null) {
- final TreeIterator<EObject> iter = additionalContentsFacetSet.eAllContents();
-
- while(iter.hasNext()) {
- final EObject current = iter.next();
- if(current instanceof ProfileFacetSet) {
- mapProfileQNameFacetSet.put(((ProfileFacetSet)current).getProfileQualifiedName(), (ProfileFacetSet)current);
- }
- }
- }
-
- final List<FacetSet> additionalFacetSet = new ArrayList<FacetSet>();
- for(final Profile current : usedProfile) {
- final String profileQN = current.getQualifiedName();
- final XMIResource res = (XMIResource)current.eResource();
- final String profile_XMI_ID = res.getID(current);
- if(!mapProfileQNameFacetSet.containsKey(profileQN)) {//the profile is not known by the AdditionContentsFacetSet
- //we look for a registered profile FacetSet representation of this profile
- FacetSet registeredFacetSet = findRegisteredProfileFacetSet(profileQN, profile_XMI_ID);
- if(registeredFacetSet != null) {
- additionalFacetSet.add(registeredFacetSet);
- } else { //we generate a ProfileFacetSet for this profile
- final ProfileFacetGenericFactory factory = new ProfileFacetGenericFactory();
- ProfileFacetSet set = factory.createProfileFacetSet(current);
- if(set != null) {
- additionalFacetSet.add(set);
- }
- }
- }
- }
-
- return additionalFacetSet;
- }
-
- /**
- *
- * @param rootProfileQualifiedName
- * the qualified name of the profile that we are looking for
- * @param rootProfileXMI_ID
- * the XMI_ID of the profile that we are looking for
- * @return
- */
- protected ProfileFacetSet findRegisteredProfileFacetSet(final String rootProfileQualifiedName, final String rootProfileXMI_ID) {
- if(rootProfileQualifiedName != null && rootProfileXMI_ID != null) {
- final HashSet<FacetSet> availableFacetSets = new HashSet<FacetSet>();
- availableFacetSets.addAll(FacetSetCatalog.getSingleton().getAllFacetSets());
- final Iterator<FacetSet> iter = availableFacetSets.iterator();
- while(iter.hasNext()) {
- final FacetSet current = iter.next();
- if(current instanceof ProfileFacetSet) {
- final ProfileFacetSet set = (ProfileFacetSet)current;
- if(rootProfileQualifiedName.equals(set.getProfileQualifiedName()) && rootProfileXMI_ID.equals(set.getRepresentedElement_XMI_ID())) {
- return set;
- }
- }
- }
- }
-
-
- //FIXME : the facetcatalogue refuses to load the file sysml_profilefacet.facetset because :
- //- the name of the file is not the name of the root facetset
- //- the name of the subfacetset are not the name of the file
- // and so on...
- if(rootProfileQualifiedName.equals("SysML")) {
- ResourceSet set = this.pTable.eResource().getResourceSet();
- URI uri = URI.createPlatformPluginURI("org.eclipse.papyrus.sysml.facets/resources/sysml_profilefacet.facetSet", true);
- final Resource res = set.getResource(uri, true);
- if(res != null && !res.getContents().isEmpty() && res.getContents().get(0) instanceof ProfileFacetSet) {
- EcoreUtil.resolveAll(res);
- return (ProfileFacetSet)res.getContents().get(0);
- }
- }
-
- return null;
-
- }
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/SortedFeaturesContentProvider.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/SortedFeaturesContentProvider.java
deleted file mode 100644
index 5e7bbd8..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/SortedFeaturesContentProvider.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Vincent Lorenzo (CEA-LIST) - bug 337326 - Show/Hide Column : Sort the columns by name
- * Gregoire Dupe (Mia-Software) - Bug 366804 - [Restructuring] Table widget upgrade
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.provider;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.facet.infra.facet.Facet;
-import org.eclipse.emf.facet.infra.facet.FacetSet;
-import org.eclipse.emf.facet.infra.facet.FacetStructuralFeature;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.emf.utils.ENamedElementComparator;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.ProfileFacetSet;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypeFacet;
-import org.eclipse.papyrus.uml.profilefacet.metamodel.profilefacet.StereotypePropertyElement;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Feature;
-
-/**
- * A Content Provider which allows to sort the provided elements
- *
- *
- *
- */
-public class SortedFeaturesContentProvider implements ITreeContentProvider {
-
- /** the comparator used to sort the element */
- private final Comparator<ENamedElement> comparator = new ENamedElementComparator();
-
- private final Comparator<StereotypePropertyElement> stereotypePropertyElement = new Comparator<StereotypePropertyElement>() {
-
- public int compare(StereotypePropertyElement namedElement1, StereotypePropertyElement namedElement2) {
- if(namedElement1 == null) {
- return namedElement2 == null ? 0 : -1;
- }
-
- return Collator.getInstance().compare(namedElement1.getPropertyQualifiedName(), namedElement2.getPropertyQualifiedName());
- }
- };
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- *
- */
- public void dispose() {
- // Nothing to do
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
- *
- * @param inputElement
- * @return
- */
- public Object[] getElements(final Object inputElement) {
- if(inputElement instanceof Set<?>) {
- return ((Collection<?>)inputElement).toArray();
- }
- return new Object[0];
- }
-
-
-
- /**
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- *
- * @param parentElement
- * @return
- */
- public Object[] getChildren(final Object parentElement) {
- if(parentElement instanceof StereotypeFacet) {
- final Set<StereotypePropertyElement> facetElements = new TreeSet<StereotypePropertyElement>(stereotypePropertyElement);
- facetElements.addAll(((StereotypeFacet)parentElement).getStereotypePropertyElements());
- return facetElements.toArray();
- }
- if(parentElement instanceof EStructuralFeature) {
- return new Object[0];
- }
- if(parentElement instanceof Facet) {
- final Set<ENamedElement> facetElements = new TreeSet<ENamedElement>(comparator);
- for(final Object current : ((Facet)parentElement).getEStructuralFeatures()) {
- if(current instanceof ENamedElement) {
- facetElements.add((ENamedElement)current);
- }
-
- }
- return facetElements.toArray();
- }
-
- if(parentElement instanceof ProfileFacetSet) {
- ProfileFacetSet set = (ProfileFacetSet)parentElement;
- final Set<ENamedElement> subFacetSet = new TreeSet<ENamedElement>(comparator);
- subFacetSet.addAll(set.getSubProfileFacetSet());
- final Set<ENamedElement> subFacets = new TreeSet<ENamedElement>(new ENamedElementComparator());
- subFacets.addAll(set.getStereotypeFacets());
- final List<ENamedElement> contents = new ArrayList<ENamedElement>();
- contents.addAll(subFacets);
- contents.addAll(subFacetSet);
- return contents.toArray();
- }
-
- if(parentElement instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet)parentElement;
- final Set<ENamedElement> subFacetSet = new TreeSet<ENamedElement>(comparator);
- subFacetSet.addAll(facetSet.getESubpackages());
- final Set<ENamedElement> subFacets = new TreeSet<ENamedElement>(new ENamedElementComparator());
- subFacets.addAll(((FacetSet)parentElement).getEClassifiers());
- final List<ENamedElement> contents = new ArrayList<ENamedElement>();
- contents.addAll(subFacets);
- contents.addAll(subFacetSet);
- return contents.toArray();
- }
- return new Object[0];
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- *
- * @param element
- * @return
- */
- public Object getParent(final Object element) {
- if(element instanceof StereotypePropertyElement) {
- return ((StereotypePropertyElement)element).eContainer();
- }
- if(element instanceof StereotypeFacet) {
- return ((StereotypeFacet)element).eContainer();
- }
- if(element instanceof ProfileFacetSet) {
- return ((ProfileFacetSet)element).eContainer();
- }
- if(element instanceof Facet) {
- return ((Facet)element).eContainer();
- }
- if(element instanceof FacetSet) {
- return null;
- }
- if(element instanceof FacetStructuralFeature) {
- return ((FacetStructuralFeature)element).eContainer();
- }
- //FIXME
- // if(element instanceof Element) {
- // return ((Element)element).eContainer();
- // } else if(element instanceof FacetElement) {
- // return ((FacetElement)element).eContainer();
- // } else if(element instanceof Facet) {
- // return ((Facet)element).eContainer();
- // } else if(element instanceof FacetSet) {
- // FacetSet set = (FacetSet)element;
- // EObject container = set.eContainer();
- // if(container instanceof FacetSet) {
- // if(!AdditionalContentsFacetSetUtils.ADDITIONAL_CONTENTS_FACET_SET_NS_URI.equals(((FacetSet)container).getNsURI())) {
- // return container;
- // }
- // }
- // }
- return null;
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- *
- * @param element
- * @return
- */
- public boolean hasChildren(final Object element) {
- return getChildren(element).length != 0;
- }
-
-
- /**
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- *
- * @param viewer
- * @param oldInput
- * @param newInput
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- //nothing to do
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/UMLTablePropertyTester.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/UMLTablePropertyTester.java
deleted file mode 100644
index d7c4ae0..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/provider/UMLTablePropertyTester.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.provider;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.uml.table.common.editor.AbstractUMLTableEditor;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-
-public class UMLTablePropertyTester extends PropertyTester {
-
- private static final String IS_UML_TABLE = "isUMLTable"; //$NON-NLS-1$
-
- public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
- IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if(activeWindow == null || activeWindow.getActivePage() == null) {
- return false;
- }
-
- final IWorkbenchPart activePart = activeWindow.getActivePage().getActivePart();
- if(IS_UML_TABLE.equals(property) && activePart instanceof IMultiDiagramEditor) {
- final IEditorPart editor = ((IMultiDiagramEditor)activePart).getActiveEditor();
- return expectedValue.equals(new Boolean(editor instanceof AbstractUMLTableEditor));
- }
- return false;
- }
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/AbstractWarningPasteResultStatus.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/AbstractWarningPasteResultStatus.java
deleted file mode 100644
index 221e9df..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/AbstractWarningPasteResultStatus.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.status;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.uml.table.common.Activator;
-
-
-public abstract class AbstractWarningPasteResultStatus implements IStatus {
-
- /**
- * the element on which we have a problem
- */
- private EObject element;
-
- private Collection<IStatus> children;
-
- private String message;
-
- /**
- *
- * Constructor.
- *
- * @param element
- * the element on which we have a problem
- */
- public AbstractWarningPasteResultStatus(final String message, final EObject element) {
- this.element = element;
- this.children = new ArrayList<IStatus>();
- this.message = message;
- }
-
- /**
- *
- * @return
- * the element on which we have a problem
- */
- public final EObject getElement() {
- return this.element;
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#getChildren()
- *
- * @return
- */
- public IStatus[] getChildren() {
- return this.children.toArray(new IStatus[this.children.size()]);
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#getCode()
- *
- * @return
- */
- public int getCode() {
- return IStatus.WARNING;
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#getException()
- *
- * @return
- */
- public Throwable getException() {
- return null;
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#getMessage()
- *
- * @return
- */
- public String getMessage() {
- return "Paste Warning: " + this.message;
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#getPlugin()
- *
- * @return
- */
- public String getPlugin() {
- return Activator.PLUGIN_ID;
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#getSeverity()
- *
- * @return
- */
- public int getSeverity() {
- return IStatus.WARNING;
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#isMultiStatus()
- *
- * @return
- */
- public boolean isMultiStatus() {
- return !this.children.isEmpty();
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#isOK()
- *
- * @return
- */
- public boolean isOK() {
- return false;
- }
-
- /**
- *
- * @see org.eclipse.core.runtime.IStatus#matches(int)
- *
- * @param severityMask
- * @return
- */
- public boolean matches(int severityMask) {
- return false;
- }
-
- /**
- * Add a child status
- *
- * @param child
- * a child status
- */
- public void addChildren(final IStatus child) {
- this.children.add(child);
- }
-
- /**
- * Setter for {@link #element}. The set is propagated to its children
- *
- * @param element
- * the element on which we have a problem
- */
- public void setElement(final EObject element) {
- this.element = element;
- for(final IStatus status : children) {
- if(status instanceof AbstractWarningPasteResultStatus) {
- ((AbstractWarningPasteResultStatus)status).setElement(element);
- }
- }
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/PasteWarningStatus.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/PasteWarningStatus.java
deleted file mode 100644
index f0f78e7..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/PasteWarningStatus.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.status;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.uml.table.common.Activator;
-
-
-public class PasteWarningStatus extends AbstractWarningPasteResultStatus implements IStatus {
-
- /**
- * Instantiates a new error in paste status.
- *
- * @param statusMessage
- * the status message
- * @param element
- * the element
- * @param feature
- * the feature
- * @param pastedString
- * the pasted string
- */
- public PasteWarningStatus(final String statusMessage, final EObject element) {
- super(statusMessage, element);
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/StereotypeApplicationErrorStatus.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/StereotypeApplicationErrorStatus.java
deleted file mode 100644
index 2394199..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/StereotypeApplicationErrorStatus.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.status;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-
-
-/**
- * This status indicates that we have a problem with a stereotype
- */
-public class StereotypeApplicationErrorStatus extends AbstractWarningPasteResultStatus implements IStatus {
-
- /** The pasted string. */
- private final String stereotypeQualifiedName;
-
- /**
- *
- * Constructor.
- *
- * @param statusMessage
- * the message for this status
- * @param element
- * the element on which we have a problem
- * @param stereotypeQualifiedName
- * the qualified name of the stereotype with which we have a problem
- */
- public StereotypeApplicationErrorStatus(final String statusMessage, final EObject element, final String stereotypeQualifiedName) {
- super(statusMessage, element);
- this.stereotypeQualifiedName = stereotypeQualifiedName;
- }
-
- /**
- * Gets the pasted string.
- *
- * @return the pastedString
- */
- public String getStereotypeQualifiedName() {
- return stereotypeQualifiedName;
- }
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/UnresolvedReferenceErrorInPasteStatus.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/UnresolvedReferenceErrorInPasteStatus.java
deleted file mode 100644
index fbe7737..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/status/UnresolvedReferenceErrorInPasteStatus.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.status;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-
-/**
- * This status is used for unresolved element during the paste
- */
-public class UnresolvedReferenceErrorInPasteStatus extends AbstractWarningPasteResultStatus implements IStatus {
-
- /** The feature where we can do the set. */
- private final EStructuralFeature feature;
-
- /**
- * the string pasted
- */
- private final String pastedString;
-
- public UnresolvedReferenceErrorInPasteStatus(String message, EObject element, final EStructuralFeature feature, final String pastedString) {
- super(message, element);
- this.feature = feature;
- this.pastedString = pastedString;
-
- }
-
- /**
- * Gets the feature.
- *
- * @return the feature
- */
- public EStructuralFeature getFeature() {
- return feature;
- }
-
-
- /**
- * Gets the pasted string.
- *
- * @return the pastedString
- */
- public String getPastedString() {
- return pastedString;
- }
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/utils/MultiValueContainer.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/utils/MultiValueContainer.java
deleted file mode 100644
index bab41e1..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/utils/MultiValueContainer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.utils;
-
-import java.util.Collection;
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- *
- * This class allows to store the value created for a pasted String AND a result status associated to this pasted String
- *
- * @param <T>
- */
-public class MultiValueContainer<T> extends ValueContainer<Collection<T>>{
-
-
-
- /**
- *
- * Constructor.
- *
- * @param realValue
- * a monovalued Value (can be <code>null</code>)
- * @param realListValue
- * a collection value (can be <code>null</code>)
- * @param status
- * a status (can be <code>null</code>)
- */
- public MultiValueContainer(final Collection<T> realValue, final IStatus status) {
- super(realValue, status);
- }
-
- /**
- *
- * Constructor.
- *
- * @param realValue
- * the value (can be <code>null</code>)
- */
- public MultiValueContainer(final Collection<T> realValue) {
- this(realValue, null);
- }
-
-
-}
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/utils/ValueContainer.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/utils/ValueContainer.java
deleted file mode 100644
index c3816a5..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/utils/ValueContainer.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.table.common.utils;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.internal.CommonCoreStatusCodes;
-import org.eclipse.gmf.runtime.common.core.util.StringStatics;
-import org.eclipse.papyrus.uml.table.common.Activator;
-import org.eclipse.papyrus.uml.table.common.status.AbstractWarningPasteResultStatus;
-
-/**
- *
- * This class allows to store the value created for a pasted String AND a result status associated to this pasted String
- *
- * @param <T>
- */
-public class ValueContainer<T> {
-
- /**
- * this field is used when the pasted value is monobalued
- */
- private final T value;
-
- /**
- * the resulting status of the parsing
- */
- private final IStatus status;
-
- /**
- *
- * Constructor.
- *
- * @param realValue
- * a monovalued Value (can be <code>null</code>)
- * @param realListValue
- * a collection value (can be <code>null</code>)
- * @param status
- * a status (can be <code>null</code>)
- */
- public ValueContainer(final T realValue, final IStatus status) {
- this.value = realValue;
- if(status == null) {
- this.status = new Status(IStatus.OK, Activator.PLUGIN_ID, CommonCoreStatusCodes.OK, StringStatics.BLANK, null);
- } else {
- this.status = status;
- }
- }
-
- /**
- *
- * Constructor.
- *
- * @param realValue
- * the value (can be <code>null</code>)
- */
- public ValueContainer(final T realValue) {
- this(realValue, null);
- }
-
-
- /**
- * This method
- *
- * @param element
- * the element for which we are looking for its status (CAN'T BE <code>null</code>).
- * This argument is used to do {@link AbstractWarningPasteResultStatus#setElement(EObject)} to the referenced
- * {@link AbstractWarningPasteResultStatus}
- * @return
- * the status resulting of the parsing of the pasted string
- */
- public IStatus getStatus(final EObject element) {
- if(this.status instanceof AbstractWarningPasteResultStatus) {
- ((AbstractWarningPasteResultStatus)this.status).setElement(element);
- }
- return this.status;
- }
-
- /**
- *
- * @return
- * the value
- */
- public Object getValue() {
- return this.value;
- }
-} \ No newline at end of file
diff --git a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/widget/FilteredCheckboxTree.java b/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/widget/FilteredCheckboxTree.java
deleted file mode 100644
index 29bd577..0000000
--- a/deprecated/org.eclipse.papyrus.uml.table.common/src/org/eclipse/papyrus/uml/table/common/widget/FilteredCheckboxTree.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Duplicated and adapted code from org.eclipse.pde.internal.ui.launcher.FilteredCheckboxTree
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.table.common.widget;
-
-import java.util.*;
-import java.util.List;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.viewers.*;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
-import org.eclipse.ui.dialogs.FilteredTree;
-import org.eclipse.ui.dialogs.PatternFilter;
-import org.eclipse.ui.progress.WorkbenchJob;
-
-/**
- * A FilteredChecboxTree. This tree stores all the tree elements internally, and keeps the
- * check state in sync. This way, even if an element is filtered, the caller can get and set the
- * checked state.
- *
- * The internal representation is additive. That is, elements are never removed from the internal
- * representation. This is OK since the PDE launch Dialog never changes the elements once
- * the view is opened. If any other tree is based on this code, they may want to address this issue.
- *
- * This is not public because it was customized for the Launch Dialog.
- *
- */
-public class FilteredCheckboxTree extends FilteredTree {
-
- private WorkbenchJob refreshJob;
-
- /**
- * The FilteredCheckboxTree Constructor.
- *
- * @param parent
- * The parent composite where this Tree will be placed.
- * @param treeStyle
- * Tree styles
- * @param filter
- * The pattern filter that will be used to filter elements
- */
- public FilteredCheckboxTree(Composite parent, int treeStyle, PatternFilter filter) {
- super(parent, treeStyle, filter, true);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredTree#doCreateTreeViewer(org.eclipse.swt.widgets.Composite, int)
- */
- protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
- return new FilterableCheckboxTreeViewer(parent, style);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.dialogs.FilteredTree#doCreateRefreshJob()
- */
- protected WorkbenchJob doCreateRefreshJob() {
- // Since refresh job is private, we have to get a handle to it
- // when it is created, and store it locally.
- //
- // See: 218903: [Viewers] support extensibility of the refresh job in FilteredTree
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=218903
- WorkbenchJob job = super.doCreateRefreshJob();
- refreshJob = job;
- return job;
- }
-
- /**
- * Resets the filter and returns when the refresh is complete
- */
- public void resetFilter() {
- // Set the next to the initial Text, stop any outstanding jobs
- // and call the refresh job to run synchronously.
- getFilterControl().setText(this.initialText);
- refreshJob.cancel();
- refreshJob.runInUIThread(new NullProgressMonitor());
- }
-
- /**
- * Get the number of pixels the tree viewer is from the top of the filtered
- * checkbox tree viewer. This is useful if you wish to align buttons with the
- * tree.
- *
- * @return the offset of the Tree from the top of the container
- */
- int getTreeLocationOffset() {
- GridLayout layout = (GridLayout)getLayout();
- return layout.horizontalSpacing + layout.marginTop + ((GridData)getLayoutData()).verticalIndent + getFilterControl().getSize().y + 1;
- }
-
- /**
- * Classes which implement this interface deal with notifications from the
- * filtered checkbox tree viewer. The notifications are fired before a refresh
- * happens.
- */
- interface PreRefreshNotifier {
-
- public void preRefresh(FilterableCheckboxTreeViewer viewer, boolean filtered);
- }
-
- /**
- * A CheckboxTreeViewer that maintains an internal representation of all the nodes.
- *
- */
- public class FilterableCheckboxTreeViewer extends ContainerCheckedTreeViewer {
-
- static final String NONE = "none"; //$NON-NLS-1$
-
- static final String CHECKED = "checked"; //$NON-NLS-1$
-
- static final String GREYED = "greyed"; //$NON-NLS-1$
-
- static final String CHECKED_GREYED = "checked_greyed"; //$NON-NLS-1$
-
- /**
- * The internal node for the FilterableCheckboxTreeViewer
- */
- class FilteredCheckboxTreeItem {
-
- Object data; // Data element
-
- String state; // Checked State
-
- List children = new ArrayList();
-
- public FilteredCheckboxTreeItem(Object data, String state, Map itemCache, FilteredCheckboxTreeItem parent) {
- this.data = data;
- this.state = state;
- itemCache.put(data, this);
- if(parent != null) {
- parent.children.add(this);
- }
- }
- }
-
- /* A cache of all the nodes */
- Map itemCache = new HashMap();
-
- /* The preRefresh Listeners */
- List refreshingListeners = new ArrayList();
-
- protected void unmapAllElements() {
- itemCache = new HashMap();
- super.unmapAllElements();
- }
-
- /**
- * FilterableCheckboxTreeViewer constructor. This creates the tree part of the filtered tree.
- */
- public FilterableCheckboxTreeViewer(Composite parent, int style) {
- super(parent, style);
- addCheckStateListener(new ICheckStateListener() {
-
- public void checkStateChanged(CheckStateChangedEvent event) {
- FilteredCheckboxTreeItem item = (FilteredCheckboxTreeItem)itemCache.get(event.getElement());
- if(item != null) {
- item.state = event.getChecked() ? CHECKED : NONE;
- }
- }
- });
- }
-
- /**
- * Allows clients to listen to the tree refresh.
- */
- public void addPreRefreshNotifier(PreRefreshNotifier notifier) {
- if(refreshingListeners.contains(notifier))
- return;
- refreshingListeners.add(notifier);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.CheckboxTreeViewer#getChecked(java.lang.Object)
- */
- public boolean getChecked(Object element) {
- Widget testFindItem = getViewer().testFindItem(element);
- testFindItem = null;
- if(testFindItem == null) {
- if(itemCache.containsKey(element)) {
- FilteredCheckboxTreeItem item = (FilteredCheckboxTreeItem)itemCache.get(element);
- if(item.state.equals(CHECKED))
- return true;
- if(item.state.equals(CHECKED_GREYED))
- return true;
- if(item.state.equals(GREYED))
- return true;
- else if(item.state.equals(NONE))
- return false;
- }
- }
- return super.getChecked(element);
- }
-
- public Object[] getCheckedChildren(Object element) {
- FilteredCheckboxTreeItem item = (FilteredCheckboxTreeItem)itemCache.get(element);
- List checkedChildren = new ArrayList();
- if(item != null) {
- List children = item.children;
- Iterator iterator = children.iterator();
- while(iterator.hasNext()) {
- FilteredCheckboxTreeItem child = (FilteredCheckboxTreeItem)iterator.next();
- if(child.state == CHECKED) {
- checkedChildren.add(child.data);
- }
- }
- }
- return checkedChildren.toArray();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.CheckboxTreeViewer#getCheckedElements()
- */
- public Object[] getCheckedElements() {
- Iterator iterator = itemCache.values().iterator();
- List checkedElements = new LinkedList();
- while(iterator.hasNext()) {
- FilteredCheckboxTreeItem item = (FilteredCheckboxTreeItem)iterator.next();
- Widget testFindItem = getViewer().testFindItem(item.data);
- testFindItem = null;
- if(testFindItem == null) {
- if(item.state.equals(CHECKED) || item.state.equals(CHECKED_GREYED) || item.state.equals(GREYED)) {
- checkedElements.add(item.data);
- }
- } else {
- if(((TreeItem)testFindItem).getChecked()) {
- checkedElements.add(testFindItem.getData());
- }
- }
- }
- return checkedElements.toArray();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.CheckboxTreeViewer#setChecked(java.lang.Object, boolean)
- */
- public boolean setChecked(Object element, boolean state) {
- if(itemCache.containsKey(element)) {
- FilteredCheckboxTreeItem item = (FilteredCheckboxTreeItem)itemCache.get(element);
- item.state = state ? CHECKED : NONE;
- }
- return super.setChecked(element, state);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.CheckboxTreeViewer#setCheckedElements(java.lang.Object[])
- */
- public void setCheckedElements(Object[] elements) {
- Set s = new HashSet(itemCache.keySet());
- s.removeAll(new HashSet(Arrays.asList(elements)));
- for(int i = 0; i < elements.length; i++) {
- FilteredCheckboxTreeItem item = (FilteredCheckboxTreeItem)itemCache.get(elements[i]);
- if(item != null) {
- item.state = CHECKED;
- }
- }
- for(Iterator iterator = s.iterator(); iterator.hasNext();) {
- Object object = iterator.next();
- FilteredCheckboxTreeItem item = (FilteredCheckboxTreeItem)itemCache.get(object);
- if(item != null) {
- item.state = NONE;
- }
- }
- super.setCheckedElements(elements);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.CheckboxTreeViewer#setSubtreeChecked(java.lang.Object, boolean)
- */
- public boolean setSubtreeChecked(Object element, boolean state) {
- String newState = state ? CHECKED : NONE;
- TreeItem item = (TreeItem)testFindItem(element);
- FilteredCheckboxTreeItem filteredCheckboxTreeItem = (FilteredCheckboxTreeItem)itemCache.get(element);
- if(item != null && filteredCheckboxTreeItem != null) {
- filteredCheckboxTreeItem.state = newState;
- TreeItem[] items = item.getItems();
- for(int i = 0; i < items.length; i++) {
- item = items[i];
- if(item != null) {
- filteredCheckboxTreeItem = (FilteredCheckboxTreeItem)itemCache.get(item.getData());
- if(filteredCheckboxTreeItem != null) {
- filteredCheckboxTreeItem.state = newState;
- }
- }
- }
- }
- return super.setSubtreeChecked(element, state);
- }
-
- /*
- * public boolean setSubtreeChecked(Object element, boolean state) {
- * String newState = state ? CHECKED : NONE;
- * FilteredCheckboxTreeItem filteredCheckboxTreeItem = (FilteredCheckboxTreeItem) itemCache.get(element);
- * if (filteredCheckboxTreeItem != null) {
- * filteredCheckboxTreeItem.state = newState;
- * List children = filteredCheckboxTreeItem.children;
- * for (Iterator iterator = children.iterator(); iterator.hasNext();) {
- * FilteredCheckboxTreeItem child = (FilteredCheckboxTreeItem) iterator.next();
- * child.state = newState;
- * }
- * }
- * return super.setSubtreeChecked(element, state);
- * }
- */
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.CheckboxTreeViewer#preservingSelection(java.lang.Runnable)
- */
- protected void preservingSelection(Runnable updateCode) {
- super.preservingSelection(updateCode);
-
- // Re-apply the checked state
- ArrayList allTreeItems = getAllTreeItems(treeViewer.getTree().getItems());
- for(Iterator iterator = allTreeItems.iterator(); iterator.hasNext();) {
- TreeItem item = (TreeItem)iterator.next();
- doApplyCheckedState(item, item.getData());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#internalRefresh(java.lang.Object, boolean)
- */
- protected void internalRefresh(Object element, boolean updateLabels) {
- String text = FilteredCheckboxTree.this.getFilterString();
- boolean initial = initialText != null && initialText.equals(text);
- boolean filtered = (text.length() > 0 && !initial);
-
- // Notify anybody who is listening for the refresh
- for(Iterator iterator = refreshingListeners.iterator(); iterator.hasNext();) {
- PreRefreshNotifier notifier = (PreRefreshNotifier)iterator.next();
- notifier.preRefresh(FilterableCheckboxTreeViewer.this, filtered);
- }
- saveCheckedState();
- super.internalRefresh(element, updateLabels);
- treeViewer.expandAll();
- }
-
- /*
- * Set the checked state
- */
- private void doApplyCheckedState(Item item, Object element) {
- // update the item first
- super.doUpdateItem(item, element);
-
- // Update the checked state
- TreeItem treeItem = (TreeItem)item;
- if(itemCache.containsKey(element)) {
- String state = ((FilteredCheckboxTreeItem)itemCache.get(element)).state;
- if(state.equals(CHECKED_GREYED)) {
- treeItem.setGrayed(true);
- treeItem.setChecked(true);
- } else if(state.equals(CHECKED)) {
- treeItem.setChecked(true);
- treeItem.setGrayed(false);
- } else if(state.equals(GREYED)) {
- treeItem.setGrayed(true);
- treeItem.setChecked(false);
- } else {
- treeItem.setGrayed(false);
- treeItem.setChecked(false);
- }
- }
- }
-
- /*
- * A helper method to get all the items in the tree
- */
- private ArrayList getAllTreeItems(TreeItem[] roots) {
- ArrayList list = new ArrayList();
- for(int i = 0; i < roots.length; i++) {
- TreeItem item = roots[i];
- list.add(item);
- list.addAll(getAllTreeItems(item.getItems()));
- }
- return list;
- }
-
- /**
- * Saves the checked state of all the elements in the tree
- */
- private void saveCheckedState() {
- TreeItem[] items = treeViewer.getTree().getItems();
- for(int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
- if(!itemCache.containsKey(item.getData())) {
- new FilteredCheckboxTreeItem(item.getData(), getItemState(item), itemCache, null);
- }
- FilteredCheckboxTreeItem filteredCheckboxTreeItem = (FilteredCheckboxTreeItem)itemCache.get(item.getData());
- filteredCheckboxTreeItem.state = getItemState(item);
- saveCheckedState(filteredCheckboxTreeItem, item);
- }
- }
-
- /**
- * Saves the checked state of an item and all its children
- */
- private void saveCheckedState(FilteredCheckboxTreeItem parent, TreeItem parentItem) {
- TreeItem[] items = parentItem.getItems();
- for(int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
- if(!itemCache.containsKey(item.getData())) {
- new FilteredCheckboxTreeItem(item.getData(), getItemState(item), itemCache, parent);
- }
- FilteredCheckboxTreeItem filteredCheckboxTreeItem = (FilteredCheckboxTreeItem)itemCache.get(item.getData());
- filteredCheckboxTreeItem.state = getItemState(item);
- saveCheckedState(filteredCheckboxTreeItem, item);
- }
- }
-
- /**
- * Computes the checked state from a tree item
- */
- private String getItemState(TreeItem item) {
- if(item.getChecked() && item.getGrayed()) {
- return CHECKED_GREYED;
- } else if(item.getChecked()) {
- return CHECKED;
- } else if(item.getGrayed()) {
- return GREYED;
- } else {
- return NONE;
- }
- }
-
- } // end of FilterableCheckboxTreeViewer
-
-}