Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-05-30 10:55:00 +0000
committerGerrit Code Review @ Eclipse.org2016-05-31 14:30:00 +0000
commitb82e6e300f10da43dfa6a2c547ff4179c97fbc52 (patch)
tree9ea4639bab1850712a3c979aa9da0c8de1dba92c /plugins
parent78884f12fcdc10c36624896677378a2448a2ec32 (diff)
downloadorg.eclipse.papyrus-b82e6e300f10da43dfa6a2c547ff4179c97fbc52.tar.gz
org.eclipse.papyrus-b82e6e300f10da43dfa6a2c547ff4179c97fbc52.tar.xz
org.eclipse.papyrus-b82e6e300f10da43dfa6a2c547ff4179c97fbc52.zip
bug 492873 - [Table] The Create Table Configuration menu appears
everywhere bug 493756 - [Table] Edit table configuration calls same wizard as "create..." bug 493756 - [Table] Papyrus must provide the Table creation Wizard in the New Dialog Change-Id: Ie708c6a515ffd0498b45cd961d2e3c075e938b0b Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net> Signed-off-by: Vincent LORENZO <vincent.lorenzo@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/META-INF/MANIFEST.MF4
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.properties2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.xml51
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/Activator.java44
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/CreateNattableConfigurationWizard.java329
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/FeatureFillingConfigurationDialog.java (renamed from plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/FeatureFillingConfigurationDialog.java)2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/PasteEObjectConfigurationDialog.java (renamed from plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/PasteEObjectConfigurationDialog.java)2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/TreeFillingConfigurationDialog.java (renamed from plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/TreeFillingConfigurationDialog.java)2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/handlers/CreateTableConfigurationWizardHandler.java131
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/handlers/EditExistingTableConfigurationWizardHandler.java60
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/EditGenericNattableConfigurationFieldsNattableWizardPage.java5
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/NattableConfigurationFileCreationPage.java (renamed from plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/NattableConfigurationProjectCreationPage.java)77
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/RowConfigurationWizardPage.java6
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/SlaveConfigurationWizardPage.java8
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/utils/NattableConfigurationConstants.java2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/CreateAndEditTableConfigurationWizard.java181
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/CreateNattableConfigurationProjectWizard.java223
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/EditTableConfigurationWizard.java231
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableConfigurationConstants.java26
19 files changed, 794 insertions, 592 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/META-INF/MANIFEST.MF b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/META-INF/MANIFEST.MF
index a83429a55d6..fb17f681eec 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/META-INF/MANIFEST.MF
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/META-INF/MANIFEST.MF
@@ -31,12 +31,12 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.customization.nattableconfiguration,
- org.eclipse.papyrus.customization.nattableconfiguration.ediiton,
+ org.eclipse.papyrus.customization.nattableconfiguration.edition,
org.eclipse.papyrus.customization.nattableconfiguration.handlers,
org.eclipse.papyrus.customization.nattableconfiguration.helper,
org.eclipse.papyrus.customization.nattableconfiguration.messages,
org.eclipse.papyrus.customization.nattableconfiguration.pages,
org.eclipse.papyrus.customization.nattableconfiguration.utils
Bundle-Vendor: %Bundle-Vendor
-Bundle-Description: %pluginDescription
+Bundle-Description: %Bundle-Description
Bundle-Localization: plugin
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.properties b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.properties
index cc6699a143b..e1812e03f29 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.properties
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.properties
@@ -1,3 +1,5 @@
#Properties file for org.eclipse.papyrus.uml.nattable
Bundle-Vendor = Eclipse Modeling Project
Bundle-Name = Customization of Nattable Configuration
+
+Bundle-Description = This plugin provides the Wizard used to create a new project with a Papyrus Table Configuration, to create a new Papyrus Table Configuration inside an existing project and the handler to edit an exiting table configuration \ No newline at end of file
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.xml b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.xml
index ed60a1a92d0..baaf57e1f28 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.xml
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/plugin.xml
@@ -7,16 +7,7 @@
allPopups="true"
locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu">
<command
- commandId="org.eclipse.papyrus.infra.nattable.create.configuration.wizard"
- label="Create Table Configuration"
- style="push">
- </command>
- </menuContribution>
- <menuContribution
- allPopups="true"
- locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu">
- <command
- commandId="org.eclipse.papyrus.infra.nattable.create.configuration.wizard"
+ commandId="org.eclipse.papyrus.infra.nattable.edit.configuration.wizard"
label="Edit Table Configuration"
style="push">
<visibleWhen
@@ -33,32 +24,46 @@
</adapt>
</iterate>
</visibleWhen>
- <parameter
- name="org.eclipse.papyrus.customization.nattableconfiguration.configurationParemeter"
- value="nattableconfiguration">
- </parameter>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
- defaultHandler="org.eclipse.papyrus.customization.nattableconfiguration.handlers.CreateTableConfigurationWizardHandler"
- id="org.eclipse.papyrus.infra.nattable.create.configuration.wizard"
- name="Create Table Configuration Wizard">
- <commandParameter
- id="org.eclipse.papyrus.customization.nattableconfiguration.configurationParemeter"
- name="selection"
- optional="true">
- </commandParameter>
+ defaultHandler="org.eclipse.papyrus.customization.nattableconfiguration.handlers.EditExistingTableConfigurationWizardHandler"
+ id="org.eclipse.papyrus.infra.nattable.edit.configuration.wizard"
+ name="Edit Table Configuration Wizard">
</command>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
- commandId="org.eclipse.papyrus.infra.nattable.create.configuration.wizard"
+ commandId="org.eclipse.papyrus.infra.nattable.edit.configuration.wizard"
icon="icons/wizard_icon.png">
</image>
</extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ category="org.eclipse.papyrus.wizards.category"
+ class="org.eclipse.papyrus.customization.nattableconfiguration.wizards.CreateNattableConfigurationProjectWizard"
+ hasPages="true"
+ icon="icons/wizard_icon.png"
+ id="org.eclipse.papyrus.customization.nattableconfiguration.createconfigurationproject"
+ name="Create Papyrus Table Configuration Project"
+ preferredPerspectives="org.eclipse.papyrus.infra.core.perspective"
+ project="true">
+ </wizard>
+ <wizard
+ category="org.eclipse.papyrus.wizards.category"
+ class="org.eclipse.papyrus.customization.nattableconfiguration.wizards.CreateAndEditTableConfigurationWizard"
+ hasPages="true"
+ icon="icons/wizard_icon.png"
+ id="org.eclipse.papyrus.customization.nattableconfiguration.createandeditconfigurationfile"
+ name="Create Papyrus Table Configuration File"
+ preferredPerspectives="org.eclipse.papyrus.infra.core.perspective"
+ project="true">
+ </wizard>
+ </extension>
</plugin>
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/Activator.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/Activator.java
index fcc41eb71b9..347b9c03825 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/Activator.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/Activator.java
@@ -15,6 +15,7 @@ package org.eclipse.papyrus.customization.nattableconfiguration;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -33,6 +34,8 @@ public class Activator extends AbstractUIPlugin {
*/
private static Activator plugin;
+
+ public static LogHelper log;
/**
* The constructor
*/
@@ -48,6 +51,7 @@ public class Activator extends AbstractUIPlugin {
public void start(final BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ log = new LogHelper(this);
}
/**
@@ -70,45 +74,5 @@ public class Activator extends AbstractUIPlugin {
return plugin;
}
- /**
- * Logs a warning message in the plugin log
- *
- * @param message
- * the message to log
- */
- public static void logWarning(final String message) {
- getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, message));
- }
-
- /**
- * Logs an error message in the plugin log
- *
- * @param message
- * the message to log
- */
- public static void logError(final String message) {
- getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message));
- }
-
- /**
- * Logs an information message in the plugin log
- *
- * @param message
- * the message to log
- */
- public static void logInfo(final String message) {
- getDefault().getLog().log(new Status(IStatus.INFO, Activator.PLUGIN_ID, message));
- }
-
- /**
- * Logs an error message in the plugin log
- *
- * @param exception
- * the exception to log
- */
- public static void logException(final Exception exception) {
- getDefault().getLog().log(
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, exception.getLocalizedMessage(), exception));
- }
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/CreateNattableConfigurationWizard.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/CreateNattableConfigurationWizard.java
deleted file mode 100644
index 333cf33e55d..00000000000
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/CreateNattableConfigurationWizard.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
- * 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 FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.customization.nattableconfiguration;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.customization.nattableconfiguration.helper.TableConfigurationHelper;
-import org.eclipse.papyrus.customization.nattableconfiguration.messages.Messages;
-import org.eclipse.papyrus.customization.nattableconfiguration.pages.ColumnConfigurationWizardPage;
-import org.eclipse.papyrus.customization.nattableconfiguration.pages.EditGenericNattableConfigurationFieldsNattableWizardPage;
-import org.eclipse.papyrus.customization.nattableconfiguration.pages.NattableConfigurationProjectCreationPage;
-import org.eclipse.papyrus.customization.nattableconfiguration.pages.RowConfigurationWizardPage;
-import org.eclipse.papyrus.customization.nattableconfiguration.pages.SlaveConfigurationWizardPage;
-import org.eclipse.papyrus.customization.nattableconfiguration.utils.NattableConfigurationConstants;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceSet;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
-import org.eclipse.papyrus.infra.nattable.wizard.AbstractTableWizard;
-import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
-import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation;
-import org.eclipse.pde.internal.ui.wizards.plugin.PluginContentPage;
-import org.eclipse.pde.internal.ui.wizards.plugin.PluginFieldData;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * The wizard to manage the nattable configuration.
- */
-public class CreateNattableConfigurationWizard extends AbstractTableWizard {
-
- /**
- * The dot string.
- */
- private static final String DOT = "."; //$NON-NLS-1$
-
- /**
- * The generate plugin activator setting.
- */
- private static final String GENERATE_PlUGIN_ACTIVATOR = "generatePluginActivator"; //$NON-NLS-1$
-
- /**
- * The ui plugin setting.
- */
- private static final String UI_PLUGIN = "uiPlugin"; //$NON-NLS-1$
-
- /**
- * The edited table configuration
- */
- private final TableConfiguration configuration;
-
- /**
- * The initial resource selected.
- */
- private Resource initialResource;
-
- /**
- * the edited Table Configuration Helper;
- */
- private TableConfigurationHelper helper;
-
- /**
- * Boolean to determinate if this is a project creation or just an edition.
- */
- private boolean isProjectCreation = false;
-
- /**
- * The page for the project creation.
- */
- private NattableConfigurationProjectCreationPage nattableConfigurationProjectCreationPage;
-
- /**
- * The project provider.
- */
- private IProjectProvider projectProvider;
-
- /**
- * The content page for the project creation.
- */
- protected PluginContentPage contentPage;
-
- /**
- * The fields data to manage the project creation
- */
- private PluginFieldData pluginData;
-
- /**
- * Constructor.
- *
- * @param configuration
- * The edited table configuration.
- * @param initialResource
- * The initial nattable configuration resource.
- */
- public CreateNattableConfigurationWizard(final TableConfiguration configuration, final Resource initialResource) {
- this.configuration = configuration;
- this.helper = new TableConfigurationHelper(this.configuration);
- final ImageDescriptor desc = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImageDescriptor(Activator.PLUGIN_ID, NattableConfigurationConstants.ICON_WIZBAN_PATH);
- setDefaultPageImageDescriptor(desc);
- setWindowTitle(Messages.CreateNattableConfigurationWizard_WizardTitke);
- setForcePreviousAndNextButtons(true);
-
- this.initialResource = initialResource;
-
- isProjectCreation = null == this.initialResource;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.wizard.Wizard#addPages()
- */
- @Override
- public void addPages() {
- if (isProjectCreation) {
-
- pluginData = new PluginFieldData();
-
- nattableConfigurationProjectCreationPage = new NattableConfigurationProjectCreationPage(pluginData, new StructuredSelection());
- addPage(nattableConfigurationProjectCreationPage);
-
- projectProvider = new IProjectProvider() {
- @Override
- public String getProjectName() {
- return nattableConfigurationProjectCreationPage.getProjectName();
- }
-
- @Override
- public IProject getProject() {
- return nattableConfigurationProjectCreationPage.getProjectHandle();
- }
-
- @Override
- public IPath getLocationPath() {
- return nattableConfigurationProjectCreationPage.getLocationPath();
- }
- };
-
- contentPage = new PluginContentPage("page2", projectProvider, nattableConfigurationProjectCreationPage, pluginData); //$NON-NLS-1$
-
- addPage(contentPage);
- }
- addPage(new EditGenericNattableConfigurationFieldsNattableWizardPage(this.helper));
- addPage(new RowConfigurationWizardPage(this.helper));
- addPage(new ColumnConfigurationWizardPage(this.helper));
- addPage(new SlaveConfigurationWizardPage(this.helper));
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.wizard.Wizard#getDialogSettings()
- */
- @Override
- public IDialogSettings getDialogSettings() {
- DialogSettings dialogSettings = new DialogSettings(""); //$NON-NLS-1$
- dialogSettings.put(GENERATE_PlUGIN_ACTIVATOR, true);
- dialogSettings.put(UI_PLUGIN, false);
- return dialogSettings;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
- @Override
- public boolean performFinish() {
- boolean result = false;
-
- IProject createdProject = null;
-
- if (isProjectCreation) {
- try {
-
- // Create the project
- getContainer().run(false, true, new NewProjectCreationOperation(pluginData, projectProvider, null));
-
- createdProject = projectProvider.getProject();
-
- // Set the project into the working sets
- final IWorkingSet[] workingSets = nattableConfigurationProjectCreationPage.getSelectedWorkingSets();
- if (0 < workingSets.length) {
- PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(createdProject, workingSets);
- }
-
- // Copy the about file
- copyAboutFile(createdProject);
-
- StringBuilder nattableConfigurationFileName = new StringBuilder(nattableConfigurationProjectCreationPage.getNattableConfigurationFileName());
-
- // Check if the file has the nattable configuration extension file, else add it
- if (!nattableConfigurationFileName.toString().contains(DOT)
- || !NattableConfigurationConstants.NATTABLE_CONFIGURATION_EXTENSION_FILE.equals(nattableConfigurationFileName.toString().substring(nattableConfigurationFileName.lastIndexOf(DOT) + 1))) {
- nattableConfigurationFileName.append(DOT);
- nattableConfigurationFileName.append(NattableConfigurationConstants.NATTABLE_CONFIGURATION_EXTENSION_FILE);
- }
-
- final ResourceSet set = new ResourceSetImpl();
- final StringBuilder nattableConfFileURI = new StringBuilder();
- nattableConfFileURI.append(createdProject.getLocation());
- nattableConfFileURI.append(NattableConfigurationConstants.CONFIG_FOLDER);
- nattableConfFileURI.append(nattableConfigurationFileName);
- initialResource = set.createResource(URI.createFileURI(nattableConfFileURI.toString()));
- initialResource.getContents().add(configuration);
-
- result = true;
- } catch (final InvocationTargetException e) {
- Activator.logException(e);
- } catch (final InterruptedException e) {
- Activator.logException(e);
- }
- } else if (null != initialResource) {
- ServicesRegistry registry;
- try {
- registry = ServiceUtilsForResourceSet.getInstance().getServiceRegistry(initialResource.getResourceSet());
- final TransactionalEditingDomain editingDomain = registry.getService(TransactionalEditingDomain.class);
-
- final CommandStack commandStack = editingDomain.getCommandStack();
- commandStack.execute(new RecordingCommand(editingDomain) {
-
- @Override
- protected void doExecute() {
- // Save DiagramDialog at proper position
- if (null != initialResource) {
- initialResource.getContents().clear();
- initialResource.getContents().add(configuration);
- }
- }
- });
-
- result = true;
- } catch (final ServiceException e) {
- Activator.logException(e);
- }
- }
-
- final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
- saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
- saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED);
-
- try {
- initialResource.save(saveOptions);
- } catch (final IOException e) {
- Activator.logException(e);
- result = false;
- }
-
- return result;
- }
-
- /**
- * This allows to copy the about file in the created project.
- *
- * @param createdProject
- * The created project.
- */
- protected void copyAboutFile(final IProject createdProject) {
- InputStream inputStream = null;
- OutputStream outputStream = null;
- try {
- final URL url = Activator.getDefault().getBundle().getResource(NattableConfigurationConstants.ABOUT_FILE_NAME);
- inputStream = url.openStream();
-
- final File newAboutFile = new File(createdProject.getLocation().toOSString() + File.separator + NattableConfigurationConstants.ABOUT_FILE_NAME);
- newAboutFile.createNewFile();
-
- outputStream = new FileOutputStream(newAboutFile);
-
- int read = 0;
- byte[] bytes = new byte[1024];
-
- while ((read = inputStream.read(bytes)) != -1) {
- outputStream.write(bytes, 0, read);
- }
- } catch (final IOException e) {
- Activator.logException(e);
- } finally {
- if (null != inputStream) {
- try {
- inputStream.close();
- } catch (final IOException e) {
- Activator.logException(e);
- }
- }
- if (null != outputStream) {
- try {
- // outputStream.flush();
- outputStream.close();
- } catch (final IOException e) {
- Activator.logException(e);
- }
-
- }
- }
- }
-}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/FeatureFillingConfigurationDialog.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/FeatureFillingConfigurationDialog.java
index 7cce581b193..045d11569a2 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/FeatureFillingConfigurationDialog.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/FeatureFillingConfigurationDialog.java
@@ -11,7 +11,7 @@
*
*****************************************************************************/
-package org.eclipse.papyrus.customization.nattableconfiguration.ediiton;
+package org.eclipse.papyrus.customization.nattableconfiguration.edition;
import java.util.Collections;
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/PasteEObjectConfigurationDialog.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/PasteEObjectConfigurationDialog.java
index 5cda8eeacc8..4be86896f1a 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/PasteEObjectConfigurationDialog.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/PasteEObjectConfigurationDialog.java
@@ -11,7 +11,7 @@
*
*****************************************************************************/
-package org.eclipse.papyrus.customization.nattableconfiguration.ediiton;
+package org.eclipse.papyrus.customization.nattableconfiguration.edition;
import java.util.ArrayList;
import java.util.Collection;
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/TreeFillingConfigurationDialog.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/TreeFillingConfigurationDialog.java
index d7cc9139848..adfda5c7c68 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/ediiton/TreeFillingConfigurationDialog.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/edition/TreeFillingConfigurationDialog.java
@@ -11,7 +11,7 @@
*
*****************************************************************************/
-package org.eclipse.papyrus.customization.nattableconfiguration.ediiton;
+package org.eclipse.papyrus.customization.nattableconfiguration.edition;
import java.util.ArrayList;
import java.util.Arrays;
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/handlers/CreateTableConfigurationWizardHandler.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/handlers/CreateTableConfigurationWizardHandler.java
deleted file mode 100644
index c7d4bc59db9..00000000000
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/handlers/CreateTableConfigurationWizardHandler.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
- * 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 FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.customization.nattableconfiguration.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.internal.resources.File;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.papyrus.customization.nattableconfiguration.CreateNattableConfigurationWizard;
-import org.eclipse.papyrus.customization.nattableconfiguration.utils.NattableConfigurationConstants;
-import org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationFactory;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.NattableconfigurationFactory;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
-import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * The handler of the nattable configuration wwizard.
- */
-public class CreateTableConfigurationWizardHandler extends AbstractTableHandler {
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(final ExecutionEvent event) throws ExecutionException {
-
- final String selectionParameter = event.getParameter("org.eclipse.papyrus.customization.nattableconfiguration.configurationParemeter"); //$NON-NLS-1$
-
- Resource resourceSelected = null;
-
- if(null != selectionParameter && selectionParameter.equals("nattableconfiguration")){ //$NON-NLS-1$
- final ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- resourceSelected = getSelectedResource(currentSelection);
- }
-
- final TableConfiguration configuration = getEditedTableConfiguration(resourceSelected);
- final CreateNattableConfigurationWizard wizard = new CreateNattableConfigurationWizard(configuration, resourceSelected);
- final WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
- dialog.open();
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
- */
- @Override
- public void setEnabled(final Object evaluationContext) {
- super.setEnabled(evaluationContext);
- setBaseEnabled(true);
- }
-
- protected Resource getSelectedResource(final ISelection currentSelection) {
- Resource resource = null;
-
- if (currentSelection instanceof StructuredSelection && 1 == ((StructuredSelection) currentSelection).size()) {
- final Object selectedElement = ((StructuredSelection) currentSelection).getFirstElement();
- if (selectedElement instanceof File && NattableConfigurationConstants.NATTABLE_CONFIGURATION_EXTENSION_FILE.equals(((File) selectedElement).getFileExtension())) {
-
- INattableModelManager manager = null;
- final IEditorPart currentPart = getActivePart().getSite().getPage().getActiveEditor();
- if (null != currentPart) {
- manager = (INattableModelManager) currentPart.getAdapter(INattableModelManager.class);
- }
-
- if (null != manager) {
- resource = TableEditingDomainUtils.getTableEditingDomain(manager.getTable()).getResourceSet().getResource(URI.createFileURI(((File) selectedElement).getLocation().toString()), true);
- }
- }
- }
-
- return resource;
- }
-
- /**
- * Get the edited table configuration.
- *
- * @return
- * the edited table configuration.
- */
- protected TableConfiguration getEditedTableConfiguration(final Resource resource) {
- TableConfiguration configuration = null;
-
- boolean isCreation = true;
-
- if (null != resource) {
- if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof TableConfiguration) {
- configuration = EcoreUtil.copy((TableConfiguration) resource.getContents().get(0));
- isCreation = false;
- }
- }
-
- if (isCreation) {
- // 1. create the configuration itself
- configuration = NattableconfigurationFactory.eINSTANCE.createTableConfiguration();
-
- // 2. create the row and the column header axis configuration
- final TableHeaderAxisConfiguration rowHeaderAxisConfiguration = NattableaxisconfigurationFactory.eINSTANCE.createTableHeaderAxisConfiguration();
- final TableHeaderAxisConfiguration columnHeaderAxisConfiguration = NattableaxisconfigurationFactory.eINSTANCE.createTableHeaderAxisConfiguration();
- configuration.setColumnHeaderAxisConfiguration(columnHeaderAxisConfiguration);
- configuration.setRowHeaderAxisConfiguration(rowHeaderAxisConfiguration);
- }
-
- return configuration;
- }
-}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/handlers/EditExistingTableConfigurationWizardHandler.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/handlers/EditExistingTableConfigurationWizardHandler.java
new file mode 100644
index 00000000000..d227167e975
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/handlers/EditExistingTableConfigurationWizardHandler.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * 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 and Bug 49356
+ *****************************************************************************/
+
+package org.eclipse.papyrus.customization.nattableconfiguration.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.customization.nattableconfiguration.wizards.EditTableConfigurationWizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * The handler used to edit an existing table configuration
+ */
+public class EditExistingTableConfigurationWizardHandler extends AbstractHandler {
+
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final EditTableConfigurationWizard wizard = new EditTableConfigurationWizard();
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof StructuredSelection) {
+ wizard.init(PlatformUI.getWorkbench(), (IStructuredSelection) selection);
+ final WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
+ dialog.open();
+ }
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
+ */
+ @Override
+ public void setEnabled(final Object evaluationContext) {
+ super.setEnabled(evaluationContext);
+ setBaseEnabled(true);
+ }
+}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/EditGenericNattableConfigurationFieldsNattableWizardPage.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/EditGenericNattableConfigurationFieldsNattableWizardPage.java
index d5884a115d0..29630976bac 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/EditGenericNattableConfigurationFieldsNattableWizardPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/EditGenericNattableConfigurationFieldsNattableWizardPage.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) vincent.lorenzo@cea.fr - Bug 493756
*
*****************************************************************************/
@@ -86,8 +87,8 @@ public class EditGenericNattableConfigurationFieldsNattableWizardPage extends Ab
public void createControl(final Composite parent) {
setPageComplete(isPageComplete());
final Composite container = new Composite(parent, SWT.BORDER);
- container.setLayout(new GridLayout(2, false));
-
+ container.setLayout(new GridLayout(1, false));
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// Create the table group and its grid data
final Group tableGroup = new Group(container, SWT.NONE);
tableGroup.setLayout(new GridLayout(2, false));
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/NattableConfigurationProjectCreationPage.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/NattableConfigurationFileCreationPage.java
index e9fe7cb0bfc..c6b2fc8a482 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/NattableConfigurationProjectCreationPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/NattableConfigurationFileCreationPage.java
@@ -7,18 +7,14 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ * CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.customization.nattableconfiguration.pages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.customization.nattableconfiguration.helper.TableConfigurationHelper;
import org.eclipse.papyrus.customization.nattableconfiguration.messages.Messages;
-import org.eclipse.pde.internal.ui.wizards.plugin.AbstractFieldData;
-import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -29,10 +25,10 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
/**
- * This allows to initialise the nattable configuration creation by getting the name of the plugin to create and the nattable configuration name.
+ * This page allows to edit the name of the Papyrus Table configuration to create
+ *
*/
-public class NattableConfigurationProjectCreationPage extends NewProjectCreationPage {
-
+public class NattableConfigurationFileCreationPage extends EditGenericNattableConfigurationFieldsNattableWizardPage {
/**
* The nattable configuration file name text composite.
*/
@@ -48,15 +44,14 @@ public class NattableConfigurationProjectCreationPage extends NewProjectCreation
setPageComplete(canFlipToNextPage());
}
};
-
+
/**
* Constructor.
*
* @param helper
- * The table configuration helper.
*/
- public NattableConfigurationProjectCreationPage(final AbstractFieldData data, final IStructuredSelection selection) {
- super(Messages.NattableConfigurationProjectCreationPage_pageName, data, false, selection);
+ public NattableConfigurationFileCreationPage(TableConfigurationHelper helper) {
+ super(helper);
}
/**
@@ -66,18 +61,17 @@ public class NattableConfigurationProjectCreationPage extends NewProjectCreation
*/
@Override
public void createControl(final Composite parent) {
-
- super.createControl(parent);
- final Composite composite = (Composite) getControl();
- composite.setLayoutData(new GridData(SWT.FILL, SWT.DOWN, true, false));
+ Composite container = new Composite(parent, SWT.BORDER);
final GridLayout gridLayout = new GridLayout(1, false);
- composite.setLayout(gridLayout);
- setControl(composite);
- final Group group = createGroup(composite, Messages.NattableConfigurationProjectCreationPage_nattableConfigurationFileNameLabel);
+ container.setLayout(gridLayout);
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ final Group group = createGroup(container, Messages.NattableConfigurationProjectCreationPage_nattableConfigurationFileNameLabel);
nattableConfigurationFileName = new Text(group, SWT.BORDER);
nattableConfigurationFileName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
nattableConfigurationFileName.addListener(SWT.Modify, fileNameModifyListener);
- setPageComplete(false);
+ super.createControl(container);
+ setControl(container);
}
/**
@@ -101,8 +95,13 @@ public class NattableConfigurationProjectCreationPage extends NewProjectCreation
return group;
}
+ /**
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.pages.EditGenericNattableConfigurationFieldsNattableWizardPage#isPageComplete()
+ *
+ * @return
+ */
@Override
- protected boolean validatePage() {
+ public boolean isPageComplete() {
if (null != nattableConfigurationFileName) {
if ("".equals(nattableConfigurationFileName.getText())) { //$NON-NLS-1$
this.setErrorMessage("Set nattable configuration file name"); //$NON-NLS-1$
@@ -110,41 +109,11 @@ public class NattableConfigurationProjectCreationPage extends NewProjectCreation
}
}
- return super.validatePage();
+ return super.isPageComplete();
}
-
+
public String getNattableConfigurationFileName() {
return nattableConfigurationFileName.getText();
}
- /**
- * This method is used to avoid case conflicts between existing and newly created projects
- *
- * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
- *
- * @return
- */
- @Override
- public boolean canFlipToNextPage() {
- // retrieve the selected elements and get its children
- boolean canFlip = true;
-
- final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- if (canFlip) {
- for (IProject iproject : projects) {
- if (this.getProjectName().equalsIgnoreCase(iproject.getName())) {
- canFlip = false;
- this.setErrorMessage("There already is a project with this name: " + iproject.getName()); //$NON-NLS-1$
- // A conflict has been found, no need to go further
- break;
- }
- }
- }
-
- if (!validatePage()) {
- canFlip = false;
- }
-
- return canFlip;
- }
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/RowConfigurationWizardPage.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/RowConfigurationWizardPage.java
index fba5fc0a08b..9828c661c4e 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/RowConfigurationWizardPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/RowConfigurationWizardPage.java
@@ -41,9 +41,9 @@ import org.eclipse.jface.viewers.TreeColumnViewerLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.customization.nattableconfiguration.ediiton.FeatureFillingConfigurationDialog;
-import org.eclipse.papyrus.customization.nattableconfiguration.ediiton.PasteEObjectConfigurationDialog;
-import org.eclipse.papyrus.customization.nattableconfiguration.ediiton.TreeFillingConfigurationDialog;
+import org.eclipse.papyrus.customization.nattableconfiguration.edition.FeatureFillingConfigurationDialog;
+import org.eclipse.papyrus.customization.nattableconfiguration.edition.PasteEObjectConfigurationDialog;
+import org.eclipse.papyrus.customization.nattableconfiguration.edition.TreeFillingConfigurationDialog;
import org.eclipse.papyrus.customization.nattableconfiguration.helper.TableConfigurationHelper;
import org.eclipse.papyrus.customization.nattableconfiguration.messages.Messages;
import org.eclipse.papyrus.customization.nattableconfiguration.utils.NameSimplifier;
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/SlaveConfigurationWizardPage.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/SlaveConfigurationWizardPage.java
index 360cf0f6b39..b14e7d8a584 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/SlaveConfigurationWizardPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/pages/SlaveConfigurationWizardPage.java
@@ -681,8 +681,8 @@ public class SlaveConfigurationWizardPage extends AbstractTableConfigurationWiza
protected SlaveObjectAxisProvider getSlaveObjectAxisProvider(final TableConfiguration configuration) {
SlaveObjectAxisProvider slave = null;
- // Try to get an existing master axis provider
- if (0 < configuration.getRowAxisProviders().size()) {
+ // Try to get an existing slave axis provider
+ if (0 < configuration.getColumnAxisProviders().size()) {
final Iterator<AbstractAxisProvider> columnAxisProvidersIterator = configuration.getColumnAxisProviders().iterator();
while (columnAxisProvidersIterator.hasNext() && null == slave) {
AbstractAxisProvider axisProvider = columnAxisProvidersIterator.next();
@@ -705,13 +705,13 @@ public class SlaveConfigurationWizardPage extends AbstractTableConfigurationWiza
protected SlaveObjectAxisProvider getOrCreateSlaveObjectAxisProvider(final TableConfiguration configuration) {
SlaveObjectAxisProvider slave = getSlaveObjectAxisProvider(configuration);
- // The master doesn't exist, create it
+ // The slave doesn't exist, create it
if (null == slave) {
slave = NattableaxisproviderFactory.eINSTANCE.createSlaveObjectAxisProvider();
configuration.getColumnAxisProviders().add(slave);
}
- // Set the master as default row axis provider if this is not already done
+ // Set the slave as default row axis provider if this is not already done
if (null == configuration.getDefaultColumnAxisProvider()) {
configuration.setDefaultColumnAxisProvider(slave);
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/utils/NattableConfigurationConstants.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/utils/NattableConfigurationConstants.java
index c1257afc4cb..aaa7c6e7961 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/utils/NattableConfigurationConstants.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/utils/NattableConfigurationConstants.java
@@ -28,7 +28,7 @@ public class NattableConfigurationConstants {
/**
* The extension for the nattable configuration file.
*/
- public static final String NATTABLE_CONFIGURATION_EXTENSION_FILE = "nattableconfiguration"; //$NON-NLS-1$
+ public static final String NATTABLE_CONFIGURATION_EXTENSION_FILE = org.eclipse.papyrus.infra.nattable.utils.NattableConfigurationConstants.NATTABLE_CONFIGURATION_EXTENSION_FILE;
/**
* The config folder path.
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/CreateAndEditTableConfigurationWizard.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/CreateAndEditTableConfigurationWizard.java
new file mode 100644
index 00000000000..41f87ff6888
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/CreateAndEditTableConfigurationWizard.java
@@ -0,0 +1,181 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.customization.nattableconfiguration.wizards;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.customization.nattableconfiguration.Activator;
+import org.eclipse.papyrus.customization.nattableconfiguration.pages.NattableConfigurationFileCreationPage;
+import org.eclipse.papyrus.customization.nattableconfiguration.utils.NattableConfigurationConstants;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.TableHeaderAxisConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.NattableconfigurationFactory;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
+import org.eclipse.papyrus.infra.tools.util.FileUtils;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * The wizard used to create and edit a Papyrus Table configuration in an existing project
+ *
+ */
+public class CreateAndEditTableConfigurationWizard extends EditTableConfigurationWizard {
+
+ /**
+ * the page used to create the table configuration
+ */
+ private NattableConfigurationFileCreationPage page = null;
+
+ /**
+ * the initial selection done by the used on which the wizard has been called
+ */
+ private Object firstSelectedElement;
+
+ /**
+ *
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.wizards.EditTableConfigurationWizard#addEditNattableConfigurationPage()
+ *
+ */
+ protected void addEditNattableConfigurationPage() {
+ addPage(this.page = new NattableConfigurationFileCreationPage(this.helper));
+ }
+
+ /**
+ * Get the edited table configuration.
+ *
+ * @return
+ * the edited table configuration.
+ */
+ protected TableConfiguration getEditedTableConfiguration(final Resource resource) {
+ // 1. create the configuration itself
+ TableConfiguration configuration = NattableconfigurationFactory.eINSTANCE.createTableConfiguration();
+
+ // 2. create the row and the column header axis configuration
+ final TableHeaderAxisConfiguration rowHeaderAxisConfiguration = NattableaxisconfigurationFactory.eINSTANCE.createTableHeaderAxisConfiguration();
+ final TableHeaderAxisConfiguration columnHeaderAxisConfiguration = NattableaxisconfigurationFactory.eINSTANCE.createTableHeaderAxisConfiguration();
+ configuration.setColumnHeaderAxisConfiguration(columnHeaderAxisConfiguration);
+ configuration.setRowHeaderAxisConfiguration(rowHeaderAxisConfiguration);
+ return configuration;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.wizards.EditTableConfigurationWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ *
+ * @param workbench
+ * @param selection
+ */
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+ if (selection instanceof StructuredSelection) {
+ this.firstSelectedElement = selection.getFirstElement();
+ }
+ }
+
+ /**
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.wizards.EditTableConfigurationWizard#performFinish()
+ *
+ * @return
+ */
+ @Override
+ public boolean performFinish() {
+ StringBuilder nattableConfigurationFileName = new StringBuilder(this.page.getNattableConfigurationFileName());
+
+ // Check if the file has the nattable configuration extension file, else add it
+
+ if (!nattableConfigurationFileName.toString().contains(FileUtils.DOT_STRING)
+ || !NattableConfigurationConstants.NATTABLE_CONFIGURATION_EXTENSION_FILE.equals(nattableConfigurationFileName.toString().substring(nattableConfigurationFileName.lastIndexOf(FileUtils.DOT_STRING) + 1))) {
+ nattableConfigurationFileName.append(FileUtils.DOT_STRING);
+ nattableConfigurationFileName.append(NattableConfigurationConstants.NATTABLE_CONFIGURATION_EXTENSION_FILE);
+ }
+
+ final ResourceSet set = new ResourceSetImpl();
+ final StringBuilder nattableConfFileURI = new StringBuilder();
+ nattableConfFileURI.append(getPathForTableConfigurationCreation());
+ nattableConfFileURI.append(nattableConfigurationFileName);
+ this.initialResource = set.createResource(URI.createFileURI(nattableConfFileURI.toString()));
+ // the configuration is added into the resource in the super class
+ // initialResource.getContents().add(configuration);
+ boolean result = super.performFinish();
+ refreshProject();
+ return result;
+ }
+
+ /**
+ *
+ * @return
+ * the location to use to create the new Papyrus Table Configuration.
+ * The location will be the folder selected by the user or for others selections, a folfer called {@link NattableConfigurationConstants#CONFIG_FOLDER} in others cases
+ */
+ protected String getPathForTableConfigurationCreation() {
+ String location = null;
+ if (this.firstSelectedElement instanceof IFolder) {
+ String projectLocation = ((IFolder) this.firstSelectedElement).getLocation().toString();
+ StringBuilder builder = new StringBuilder(projectLocation);
+ builder.append(FileUtils.SLASH_STRING);
+ location = builder.toString();
+ } else if (this.firstSelectedElement instanceof IResource) {
+ String projectLocation = getProjectLocation();
+ StringBuilder builder = new StringBuilder(projectLocation);
+ builder.append(NattableConfigurationConstants.CONFIG_FOLDER);
+ location = builder.toString();
+ }
+ return location;
+ }
+
+ /**
+ * This method allows to refresh the project (required to display the created table configuration)
+ */
+ protected final void refreshProject() {
+ try {
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ } catch (CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+
+ /**
+ *
+ * @return
+ * the project in which is created the table configuration
+ */
+ protected IProject getProject() {
+ IProject project = null;
+ if (this.firstSelectedElement instanceof org.eclipse.core.internal.resources.Resource) {
+ project = ((org.eclipse.core.internal.resources.Resource) firstSelectedElement).getProject();
+ }
+ return project;
+ }
+
+ /**
+ *
+ * @return
+ * the location of the project
+ */
+ protected String getProjectLocation() {
+ IProject project = getProject();
+ if (null != project) {
+ return project.getLocation().toString();
+ }
+ return null;
+ }
+}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/CreateNattableConfigurationProjectWizard.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/CreateNattableConfigurationProjectWizard.java
new file mode 100644
index 00000000000..b4380c784d5
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/CreateNattableConfigurationProjectWizard.java
@@ -0,0 +1,223 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * 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 FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ * Vincent LORENZO (CEA-LIST) vincent.lorenzo@cea.fr - Bug 493756
+ *****************************************************************************/
+
+package org.eclipse.papyrus.customization.nattableconfiguration.wizards;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.customization.nattableconfiguration.Activator;
+import org.eclipse.papyrus.customization.nattableconfiguration.messages.Messages;
+import org.eclipse.papyrus.customization.nattableconfiguration.utils.NattableConfigurationConstants;
+import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
+import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationOperation;
+import org.eclipse.pde.internal.ui.wizards.plugin.NewProjectCreationPage;
+import org.eclipse.pde.internal.ui.wizards.plugin.PluginContentPage;
+import org.eclipse.pde.internal.ui.wizards.plugin.PluginFieldData;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * The wizard used to create a Papyrus Table Configuration Project
+ */
+public class CreateNattableConfigurationProjectWizard extends CreateAndEditTableConfigurationWizard implements IWorkbenchWizard {
+
+
+ /**
+ * The page for the project creation.
+ */
+ private NewProjectCreationPage nattableConfigurationProjectCreationPage;
+
+ /**
+ * The project provider.
+ */
+ private IProjectProvider projectProvider;
+
+ /**
+ * The content page for the project creation.
+ */
+ protected PluginContentPage contentPage;
+
+ /**
+ * The fields data to manage the project creation
+ */
+ private PluginFieldData pluginData;
+
+ /**
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.EditTableConfigurationWizard#addPages()
+ *
+ */
+ @Override
+ public void addPages() {
+ pluginData = new PluginFieldData();
+
+ nattableConfigurationProjectCreationPage = new NewProjectCreationPage(Messages.NattableConfigurationProjectCreationPage_pageName, pluginData, false,new StructuredSelection());
+ addPage(nattableConfigurationProjectCreationPage);
+
+ projectProvider = new IProjectProvider() {
+ @Override
+ public String getProjectName() {
+ return nattableConfigurationProjectCreationPage.getProjectName();
+ }
+
+ @Override
+ public IProject getProject() {
+ return nattableConfigurationProjectCreationPage.getProjectHandle();
+ }
+
+ @Override
+ public IPath getLocationPath() {
+ return nattableConfigurationProjectCreationPage.getLocationPath();
+ }
+ };
+
+ contentPage = new PluginContentPage("page2", projectProvider, nattableConfigurationProjectCreationPage, pluginData); //$NON-NLS-1$
+
+ addPage(contentPage);
+ super.addPages();
+ }
+
+
+
+
+ /**
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.EditTableConfigurationWizard#performFinish()
+ *
+ * @return
+ */
+ @Override
+ public boolean performFinish() {
+ boolean result = false;
+
+ IProject createdProject = null;
+
+ try {
+
+ // Create the project
+ getContainer().run(false, true, new NewProjectCreationOperation(pluginData, projectProvider, null));
+
+ createdProject = getProject();
+
+ // Set the project into the working sets
+ final IWorkingSet[] workingSets = nattableConfigurationProjectCreationPage.getSelectedWorkingSets();
+ if (0 < workingSets.length) {
+ PlatformUI.getWorkbench().getWorkingSetManager().addToWorkingSets(createdProject, workingSets);
+ }
+
+ // Copy the about file
+ copyAboutFile(createdProject);
+ result = super.performFinish();
+ } catch (final InvocationTargetException e) {
+ Activator.log.error(e);
+ } catch (final InterruptedException e) {
+ Activator.log.error(e);
+ }
+
+ if (result) {
+ result = saveResource();
+ }
+ refreshProject();
+ return result;
+ }
+
+ /**
+ * This allows to get the project created folder.
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.wizards.CreateAndEditTableConfigurationWizard#getPathForTableConfigurationCreation()
+ */
+ @Override
+ protected String getPathForTableConfigurationCreation() {
+ final String projectLocation = getProjectLocation();
+ final StringBuilder builder = new StringBuilder(projectLocation);
+ builder.append(NattableConfigurationConstants.CONFIG_FOLDER);
+
+ return builder.toString();
+ }
+
+ /**
+ * This allows to copy the about file in the created project.
+ *
+ * @param createdProject
+ * The created project.
+ */
+ protected void copyAboutFile(final IProject createdProject) {
+ InputStream inputStream = null;
+ OutputStream outputStream = null;
+ try {
+ final URL url = Activator.getDefault().getBundle().getResource(NattableConfigurationConstants.ABOUT_FILE_NAME);
+ inputStream = url.openStream();
+
+ final java.io.File newAboutFile = new java.io.File(createdProject.getLocation().toOSString() + java.io.File.separator + NattableConfigurationConstants.ABOUT_FILE_NAME);
+ newAboutFile.createNewFile();
+
+ outputStream = new FileOutputStream(newAboutFile);
+
+ int read = 0;
+ byte[] bytes = new byte[1024];
+
+ while ((read = inputStream.read(bytes)) != -1) {
+ outputStream.write(bytes, 0, read);
+ }
+ } catch (final IOException e) {
+ Activator.log.error(e);
+ } finally {
+ if (null != inputStream) {
+ try {
+ inputStream.close();
+ } catch (final IOException e) {
+ Activator.log.error(e);
+ }
+ }
+ if (null != outputStream) {
+ try {
+ // outputStream.flush();
+ outputStream.close();
+ } catch (final IOException e) {
+ Activator.log.error(e);
+ }
+
+ }
+ }
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.wizards.CreateAndEditTableConfigurationWizard#getProject()
+ *
+ * @return
+ */
+ @Override
+ protected IProject getProject() {
+ return this.projectProvider.getProject();
+ }
+
+ /**
+ * @see org.eclipse.papyrus.customization.nattableconfiguration.wizards.CreateAndEditTableConfigurationWizard#getProjectLocation()
+ *
+ * @return
+ */
+ @Override
+ protected String getProjectLocation() {
+ IProject createdProject = getProject();
+ return createdProject.getLocation().toString();
+ }
+}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/EditTableConfigurationWizard.java b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/EditTableConfigurationWizard.java
new file mode 100644
index 00000000000..3bd3bf34759
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.nattableconfiguration/src/org/eclipse/papyrus/customization/nattableconfiguration/wizards/EditTableConfigurationWizard.java
@@ -0,0 +1,231 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * 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 FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.customization.nattableconfiguration.wizards;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.internal.resources.File;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.jface.dialogs.DialogSettings;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.papyrus.customization.nattableconfiguration.Activator;
+import org.eclipse.papyrus.customization.nattableconfiguration.helper.TableConfigurationHelper;
+import org.eclipse.papyrus.customization.nattableconfiguration.messages.Messages;
+import org.eclipse.papyrus.customization.nattableconfiguration.pages.ColumnConfigurationWizardPage;
+import org.eclipse.papyrus.customization.nattableconfiguration.pages.EditGenericNattableConfigurationFieldsNattableWizardPage;
+import org.eclipse.papyrus.customization.nattableconfiguration.pages.RowConfigurationWizardPage;
+import org.eclipse.papyrus.customization.nattableconfiguration.pages.SlaveConfigurationWizardPage;
+import org.eclipse.papyrus.customization.nattableconfiguration.utils.NattableConfigurationConstants;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableconfiguration.TableConfiguration;
+import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
+import org.eclipse.papyrus.infra.nattable.wizard.AbstractTableWizard;
+import org.eclipse.papyrus.infra.ui.util.WorkbenchPartHelper;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+
+/**
+ * The wizard to edit an existing TableConfiguration file
+ */
+public class EditTableConfigurationWizard extends AbstractTableWizard implements IWorkbenchWizard {
+
+ /**
+ * The generate plugin activator setting.
+ */
+ private static final String GENERATE_PlUGIN_ACTIVATOR = "generatePluginActivator"; //$NON-NLS-1$
+
+ /**
+ * The ui plugin setting.
+ */
+ private static final String UI_PLUGIN = "uiPlugin"; //$NON-NLS-1$
+
+ /**
+ * The edited table configuration
+ */
+ protected TableConfiguration configuration;
+
+ /**
+ * The initial resource selected.
+ */
+ protected Resource initialResource;
+
+ /**
+ * the edited Table Configuration Helper;
+ */
+ protected TableConfigurationHelper helper;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * Thi sconstructor is used when we create a new Papyrus Table Configuration Poject from the wizard Dialog
+ *
+ */
+ public EditTableConfigurationWizard() {
+ final ImageDescriptor desc = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImageDescriptor(Activator.PLUGIN_ID, NattableConfigurationConstants.ICON_WIZBAN_PATH);
+ setDefaultPageImageDescriptor(desc);
+ setWindowTitle(Messages.CreateNattableConfigurationWizard_WizardTitke);
+ setForcePreviousAndNextButtons(true);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.nattable.wizard.AbstractTableWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ *
+ * @param workbench
+ * @param selection
+ */
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+ this.initialResource = getSelectedResource(selection);
+ this.configuration = getEditedTableConfiguration(this.initialResource);
+ Assert.isNotNull(this.configuration);
+ this.helper = new TableConfigurationHelper(configuration);
+ }
+
+ /**
+ *
+ * @param currentSelection
+ * the current selection
+ * @return
+ * the resource if it already exist or <code>null</code>;
+ */
+ protected Resource getSelectedResource(final ISelection currentSelection) {
+ Resource resource = null;
+
+ if (currentSelection instanceof StructuredSelection && 1 == ((StructuredSelection) currentSelection).size()) {
+ final Object selectedElement = ((StructuredSelection) currentSelection).getFirstElement();
+ if (selectedElement instanceof File && NattableConfigurationConstants.NATTABLE_CONFIGURATION_EXTENSION_FILE.equals(((File) selectedElement).getFileExtension())) {
+
+ INattableModelManager manager = null;
+ // TODO required ?
+ final IEditorPart currentPart = WorkbenchPartHelper.getCurrentActiveWorkbenchPart().getSite().getPage().getActiveEditor();
+ if (null != currentPart) {
+ manager = (INattableModelManager) currentPart.getAdapter(INattableModelManager.class);
+ }
+
+ if (null != manager) {
+ resource = TableEditingDomainUtils.getTableEditingDomain(manager.getTable()).getResourceSet().getResource(URI.createFileURI(((File) selectedElement).getLocation().toString()), true);
+ } else {
+ final ResourceSet set = new ResourceSetImpl();
+ resource = set.getResource(URI.createFileURI(((File) selectedElement).getLocation().toString()), true);
+ }
+ }
+ }
+
+ return resource;
+ }
+
+ /**
+ * Get the edited table configuration.
+ *
+ * @return
+ * the edited table configuration.
+ */
+ protected TableConfiguration getEditedTableConfiguration(final Resource resource) {
+ TableConfiguration configuration = null;
+ if (null != resource) {
+ if (!resource.getContents().isEmpty() && resource.getContents().get(0) instanceof TableConfiguration) {
+ configuration = EcoreUtil.copy((TableConfiguration) resource.getContents().get(0));
+ }
+ }
+ return configuration;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ addEditNattableConfigurationPage();
+ addPage(new RowConfigurationWizardPage(this.helper));
+ addPage(new ColumnConfigurationWizardPage(this.helper));
+ addPage(new SlaveConfigurationWizardPage(this.helper));
+ }
+
+ protected void addEditNattableConfigurationPage(){
+ addPage(new EditGenericNattableConfigurationFieldsNattableWizardPage(this.helper));
+ }
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.wizard.Wizard#getDialogSettings()
+ */
+ @Override
+ public IDialogSettings getDialogSettings() {
+ DialogSettings dialogSettings = new DialogSettings(""); //$NON-NLS-1$
+ dialogSettings.put(GENERATE_PlUGIN_ACTIVATOR, true);
+ dialogSettings.put(UI_PLUGIN, false);
+ return dialogSettings;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+
+ boolean result = false;
+
+ // The resource is modified directly without command (undo/redo impossible)
+ // Save DiagramDialog at proper position
+ if (null != this.initialResource) {
+ this.initialResource.getContents().clear();
+ this.initialResource.getContents().add(this.configuration);
+ result = true;
+ }
+ if (result) {
+ result = saveResource();
+ }
+
+ return result;
+ }
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the resource has been properly saved
+ */
+ protected final boolean saveResource() {
+ boolean result = true;
+ final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED);
+
+ try {
+ initialResource.save(saveOptions);
+ } catch (final IOException e) {
+ Activator.log.error(e);
+ result = false;
+ }
+ return result;
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableConfigurationConstants.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableConfigurationConstants.java
new file mode 100644
index 00000000000..37c2559be2c
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/NattableConfigurationConstants.java
@@ -0,0 +1,26 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.nattable.utils;
+
+/**
+ * @author VL222926
+ *
+ */
+public class NattableConfigurationConstants {
+
+ /**
+ * The extension for the nattable configuration file.
+ */
+ public static final String NATTABLE_CONFIGURATION_EXTENSION_FILE = "nattableconfiguration"; //$NON-NLS-1$
+}

Back to the top