Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/org.eclipse.papyrus.infra.table.efacet.menu')
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.classpath7
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.project28
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/META-INF/MANIFEST.MF27
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/build.properties5
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/plugin.xml28
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/Activator.java53
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/CustomizationUtils.java83
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/ITableCommandFactory.java48
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableCommandFactory.java528
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableInstanceCommandFactory.java349
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableInstanceUtils.java223
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/ColumnsToShowDialog.java384
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/Constants.java22
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/EcoreENamedElementComparator.java14
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FacetFactory.java352
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FacetOperationUtils.java230
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FilteredCheckboxTree.java456
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/SelectColumnsHandler.java752
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/SortedColumnContentProvider.java175
-rw-r--r--sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/StereotypeManagement.java82
21 files changed, 0 insertions, 3853 deletions
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.classpath b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.classpath
deleted file mode 100644
index 2d1a4302f04..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.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 kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.project b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.project
deleted file mode 100644
index 6ca4b401b01..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.papyrus.infra.table.efacet.menu</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/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.settings/org.eclipse.jdt.core.prefs b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 44217f8c068..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/.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/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/META-INF/MANIFEST.MF b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/META-INF/MANIFEST.MF
deleted file mode 100644
index e2d68056628..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,27 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: Menu for EFacet Table (Incubation)
-Bundle-SymbolicName: org.eclipse.papyrus.infra.table.efacet.menu;singleton:=true
-Bundle-Version: 0.9.0.qualifier
-Bundle-Activator: org.eclipse.papyrus.infra.table.efacet.menu.Activator
-Bundle-Vendor: Eclispe Modeling Project
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.emf.ecore;bundle-version="2.8.0",
- org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.papyrus.infra.core;bundle-version="0.9.1",
- org.eclipse.emf.facet.widgets.table.metamodel;bundle-version="0.2.1",
- org.eclipse.emf.facet.widgets.table.ui;bundle-version="0.2.1",
- org.eclipse.papyrus.infra.emf;bundle-version="0.9.1",
- org.eclipse.papyrus.infra.table.efacet.common;bundle-version="0.9.1",
- org.eclipse.papyrus.infra.table.efacet.metamodel;bundle-version="0.9.1",
- org.eclipse.uml2.uml;bundle-version="4.0.0",
- org.eclipse.gmf.runtime.common.core;bundle-version="1.4.1",
- org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0",
- org.eclipse.emf.facet.widgets.celleditors.ecore;bundle-version="0.2.1",
- org.eclipse.emf.facet.efacet.core,
- org.eclipse.papyrus.uml.tools;bundle-version="0.9.1",
- org.eclipse.papyrus.uml.tools.utils,
- org.eclipse.papyrus.uml.umlefacet.metamodel;bundle-version="0.9.2"
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-ActivationPolicy: lazy
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/build.properties b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/build.properties
deleted file mode 100644
index 6f20375d6c7..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/build.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/plugin.xml b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/plugin.xml
deleted file mode 100644
index c363cecf8ee..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/plugin.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- point="org.eclipse.ui.commands">
- <command
- categoryId="org.eclipse.papyrus.editor.category"
- defaultHandler="org.eclipse.papyrus.infra.table.efacet.menu.handler.SelectColumnsHandler"
- description="Select the Columns to display in the table"
- id="org.eclipse.papyrus.infra.table.efacet.menu.command.select.columns"
- name="Select Columns">
- </command>
- </extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.ui.popup.any">
- <command
- commandId="org.eclipse.papyrus.infra.table.efacet.menu.command.select.columns"
- label="Select Columns To Show"
- style="push"
- tooltip="Select the columns to display">
- </command>
- </menuContribution>
- </extension>
-
-</plugin>
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/Activator.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/Activator.java
deleted file mode 100644
index 34769f21524..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/Activator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.eclipse.papyrus.infra.table.efacet.menu;
-
-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.infra.table.efacet.menu"; //$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);
- log = new LogHelper(this);
- plugin = 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/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/CustomizationUtils.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/CustomizationUtils.java
deleted file mode 100644
index 16dafbfee7b..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/CustomizationUtils.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.infra.table.efacet.menu.factory;
-
-import java.util.Collection;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.FacetCustomization;
-import org.eclipse.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-//TODO duplicated and adapted code from EMF-Facet
-//EMF-Facet should provides a best way to hide columns
-public final class CustomizationUtils {
-
- private CustomizationUtils() {
- // Must not be used.
- }
-
- /** @return the {@link Facet}s customized by the given customizations. */
- public static Set<FacetSet> findFacetsCustomizedBy(final List<Customization> customizations) {
- final Set<FacetSet> referencedFS = new HashSet<FacetSet>();
- for(Customization customization : customizations) {
- for(EClassifier eClassifier : customization.getEClassifiers()) {
- if(eClassifier instanceof FacetCustomization) {
- final FacetCustomization facetCustom = (FacetCustomization)eClassifier;
- for(Facet extFacet : facetCustom.getExtendedFacets()) {
- referencedFS.add((FacetSet)extFacet.getEPackage());
- }
- }
- }
- }
- return referencedFS;
- }
-
- /** Returns the first customization among the given list of customizations that extends the given EPackage. */
- public static Customization findCustomizationExtendingEPackage(final List<Customization> customizations, final EPackage ePackage) {
- if(ePackage == null) {
- throw new IllegalArgumentException("ePackage must not be null"); //$NON-NLS-1$
- }
- Customization result = null;
- for(Customization customization : customizations) {
- if(customization != null && ePackage.equals(FacetUtils.getExtendedEPackage(customization))) {
- result = customization;
- break;
- }
- }
- return result;
- }
-
- /** Returns the first {@link Facet} among the given list of facets that extends the given EClass. */
- public static Facet findFacetByExtendedMetaclass(final Collection<Facet> facets, final EClass extendedMetaClass) {
- Facet result = null;
- for(Facet facet : facets) {
- Facet candidate = facet;
- if(candidate.getExtendedMetaclass() == extendedMetaClass) {
- result = candidate;
- break;
- }
- }
- return result;
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/ITableCommandFactory.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/ITableCommandFactory.java
deleted file mode 100644
index 1faa783424b..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/ITableCommandFactory.java
+++ /dev/null
@@ -1,48 +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:
- * Gregoire Dupe (Mia-Software) - Bug 374903 - [Table] ITableWidget.setLoadedFacetSets
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 376158 - [Table] Unexpected columns when customizations are loaded
- * Gregoire Dupe (Mia-Software) - Bug 378701 - [Unit Test Failure] org.eclipse.emf.facet.widgets.table.tests.internal.v0_2.notuithread.Bug354224Test*
- * Gregoire Dupe (Mia-Software) - Bug 380126 - [Table] Row sort too long
- *******************************************************************************/
-package org.eclipse.papyrus.infra.table.efacet.menu.factory;
-
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Column;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.FeatureColumn;
-import org.eclipse.emf.facet.widgets.table.ui.internal.exported.ColumnSortDirection;
-
-/***
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ITableCommandFactory {
-
- Command createSetLoadedFacetSetsCommand(List<FacetSet> facetSets);
-
- Command createRemoveColumnCommand(Column column);
-
- Command createAddColumnCommand(List<ETypedElement> eTypedElements,
- List<FacetSet> facetSets);
-
- Command createSetCustomizationCommand(List<Customization> customizations);
-
- Command createRemoveColumnsCommand(List<ETypedElement> elements);
-
-// Command createSortRowCommand(FeatureColumn featureColumn,
-// ColumnSortDirection direction);
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableCommandFactory.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableCommandFactory.java
deleted file mode 100644
index 37f6d7b451e..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableCommandFactory.java
+++ /dev/null
@@ -1,528 +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:
- * Gregoire Dupe (Mia-Software) - Bug 374903 - [Table] ITableWidget.setLoadedFacetSets
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Gregoire Dupe (Mia-Software) - Bug 376158 - [Table] Unexpected columns when customizations are loaded
- * Gregoire Dupe (Mia-Software) - Bug 378701 - [Unit Test Failure] org.eclipse.emf.facet.widgets.table.tests.internal.v0_2.notuithread.Bug354224Test*
- * Gregoire Dupe (Mia-Software) - Bug 380126 - [Table] Row sort too long
- * Contributors imported from org.eclipse.emf.facet.widgets.table.ui.internal.TableInstanceCommandFactory (Bug 387008):
- * Nicolas Bros (Mia-Software) - Bug 331203 - table model editor - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 332437 - NatTable : pluggable cell editors
- * Nicolas Guyomar (Mia-Software) - Bug 331442 - To be able to add and remove lines (model elements) from the table
- * Nicolas Bros (Mia-Software) - Bug 332226 - To be able to create or delete model element from the table
- * Nicolas Guyomar (Mia-Software) - Bug 332226 - To be able to create or delete model element from the table
- * Nicolas Bros (Mia-Software) - Bug 332438 - NatTable : table type
- * Nicolas Bros (Mia-Software) - Bug 332440 - NatTable : force cell editors
- * Nicolas Bros (Mia-Software) - Bug 331675 - NatTable : copy cells as text
- * Nicolas Bros (Mia-Software) - Bug 331900 - customizable NatTable
- * Nicolas Bros (Mia-Software) - Bug 332010 - view Facet customizations on NatTable
- * Nicolas Bros (Mia-Software) - Bug 332215 - customizable NatTable column headers
- * Nicolas Guyomar (Mia-Software) - Bug 332215 - customizable NatTable column headers
- * Nicolas Guyomar (Mia-Software) - Bug 332924 - To be able to save the table
- * Nicolas Guyomar (Mia-Software) - Bug 332998 - To be able to add a column and fill it with the result of a query
- * Gregoire Dupe (Mia-Software) - Bug 332998 - To be able to add a column and fill it with the result of a query
- * Gregoire Dupe (Mia-Software) - Bug 333015 - To be able to hide columns
- * Nicolas Guyomar (Mia-Software) - Bug 333015 - To be able to hide columns
- * Nicolas Guyomar (Mia-Software) - Bug 333029 - To be able to save the size of the lines and the columns
- * Nicolas Guyomar (Mia-Software) - Bug 333414 - The user must be able to save the column order
- * Nicolas Guyomar (Mia-Software) - Bug 335154 - Sort Column By Type : Cannot modify resource set without a write transaction
- * Nicolas Guyomar (Mia-Software) - Bug 335155 - Hide Empty Column : Cannot modify resource set without a write transaction
- * Nicolas Guyomar (Mia-Software) - Bug 335156 - Only Show Common column : Cannot modify resource set without a write transaction
- * Nicolas Guyomar (Mia-Software) - Bug 335020 - Nattable widget should use the Eclipse framework
- * Nicolas Guyomar (Mia-Software) - Bug 337322 - [TableConfiguration] Customization declared in the file tableconfiguration is not loaded
- * Nicolas Guyomar (Mia-Software) - Bug 338536 - Problem with the refresh of the table : the scrollbar returns to this initial position
- * Nicolas Bros (Mia-Software) - Bug 338536 - Problem with the refresh of the table : the scrollbar returns to this initial position
- * Nicolas Guyomar (Mia-Software) - Bug 337454 - We can't delete a query Column
- * Nicolas Guyomar (Mia-Software) - Bug 337395 - Unused columns should be destroyed
- * Nicolas Guyomar (Mia-Software) - Bug 339554 - org.eclipse.emf.facet.widgets.celleditors API cleaning
- * Nicolas Guyomar (Mia-Software) - Bug 339922 - INatTableWidget method isCellSelected should use the plural
- * Nicolas Guyomar (Mia-Software) - Bug 340681 - Facet column implementation
- * Vincent Lorenzo (CEA-LIST) - Bug 337326 - Show/Hide Column : Sort the columns by name
- * Nicolas Guyomar (Mia-Software) - Bug 340940 - To be able to view facet attributes and facet references in a table
- * Vincent Lorenzo (CEA-LIST) - Bug 337408 - Add an action to sort columns by name
- * Nicolas Guyomar (Mia-Software) - Bug 336482 - KeyBinding to edit element in Table : F2
- * Vincent Lorenzo (CEA-LIST) - Bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Gregoire Dupe (Mia-Software) - Bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Nicolas Guyomar (Mia-Software) - Bug 342451 - To be able to edit derived facet attributes and derived facet references in a table
- * Vincent Lorenzo (CEA-LIST) - Bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Nicolas Guyomar (Mia-Software) - Bug 343411 - [Table] Create new elements does not support IJavaModelQuery anymore
- * Gregoire Dupe (Mia-Software) - Bug 343811 - EMF Facet Regression : Created elements in a table are not serialized
- * Vincent Lorenzo (CEA-LIST) - Bug 344125 - The API should provide a method selectRows(List<EObject> elementsToSelect)
- * Nicolas Guyomar (Mia-Software) - Bug 344274 - SWT BOT fail on Hudson
- * Nicolas Guyomar (Mia-Software) - Bug 344475 - To be able to select a cell by EStructuralFeature in the table
- * Nicolas Guyomar (Mia-Software) - Bug 342028 - Field can be edited even if they are marked as N/A
- * Nicolas Guyomar (Mia-Software) - Bug 344413 - Facet Columns are never created when we begin with an empty table
- * Gregoire Dupe (Mia-Software) - Bug 343859 - The local customizations are not applied when we reopen a table
- * Nicolas Guyomar (Mia-Software) - Bug 344670 - Problems with the columns creation : very slow + scrollbar blinked
- * Vincent Lorenzo (CEA LIST) - Bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Nicolas Guyomar (Mia-Software) - Bug 344925 - Undo/Redo after the action Show Columns
- * Gregoire Dupe (Mia-Software) - Bug 344925 - Undo/Redo after the action Show Columns - Regression fix
- * Nicolas Guyomar (Mia-Software) - Bug 345665 - Columns are duplicated when you drop many elements in the same time
- * Nicolas Guyomar (Mia-Software) - Bug 346465 - [EMF Facet Table] Remove line does not remove obsolete column
- * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table
- * Gregoire Dupe (Mia-Software) - Bug 354224 - mutually exclusive Facets
- * Grégoire Dupé (Mia-Software) - Bug 356795 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.Bug344413Test.testBug344413
- * Gregoire Dupe (Mia-Software) - Bug 366804 - [Restructuring] Table widget upgrade
- * Gregoire Dupe (Mia-Software) - Bug 367613 - Table widget refactoring
- * Gregoire Dupe (Mia-Software) - Bug 367700 - [Unit Test Failure][0.2/3.8] org.eclipse.emf.facet.widgets.table.tests.internal.v0_2.swtbot.NatTableUITests.testOpenLoadCustomizationDialog
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Gregoire Dupe (Mia-Software) - Bug 376158 - [Table] Unexpected columns when customizations are loaded
- * Nicolas Bros (Mia-Software) - Bug 378475 - unit test failures after table refactoring
- * Olivier Remaud (Soft-Maint) - Bug 378499 - optimizing table opening
- * Gregoire Dupe (Mia-Software) - Bug 387008 - [Table] Papyrus needs methods provided by TableInstanceCommandFactory
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 387008 - [Table] Papyrus needs methods provided by TableInstanceCommandFactory
- *******************************************************************************/
-package org.eclipse.papyrus.infra.table.efacet.menu.factory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import javax.management.RuntimeErrorException;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactory;
-import org.eclipse.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactoryFactory;
-import org.eclipse.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.emf.facet.util.emf.core.command.ICommandFactoryResult;
-import org.eclipse.emf.facet.util.emf.core.command.ICommandFactoryResultFactory;
-import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Column;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.FeatureColumn;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Row;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Table;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.TableFactory;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.TablePackage;
-import org.eclipse.emf.facet.widgets.table.ui.command.ITableCommandFactory;
-import org.eclipse.emf.facet.widgets.table.ui.internal.exported.TableWidgetUtils;
-import org.eclipse.osgi.util.NLS;
-
-//TODO Remove implementation of org.eclipse.emf.facet.widgets.table.ui.internal.ITableCommandFactory
-public class TableCommandFactory implements org.eclipse.papyrus.infra.table.efacet.menu.factory.ITableCommandFactory, ITableCommandFactory {
-
- // private static final boolean DEBUG = DebugUtils.getDebugStatus(Activator.getDefault());
-
- private final Table table;
-
- private final EditingDomain editingDomain;
-
- private final ICommandFactory commandFactory;
-
- private final IFacetManager facetManager;
-
- public TableCommandFactory(final Table table, final EditingDomain editingDomain, final ICommandFactory commandFactory, final IFacetManager facetManager) {
- this.table = table;
- this.editingDomain = editingDomain;
- this.commandFactory = commandFactory;
- this.facetManager = facetManager;
- }
-
- /**
- * @param facetSets
- * must not contains more than one reference to a same FacetSet
- */
- public Command createSetLoadedFacetSetsCommand(final List<FacetSet> facetSets) {
- return this.createSetFacetSetsCommand(facetSets);
- }
-
- /**
- * @param facetSets
- * must not contains more than one reference to a same FacetSet
- * @param manageCustoms
- */
- private Command createSetLoadedFacetSetsCommand(final List<? extends FacetSet> facetSets, final boolean manageCustoms) {
- // It is expected that the column points to the override feature (the
- // signature)
- final List<Command> commandList = new CommandList();
- final List<FeatureColumn> columnsToRemove = TableInstanceUtils.columnsToRemove(this.table, facetSets, this.table.getRows());
- for(Column columnToRemove : columnsToRemove) {
- final Command removeColumnCmd = createRemoveColumnCommand(columnToRemove);
- commandList.add(removeColumnCmd);
- }
- if(!this.table.getFacetSets().equals(facetSets)) {
- final Command setCommand = this.commandFactory.createSetCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_FacetSets(), facetSets);
- commandList.add(setCommand);
- }
- // If some added facetSet are also customizations they have to be
- // loaded. This
- // is required by this aggregate.
- final List<Customization> addedCustoms = new LinkedList<Customization>();
- for(FacetSet facetSet : facetSets) {
- if(facetSet instanceof Customization) {
- final Customization custom = (Customization)facetSet;
- addedCustoms.add(custom);
- }
- }
- if(manageCustoms) {
- // If some removed facetSet are also customizations they have to be
- // unloaded. This
- // is required by this aggregate.
-
- final List<FacetSet> removedFacetSet = new ArrayList<FacetSet>();
- removedFacetSet.addAll(this.table.getFacetSets());
- removedFacetSet.removeAll(facetSets);
- final List<Customization> removedCustoms = new LinkedList<Customization>();
- for(FacetSet facetSet : removedFacetSet) {
- if(facetSet instanceof Customization) {
- final Customization custom = (Customization)facetSet;
- removedCustoms.add(custom);
- }
- }
- if(!(addedCustoms.isEmpty() && removedCustoms.isEmpty())) {
- final List<Customization> customizations = new ArrayList<Customization>();
- customizations.addAll(this.table.getCustomizations());
- customizations.removeAll(removedCustoms);
- customizations.addAll(addedCustoms);
- final Command loadCustom = createCoreSetCustomizationsCommand(customizations);
- commandList.add(loadCustom);
- }
- }
- return createResult(commandList, "Set loaded facetSets"); //$NON-NLS-1$
- }
-
- private static Command createResult(final List<Command> commandList, final String label) {
- Command result = null;
- while(commandList.contains(null)) {
- commandList.remove(null);
- }
- if(!commandList.isEmpty()) {
- result = new CompoundCommand(label, commandList);
- }
- return result;
- }
-
- public Command createRemoveColumnCommand(final Column column) {
- final List<Command> commandList = new ArrayList<Command>();
- if(this.table.getColumns().contains(column)) {
- final Command command = this.commandFactory.createRemoveCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Columns(), column);
- // This compoundCommand is only used to hold debug informations.
- commandList.add(command);
- }
- return createResult(commandList, "Remove column"); //$NON-NLS-1$
- }
-
- public Command createAddColumnCommand(final List<ETypedElement> eTypedElements, final List<FacetSet> facetSets) {
- final List<Command> commandList = new CommandList();
- final Set<FacetSet> newFacetSets = new LinkedHashSet<FacetSet>();
- newFacetSets.addAll(facetSets);
- newFacetSets.addAll(this.table.getFacetSets());
- for(ETypedElement eTypedElement : eTypedElements) {
- final FacetSet signatureFS = getSignatureFacetSet(eTypedElement);
- if(signatureFS != null) {
- newFacetSets.add(signatureFS);
- }
- }
- final Command addFacetCommand = createSetLoadedFacetSetsCommand(new ArrayList<FacetSet>(newFacetSets));
- commandList.add(addFacetCommand);
- final Command addColumn = createAddColumn(eTypedElements);
- commandList.add(addColumn);
- return createResult(commandList, "Add columns and facetSets"); //$NON-NLS-1$
- }
-
- private static FacetSet getSignatureFacetSet(final ETypedElement eTypedElement) {
- FacetSet result = null;
- if(eTypedElement instanceof DerivedTypedElement) {
- final DerivedTypedElement derivedTE = (DerivedTypedElement)eTypedElement;
- DerivedTypedElement signatureTE = null;
- try {
- signatureTE = FacetUtils.getTopOverrideFeature(derivedTE);
- } catch (FacetManagerException e) {
- //FIXME
- throw new RuntimeException(e);
-// throw new TableWidgetRuntimeException(e);
- }
- if(derivedTE.getOverride() != null && signatureTE != null) {
- final FacetSet signatureFS = FacetUtils.getFacetSet(signatureTE);
- result = signatureFS;
- }
- }
- return result;
- }
-
- private Command createAddColumn(final List<ETypedElement> eTypedElements) {
- final List<Command> commandList = new CommandList();
- for(ETypedElement eTypedElement : eTypedElements) {
- final Command addColumn = createAddColumn(eTypedElement);
- commandList.add(addColumn);
- }
- return createResult(commandList, "Add columns"); //$NON-NLS-1$
- }
-
- private Command createAddColumn(final ETypedElement eTypedElement) {
- ETypedElement signature = eTypedElement;
- if(eTypedElement instanceof FacetOperation) {
- final FacetOperation facetOperation = (FacetOperation)eTypedElement;
- signature = FacetUtils.getSignature(facetOperation);
- }
- Column existingColumn = null;
- for(Column column : this.table.getColumns()) {
- if(column instanceof FeatureColumn) {
- final FeatureColumn featureColumn = (FeatureColumn)column;
- if(featureColumn.getFeature().equals(signature)) {
- existingColumn = column;
- break;
- }
- }
- }
- final List<Command> commandList = new CommandList();
- if(existingColumn == null) {
- final FeatureColumn column = TableFactory.eINSTANCE.createFeatureColumn();
- final Command setColumn = this.commandFactory.createAddCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Columns(), column);
- commandList.add(setColumn);
- final Command setETypedElement = this.commandFactory.createSetCommand(this.editingDomain, column, TablePackage.eINSTANCE.getFeatureColumn_Feature(), signature);
- commandList.add(setETypedElement);
- }
- return createResult(commandList, "Add column"); //$NON-NLS-1$
- }
-
- public Command createSetCustomizationCommand(final List<Customization> customizations) {
- final List<Command> commandList = new CommandList();
- final Set<FacetSet> referredFS = CustomizationUtils.findFacetsCustomizedBy(customizations);
- final List<FacetSet> alreadyLoaded = this.table.getFacetSets();
- final List<Customization> removedCustoms = new ArrayList<Customization>();
- removedCustoms.addAll(this.table.getCustomizations());
- removedCustoms.removeAll(customizations);
- final List<FacetSet> facetSets = new ArrayList<FacetSet>();
- facetSets.addAll(customizations);
- // This "remove" avoid to have a same object in twice in the list.
- facetSets.removeAll(alreadyLoaded);
- facetSets.addAll(alreadyLoaded);
- // This "remove" avoid to have a same object in twice in the list.
- facetSets.removeAll(referredFS);
- facetSets.addAll(referredFS);
- facetSets.removeAll(removedCustoms);
- final Command facetLoad = createSetLoadedFacetSetsCommand(facetSets, false);
- commandList.add(facetLoad);
- final Command customLoad = createCoreSetCustomizationsCommand(customizations);
- commandList.add(customLoad);
- return createResult(commandList, "Load cutomizations and associated facet sets"); //$NON-NLS-1$
- }
-
- private Command createCoreSetCustomizationsCommand(final List<Customization> customizations) {
- final List<Customization> sortedCustoms = new ArrayList<Customization>();
- sortedCustoms.addAll(this.table.getLocalCustomizations());
- for(Customization customization : customizations) {
- if(!sortedCustoms.contains(customization)) {
- sortedCustoms.add(customization);
- }
- }
- final List<Command> commandList = new CommandList();
- if(!this.table.getCustomizations().equals(sortedCustoms)) {
- final Command command = this.commandFactory.createSetCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Customizations(), sortedCustoms);
- commandList.add(command);
- }
- return createResult(commandList, "Set loaded cutomizations"); //$NON-NLS-1$
- }
-
- class CommandList extends LinkedList<Command> {
-
- private static final long serialVersionUID = 8581553157248060152L;
-
- @Override
- public boolean add(final Command command) {
- boolean result;
- if(command == null) {
- result = false;
- } else {
- result = super.add(command);
- }
- return result;
- }
- }
-
- public Command createRemoveColumnsCommand(final List<ETypedElement> elements) {
- final List<Command> commandList = new ArrayList<Command>();
- if(elements != null && !elements.isEmpty()) {
- for(Column column : this.table.getColumns()) {
- if(column instanceof FeatureColumn) {
- final FeatureColumn featureColumn = (FeatureColumn)column;
- if(elements.contains(featureColumn.getFeature())) {
- final Command rmCommand = this.commandFactory.createRemoveCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Columns(), featureColumn);
- commandList.add(rmCommand);
- }
- }
- }
-
- }
- return createResult(commandList, NLS.bind("Remove {0} columms", Integer.valueOf(commandList.size()))); //$NON-NLS-1$
- }
-
-// public Command createSortRowCommand(final FeatureColumn featureColumn, final ColumnSortDirection direction) {
-// final List<Row> rows = new ArrayList<Row>(this.table.getRows());
-// final ETypedElement eTypedElement = featureColumn.getFeature();
-// final RowComparator comparator = new RowComparator(eTypedElement, direction, this.facetManager);
-// Collections.sort(rows, comparator);
-// return new BrutalListSetCommand(this.table, TablePackage.eINSTANCE.getTable_Rows(), rows, Messages.TableCommandFactory_row_sort_label, NLS.bind(Messages.TableCommandFactory_row_sort_description, eTypedElement.getName()));
-// }
-
- public Command createRemoveRowByEObjectCommand(final Collection<? extends EObject> eObjectRows) {
- final List<Row> rowsToRemove = new ArrayList<Row>();
- for(Row row : this.table.getRows()) {
- if(eObjectRows.contains(row.getElement())) {
- rowsToRemove.add(row);
- }
- }
- return createRemoveRowsCommand(rowsToRemove);
- }
-
- public Command createRemoveUselessColumnsCommand(final Collection<Row> rowsToRemove, final List<FacetSet> nextLoadedFS) {
- final List<Command> commandList = new CommandList();
- final List<Row> rowsToKeep = new ArrayList<Row>(this.table.getRows());
- rowsToKeep.removeAll(rowsToRemove);
- List<FacetSet> facetSets;
- if(nextLoadedFS == null) {
- facetSets = this.table.getFacetSets();
- } else {
- facetSets = nextLoadedFS;
- }
- final List<FeatureColumn> columns = TableInstanceUtils.columnsToRemove(this.table, facetSets, rowsToKeep);
-
- for(FeatureColumn column : columns) {
-// DebugUtils.debug(TableCommandFactory.DEBUG, "column to remove: " //$NON-NLS-1$
-// + EcoreUtil.getURI(column.getFeature()));
- final Command rmColumnCmd = this.commandFactory.createRemoveCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Columns(), column);
- commandList.add(rmColumnCmd);
- }
-// if(TableCommandFactory.DEBUG) {
-// DebugUtils.debug("Columns to be removed: " + commandList.size()); //$NON-NLS-1$
-// }
- return createResult(commandList,"remove useless column");
- }
-
- public Command createRemoveRowsCommand(final Collection<Row> rows) {
- final List<Command> cmdList = new CommandList();
- for(Row row : rows) {
- final Command removeRowCommand = this.commandFactory.createRemoveCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Rows(), row);
- cmdList.add(removeRowCommand);
- }
- final Command updateColumnCmd = createRemoveUselessColumnsCommand(rows, null);
- cmdList.add(updateColumnCmd);
- return createResult(cmdList, NLS.bind("Remove {0} row(s)", Integer.valueOf(cmdList.size()))); //$NON-NLS-1$;
- }
-
- public Command createAddRowsCommand(final Collection<? extends EObject> eObjects) {
- final List<Command> cmdList = new CommandList();
- int nbRows = 0;
- // the EPackage for which the MetamodelView has already been created
- final Set<EPackage> alreadyDone = new HashSet<EPackage>();
- final List<EStructuralFeature> processedSF = new ArrayList<EStructuralFeature>();
- final List<EObject> tableContent = TableWidgetUtils.getElements(this.table);
- for(EObject eObject : eObjects) {
- if(!tableContent.contains(eObject)) {
- final Row row = TableFactory.eINSTANCE.createRow();
- final Command setToRowCmd = this.commandFactory.createSetCommand(this.editingDomain, row, TablePackage.eINSTANCE.getRow_Element(), eObject);
- cmdList.add(setToRowCmd);
- final Command addRowCmd = this.commandFactory.createAddCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Rows(), row);
- cmdList.add(addRowCmd);
- nbRows++;
- for(EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) {
- if(!processedSF.contains(eStructuralFeature)) {
- processedSF.add(eStructuralFeature);
- final Command createAddColumn = createAddColumn(alreadyDone, eStructuralFeature);
- cmdList.add(createAddColumn);
- }
- }
- }
- }
- return createResult(cmdList, NLS.bind("Add of {0} rows", Integer.valueOf(nbRows))); //$NON-NLS-1$
- }
-
- private Command createAddColumn(final Set<EPackage> alreadyDone, final EStructuralFeature structuralFeature) {
- final List<Command> cmdList = new CommandList();
- if(!TableInstanceUtils.isColumnAlreadyDeclared(this.table, structuralFeature)) {
- final FeatureColumn referenceColumn = TableFactory.eINSTANCE.createFeatureColumn();
- referenceColumn.setFeature(structuralFeature);
- final Command cmd = this.commandFactory.createAddCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Columns(), referenceColumn);
- cmdList.add(cmd);
- // we add the local customization file
- final List<Customization> localCustoms = this.table.getLocalCustomizations();
- final EClass eClass = structuralFeature.getEContainingClass();
- if(eClass != null) {
- final EPackage ePackage = eClass.getEPackage();
- if(!alreadyDone.contains(ePackage) && CustomizationUtils.findCustomizationExtendingEPackage(localCustoms, ePackage) == null) {
- final Command localCustomCmd = createAddLocalCustomCommand(ePackage);
- if(localCustomCmd.canExecute()) {
- cmdList.add(localCustomCmd);
- }
- alreadyDone.add(ePackage);
- }
- }
- }
- return createResult(cmdList, NLS.bind("Add a column for {0}::{1}", //$NON-NLS-1$
- structuralFeature.getEContainingClass().getName(), structuralFeature.getName()));
- }
-
- private Command createAddLocalCustomCommand(final EPackage ePackage) {
- final List<Command> cmdList = new CommandList();
- final ICommandFactoryResult<Customization> cmdFactoryResult = createCreateLocalCustom(ePackage);
- final Customization newCustom = cmdFactoryResult.getResult();
- cmdList.add(cmdFactoryResult.getCommand());
- final List<Customization> customs = new ArrayList<Customization>();
- customs.addAll(this.table.getCustomizations());
- // we look for the index of the new local custom
- final List<Customization> localCustoms = this.table.getLocalCustomizations();
- int index = 0;
- for(Customization custom : customs) {
- if(localCustoms.contains(custom)) {
- break;
- }
- index++;
- }
- customs.add(index, newCustom);
- final Command setCustomCmd = this.commandFactory.createSetCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Customizations(), customs);
- cmdList.add(setCustomCmd);
- return createResult(cmdList, NLS.bind("Add of a new customization for the ePackage '{0}'", //$NON-NLS-1$
- ePackage.getName()));
- }
-
- public ICommandFactoryResult<Customization> createCreateLocalCustom(final EPackage ePackage) {
- final ICustomizationCommandFactory customCmdFactory = ICustomizationCommandFactoryFactory.DEFAULT.createCustomizationCommandFactory(this.editingDomain, this.commandFactory);
- final List<Command> cmdList = new CommandList();
- final ICommandFactoryResult<Customization> cmdFactoryResult = customCmdFactory.createCustomization("Column hiding customization for " //$NON-NLS-1$
- + ePackage.getName());
- final Customization customization = cmdFactoryResult.getResult();
- cmdList.add(cmdFactoryResult.getCommand());
- final Command addToLocalCmd = this.commandFactory.createAddCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_LocalCustomizations(), customization);
- cmdList.add(addToLocalCmd);
- final Command addAllCmd = this.commandFactory.createAddCommand(this.editingDomain, this.table, TablePackage.eINSTANCE.getTable_Customizations(), customization);
- cmdList.add(addAllCmd);
- final Command cmd = createResult(cmdList, "Create a local custom."); //$NON-NLS-1$
- return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(cmd, customization);
-
- }
-
- public Command createSetFacetSetsCommand(final List<? extends FacetSet> facetSets) {
- return createSetLoadedFacetSetsCommand(facetSets, true);
- }
-
-
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableInstanceCommandFactory.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableInstanceCommandFactory.java
deleted file mode 100644
index 6e522d3f108..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableInstanceCommandFactory.java
+++ /dev/null
@@ -1,349 +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.infra.table.efacet.menu.factory;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.EClassCustomization;
-import org.eclipse.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactory;
-import org.eclipse.emf.facet.custom.ui.internal.exported.ICustomizationCommandFactoryFactory;
-import org.eclipse.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IsOneOfQuery;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryFactory;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.eclipse.emf.facet.util.emf.core.command.ICommandFactoryResult;
-import org.eclipse.emf.facet.util.emf.core.command.ICommandFactoryResultFactory;
-import org.eclipse.emf.facet.widgets.celleditors.ICommandFactoriesRegistry;
-import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Column;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.FeatureColumn;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Row;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.SourceColumn;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Table;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.TablePackage;
-import org.eclipse.emf.facet.widgets.table.ui.internal.exported.ITableWidgetInternal;
-
-
-//FIXME duplicated and adapted code from EMF-Facet
-//EMF-Facet should provides a best way to hide columns
-public final class TableInstanceCommandFactory {
-
- public static Command createShowHideColumnCommand(final ITableWidgetInternal widgetController,final EditingDomain editingDomain, final ICommandFactory commandFactory, final Table table, final List<Column> columnsToShow, final List<Column> columnsToHide, final boolean putOnTheTop) {
- final CompoundCommand compoundCommand = new CompoundCommand("Show/hide column"); //$NON-NLS-1$
-
- for(final Column current : columnsToShow) {
- if(current instanceof SourceColumn) {
- final Command cmd = commandFactory.createSetCommand(editingDomain, current, TablePackage.eINSTANCE.getSourceColumn_IsHidden(), Boolean.FALSE);
- if(cmd.canExecute()) {
- compoundCommand.append(cmd);
- }
- }
- }
-// HashSet<FeatureColumn> fColumnsToHide = new HashSet<FeatureColumn>();
- final HashSet<ETypedElement> featureToHide = new HashSet<ETypedElement>();
- for(final Column current : columnsToHide) {
- if(current instanceof FeatureColumn) {
-// fColumnsToHide.add((FeatureColumn)current);
- featureToHide.add(((FeatureColumn)current).getFeature());
- } else {
- final Command cmd = commandFactory.createSetCommand(editingDomain, current, TablePackage.eINSTANCE.getSourceColumn_IsHidden(), Boolean.TRUE);
- compoundCommand.append(cmd);
- }
- }
-
- final EList<Column> currentColumns = table.getColumns();
- final List<Column> toHide2 = new ArrayList<Column>(currentColumns);
- toHide2.removeAll(columnsToHide);
- toHide2.removeAll(columnsToShow);
- final List<Column> visibleColumns = widgetController.getVisibleColumns(false);
- for(final Column col : toHide2) {
- if(visibleColumns.contains(col)) {
- columnsToShow.add(col);
- } else if(col instanceof FeatureColumn) {
- featureToHide.add(((FeatureColumn)col).getFeature());
- }
- }
-
- final Command tmp = createHideColumnCommand(widgetController,editingDomain, table,featureToHide);
-
- if(tmp != null) {
- compoundCommand.append(tmp);
- }
- //FIXME : we ignore it in Papyrus...
- // if (putOnTheTop) {
- // Command cmd = createPutLocalCustomizationOnTheTopCommand(widgetController);
- // if (cmd.canExecute()) {
- // compoundCommand.append(cmd);
- // }
- // }
- return compoundCommand;
- }
-
- //public static Command createPutLocalCustomizationOnTheTopCommand(final EditingDomain editingDomain
- // final Object natTableWidget) {
- // ICommandFactory commandFactory = natTableWidget.getCommandFactory();
- // List<Customization> localCustoms = natTableWidget.getLocalCustomizations();
- // List<Customization> customizations = new ArrayList<Customization>();
- // customizations.addAll(natTableWidget.getTable().getCustomizations());
- // customizations.removeAll(localCustoms);
- // customizations.addAll(0, localCustoms);
- // return commandFactory.createSetCommand(natTableWidget.getEditingDomain(),
- // natTableWidget.getTable(),
- // TablePackage.eINSTANCE.getTable_Customizations(),
- // customizations);
- //}
-
-
-
- private TableInstanceCommandFactory() {
- // Prevents instantiation
- }
-
- /**
- * This method retruns an EMF command deleting the a collection of EObject
- *
- * @param label
- * This label will be visible in the menu 'Edit'.
- * @param eObjects
- * @param controller
- * @return
- */
- public static Command delete(final String label, final Collection<? extends EObject> eObjects, final EditingDomain domain, final ICommandFactory factory) {
- final List<Command> cmdList = new ArrayList<Command>();
- for(final EObject eObject : eObjects) {
- final Command command = factory.createDeleteCommand(domain, eObject);
- cmdList.add(command);
- }
- Command result = null;
- if(!cmdList.isEmpty()) {
- result = new CompoundCommand(label, cmdList);
- }
- return result;
- }
-
- /**
- * This method create a command deleting use less row and columns.
- *
- * @param controller
- * @return null if no action has to be performed.
- */
- public static final Command createRemoveUselessRowsAndColumnsCommand(final EditingDomain domain, final ICommandFactory factory, final Table table) {
- final List<Command> cmdList = new ArrayList<Command>();
- final List<Row> rowsToRemove = TableInstanceUtils.findUselessRow(table);
-// if(TableWidgetController.DEBUG_REMOVE_USELESS_ROWS_AND_COLUMNS) {
-// DebugUtils.debug("Rows to be removed: " + rowsToRemove.size()); //$NON-NLS-1$
-// }
- final Command deleteRows = TableInstanceCommandFactory.delete("Delete useless row", rowsToRemove,domain, factory);
- if(deleteRows != null) {
- cmdList.add(deleteRows);
- }
- final TableCommandFactory tableCmdFactory = new TableCommandFactory(table,domain, factory, null);
- final Command removeColumnCommand = tableCmdFactory.createRemoveUselessColumnsCommand(rowsToRemove, null);
- if(removeColumnCommand != null) {
- if(!removeColumnCommand.canExecute()) {
- //FIXME
- throw new RuntimeException("Command cannot be executed");
-// throw new TableWidgetRuntimeException("Command cannot be executed"); //$NON-NLS-1$
- }
- cmdList.add(removeColumnCommand);
- }
- CompoundCommand command = null;
- if(!cmdList.isEmpty()) {
- command = new CompoundCommand("Remove useless columns", cmdList);
- }
- return command;
- }
-
- /**
- *
- * @param column
- * a column
- * @param isHidden
- * the new feature value for this column
- * @param customizedFeatureName
- * the customized feature name
- * @return
- */
- public static Command createHideColumnCommand(final ITableWidgetInternal widgetController, final EditingDomain domain, final Table table, final Collection<ETypedElement> featuresToHide) {
- final FacetOperation isVisibleProperty = widgetController.getCustomPropertiesHandler().getIsVisible();
- final CompoundCommand resultCmd = new CompoundCommand("Show/hide column"); //$NON-NLS-1$
- final EditingDomain editingDomain = domain;
- final ICommandFactory commandFactory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(editingDomain);
- // final EStructuralFeature featureOfTheColumn = featureColumn
- // .getFeature();
- // EObject packageLevel = featureOfTheColumn.eContainer().eContainer();
- // if (!(packageLevel instanceof EPackage)) {
- // throw new IllegalStateException(
- // "Unexpected feature container type " + packageLevel + " found. (EPackage is execpected)"); //$NON-NLS-1$ //$NON-NLS-2$
- // }
- // final EPackage customizedEPackage = (EPackage) packageLevel;
- // 1 we look for the corresponding customization
- final List<Customization> localCustomizations = table.getLocalCustomizations();
- Customization customization = null;
- if(!localCustomizations.isEmpty()) {
- customization = localCustomizations.get(0);
- }
- final ICustomizationCommandFactory customCmdFactory = ICustomizationCommandFactoryFactory.DEFAULT.createCustomizationCommandFactory(editingDomain, commandFactory);
- // If the wanted customization does not exist then we create it.
- if(customization == null) {
- // final TableCommandFactory factory = new TableCommandFactory(table, domain, commandFactory, null);
- final ICommandFactoryResult<Customization> cmdFactoryResult = createCreateLocalCustom(editingDomain, commandFactory, table, EcorePackage.eINSTANCE);
- customization = cmdFactoryResult.getResult();
- resultCmd.append(cmdFactoryResult.getCommand());
- }
- Facet typeCustomization = CustomizationUtils.findFacetByExtendedMetaclass(FacetUtils.getFacets(customization), EcorePackage.eINSTANCE.getETypedElement());
- IsOneOfQuery conformanceQuery;
- if(typeCustomization == null) {
- conformanceQuery = QueryFactory.eINSTANCE.createIsOneOfQuery();
- final ICommandFactoryResult<EClassCustomization> createEClassCustom = customCmdFactory.createEClassCustomization(customization, EcorePackage.eINSTANCE.getETypedElement(), conformanceQuery);
- typeCustomization = createEClassCustom.getResult();
- resultCmd.append(createEClassCustom.getCommand());
- } else {
- if(!(typeCustomization instanceof EClassCustomization)) {
- // throw new TableWidgetRuntimeException("Unexpected type for the variable 'featureContainer'"); //$NON-NLS-1$
- //TODO
- }
- final DerivedTypedElement conformanceTE = (DerivedTypedElement)typeCustomization.getConformanceTypedElement();
- conformanceQuery = (IsOneOfQuery)conformanceTE.getQuery();
- }
- // final HashSet<ETypedElement> featuresToHide = new HashSet<ETypedElement>();
- // for(FeatureColumn column : featureColumns) {
- // featuresToHide.add(column.getFeature());
- // }
- final Command initQuery = commandFactory.createSetCommand(editingDomain, conformanceQuery, QueryPackage.eINSTANCE.getIsOneOfQuery_ExpectedEObjects(), new ArrayList<ETypedElement>(featuresToHide));
- resultCmd.append(initQuery);
- final Query query = QueryFactory.eINSTANCE.createFalseLiteralQuery();
- final ICommandFactoryResult<Facet> propConfigCmd = customCmdFactory.setPropertyConfig(typeCustomization, null, isVisibleProperty, query);
- resultCmd.append(propConfigCmd.getCommand());
- return resultCmd;
- }
-
-
- public static ICommandFactoryResult<Customization> createCreateLocalCustom(final EditingDomain editingDomain, final ICommandFactory commandFactory, final Table table, final EPackage ePackage) {
- final ICustomizationCommandFactory customCmdFactory = ICustomizationCommandFactoryFactory.DEFAULT.createCustomizationCommandFactory(editingDomain, commandFactory);
- final List<Command> cmdList = new CommandList();
- final ICommandFactoryResult<Customization> cmdFactoryResult = customCmdFactory.createCustomization("Column hiding customization for " //$NON-NLS-1$
- + ePackage.getName());
- final Customization customization = cmdFactoryResult.getResult();
- cmdList.add(cmdFactoryResult.getCommand());
- final Command addToLocalCmd = commandFactory.createAddCommand(editingDomain, table, TablePackage.eINSTANCE.getTable_LocalCustomizations(), customization);
- cmdList.add(addToLocalCmd);
- final Command addAllCmd = commandFactory.createAddCommand(editingDomain, table, TablePackage.eINSTANCE.getTable_Customizations(), customization);
- cmdList.add(addAllCmd);
- final Command cmd = createResult(cmdList, "Create a local custom."); //$NON-NLS-1$
- return ICommandFactoryResultFactory.DEFAULT.createCommandFactoryResult(cmd, customization);
-
- }
-
- private static Command createResult(final List<Command> commandList, final String label) {
- Command result = null;
- while(commandList.contains(null)) {
- commandList.remove(null);
- }
- if(!commandList.isEmpty()) {
- result = new CompoundCommand(label, commandList);
- }
- return result;
- }
-
-
-
- // /**
- // * This method retruns an EMF command deleting the a collection of EObject
- // *
- // * @param label
- // * This label will be visible in the menu 'Edit'.
- // * @param eObjects
- // * @param controller
- // * @return
- // */
- // public static Command delete(final String label, final Collection<? extends EObject> eObjects, final TableWidgetController controller) {
- // List<Command> cmdList = new ArrayList<Command>();
- // for(EObject eObject : eObjects) {
- // Command command = controller.getCommandFactory().createDeleteCommand(controller.getEditingDomain(), eObject);
- // cmdList.add(command);
- // }
- // Command result = null;
- // if(!cmdList.isEmpty()) {
- // result = new CompoundCommand(label, cmdList);
- // }
- // return result;
- // }
- //
- // /**
- // * This method create a command deleting use less row and columns.
- // *
- // * @param controller
- // * @return null if no action has to be performed.
- // */
- // public static final Command createRemoveUselessRowsAndColumnsCommand(final TableWidgetController controller) {
- // List<Command> cmdList = new ArrayList<Command>();
- // List<Row> rowsToRemove = TableInstanceUtils.findUselessRow(controller.getTable());
- // if(TableWidgetController.DEBUG_REMOVE_USELESS_ROWS_AND_COLUMNS) {
- // DebugUtils.debug("Rows to be removed: " + rowsToRemove.size()); //$NON-NLS-1$
- // }
- // final Command deleteRows = TableInstanceCommandFactory.delete(Messages.TableWidgetController_DeleteUselessRows, rowsToRemove, controller);
- // if(deleteRows != null) {
- // cmdList.add(deleteRows);
- // }
- // final TableCommandFactory tableCmdFactory = new TableCommandFactory(controller.getTable(), controller.getEditingDomain(), controller.getCommandFactory(), null);
- // final Command removeColumnCommand = tableCmdFactory.createRemoveUselessColumnsCommand(rowsToRemove, null);
- // if(removeColumnCommand != null) {
- // if(!removeColumnCommand.canExecute()) {
- // throw new TableWidgetRuntimeException("Command cannot be executed"); //$NON-NLS-1$
- // }
- // cmdList.add(removeColumnCommand);
- // }
- // CompoundCommand command = null;
- // if(!cmdList.isEmpty()) {
- // command = new CompoundCommand(Messages.TableWidgetController_RemoveUselessRowsAndColumns, cmdList);
- // }
- // return command;
- // }
- private static class CommandList extends LinkedList<Command> {
-
- /**
- *
- */
- private static final long serialVersionUID = 4393120485370832319L;
-
- @Override
- public boolean add(final Command command) {
- boolean result;
- if(command == null) {
- result = false;
- } else {
- result = super.add(command);
- }
- return result;
- }
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableInstanceUtils.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableInstanceUtils.java
deleted file mode 100644
index 29514ec5451..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/factory/TableInstanceUtils.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011, 2012 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - Bug 331203 - table model editor - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 332437 - NatTable : pluggable cell editors
- * Nicolas Guyomar (Mia-Software) - Bug 331442 - To be able to add and remove lines (model elements) from the table
- * Nicolas Bros (Mia-Software) - Bug 332226 - To be able to create or delete model element from the table
- * Nicolas Guyomar (Mia-Software) - Bug 332226 - To be able to create or delete model element from the table
- * Nicolas Bros (Mia-Software) - Bug 332438 - NatTable : table type
- * Nicolas Bros (Mia-Software) - Bug 332440 - NatTable : force cell editors
- * Nicolas Bros (Mia-Software) - Bug 331675 - NatTable : copy cells as text
- * Nicolas Bros (Mia-Software) - Bug 331900 - customizable NatTable
- * Nicolas Bros (Mia-Software) - Bug 332010 - view Facet customizations on NatTable
- * Nicolas Bros (Mia-Software) - Bug 332215 - customizable NatTable column headers
- * Nicolas Guyomar (Mia-Software) - Bug 332215 - customizable NatTable column headers
- * Nicolas Guyomar (Mia-Software) - Bug 332924 - To be able to save the table
- * Nicolas Guyomar (Mia-Software) - Bug 332998 - To be able to add a column and fill it with the result of a query
- * Gregoire Dupe (Mia-Software) - Bug 332998 - To be able to add a column and fill it with the result of a query
- * Gregoire Dupe (Mia-Software) - Bug 333015 - To be able to hide columns
- * Nicolas Guyomar (Mia-Software) - Bug 333015 - To be able to hide columns
- * Nicolas Guyomar (Mia-Software) - Bug 333029 - To be able to save the size of the lines and the columns
- * Nicolas Guyomar (Mia-Software) - Bug 333414 - The user must be able to save the column order
- * Nicolas Guyomar (Mia-Software) - Bug 335154 - Sort Column By Type : Cannot modify resource set without a write transaction
- * Nicolas Guyomar (Mia-Software) - Bug 335155 - Hide Empty Column : Cannot modify resource set without a write transaction
- * Nicolas Guyomar (Mia-Software) - Bug 335156 - Only Show Common column : Cannot modify resource set without a write transaction
- * Nicolas Guyomar (Mia-Software) - Bug 335020 - Nattable widget should use the Eclipse framework
- * Nicolas Guyomar (Mia-Software) - Bug 337322 - [TableConfiguration] Customization declared in the file tableconfiguration is not loaded
- * Nicolas Guyomar (Mia-Software) - Bug 338536 - Problem with the refresh of the table : the scrollbar returns to this initial position
- * Nicolas Bros (Mia-Software) - Bug 338536 - Problem with the refresh of the table : the scrollbar returns to this initial position
- * Nicolas Guyomar (Mia-Software) - Bug 337454 - We can't delete a query Column
- * Nicolas Guyomar (Mia-Software) - Bug 337395 - Unused columns should be destroyed
- * Nicolas Guyomar (Mia-Software) - Bug 339554 - org.eclipse.emf.facet.widgets.celleditors API cleaning
- * Nicolas Guyomar (Mia-Software) - Bug 339922 - INatTableWidget method isCellSelected should use the plural
- * Nicolas Guyomar (Mia-Software) - Bug 340681 - Facet column implementation
- * Vincent Lorenzo (CEA-LIST) - Bug 337326 - Show/Hide Column : Sort the columns by name
- * Nicolas Guyomar (Mia-Software) - Bug 340940 - To be able to view facet attributes and facet references in a table
- * Vincent Lorenzo (CEA-LIST) - Bug 337408 - Add an action to sort columns by name
- * Nicolas Guyomar (Mia-Software) - Bug 336482 - KeyBinding to edit element in Table : F2
- * Vincent Lorenzo (CEA-LIST) - Bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Gregoire Dupe (Mia-Software) - Bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Nicolas Guyomar (Mia-Software) - Bug 342451 - To be able to edit derived facet attributes and derived facet references in a table
- * Vincent Lorenzo (CEA-LIST) - Bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Nicolas Guyomar (Mia-Software) - Bug 343411 - [Table] Create new elements does not support IJavaModelQuery anymore
- * Gregoire Dupe (Mia-Software) - Bug 343811 - EMF Facet Regression : Created elements in a table are not serialized
- * Vincent Lorenzo (CEA-LIST) - Bug 344125 - The API should provide a method selectRows(List<EObject> elementsToSelect)
- * Nicolas Guyomar (Mia-Software) - Bug 344274 - SWT BOT fail on Hudson
- * Nicolas Guyomar (Mia-Software) - Bug 344475 - To be able to select a cell by EStructuralFeature in the table
- * Nicolas Guyomar (Mia-Software) - Bug 342028 - Field can be edited even if they are marked as N/A
- * Nicolas Guyomar (Mia-Software) - Bug 344413 - Facet Columns are never created when we begin with an empty table
- * Gregoire Dupe (Mia-Software) - Bug 343859 - The local customizations are not applied when we reopen a table
- * Nicolas Guyomar (Mia-Software) - Bug 344670 - Problems with the columns creation : very slow + scrollbar blinked
- * Vincent Lorenzo (CEA LIST) - Bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
- * Nicolas Guyomar (Mia-Software) - Bug 344925 - Undo/Redo after the action Show Columns
- * Gregoire Dupe (Mia-Software) - Bug 344925 - Undo/Redo after the action Show Columns - Regression fix
- * Nicolas Guyomar (Mia-Software) - Bug 345665 - Columns are duplicated when you drop many elements in the same time
- * Nicolas Guyomar (Mia-Software) - Bug 346465 - [EMF Facet Table] Remove line does not remove obsolete column
- * Gregoire Dupe (Mia-Software) - Bug 345730 - Deleting an element in the model breaks the table
- * Gregoire Dupe (Mia-Software) - Bug 354224 - mutually exclusive Facets
- * Grégoire Dupé (Mia-Software) - Bug 356795 - [Unit Test Failure][0.2/4.2][0.2/3.8] org.eclipse.emf.facet.widgets.nattable.tests.Bug344413Test.testBug344413
- * Gregoire Dupe (Mia-Software) - Bug 366804 - [Restructuring] Table widget upgrade
- * Gregoire Dupe (Mia-Software) - Bug 367613 - Table widget refactoring
- * Gregoire Dupe (Mia-Software) - Bug 367700 - [Unit Test Failure][0.2/3.8] org.eclipse.emf.facet.widgets.table.tests.internal.v0_2.swtbot.NatTableUITests.testOpenLoadCustomizationDialog
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Gregoire Dupe (Mia-Software) - Bug 374903 - [Table] ITableWidget.setLoadedFacetSets
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Gregoire Dupe (Mia-Software) - Bug 387008 - [Table] Papyrus needs methods provided by TableInstanceCommandFactory
- * Gregoire Dupe (Mia-Software) - Bug 380293 - [Table] Columns declared in tableconfiguration are never created when we create an empty table
- *******************************************************************************/
-package org.eclipse.papyrus.infra.table.efacet.menu.factory;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.emf.facet.efacet.core.IFacetManagerFactory;
-import org.eclipse.emf.facet.efacet.core.exception.FacetManagerException;
-import org.eclipse.emf.facet.efacet.core.internal.exported.IResolverManager;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-//import org.eclipse.emf.facet.util.core.Logger;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Column;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.FeatureColumn;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Row;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Table;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.tableconfiguration.TableConfiguration;
-//import org.eclipse.emf.facet.widgets.table.ui.internal.exported.exception.UnresolvedProxyException;
-
-//FIXME : duplicted code used in the local tableinstancecommand factory -> EMF-Facet should open its API
-public final class TableInstanceUtils {
-
- private TableInstanceUtils() {
- // Must not be used
- }
-
- /**
- * This methods the row referring a deleted or detached element.
- *
- * @param tableInstance
- * @return
- */
- public static List<Row> findUselessRow(final Table tableInstance) {
- final List<Row> rowsToRemove = new ArrayList<Row>();
- for(Row row : tableInstance.getRows()) {
- if(row.getElement() == null || row.getElement().eResource() == null) {
- rowsToRemove.add(row);
- }
- }
- return rowsToRemove;
- }
-
- /**
- * This method returns the list of structural feature required to presents
- * the chosen rows.
- *
- * @param table
- * @param rowsToKeep
- * @param nextLoadedFacets
- * can be null.
- * @param facetManager
- * @return
- */
- public static Set<ETypedElement> getAllETypedElement(final Table table,
- final List<Row> rowsToKeep,
- final List<? extends FacetSet> nextLoadedFacets) {
- final Set<ETypedElement> eTypedElements = new HashSet<ETypedElement>();
- final IFacetManager facetManager = IFacetManagerFactory.DEFAULT
- .getOrCreateFacetManager(new ResourceSetImpl());
- if (nextLoadedFacets == null) {
- facetManager.getManagedFacetSets().addAll(table.getFacetSets());
- } else {
- facetManager.getManagedFacetSets().addAll(nextLoadedFacets);
- }
- for (Row row : rowsToKeep) {
- final EClass eClass = row.getElement().eClass();
- eTypedElements.addAll(eClass.getEAllStructuralFeatures());
- eTypedElements.addAll(eClass.getEAllOperations());
- try {
- final Set<ETypedElement> facetTEs = FacetUtils
- .getETypedElements(row.getElement(),
- ETypedElement.class, facetManager);
- eTypedElements.addAll(facetTEs);
- } catch (FacetManagerException e) {
- //FIXME
-// Logger.logError(
-// e,
-// "An exception has occured while retrieving structural features of:" + row.getElement(), Activator.getDefault()); //$NON-NLS-1$
- }
- }
- return eTypedElements;
- }
-
- public static List<FeatureColumn> columnsToRemove(final Table table, final List<? extends FacetSet> newFacetSets, final List<Row> rowsToKeep) {
-
- final List<FeatureColumn> result = new LinkedList<FeatureColumn>();
- if(rowsToKeep.isEmpty()) {
- // If there is no rows, then there should not be any column
- for(Column column : table.getColumns()) {
- if(column instanceof FeatureColumn) {
- final FeatureColumn featureColumn = (FeatureColumn)column;
- addToListNotDefault(featureColumn, result, table);
- }
- }
- } else {
- final List<? extends ETypedElement> eTypedElements = new ArrayList<ETypedElement>(TableInstanceUtils.getAllETypedElement(table, rowsToKeep, newFacetSets));
- for(Column column : table.getColumns()) {
- if(column instanceof FeatureColumn) {
- final FeatureColumn featureColumn = (FeatureColumn)column;
- ETypedElement eTypedElement = featureColumn.getFeature();
- eTypedElement = (ETypedElement)EcoreUtil.resolve(eTypedElement, table);
- if(eTypedElement.eIsProxy()) {
- throw new RuntimeException("The current structural feature should have been resolved. " + EcoreUtil.getURI(eTypedElement)); //$NON-NLS-1$
- }
- final ETypedElement resolvedTE = IResolverManager.DEFAULT.resolve(eTypedElement, ETypedElement.class);
- if(resolvedTE != null) {
- eTypedElement = resolvedTE;
- }
- if(!eTypedElements.contains(eTypedElement)) {
- addToListNotDefault(featureColumn, result, table);
- }
- }
- }
- }
- return result;
- }
-
- private static void addToListNotDefault(final FeatureColumn featureColumn, final List<FeatureColumn> list, final Table table) {
- // The column declared as default in the table configuration must not be
- // removed
- final TableConfiguration tableConfig = table.getTableConfiguration();
- if(tableConfig == null || !tableConfig.getDefaultColumns().contains(featureColumn.getFeature())) {
- list.add(featureColumn);
- }
- }
-
- public static boolean isColumnAlreadyDeclared(final Table table, final EStructuralFeature structuralFeature) {
- boolean result = false;
- for(Column column : table.getColumns()) {
- if(column instanceof FeatureColumn) {
- final FeatureColumn featureColumn = (FeatureColumn)column;
- if(featureColumn.getFeature() == structuralFeature) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/ColumnsToShowDialog.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/ColumnsToShowDialog.java
deleted file mode 100644
index 9ea0802cf45..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/ColumnsToShowDialog.java
+++ /dev/null
@@ -1,384 +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.infra.table.efacet.menu.handler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-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 IContentProvider 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;
-
- /**
- *
- * Constructor.
- *
- * @param parentShell
- * the parent shell
- * @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 Collection<ETypedElement> features, final Collection<ENamedElement> additionalFeatures, final Collection<ETypedElement> initialSelection, final ILabelProvider labelProvider, final IContentProvider contentProvider) {
- super(parentShell);
- setTitle("Select the columns to show");
- this.directFeatures = features;
- this.additionalFeatures = additionalFeatures;
- this.labelProvider = labelProvider;
- this.contentProvider = contentProvider;
- this.initialSelection = initialSelection;
- }
-
- @Override
- public void create() {
- super.create();
-
- final Composite parent = (Composite)getDialogArea();
- final GridLayout layout = (GridLayout)parent.getLayout();
- layout.numColumns = 2;
- layout.makeColumnsEqualWidth = true;
-
- 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));
-
- createDirectFeaturesSection(selectorPane);
- createAdditionalFeaturesSection(selectedPane);
-
- getShell().setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
- getShell().layout();
-
- //TODO
- // super.getShell().setImage(Activator.getDefault().getImage("/icons/papyrus.png")); //$NON-NLS-1$
- }
-
- /**
- *
- * @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("Direct Features");
-
- //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("Select All");
- selectAllFeaturesButton.setToolTipText("Select all available features.");
- 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("Deselect All");
- deselectAllFeaturesButton.setToolTipText("Deselect all available features.");
- 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("Additional Features");
-
- //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().setLabelProvider(this.labelProvider);
- this.additionnalFeaturesTree.getViewer().setContentProvider(this.contentProvider);
- this.additionnalFeaturesTree.getViewer().setInput(this.additionalFeatures);
- this.additionnalFeaturesTree.getViewer().expandAll();
- ((ContainerCheckedTreeViewer)this.additionnalFeaturesTree.getViewer()).setCheckedElements(this.initialSelection.toArray());
-
- //4. create the buttons select all and deselect all
- final Composite buttonsPanel = createButtonPanel(facetComposite);
- final Button selectAllAdditionalFeaturesButton = new Button(buttonsPanel, SWT.NONE);
- selectAllAdditionalFeaturesButton.setText("Select All");
- selectAllAdditionalFeaturesButton.setToolTipText("Select all available additional features.");
- 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("Deselect All");
- deselectAllAdditionalFeaturesButton.setToolTipText("Deselect all available additional features.");
- 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();
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/Constants.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/Constants.java
deleted file mode 100644
index 5889324b8b0..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/Constants.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.eclipse.papyrus.infra.table.efacet.menu.handler;
-
-
-//TODO merge with the same class in oep.uml.efacet
-public class Constants {
-
-
- private Constants() {
- //to prevent instanciation
- }
-
- public static final String STEREOTYPE_QUALIFIED_NAME = "stereotypeQualifiedName";
- public static final String STEREOTYPE_PROPERTY_NAME = "stereotypePropertyName";
-
- public static final String ADDITIONAL_CONTENTS_FACET_SET_NAME = "AdditionalContentsForTable";
-
- public static final String ADDITIONAL_CONTENTS_FACET_SET_NS_URI = "http://www.eclipse.org/papyrustableefacet/additionalcontentsfacetset";
-
- public static final String ADDITIONAL_CONTENTS_FACET_SET_PREFIX = "additionalcontentsfacetset";
-
- public static final String ADDITIONAL_CONTENTS_FACET_SET_DOCUMENTATION = "This FacetSet provides facets to edit easily additional contents (as Stereotype Properties). It had been generated by the Papyrus Show/Hide columns";
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/EcoreENamedElementComparator.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/EcoreENamedElementComparator.java
deleted file mode 100644
index 68f74f01e9e..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/EcoreENamedElementComparator.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.eclipse.papyrus.infra.table.efacet.menu.handler;
-
-import java.util.Comparator;
-
-import org.eclipse.emf.ecore.ENamedElement;
-
-
-public class EcoreENamedElementComparator implements Comparator<ENamedElement> {
-
- public int compare(final ENamedElement o1, final ENamedElement o2) {
- return o1.getName().compareToIgnoreCase(o2.getName());
- }
-
-} \ No newline at end of file
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FacetFactory.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FacetFactory.java
deleted file mode 100644
index 805eefea3fb..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FacetFactory.java
+++ /dev/null
@@ -1,352 +0,0 @@
-package org.eclipse.papyrus.infra.table.efacet.menu.handler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetFactory;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.EObjectLiteralQuery;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.OperationCallQuery;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryFactory;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.StringLiteralQuery;
-import org.eclipse.papyrus.uml.efacet.metamodel.umlefacet.ProfileFacetSet;
-import org.eclipse.papyrus.uml.efacet.metamodel.umlefacet.StereotypeFacet;
-import org.eclipse.papyrus.uml.efacet.metamodel.umlefacet.StereotypePropertyFacetAttribute;
-import org.eclipse.papyrus.uml.efacet.metamodel.umlefacet.StereotypePropertyFacetReference;
-import org.eclipse.papyrus.uml.efacet.metamodel.umlefacet.UmlEFacetFactory;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.DataType;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.PackageableElement;
-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;
-
-public class FacetFactory {
-
-
- private FacetFactory() {
- //to prevent instanciation
- }
-
- public static final String UML_BOOLEAN = "Boolean";
-
- public static final String UML_INTEGER = "Integer";
-
- public static final String UML_STRING = "String";
-
- public static final String UML_REAL = "Real";
-
- public static final String UML_UNLIMITED_NATURAL = "UnlimitedNatural";
-
- public static final FacetSet createFacetSet(final String name, final String nsPrefix, final String nsURI, final String documentation) {
- final FacetSet set = EFacetFactory.eINSTANCE.createFacetSet();
- set.setName(name);
- set.setNsPrefix(nsPrefix);
- set.setNsURI(nsURI);
- set.setDocumentation(documentation);
- return set;
- }
-
- /**
- *
- * @param profile
- * @return
- * the ProfileFacetSet for this profile or <code>null</code> if the profile argument doesn't contains steretoypes with properties
- */
- public static final ProfileFacetSet createProfileFacetSet(final Profile profile) {
- final ProfileFacetSet set = UmlEFacetFactory.eINSTANCE.createProfileFacetSet();
- set.setName(profile.getName());
- set.setProfileQualifiedName(profile.getQualifiedName());
- profile.getPackagedElements();
- for(final PackageableElement packagedElement : profile.getPackagedElements()) {
- if(packagedElement instanceof Profile) {
- final ProfileFacetSet subProfile = createProfileFacetSet((Profile)packagedElement);
- //We ignore empty facetSet
- if(subProfile != null && (subProfile.getEClassifiers().size() != 0 || subProfile.getESubpackages().size() != 0)) {
- set.getESubpackages().add(subProfile);
- }
- } else if(packagedElement instanceof Stereotype) {
- //TODO and inherited properties
- //we ignore stereotypes without properties
- final StereotypeFacet stereotypeFacet = createFacet((Stereotype)packagedElement);
- if(stereotypeFacet.getFacetElements().size() != 0) {
- set.getEClassifiers().add(stereotypeFacet);
- }
- }
- }
-
- //TODO
- // set.setNsPrefix(nsPrefix);
- // set.setNsURI(nsURI);
- // set.setDocumentation(documentation);
-
- if(set.getEClassifiers().size() != 0 || set.getESubpackages().size() != 0) {
- return set;
- }
- return null;
-
- }
-
- public static final StereotypeFacet createFacet(final Stereotype stereotype) {
- final StereotypeFacet facet = UmlEFacetFactory.eINSTANCE.createStereotypeFacet();
- facet.setStereotypeQualifiedName(stereotype.getQualifiedName());
- facet.setName(stereotype.getName());
- facet.setDocumentation("This facet represents the eClass " + stereotype.getName());
- // facet.setConformanceTypedElement(value);//TODO
- facet.setExtendedMetaclass(UMLPackage.eINSTANCE.getElement());//TODO
- //TODO and inherited properties?
- final Collection<String> ignoredPropertyName = new ArrayList<String>();
-
- final String BASE_ = "base_"; //TODO move it in another plugin!
- for(final Class tutu : stereotype.getExtendedMetaclasses()) {
- ignoredPropertyName.add(BASE_ + tutu.getName());
- }
- for(final Property attribute : stereotype.getOwnedAttributes()) {
- if(ignoredPropertyName.contains(attribute.getName())) {
- continue;
- }
- if(attribute.getType() instanceof DataType) {
- final StereotypePropertyFacetAttribute facetAttr = createFacetAttribute(attribute, stereotype);
- facet.getFacetElements().add(facetAttr);
- } else if(attribute.getType() instanceof Element) {//or EObject TODO ?
- final StereotypePropertyFacetReference facetRef = createFacetReference(attribute, stereotype);
- facet.getFacetElements().add(facetRef);
- }
- }
-
- // //We create the query to get the reprensentedStereotype
- // final FacetOperation operation = EFacetFactory.eINSTANCE.createFacetOperation();
- // operation.setLowerBound(1);
- // operation.setUpperBound(1);
- // operation.setDocumentation("Returns the qualified name of the represented stereotype");
- // operation.setName("getStereotypeQualifiedName");
- // // operation.setEType(); //string
- // final StringLiteralQuery query = QueryFactory.eINSTANCE.createStringLiteralQuery();
- // query.setValue(stereotype.getQualifiedName());
- // operation.setQuery(query);
- return facet;
- }
-
-
-
-
-
- public static final StereotypePropertyFacetReference createFacetReference(final Property attribute2, final Stereotype ste) {
- final StereotypePropertyFacetReference facetReference = UmlEFacetFactory.eINSTANCE.createStereotypePropertyFacetReference();
- facetReference.setIsDerived(attribute2.isDerived());
- facetReference.setPropertyName(attribute2.getName());
-
- facetReference.setName(attribute2.getName());
- facetReference.setDocumentation("This Facet Attribute represents the stereotype property " + attribute2.getQualifiedName());
- facetReference.setChangeable(!attribute2.isDerived());
- facetReference.setDerived(true);
- final Type type = attribute2.getType();
- final EClassifier eType = EcorePackage.eINSTANCE.getEObject(); //TODO or element ?
- OperationCallQuery query;
- FacetOperation facetOperationCalled = null;
- final int upperBound = attribute2.upperBound();
-
- //UML primitive type
- if(type instanceof Element) {
- if(upperBound == -1 || upperBound > 1) {
- facetOperationCalled = FacetOperationUtils.getEObjectMultiReferenceOperation(attribute2.eResource().getResourceSet());
- } else {
- facetOperationCalled = FacetOperationUtils.getEObjectSingleReferenceOperation(attribute2.eResource().getResourceSet());
- }
-
- //we prepare the arguments
- query = QueryFactory.eINSTANCE.createOperationCallQuery();
- query.setCanHaveSideEffects(false);
-
- final EObjectLiteralQuery featureQuery = QueryFactory.eINSTANCE.createEObjectLiteralQuery();
- featureQuery.setElement(facetReference);
- query.getArguments().add(featureQuery);
-// final StringLiteralQuery qualifiedNameQuery = QueryFactory.eINSTANCE.createStringLiteralQuery();
-// qualifiedNameQuery.setValue(ste.getQualifiedName());
-// query.getArguments().add(qualifiedNameQuery);
-//
-// final StringLiteralQuery propertyNameQuery = QueryFactory.eINSTANCE.createStringLiteralQuery();
-// propertyNameQuery.setValue(attribute2.getName());
-// query.getArguments().add(propertyNameQuery);
-
- facetReference.setQuery(query);
-
- query.setOperation(facetOperationCalled);
- } else {
- //TODO?
- }
- facetReference.setEType(eType);
- facetReference.setLowerBound(attribute2.getLower());
- facetReference.setUpperBound(attribute2.getUpper());
- return facetReference;
- }
-
-
-
- //the first version with the qualifiedName
- public static final StereotypePropertyFacetAttribute createFacetAttribute(final Property attribute2, final Stereotype ste) {
- final ResourceSet set = attribute2.eResource().getResourceSet();
- // final FacetAttribute facetAttribute = EFacetFactory.eINSTANCE.createFacetAttribute();
-
- final StereotypePropertyFacetAttribute facetAttribute = UmlEFacetFactory.eINSTANCE.createStereotypePropertyFacetAttribute();
- facetAttribute.setIsDerived(attribute2.isDerived());
- facetAttribute.setPropertyName(attribute2.getName());
-
-
- facetAttribute.setName(attribute2.getName());
- facetAttribute.setDocumentation("This Facet Attribute represents the stereotype property " + attribute2.getQualifiedName());
- facetAttribute.setChangeable(!attribute2.isDerived());
- facetAttribute.setDerived(true);
- final Type type = attribute2.getType();
- EClassifier eType = null;
- OperationCallQuery query;
- FacetOperation facetOperationCalled = null;
- final int upperBound = attribute2.upperBound();
-
- //UML primitive type
- if(type instanceof PrimitiveType) {
- final PrimitiveType pType = (PrimitiveType)type;
- final String name = pType.getName();
- if(UML_BOOLEAN.equals(name)) {
- eType = EcorePackage.eINSTANCE.getEBoolean();
- if(upperBound == -1 || upperBound > 1) {
- facetOperationCalled = FacetOperationUtils.getBooleanMultiValueOperation(set);
- } else {
- facetOperationCalled = FacetOperationUtils.getBooleanSingleValueOperation(set);
- }
- } else if(UML_INTEGER.equals(name)) {
- eType = EcorePackage.eINSTANCE.getEInt();
- if(upperBound == -1 || upperBound > 1) {
- facetOperationCalled = FacetOperationUtils.getIntegerMultiValueOperation(set);
- } else {
- facetOperationCalled = FacetOperationUtils.getIntegerSingleValueOperation(set);
- }
-
- } else if(UML_REAL.equals(name)) {
- eType = EcorePackage.eINSTANCE.getEDouble();
- if(upperBound == -1 || upperBound > 1) {
- facetOperationCalled = FacetOperationUtils.getRealMultiValueOperation(set);
- } else {
- facetOperationCalled = FacetOperationUtils.getRealSingleValueOperation(set);
- }
-
- } else if(UML_STRING.equals(name)) {
- eType = EcorePackage.eINSTANCE.getEString();
- if(upperBound == -1 || upperBound > 1) {
- facetOperationCalled = FacetOperationUtils.getStringMultiValueOperation(set);
- } else {
- facetOperationCalled = FacetOperationUtils.getStringSingleValueOperation(set);
- }
-
- } else if(UML_UNLIMITED_NATURAL.equals(name)) {
- eType = EcorePackage.eINSTANCE.getEInt();
- if(upperBound == -1 || upperBound > 1) {
- facetOperationCalled = FacetOperationUtils.getUnlimitedNaturalMultiValueOperation(set);
- } else {
- facetOperationCalled = FacetOperationUtils.getUnlimitedNaturalSingleValueOperation(attribute2.eResource().getResourceSet());
- }
-
- }
-
-
- //we prepare the arguments
- query = QueryFactory.eINSTANCE.createOperationCallQuery();
- query.setCanHaveSideEffects(false);
-
- final EObjectLiteralQuery featureQuery = QueryFactory.eINSTANCE.createEObjectLiteralQuery();
- featureQuery.setElement(facetAttribute);
- query.getArguments().add(featureQuery);
-
-// final StringLiteralQuery qualifiedNameQuery = QueryFactory.eINSTANCE.createStringLiteralQuery();
-// qualifiedNameQuery.setValue(ste.getQualifiedName());
-// query.getArguments().add(qualifiedNameQuery);
-//
-// final StringLiteralQuery propertyNameQuery = QueryFactory.eINSTANCE.createStringLiteralQuery();
-// propertyNameQuery.setValue(attribute2.getName());
-// query.getArguments().add(propertyNameQuery);
- facetAttribute.setQuery(query);
-
- query.setOperation(facetOperationCalled);
-
- } else if(type instanceof DataType) {
- //TODO
- }
-
- facetAttribute.setEType(eType);//TODO
- // attribute.setQuery(query);////TODO
- facetAttribute.setLowerBound(attribute2.getLower());
- facetAttribute.setUpperBound(attribute2.getUpper());
- return facetAttribute;
- }
-
- // //the second version with references to property and stereitype
- // public static final FacetAttribute createFacetAttribute2(Property attribute2, final Stereotype ste) {
- // FacetAttribute facetAttribute = EFacetFactory.eINSTANCE.createFacetAttribute();
- // facetAttribute.setName(attribute2.getName());
- // facetAttribute.setDocumentation("This Facet Attribute represents the stereotype property " + attribute2.getQualifiedName());
- // facetAttribute.setChangeable(!attribute2.isDerived());
- // facetAttribute.setDerived(true);
- // Type type = attribute2.getType();
- // EClassifier eType = null;
- // OperationCallQuery query;
- // FacetOperation facetOperationCalled = null;
- // int upperBound = facetAttribute.getUpperBound();
- // if(type instanceof PrimitiveType) {
- // PrimitiveType pType = (PrimitiveType)type;
- // final String name = pType.getName();
- // if("EString".equals(name) || "String".equals(name)) {
- // eType = EcorePackage.eINSTANCE.getEString();
- // if(upperBound > 1) {
- // //TODO
- // } else {
- // facetOperationCalled = getSingleStringValueOperation2(attribute2.eResource().getResourceSet());
- // }
- // } else if("EBoolean".equals(name)) {
- // eType = EcorePackage.eINSTANCE.getEBoolean();
- // } else if("EInt".equals(name)) {
- // eType = EcorePackage.eINSTANCE.getEInt();
- // }
- // //else TODO to finish
- //
- //
- //
- //
- //
- // //we prepare the arguments
- // query = QueryFactory.eINSTANCE.createOperationCallQuery();
- // query.setCanHaveSideEffects(false);
- //
- // EObjectLiteralQuery qualifiedNameQuery = QueryFactory.eINSTANCE.createEObjectLiteralQuery();
- // qualifiedNameQuery.setElement(ste);
- // query.getArguments().add(qualifiedNameQuery);
- //
- // EObjectLiteralQuery propertyNameQuery = QueryFactory.eINSTANCE.createEObjectLiteralQuery();
- // propertyNameQuery.setElement(attribute2);
- // query.getArguments().add(propertyNameQuery);
- // facetAttribute.setQuery(query);
- //
- // query.setOperation(facetOperationCalled);
- //
- // }
- // facetAttribute.setEType(eType);//TODO
- // // attribute.setQuery(query);////TODO
- // facetAttribute.setLowerBound(attribute2.getLower());
- // facetAttribute.setUpperBound(attribute2.getUpper());
- // return facetAttribute;
- // }
-
- public static final FacetReference createFacetReference() {
- final FacetReference reference = EFacetFactory.eINSTANCE.createFacetReference();
- return reference;
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FacetOperationUtils.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FacetOperationUtils.java
deleted file mode 100644
index c6030c134d4..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FacetOperationUtils.java
+++ /dev/null
@@ -1,230 +0,0 @@
-package org.eclipse.papyrus.infra.table.efacet.menu.handler;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.facet.efacet.core.IFacetSetCatalogManager;
-import org.eclipse.emf.facet.efacet.core.IFacetSetCatalogManagerFactory;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-
-public class FacetOperationUtils {
-
- /** the facet providing the operation to edit stereotype properties */
- private static Facet stereotypedElementFacet;
-
- private static FacetOperation stringSingleValueOperation;
-
- private static FacetOperation stringMultiValueOperation;
-
-
- private static FacetOperation eobjectMultiReferenceOperation;
-
- private static FacetOperation eobejctMonoReferenceOperation;
-
- private static FacetOperation booleanSingleValueOperation;
-
- private static FacetOperation booleanMultiValueOperation;
-
- private static FacetOperation integerMultiValueOperation;
-
- private static FacetOperation integerSingleValueOperation;
-
- private static FacetOperation realSingleValueOperation;
-
- private static FacetOperation realMultiValueOperation;
-
- private static FacetOperation unlimitedNaturalSingleValueOperation;
-
- private static FacetOperation unlimitedNaturalMultiValueOperation;
-
- private FacetOperationUtils() {
- //to prevent instanciation
- }
-
- public static final Facet getStereotypedElementFacet(final ResourceSet resourceSet) {
- if(stereotypedElementFacet == null) {
- IFacetSetCatalogManager manager = IFacetSetCatalogManagerFactory.DEFAULT.getOrCreateFacetSetCatalogManager(resourceSet);
- for(FacetSet set : manager.getRegisteredFacetSets()) {
- if("org.eclipse.papyrus.uml.efacet/0.9/UML_stereotype".equals(set.getNsURI())) {
- stereotypedElementFacet = (Facet)set.getEClassifier("stereotyped_element");
- break;
- }
- }
- }
- return stereotypedElementFacet;
- }
-
- public static FacetOperation getBooleanMultiValueOperation(final ResourceSet resourceSet) {
- if(booleanMultiValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getBooleanMultiValue".equals(op.getName())) {
- booleanMultiValueOperation = op;
- break;
- }
- }
- }
- return booleanMultiValueOperation;
- }
-
-
-
- public static FacetOperation getBooleanSingleValueOperation(final ResourceSet resourceSet) {
- if(booleanSingleValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getBooleanSingleValue".equals(op.getName())) {
- booleanSingleValueOperation = op;
- break;
- }
- }
- }
- return booleanSingleValueOperation;
- }
-
-
- public static FacetOperation getEObjectMultiReferenceOperation(final ResourceSet resourceSet) {
- if(eobjectMultiReferenceOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getEObjectMultiReference".equals(op.getName())) {
- eobjectMultiReferenceOperation = op;
- break;
- }
- }
- }
- return eobjectMultiReferenceOperation;
- }
-
- public static FacetOperation getEObjectSingleReferenceOperation(final ResourceSet resourceSet) {
- if(eobejctMonoReferenceOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getEObjectSingleReference".equals(op.getName())) {
- eobejctMonoReferenceOperation = op;
- break;
- }
- }
- }
- return eobejctMonoReferenceOperation;
- }
-
- public static FacetOperation getIntegerMultiValueOperation(final ResourceSet resourceSet) {
- if(integerMultiValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getIntegerMultiValue".equals(op.getName())) {
- integerMultiValueOperation = op;
- break;
- }
- }
- }
- return integerMultiValueOperation;
- }
-
- public static FacetOperation getIntegerSingleValueOperation(final ResourceSet resourceSet) {
- if(integerSingleValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getIntegerSingleValue".equals(op.getName())) {
- integerSingleValueOperation = op;
- break;
- }
- }
- }
- return integerSingleValueOperation;
- }
-
-
- public static FacetOperation getRealMultiValueOperation(final ResourceSet resourceSet) {
- if(realMultiValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getRealMultiValue".equals(op.getName())) {
- realMultiValueOperation = op;
- break;
- }
- }
- }
- return realMultiValueOperation;
- }
-
- public static FacetOperation getRealSingleValueOperation(final ResourceSet resourceSet) {
- if(realSingleValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getRealSingleValue".equals(op.getName())) {
- realSingleValueOperation = op;
- break;
- }
- }
- }
- return realSingleValueOperation;
- }
-
- public static FacetOperation getStringMultiValueOperation(final ResourceSet resourceSet) {
- if(stringMultiValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getStringMultiValue".equals(op.getName())) {
- stringMultiValueOperation = op;
- break;
- }
- }
- }
- return stringMultiValueOperation;
- }
-
- public static FacetOperation getStringSingleValueOperation(final ResourceSet resourceSet) {
- if(stringSingleValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getStringSingleValue".equals(op.getName())) {
- stringSingleValueOperation = op;
- break;
- }
- }
- }
- return stringSingleValueOperation;
- }
-
- public static FacetOperation getUnlimitedNaturalMultiValueOperation(final ResourceSet resourceSet) {
- if(unlimitedNaturalMultiValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getUnlimitedNaturalMultiValue".equals(op.getName())) {
- unlimitedNaturalMultiValueOperation = op;
- break;
- }
- }
- }
- return unlimitedNaturalMultiValueOperation;
- }
-
-
- public static FacetOperation getUnlimitedNaturalSingleValueOperation(final ResourceSet resourceSet) {
- if(unlimitedNaturalSingleValueOperation == null) {
- final Facet stereotypedElementFacet = getStereotypedElementFacet(resourceSet);
- if(stereotypedElementFacet != null)
- for(final FacetOperation op : stereotypedElementFacet.getFacetOperations()) {
- if("getUnlimitedNaturalSingleValue".equals(op.getName())) {
- unlimitedNaturalSingleValueOperation = op;
- break;
- }
- }
- }
- return unlimitedNaturalSingleValueOperation;
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FilteredCheckboxTree.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/FilteredCheckboxTree.java
deleted file mode 100644
index a5838624ed4..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/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.infra.table.efacet.menu.handler;
-
-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
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/SelectColumnsHandler.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/SelectColumnsHandler.java
deleted file mode 100644
index 31023fdfb65..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/SelectColumnsHandler.java
+++ /dev/null
@@ -1,752 +0,0 @@
-package org.eclipse.papyrus.infra.table.efacet.menu.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.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.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.Setting;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.emf.facet.efacet.core.IFacetManagerFactory;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetFactory;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetElement;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.impl.FacetSetImpl;
-import org.eclipse.emf.facet.widgets.celleditors.ICommandFactoriesRegistry;
-import org.eclipse.emf.facet.widgets.celleditors.ICommandFactory;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Column;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.FeatureColumn;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Table;
-import org.eclipse.emf.facet.widgets.table.ui.internal.exported.ITableWidget;
-import org.eclipse.emf.facet.widgets.table.ui.internal.exported.ITableWidgetInternal;
-import org.eclipse.emf.facet.widgets.table.ui.internal.exported.ITableWidgetProvider;
-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.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
-import org.eclipse.papyrus.infra.table.efacet.common.editor.AbstractTableEditor;
-import org.eclipse.papyrus.infra.table.efacet.menu.Activator;
-import org.eclipse.papyrus.infra.table.efacet.menu.factory.ITableCommandFactory;
-import org.eclipse.papyrus.infra.table.efacet.menu.factory.TableCommandFactory;
-import org.eclipse.papyrus.infra.table.efacet.menu.factory.TableInstanceCommandFactory;
-import org.eclipse.papyrus.infra.table.efacet.metamodel.papyrustable.PapyrusTable;
-import org.eclipse.papyrus.infra.table.efacet.metamodel.papyrustable.TableContentsUtils;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-
-//FIXME : uml dependency
-public class SelectColumnsHandler extends AbstractHandler {
-
-
-
- /** all direct features available in the table */
- final protected SortedSet<ETypedElement> allDirectFeatures = new TreeSet<ETypedElement>(new EcoreENamedElementComparator());
-
- /** all additional possible contents */
- final protected Collection<FacetSet> allAdditionalContents = new HashSet<FacetSet>();
-
- /** the initial direct features visibles in the table */
- final protected Collection<ETypedElement> initialDirectFeatureSelected = new HashSet<ETypedElement>();
-
- /** the initial additional features visibles in the table */
- final protected Collection<ETypedElement> initialAdditionalFeatureSelected = new HashSet<ETypedElement>();
-
- /** the list of the facetSet used in the current table */
- final protected Collection<FacetSet> facetSetsUsedInTheTable = new HashSet<FacetSet>();
-
- /** the map between existing columns (visible or not) and the feature */
- final protected Map<ETypedElement, Column> columnsFeatureMap = new HashMap<ETypedElement, Column>();
-
-
- //TODO remove it
- final StereotypeManagement management = new StereotypeManagement();
-
- /**
- * clear the fields
- */
- protected void clearFields() {
- this.allDirectFeatures.clear();
- this.initialDirectFeatureSelected.clear();
- this.initialAdditionalFeatureSelected.clear();
- this.facetSetsUsedInTheTable.clear();
- this.columnsFeatureMap.clear();
- this.allAdditionalContents.clear();
- }
-
- //TODO look for an existing method in EMF for EPackage
- private FacetSet getRootFacetSet(final FacetElement facetElement) {
- EObject container = facetElement;
- while(container.eContainer() != null) {
- container = container.eContainer();
- }
- if(container instanceof FacetSet) {
- return (FacetSet)container;
- }
- return null;
- }
-
- /**
- * Inits the fields of this class
- *
- * @param widget
- * the table widget
- * @param papyrusTable
- * the papyrus table
- */
- protected void initField(final ITableWidget widget, final PapyrusTable papyrusTable) {
- clearFields();
- //the contents of the table
- final List<EObject> contents = TableContentsUtils.getTableContents(papyrusTable, papyrusTable.getTable().getContext(), false);
-
- //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 FeatureColumn) {
- final ETypedElement feature = ((FeatureColumn)current).getFeature();
- if(feature instanceof FacetElement) {
- this.initialAdditionalFeatureSelected.add(feature);
- } else {
- this.initialDirectFeatureSelected.add(feature);
- }
- }
- }
-
- for(final Column current : papyrusTable.getTable().getColumns()) {
- if(current instanceof FeatureColumn) {
- final FeatureColumn col = (FeatureColumn)current;
- final ETypedElement feature = col.getFeature();
- //3. we associate each features to each columns
- this.columnsFeatureMap.put(feature, col);
-
- //3 bis. we build the list of the initialSelection
- if(feature instanceof FacetElement) {
- final FacetSet set = getRootFacetSet((FacetElement)feature);
- this.facetSetsUsedInTheTable.add(set);
- }
- }
- }
-
- //4. get the additional features
- final FacetSet additionFeatureRootFacetSet = getAdditionalContentsFacetSet(papyrusTable);
- if(additionFeatureRootFacetSet != null) {
- //TODO ask for that to Grégoire Dupé!
- //TODO before update the source code of EMF-Facet
- final List<EPackage> sets = additionFeatureRootFacetSet.getESubpackages();
- for(final EPackage ePackage : sets) {
- if(ePackage instanceof FacetSet) {
- this.allAdditionalContents.add((FacetSet)ePackage);
- }
- }
- }
- this.allAdditionalContents.addAll(this.facetSetsUsedInTheTable);
- this.allAdditionalContents.addAll(this.management.getAdditionalFeatures(papyrusTable, contents, this.facetSetsUsedInTheTable));
-
- }
-
- /**
- *
- * @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");
- final PapyrusTable papyrusTable = getPapyrusTable();
- final ITableWidget widget = getTableWidget();
- final TransactionalEditingDomain domain = getEditingDomain();
- FacetSet additionFeatureRootFacetSet = getAdditionalContentsFacetSet(papyrusTable);
- 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 EcoreENamedElementComparator());
- allFacetSets.addAll(this.facetSetsUsedInTheTable);
- allFacetSets.addAll(this.allAdditionalContents);
- FacetSet set = getAdditionalContentsFacetSet(papyrusTable);
- if(set != null) {
- allFacetSets.remove(set);
- }
- final ColumnsToShowDialog dialog = new ColumnsToShowDialog(Display.getCurrent().getActiveShell(), this.allDirectFeatures, allFacetSets, initialSelection, getLabelProvider(), new SortedColumnContentProvider());
- 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];
- if(!directFeatures.equals(this.initialDirectFeatureSelected)) {
- //1. get command to show/hide direct features
- final Command cmd = getShowHideDirectFeatureColumnsCommand(papyrusTable, (ITableWidgetInternal)widget, directFeatures);
- if(cmd != null) {
- compoundCmd.append(cmd);
- }
- }
-
- if(!additionalFeatures.equals(initialAdditionalFeatureSelected)) {
- // 2. get the command to show/hide additional contents
- final Command cmd2 = getCreateDestroyAdditonalFeatureColumnsCommand(papyrusTable, (ITableWidgetInternal)widget, additionalFeatures);
- if(cmd2 != null) {
- compoundCmd.append(cmd2);
- }
- //
- // //3. get command to store/unstore facets
- // final Set<FacetSet> requiredFacetSets = new HashSet<FacetSet>();
- // final Set<FacetSet> toAddToResource = new HashSet<FacetSet>();
- // final Set<FacetSet> uselessFacetSets = new HashSet<FacetSet>();
- // for(final ETypedElement current : additionalFeatures) {
- // assert (current instanceof FacetElement);
- // final FacetSet root = getRootFacetSet((FacetElement)current);
- // assert root != null;
- // requiredFacetSets.add(root);
- // if(root.eResource() == null) {
- // toAddToResource.add(root);
- // }
- // }
- //
- // if(additionFeatureRootFacetSet != null) {
- // for(final EPackage set : additionFeatureRootFacetSet.getESubpackages()) {
- // if(set instanceof FacetSet && !requiredFacetSets.contains(set)) {
- // uselessFacetSets.add((FacetSet)set);//TODO and if this facetSet is required by another table
- // }
- // }
- // }
-
- // //4. add required facetSet to the resource
- // if(additionFeatureRootFacetSet == null) {
- // //we create the facetset
- // additionFeatureRootFacetSet = EFacetFactory.eINSTANCE.createFacetSet();
- // additionFeatureRootFacetSet.setName(this.ADDITIONAL_CONTENTS_FACET_SET_NAME);
- // additionFeatureRootFacetSet.setNsPrefix(this.ADDITIONAL_CONTENTS_FACET_SET_PREFIX);
- // additionFeatureRootFacetSet.setNsURI(this.ADDITIONAL_CONTENTS_FACET_SET_NS_URI);
- // additionFeatureRootFacetSet.setDocumentation(this.ADDITIONAL_CONTENTS_FACET_SET_DOCUMENTATION);
- // additionFeatureRootFacetSet.getESubpackages().addAll(toAddToResource);
- // final FacetSet createdFacetSet = additionFeatureRootFacetSet;
- // final ICommand addLocalFacetSetToResource = new AbstractTransactionalCommand(domain, "Add Additional Contents FacetSet to the resource", null) {
- //
- // @Override
- // protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- // papyrusTable.eResource().getContents().add(createdFacetSet);
- // return CommandResult.newOKCommandResult();
- // }
- // };
- // compoundCmd.append(new GMFtoEMFCommandWrapper(addLocalFacetSetToResource));
- // } else if(toAddToResource != null) {
- // final FacetSet localSet = additionFeatureRootFacetSet;
- // final ICommand addNewFacetSetToResource = new AbstractTransactionalCommand(domain, "Add Additional Contents FacetSet to the resource", null) {
- //
- // @Override
- // protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- // localSet.getESubpackages().addAll(toAddToResource);
- // return CommandResult.newOKCommandResult();
- // }
- // };
- // compoundCmd.append(new GMFtoEMFCommandWrapper(addNewFacetSetToResource));
- // }
-
- //5. remove useless facets set
- //TODO
- }
- if(!compoundCmd.isEmpty()) {
- domain.getCommandStack().execute(compoundCmd);
- System.out.println("fait");
- }
-
- }
- }
- //we clear the fields
- clearFields();
- return null;
- }
-
- //TODO should be moved in another classes to be used by the stereotypemanager?
- protected FacetSet getAdditionalContentsFacetSet(final PapyrusTable table) {
- FacetSet set = null;
- final Resource resource = table.eResource();
- final Iterator<EObject> iter = resource.getContents().iterator();
- while(iter.hasNext() && set == null) {
- final EObject current = iter.next();
- if(current instanceof FacetSet) {
- final FacetSet tmp = (FacetSet)current;
- if(Constants.ADDITIONAL_CONTENTS_FACET_SET_NS_URI.equals(tmp.getNsURI())) {
- set = tmp;
- }
- }
- }
-
- return set;
- }
-
- /**
- *
- * @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 PapyrusTable papyrusTable, final ITableWidgetInternal widget, final Collection<ETypedElement> selectedFeatures) {
- final CompoundCommand compoundCmd = new CompoundCommand("Show/Hide direct features command");
-
- //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();
- final ITableWidgetInternal widgetController = widget;
- final ICommandFactory commandFactory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(domain);
- final boolean putOnTheTop = false;
-
- final Command showHideCommand = TableInstanceCommandFactory.createShowHideColumnCommand(widgetController, domain, commandFactory, papyrusTable.getTable(), columnsToShow, columnsToHide, putOnTheTop);
-
- if(showHideCommand != null && showHideCommand.canExecute()) {
- compoundCmd.append(showHideCommand);
- }
-
- //columns to create should always be null with direct features!
- assert columnsToCreate.isEmpty();
- if(!compoundCmd.isEmpty() && compoundCmd.canExecute()) {
- return compoundCmd;
- }
- return null;
-
- }
-
- /**
- * FIXME : we should provide JUnit tests for this method :
- * - when the AddtionalContentsfacetSet is empty -> it should be removed from the resource
- * - when the AddtionalContentsfacetSet is not erquired 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!
- *
- * @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
- */
- private Command getCreateDestroyAdditonalFeatureColumnsCommand(final PapyrusTable papyrusTable, final ITableWidgetInternal widget, final Collection<ETypedElement> selectedAdditionalFeatures) {
- final CompoundCommand compoundCmd = new CompoundCommand("Show/Hide additional features command");
- final Resource resource = papyrusTable.eResource();
- final ResourceSet resourceSet = resource.getResourceSet();
- final TransactionalEditingDomain domain = getEditingDomain();
- final ITableCommandFactory factory = getTableCmdFactory(domain, resourceSet, papyrusTable.getTable());
- FacetSet additionFeatureRootFacetSet = getAdditionalContentsFacetSet(papyrusTable);
-
- //0. determine which current facetset are uszed for columns and which facetset are used for other things
- final Set<FacetSet> setForOtherThings = new HashSet<FacetSet>(papyrusTable.getTable().getFacetSets());
- for(final Column current : papyrusTable.getTable().getColumns()) {
- if(current instanceof FeatureColumn) {
- ETypedElement element = ((FeatureColumn)current).getFeature();
- if(element instanceof FacetElement) {
- setForOtherThings.remove(getRootFacetSet((FacetElement)element));
- }
- }
- }
-
-
- //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 FacetSet for columns are required by the table
- final Set<FacetSet> facetSetColumnsUsedInTable = new HashSet<FacetSet>(); //TODO useful?
-
- //4. determine which subfacetset for additional contents are useful
- //4bis. determine which subfacet set for additional contents should be added to the additionalcontents facetset
- final Set<FacetSet> requiredSubFacetSets = new HashSet<FacetSet>();
- final Set<FacetSet> toAddToResource = new HashSet<FacetSet>();
- for(final ETypedElement current : selectedAdditionalFeatures) {
- FacetSet root = getRootFacetSet((FacetElement)current);
- if(root.eResource() == null) {
- toAddToResource.add((FacetSet)root);
- EObject container = current;
- while(container != null) {
- if(container instanceof FacetSet) {
- requiredSubFacetSets.add((FacetSet)container);
- }
- container = container.eContainer();
- }
- } else if(root == additionFeatureRootFacetSet) {
- facetSetColumnsUsedInTable.add(additionFeatureRootFacetSet);
- EObject container = current;
- while(container != null) {
- if(container instanceof FacetSet && container != additionFeatureRootFacetSet) {
- requiredSubFacetSets.add((FacetSet)container);
- }
- container = container.eContainer();
- }
- } else {
- facetSetColumnsUsedInTable.add(root);
- }
- }
-
- //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> uselessFacetSetsInAllExistingTable = new HashSet<FacetSet>();
- final Set<FacetSet> uselessFacetSetsInCurrentTable = new HashSet<FacetSet>();
- if(additionFeatureRootFacetSet != null) {
- for(final EPackage set : additionFeatureRootFacetSet.getESubpackages()) {
- if(set instanceof FacetSet && !requiredSubFacetSets.contains(set)) {
- uselessFacetSetsInCurrentTable.add((FacetSet)set);
- final TreeIterator<EObject> it = set.eAllContents();
- boolean useless = true;
- while(it.hasNext() && useless) {
- EObject value = it.next();
- if(value instanceof FacetElement) {
- ECrossReferenceAdapter eCrossReference = CrossReferenceAdapter.getCrossReferenceAdapter(papyrusTable.eResource().getResourceSet());
- Collection<Setting> references = eCrossReference.getInverseReferences(value, false);
- Iterator<Setting> settingIter = references.iterator();
- while(settingIter.hasNext() && useless) {
- 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) {
- uselessFacetSetsInAllExistingTable.add((FacetSet)set);
- }
- }
- }
- }
-
-
- //6.we calculate the new registered FacetSet for the addition contents facetset
- final Collection<FacetSet> newRegisteredSubFacetSet = new HashSet<FacetSet>();
- final Collection<FacetSet> oldSubRegisteredFacetSet = new HashSet<FacetSet>();
- if(additionFeatureRootFacetSet != null) {
- //TODO waiting for he patch of 392413: FacetSet metamodel : FacetSet#getFacetSets always return a new list
- for(final EPackage current : additionFeatureRootFacetSet.getESubpackages()) {
- if(current instanceof FacetSet) {
- oldSubRegisteredFacetSet.add((FacetSet)current);
- }
- }
- }
- newRegisteredSubFacetSet.addAll(oldSubRegisteredFacetSet);
- newRegisteredSubFacetSet.addAll(toAddToResource);
- newRegisteredSubFacetSet.removeAll(uselessFacetSetsInAllExistingTable);
-
-
-
- //7.we calculate the usage of the additional facet set contents in the current table
- final Collection<FacetSet> usedInCurrentTable = new HashSet<FacetSet>();
- usedInCurrentTable.addAll(oldSubRegisteredFacetSet);
- usedInCurrentTable.addAll(toAddToResource);
- usedInCurrentTable.removeAll(uselessFacetSetsInCurrentTable);
-
-
- //8.boolean value to know if we can destroy the additional contents facetset
- boolean destroyAdditionalContentsFacetSet = newRegisteredSubFacetSet.size() == 0 && additionFeatureRootFacetSet != null;
-
- //9.boolean value to know if we can remove the additional contents FacetSet reference from the current table
- boolean removeAdditionalContentsFacetSetFromTheCurrentTable = usedInCurrentTable.isEmpty();
-
-
- //10. the add/remove of the columns itself!
- // if(!oldSubRegisteredFacetSet.equals(newRegisteredSubFacetSet)) {
-
- //11. register the new value for the sub facetset registred by the additional content facetset
- if(additionFeatureRootFacetSet == null && newRegisteredSubFacetSet.size() != 0) {
- additionFeatureRootFacetSet = createAdditionalContentsFacetSet();
- additionFeatureRootFacetSet.getESubpackages().addAll(newRegisteredSubFacetSet);
- compoundCmd.append(addFacetSetToResourceCommand(domain, resource, additionFeatureRootFacetSet));
- } else if(additionFeatureRootFacetSet != null && !newRegisteredSubFacetSet.equals(oldSubRegisteredFacetSet)) {
- final FacetSet localSet = additionFeatureRootFacetSet;
- final ICommand addNewFacetSetToResource = new AbstractTransactionalCommand(domain, "Set new value for sub facetset Additional Contents", null) {
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- localSet.getESubpackages().clear();
- localSet.getESubpackages().addAll(newRegisteredSubFacetSet);
- return CommandResult.newOKCommandResult();
- }
- };
- compoundCmd.append(new GMFtoEMFCommandWrapper(addNewFacetSetToResource));
- }
- // }
- if(destroyAdditionalContentsFacetSet) {
- facetSetColumnsUsedInTable.remove(additionFeatureRootFacetSet);
- } else {
- facetSetColumnsUsedInTable.add(additionFeatureRootFacetSet);
- }
-
-
- //all facetSet used in the table
- final Set<FacetSet> allFacetSets = new HashSet<FacetSet>();
- allFacetSets.addAll(facetSetColumnsUsedInTable);
- allFacetSets.addAll(setForOtherThings);
- // get the command to create columns
- if(columnsToCreate.size() != 0) {
- final Command createColumns = factory.createAddColumnCommand(columnsToCreate, new ArrayList<FacetSet>(allFacetSets));
- if(createColumns != null && createColumns.canExecute()) {
- compoundCmd.append(createColumns);
- }
- }
-
- // 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 = factory.createRemoveColumnsCommand(additionalFeaturesToHide);
- if(removeColumns != null && removeColumns.canExecute()) {
- compoundCmd.append(removeColumns);
- }
- }
-
- Command setUsedFacetSetCommand = factory.createSetLoadedFacetSetsCommand(new ArrayList<FacetSet>(allFacetSets));
- if(setUsedFacetSetCommand!=null && setUsedFacetSetCommand.canExecute()){
- compoundCmd.append(setUsedFacetSetCommand);
- }
-
- final ICommandFactory commandFactory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(domain);
-
- //exiting hidden columns are selected to be shown
- if(existingColumnsToShow.size() != 0) {
- final Command showHideCommand = TableInstanceCommandFactory.createShowHideColumnCommand(widget, domain, commandFactory, papyrusTable.getTable(), existingColumnsToShow, new ArrayList<Column>(), true);
- if(showHideCommand != null && showHideCommand.canExecute()) {
- compoundCmd.append(showHideCommand);
- }
- }
-
- // the additional contents facet set is useless in the current table. , we remove it from the list of the referenced facetset
- if(removeAdditionalContentsFacetSetFromTheCurrentTable) {
- final List<FacetSet> set = new ArrayList<FacetSet>(papyrusTable.getTable().getFacetSets());
- set.remove(additionFeatureRootFacetSet);
- compoundCmd.append(factory.createSetLoadedFacetSetsCommand(set));
- }
-
- // the additional contents facet set is useless in all table, we remove it of the resource
- if(destroyAdditionalContentsFacetSet) {
- compoundCmd.append(removeFacetSetToResourceCommand(domain, resource, additionFeatureRootFacetSet));
- }
- // }
-
- if(!compoundCmd.isEmpty()) {
- return compoundCmd;
- }
- return null;
- }
-
- private Command removeFacetSetToResourceCommand(final TransactionalEditingDomain domain, final Resource resource, final FacetSet setToRemove) {
- final ICommand removeFacetSet = new AbstractTransactionalCommand(domain, "Remove FacetSet from the resource", null) {
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- resource.getContents().remove(setToRemove);
- return CommandResult.newOKCommandResult();
- }
- };
- return new GMFtoEMFCommandWrapper(removeFacetSet);
- }
-
- private Command addFacetSetToResourceCommand(final TransactionalEditingDomain domain, final Resource resource, final FacetSet setToAdd) {
- final ICommand removeFacetSet = new AbstractTransactionalCommand(domain, "Add FacetSet from the resource", null) {
-
- @Override
- protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
- resource.getContents().add(setToAdd);
- return CommandResult.newOKCommandResult();
- }
- };
- return new GMFtoEMFCommandWrapper(removeFacetSet);
- }
-
- private FacetSet createAdditionalContentsFacetSet() {
- final FacetSet additionFeatureRootFacetSet = EFacetFactory.eINSTANCE.createFacetSet();
- additionFeatureRootFacetSet.setName(Constants.ADDITIONAL_CONTENTS_FACET_SET_NAME);
- additionFeatureRootFacetSet.setNsPrefix(Constants.ADDITIONAL_CONTENTS_FACET_SET_PREFIX);
- additionFeatureRootFacetSet.setNsURI(Constants.ADDITIONAL_CONTENTS_FACET_SET_NS_URI);
- additionFeatureRootFacetSet.setDocumentation(Constants.ADDITIONAL_CONTENTS_FACET_SET_DOCUMENTATION);
- return additionFeatureRootFacetSet;
- }
-
- /**
- *
- * @return
- * the editing domain used by this handler or <code>null</code> if not found
- */
- private TransactionalEditingDomain getEditingDomain() {
- TransactionalEditingDomain domain = null;
- domain = TransactionUtil.getEditingDomain(getPapyrusTable());
- return domain;
- }
-
- /**
- *
- * @return
- * the current table editor, or <code>null</code> if not found
- */
- private AbstractTableEditor 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 AbstractTableEditor) {
- return (AbstractTableEditor)part;
- }
-
- }
- return null;
- }
-
- /**
- *
- * @return
- * the papyrus table
- */
- private PapyrusTable getPapyrusTable() {
- final IEditorPart part = getCurrentTableEditor();
- if(part != null) {
- return (PapyrusTable)part.getAdapter(PapyrusTable.class);
- }
- return null;
- }
-
- /**
- *
- * @return
- * the table widget
- */
- private ITableWidget getTableWidget() {
- final IAdaptable editor = getCurrentTableEditor();
- final ITableWidgetProvider provider = (ITableWidgetProvider)editor.getAdapter(ITableWidgetProvider.class);
- if(provider != null) {
- return provider.getTableWidget();
- }
- 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;
- }
-
- /**
- *
- * @param editingDomain
- * the editing domain
- * @param resourceSet
- * the resource set
- * @param table
- * the table
- * @return
- * the command factory for these parameters
- */
- //TODO duplicated code from the AbstractTriggerListener
- private static ITableCommandFactory getTableCmdFactory(final TransactionalEditingDomain editingDomain, final ResourceSet resourceSet, final Table table) {
- final IFacetManager facetManager = IFacetManagerFactory.DEFAULT.getOrCreateFacetManager(resourceSet);
- final ICommandFactory commandFactory = ICommandFactoriesRegistry.INSTANCE.getCommandFactoryFor(editingDomain);
- return new TableCommandFactory(table, editingDomain, commandFactory, facetManager);
- }
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/SortedColumnContentProvider.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/SortedColumnContentProvider.java
deleted file mode 100644
index 1130f7b705d..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/SortedColumnContentProvider.java
+++ /dev/null
@@ -1,175 +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.infra.table.efacet.menu.handler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetElement;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Column;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Feature;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * A Content Provider which allows to sort the provided elements
- *
- *
- *
- */
-public class SortedColumnContentProvider implements ITreeContentProvider {
-
- /** boolean to know if the returned content should be sorted or not */
- private boolean isSorted = true;
-
- /** the initial content */
- private final List<Column> initialList = new ArrayList<Column>();
-
- /** the comparator used to sort the element */
- private Comparator<Column> comparator = null;
-
- public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
- if(newInput instanceof List) {
- for(final Object object : (List<?>)newInput) {
- if(object instanceof Column) {
- final Column column = (Column)object;
- this.initialList.add(column);
- }
- }
- }
- }
-
- public void dispose() {
- // Nothing
- }
-
- public Object[] getElements(final Object inputElement) {
- if(inputElement instanceof Map<?, ?>) {//should be deleted
- return ((Map)inputElement).keySet().toArray();
- } else if(inputElement instanceof Collection<?>) {
- return ((Collection)inputElement).toArray();
- }
- return new Object[0];
- }
-
- /**
- * Setter for {@link #comparator}
- *
- * @param comparator
- * the comparator used to sort the element
- */
- public void setComparator(final Comparator<Column> comparator) {
- this.comparator = comparator;
- }
-
- /**
- * Setter for {@link #isSorted}
- *
- * @param newValue
- *
- */
- public void setIsSorted(final boolean newValue) {
- this.isSorted = newValue;
- }
-
- public Object[] getChildren(final Object parentElement) {
- if(parentElement instanceof EClass) {
- return ((EClass)parentElement).getEAllStructuralFeatures().toArray();
- }
- if(parentElement instanceof Set<?>) {
- return ((Set)parentElement).toArray();
- }
- if(parentElement instanceof EStructuralFeature) {
- return new Object[0];
- } else if(parentElement instanceof Stereotype) {
- final EList<EStructuralFeature> allRef = ((Stereotype)parentElement).eClass().getEAllStructuralFeatures();
- final List<Feature> features = new ArrayList(((Stereotype)parentElement).allFeatures());
- Collections.sort(features, new UMLFeatureComparator());
- return features.toArray();
- }
- if(parentElement instanceof Facet) {
- return ((Facet)parentElement).getFacetElements().toArray();
- }
- if(parentElement instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet)parentElement;
- //TODO sort them
-
- final Set<ENamedElement> subFacetSet = new TreeSet<ENamedElement>(new EcoreENamedElementComparator());
-
- try {
- final EList<EPackage> subPackages = facetSet.getESubpackages();
- subFacetSet.addAll(subPackages);
-
- } catch (final Exception e) {
- final EList<EPackage> subPackages = facetSet.getESubpackages();
- subFacetSet.addAll(subPackages);
- }
- final Set<ENamedElement> subFacets = new TreeSet<ENamedElement>(new EcoreENamedElementComparator());
- subFacets.addAll(((FacetSet)parentElement).getEClassifiers());
- //
- final List<ENamedElement> contents = new ArrayList<ENamedElement>();
- contents.addAll(subFacetSet);
- contents.addAll(subFacets);
- return contents.toArray();
- }
- return new Object[0];
- }
-
- public Object getParent(final Object element) {
- if(element instanceof Element) {
- return ((Element)element).eContainer();
- } else if(element instanceof FacetElement) {
- return ((FacetElement)element).eContainer();
- }
- return null;
- }
-
- public boolean hasChildren(final Object element) {
- // return true;
- return getChildren(element).length != 0;
- }
-
- public class EcoreFeatureComparator implements Comparator<EStructuralFeature> {
-
- public int compare(final EStructuralFeature o1, final EStructuralFeature o2) {
- return o1.getName().compareToIgnoreCase(o2.getName());
- }
-
- }
-
- public class UMLFeatureComparator implements Comparator<Feature> {
-
- public int compare(final Feature o1, final Feature o2) {
- return o1.getName().compareToIgnoreCase(o2.getName());
- }
-
- }
-
-}
diff --git a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/StereotypeManagement.java b/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/StereotypeManagement.java
deleted file mode 100644
index 7a8b3443f3b..00000000000
--- a/sandbox/org.eclipse.papyrus.infra.table.efacet.menu/src/org/eclipse/papyrus/infra/table/efacet/menu/handler/StereotypeManagement.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.eclipse.papyrus.infra.table.efacet.menu.handler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.infra.table.efacet.metamodel.papyrustable.PapyrusTable;
-import org.eclipse.papyrus.uml.efacet.metamodel.umlefacet.ProfileFacetSet;
-import org.eclipse.papyrus.uml.efacet.metamodel.umlefacet.StereotypeFacet;
-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 StereotypeManagement {
-
- public StereotypeManagement() {
-
- }
-
-
- public List<FacetSet> getAdditionalFeatures(final PapyrusTable papyrusTable, final Collection<EObject> tableContents, final Collection<FacetSet> existingFacetSets) {
- final Set<Stereotype> appliedStereotypes = new HashSet<Stereotype>();
- for(final EObject current : 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));
- }
-
- //TODO provides a way to register facetset representing static profile
-
- //TODO verify that an existing FacetSet doesn't exist for it
- final String wantedURI = "http://www.eclipse.org/papyrustableefacet/additionalcontentsfacetset";
- FacetSet additionalContentsFacetSet = null;
- lookForFacetSet : for(EObject current : papyrusTable.eResource().getContents()) {
- if(current instanceof FacetSet) {
- if(wantedURI.equals(((EPackage)current).getNsURI())) {
- additionalContentsFacetSet = (FacetSet)current;
- break lookForFacetSet;
- }
- }
- }
-
- 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);
- } else if(current instanceof StereotypeFacet) {
-
- }
- }
- }
- final List<FacetSet> addtionalFacetSet = new ArrayList<FacetSet>();
- for(final Profile current : usedProfile) {
- if(!mapProfileQNameFacetSet.containsKey(current.getQualifiedName())) {
- ProfileFacetSet set = FacetFactory.createProfileFacetSet(current);
- if(set != null) {
- addtionalFacetSet.add(set);
- }
- }
- }
-
- return addtionalFacetSet;
- }
-}

Back to the top