Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-06-16 05:22:02 -0400
committerGerrit Code Review @ Eclipse.org2016-06-17 03:00:44 -0400
commit1b59801d998020b11758b2a2e520173549bb5e94 (patch)
tree7c65cf4400687ccd5d3b11a96908bf24f3ebacc2
parent08b2aa17fd2e606d29fbe6a7ab92ca5e807f21ec (diff)
downloadorg.eclipse.papyrus-1b59801d998020b11758b2a2e520173549bb5e94.tar.gz
org.eclipse.papyrus-1b59801d998020b11758b2a2e520173549bb5e94.tar.xz
org.eclipse.papyrus-1b59801d998020b11758b2a2e520173549bb5e94.zip
Bug 492246; [Table] Impossible to create a table from the catalog
https://bugs.eclipse.org/bugs/show_bug.cgi?id=492246 The wizard was disposed before to get its needed informations. We need to get this ones before the dispose. + Some minor changements for the table name (to not get a table named 'null'). Change-Id: I1578135de28093453f57b6adc1a78b5e2f320ded Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/CreateNatTableFromCatalogHandler.java38
1 files changed, 31 insertions, 7 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/CreateNatTableFromCatalogHandler.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/CreateNatTableFromCatalogHandler.java
index 29aea00f822..fba7df713cd 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/CreateNatTableFromCatalogHandler.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.common/src/org/eclipse/papyrus/infra/nattable/common/handlers/CreateNatTableFromCatalogHandler.java
@@ -13,8 +13,10 @@
package org.eclipse.papyrus.infra.nattable.common.handlers;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
@@ -106,7 +108,15 @@ public class CreateNatTableFromCatalogHandler extends AbstractHandler {
// return null;
// }
-
+ /**
+ * The view prototypes to create by the table creation wizard.
+ */
+ private Map<ViewPrototype, Integer> viewPrototypes = null;
+
+ /**
+ * The view prototypes names of the table to create (names from wizard).
+ */
+ private Map<ViewPrototype, String> tableNames = null;
// NEW CODE using ViewPrototype
/**
@@ -118,7 +128,17 @@ public class CreateNatTableFromCatalogHandler extends AbstractHandler {
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final EObject context = getSelection().get(0);
- final CreateNattableFromCatalogWizard wizard = new CreateNattableFromCatalogWizard(context);
+ final CreateNattableFromCatalogWizard wizard = new CreateNattableFromCatalogWizard(context){
+
+ @Override
+ public void dispose() {
+ // Get the view prototypes and the table names before the dispose values
+ // Create a new hashmap because the reference must be deleted with the dispose
+ viewPrototypes = new HashMap<ViewPrototype, Integer>(this.getSelectedViewPrototypes());
+ tableNames = new HashMap<ViewPrototype, String>(this.getTableNames());
+ super.dispose();
+ }
+ };
final WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
ServicesRegistry serviceRegistry = null;
TransactionalEditingDomain domain = null;
@@ -131,26 +151,30 @@ public class CreateNatTableFromCatalogHandler extends AbstractHandler {
}
if (Window.OK == dialog.open()) {
-
+
final RecordingCommand rc = new RecordingCommand(domain) {
@Override
protected void doExecute() {
- for (final ViewPrototype viewPrototype : wizard.getSelectedViewPrototypes().keySet()) {
+ for (final ViewPrototype viewPrototype : viewPrototypes.keySet()) {
if (null != viewPrototype) {
// See how many tables were required for this type
- Integer tablesQuantity = wizard.getSelectedViewPrototypes().get(viewPrototype);
+ final Integer tablesQuantity = viewPrototypes.get(viewPrototype);
// Get the chosen name for the tables under this configuration
- final String tableConfigName = wizard.getTableNames().get(viewPrototype);
+ final String tableConfigName = null != tableNames.get(viewPrototype) && !tableNames.get(viewPrototype).isEmpty() ? tableNames.get(viewPrototype) : viewPrototype.getLabel();
for (int i = 0; i < tablesQuantity; i++) {
+ final String tableNameToCreate = 1 < tablesQuantity ? tableConfigName + "_" + i : tableConfigName; //$NON-NLS-1$
// TODO : The following code line must be replaced by TableEditorCreationHelper.getTableConfigurationURI when the API for table creation is merged
- PolicyDefinedTableHandler handler = new PolicyDefinedTableHandler(getTableConfigurationURI((TableViewPrototype) viewPrototype), context, tableConfigName + "_" + i); //$NON-NLS-1$
+ PolicyDefinedTableHandler handler = new PolicyDefinedTableHandler(getTableConfigurationURI((TableViewPrototype) viewPrototype), context, tableNameToCreate);
handler.execute(viewPrototype);
}
}
}
+ // Re-initialize the global variables because we don't need it after
+ viewPrototypes = null;
+ tableNames = null;
}
};
domain.getCommandStack().execute(rc);

Back to the top