Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2014-01-24 10:53:43 -0500
committervlorenzo2014-01-24 11:19:29 -0500
commite39e251966244bc79e469c04b7178943b2d3bbb1 (patch)
tree279fa5643b9143f7841c27ce501bfd57828b6183 /extraplugins
parent78fe5647a4efd0bde3fa373d3e52a5ab867ed777 (diff)
downloadorg.eclipse.papyrus-e39e251966244bc79e469c04b7178943b2d3bbb1.tar.gz
org.eclipse.papyrus-e39e251966244bc79e469c04b7178943b2d3bbb1.tar.xz
org.eclipse.papyrus-e39e251966244bc79e469c04b7178943b2d3bbb1.zip
424099: [Diagram] Papyrus must provide a way to draw connections points
(big bendpoints) https://bugs.eclipse.org/bugs/show_bug.cgi?id=424099
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF3
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/importTablePapyrusWizban.pngbin0 -> 6414 bytes
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/import_wiz_16x16-papyrusColor.gifbin0 -> 541 bytes
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/warning.gifbin0 -> 331 bytes
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml34
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dialog/PasteImportStatusDialog.java97
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java4
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ImportTableHandler.java47
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java51
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java367
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/ImportAxisInNattableManager.java62
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/PasteAxisInNattableManager.java70
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/PasteInTableManager.java136
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java93
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties47
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CSVLexer.java281
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CSVParser.java219
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CellIterator.java32
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/RewindableTextStream.java145
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/RowIterator.java32
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/paste/PasteSeparator.java101
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/paste/TextDelimiter.java74
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java840
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java2
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CSVPasteHelper.java97
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CellHelper.java21
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtils.java50
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteEnablementStatus.java98
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelper.java154
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteModeEnumeration.java9
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java23
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ImportTableWizard.java142
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportCSVConfigurationPage.java218
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportFilePage.java184
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportInvertedTableErrorPage.java66
-rw-r--r--extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportTableErrorPage.java67
36 files changed, 3662 insertions, 204 deletions
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF b/extraplugins/table/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
index 96791288555..09ce06220bd 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/META-INF/MANIFEST.MF
@@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.papyrus.infra.widgets;bundle-version="0.10.1",
org.eclipse.papyrus.infra.services.edit;bundle-version="0.10.1",
org.eclipse.papyrus.infra.widgets.toolbox,
org.apache.commons.lang,
- com.google.guava;bundle-version="11.0.0"
+ com.google.guava;bundle-version="11.0.0",
+ org.eclipse.jface
Export-Package: org.eclipse.papyrus.infra.nattable,
org.eclipse.papyrus.infra.nattable.celleditor,
org.eclipse.papyrus.infra.nattable.celleditor.config,
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/importTablePapyrusWizban.png b/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/importTablePapyrusWizban.png
new file mode 100644
index 00000000000..2760811cabf
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/importTablePapyrusWizban.png
Binary files differ
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/import_wiz_16x16-papyrusColor.gif b/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/import_wiz_16x16-papyrusColor.gif
new file mode 100644
index 00000000000..c7be463bcd2
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/import_wiz_16x16-papyrusColor.gif
Binary files differ
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/warning.gif b/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/warning.gif
new file mode 100644
index 00000000000..2f1c5a8fa7b
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/icons/warning.gif
Binary files differ
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml b/extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml
index 98099b406d9..cc29f086118 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/plugin.xml
@@ -13,6 +13,10 @@
allPopups="true"
locationURI="popup:org.eclipse.ui.popup.any">
<command
+ commandId="org.eclipse.papyrus.infra.nattable.import.command"
+ style="push">
+ </command>
+ <command
commandId="org.eclipse.papyrus.infra.nattable.invert.axis"
style="toggle">
<visibleWhen>
@@ -1051,6 +1055,36 @@
commandId="org.eclipse.papyrus.infra.nattable.autoresize.rows"
icon="icons/auto_resize_row.png">
</image>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.papyrus.infra.nattable.category"
+ defaultHandler="org.eclipse.papyrus.infra.nattable.handler.ImportTableHandler"
+ description="Import a file into a table"
+ id="org.eclipse.papyrus.infra.nattable.import.command"
+ name="Import from file">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commandImages">
+ <image
+ commandId="org.eclipse.papyrus.infra.nattable.import.command"
+ icon="icons/import_wiz_16x16-papyrusColor.gif">
+ </image>
+ </extension>
+ <extension
+ point="org.eclipse.ui.importWizards">
+ <wizard
+ category="org.eclipse.papyrus.infra.core.importcategory"
+ class="org.eclipse.papyrus.infra.nattable.wizard.pages.ImportTableWizard"
+ icon="icons/import_wiz_16x16-papyrusColor.gif"
+ id="org.eclipse.papyrus.infra.nattable.import.category"
+ name="Import In Open Table">
+ <description>
+ This wizard allows to import a table.
+ </description>
+ </wizard>
</extension>
</plugin>
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dialog/PasteImportStatusDialog.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dialog/PasteImportStatusDialog.java
new file mode 100644
index 00000000000..de2bec5c3d0
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/dialog/PasteImportStatusDialog.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.dialog;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ *
+ * @author VL222926
+ * This dialog is used to display paste error status
+ */
+public class PasteImportStatusDialog extends MessageDialog {
+
+ /**
+ * Message displayed in the paste dialog
+ */
+ public static final String HOW_TO_PASTE_MESSAGE = Messages.PasteImportStatusDialog_PasteConfigurationMessage;
+
+ /**
+ * Title for all dialog used by this class
+ */
+ public static final String DIALOG_TITLE = Messages.PasteImportStatusDialog_ImportPasteDialogTitle;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parentShell
+ * the shell parent to use
+ * @param dialogMessage
+ * the message to display
+ */
+ public PasteImportStatusDialog(final Shell parentShell, final String dialogMessage) {
+ super(parentShell, DIALOG_TITLE, getPapyrusIcon(), dialogMessage, MessageDialog.ERROR, new String[]{ IDialogConstants.OK_LABEL }, 0);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param parentShell
+ * the shell parent to use
+ * @param dialogMessage
+ * the message to display
+ * @param dialogImageType
+ */
+ public PasteImportStatusDialog(final Shell parentShell, final String dialogMessage, final int dialogImageType) {
+ super(parentShell, DIALOG_TITLE, getPapyrusIcon(), dialogMessage, dialogImageType, new String[]{ IDialogConstants.OK_LABEL }, 0);
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.dialogs.MessageDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ * @return
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ final Composite comp = (Composite)super.createDialogArea(parent);
+ final CLabel label = new CLabel(comp, SWT.NONE);
+ label.setText(HOW_TO_PASTE_MESSAGE);
+ label.setImage(getInfoImage());
+ return comp;
+ }
+
+
+ /**
+ *
+ * @return
+ * the papyrus icon
+ */
+ private static final Image getPapyrusIcon() {
+ return org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage("icons/papyrus.png"); //$NON-NLS-1$
+ }
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
index e03aa979278..999546d41aa 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/AbstractTableHandler.java
@@ -28,13 +28,13 @@ import org.eclipse.papyrus.infra.nattable.manager.axis.IAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
import org.eclipse.papyrus.infra.nattable.utils.TableSelectionWrapper;
+import org.eclipse.papyrus.infra.tools.util.WorkbenchPartHelper;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -66,7 +66,7 @@ public abstract class AbstractTableHandler extends AbstractHandler {
* the current active part
*/
protected IWorkbenchPart getActivePart() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
+ return WorkbenchPartHelper.getCurrentActiveWorkbenchPart();
}
/**
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ImportTableHandler.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ImportTableHandler.java
new file mode 100644
index 00000000000..a2079d3a91f
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/ImportTableHandler.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.handler;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.papyrus.infra.nattable.wizard.ImportTableWizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ *
+ * This handler allows to import a table using the ImportWizard
+ *
+ */
+public class ImportTableHandler extends AbstractTableHandler {
+
+ /**
+ *
+ * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final ImportTableWizard wizard = new ImportTableWizard();
+ wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(getCurrentNattableModelManager()));
+ final WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
+ dialog.open();
+ return null;
+ }
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java
index 57937edc797..1d4d040c3f7 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/handler/PasteInTableHandler.java
@@ -15,9 +15,9 @@ package org.eclipse.papyrus.infra.nattable.handler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.papyrus.infra.nattable.manager.PasteInTableManager;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.utils.PasteModeEnumeration;
+import org.eclipse.papyrus.infra.nattable.manager.PasteAxisInNattableManager;
+import org.eclipse.papyrus.infra.nattable.utils.CSVPasteHelper;
+import org.eclipse.papyrus.infra.nattable.utils.TableClipboardUtils;
/**
* Paste Handler
@@ -28,11 +28,6 @@ import org.eclipse.papyrus.infra.nattable.utils.PasteModeEnumeration;
public class PasteInTableHandler extends AbstractTableHandler {
/**
- * the paste manager
- */
- private PasteInTableManager pasteManager;
-
- /**
* this field is used to determine if we want open a dialog to prevent the user that the command creation and the command execution can take a
* long time
*/
@@ -40,25 +35,6 @@ public class PasteInTableHandler extends AbstractTableHandler {
/**
- * the paste mode
- */
- private PasteModeEnumeration pasteMode;
-
- /**
- * the current table manager
- */
- private INattableModelManager manager;
-
- /**
- *
- * Constructor.
- *
- */
- public PasteInTableHandler() {
- this.pasteManager = new PasteInTableManager();
- }
-
- /**
*
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*
@@ -68,11 +44,12 @@ public class PasteInTableHandler extends AbstractTableHandler {
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- this.pasteManager.paste(getCurrentNattableModelManager(), pasteMode, useProgressMonitorDialog);
+ CSVPasteHelper pasteHelper = new CSVPasteHelper();
+ PasteAxisInNattableManager pasteManager = new PasteAxisInNattableManager(getCurrentNattableModelManager(), pasteHelper, useProgressMonitorDialog, TableClipboardUtils.getClipboardContentsAsString());
+ pasteManager.doPaste();
return null;
}
-
/**
* @Override
* @see org.eclipse.papyrus.infra.nattable.handler.AbstractTableHandler#setEnabled(java.lang.Object)
@@ -80,21 +57,7 @@ public class PasteInTableHandler extends AbstractTableHandler {
* @param evaluationContext
*/
public void setEnabled(Object evaluationContext) {
- pasteMode = null;
- this.manager = getCurrentNattableModelManager();
- boolean isEnabled = false;
- if(manager != null) {
- pasteMode = this.pasteManager.getPasteMode(evaluationContext, manager);
- switch(pasteMode) {
- case CANT_PASTE:
- isEnabled = false;
- break;
- default:
- isEnabled = true;
- }
-
- }
- setBaseEnabled(isEnabled);
+ setBaseEnabled(getCurrentNattableModelManager() != null);
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java
new file mode 100644
index 00000000000..13bfe2307be
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/AbstractPasteImportInNattableManager.java
@@ -0,0 +1,367 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.manager;
+
+import java.io.IOException;
+import java.io.Reader;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.dialog.PasteImportStatusDialog;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.PasteEObjectConfiguration;
+import org.eclipse.papyrus.infra.nattable.parsers.CSVParser;
+import org.eclipse.papyrus.infra.nattable.parsers.CellIterator;
+import org.eclipse.papyrus.infra.nattable.parsers.RowIterator;
+import org.eclipse.papyrus.infra.nattable.provider.PasteEObjectAxisInNattableCommandProvider;
+import org.eclipse.papyrus.infra.nattable.utils.AxisConfigurationUtils;
+import org.eclipse.papyrus.infra.nattable.utils.CSVPasteHelper;
+import org.eclipse.papyrus.infra.nattable.utils.CreatableEObjectAxisUtils;
+import org.eclipse.papyrus.infra.nattable.utils.PasteConfigurationUtils;
+import org.eclipse.papyrus.infra.nattable.utils.PasteEnablementStatus;
+import org.eclipse.papyrus.infra.nattable.utils.PasteModeEnumeration;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ *
+ * Abstract class for the copy/paste and import file in the table
+ *
+ */
+public abstract class AbstractPasteImportInNattableManager {
+
+ /**
+ * the helper used to do the paste (help for the split of the string)
+ */
+ protected final CSVPasteHelper pasteHelper;
+
+ /**
+ * the table manager
+ */
+ protected final INattableModelManager tableManager;
+
+ /**
+ * true if we must use progress monitor
+ */
+ private boolean useProgressMonitorDialog;
+
+ /**
+ * message in case of inverted table
+ */
+ private static final String INVERTED_MESSAGE = Messages.AbstractPasteImportInNattableManager_INVERTED_MESSAGE;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param pasteHelper
+ * the helper used to do the paste (help for the split of the string)
+ */
+ public AbstractPasteImportInNattableManager(final INattableModelManager tableManager, final CSVPasteHelper pasteHelper, final boolean useProgressMonitorDialog) {
+ this.pasteHelper = pasteHelper;
+ this.tableManager = tableManager;
+ this.useProgressMonitorDialog = useProgressMonitorDialog;
+ }
+
+
+
+ /**
+ * This method manages the paste and the possible error dialog before doing the paste
+ *
+ * @return
+ * <code>true</code> if the paste can be done (as it is done in a job, it will be after the return of this method)
+ */
+ public boolean doPaste() {
+ if(this.tableManager.getTable().isInvertAxis()) {
+ new PasteImportStatusDialog(Display.getDefault().getActiveShell(), INVERTED_MESSAGE).open();
+ return false;
+ }
+ final PasteEnablementStatus pasteStatus = findPasteModeFromTableConfiguration(this.tableManager);
+ if(pasteStatus.getPasteMode() == PasteModeEnumeration.PASTE_EOBJECT_ROW_OR_COLUMN) {
+ boolean value = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), PasteImportStatusDialog.DIALOG_TITLE, Messages.AbstractPasteImportInNattableManager_WhatAreYouPasting);
+ if(value) {
+ pasteStatus.getColumnStatus().add(new Status(IStatus.CANCEL, Activator.PLUGIN_ID, Messages.AbstractPasteImportInNattableManager_TheUserChosesToPasteRows));
+ } else {
+ pasteStatus.getRowStatus().add(new Status(IStatus.CANCEL, Activator.PLUGIN_ID, Messages.AbstractPasteImportInNattableManager_TheUserChosesToPasteColumns));
+ }
+ }
+ PasteModeEnumeration pasteMode = pasteStatus.getPasteMode();
+ switch(pasteMode) {
+ case PASTE_NO_CONFIGURATION:
+ return openPasteWithNoConfigurationDialog();
+ case CANT_PASTE:
+ return openCantPasteDialog(pasteStatus);
+ case PASTE_EOBJECT_ROW:
+ return pasteRow(this.tableManager, pasteStatus, pasteHelper);
+ case PASTE_EOBJECT_COLUMN:
+ return pasteColumn(this.tableManager, pasteStatus, pasteHelper);
+ case PASTE_EOBJECT_ROW_OR_COLUMN:
+ //nothing to do
+ break;
+ default:
+ break;
+ }
+
+ return false;
+ }
+
+
+ /**
+ *
+ * @param pasteStatus
+ * the paste status
+ * @return
+ */
+ private boolean openCantPasteDialog(final PasteEnablementStatus pasteStatus) {
+ final MultiStatus rowStatus = pasteStatus.getRowStatus();
+ final MultiStatus columnStatus = pasteStatus.getColumnStatus();
+ if(rowStatus == null && columnStatus != null) {
+ new PasteImportStatusDialog(Display.getCurrent().getActiveShell(), getFirstNonOKStatus(columnStatus).getMessage()).open();
+ } else if(columnStatus == null && rowStatus != null) {
+ new PasteImportStatusDialog(Display.getCurrent().getActiveShell(), getFirstNonOKStatus(rowStatus).getMessage()).open();
+ } else if(columnStatus != null && rowStatus != null) {
+ StringBuffer buffer = new StringBuffer(Messages.AbstractPasteImportInNattableManager_NoPasteConfiguration);
+ buffer.append(Messages.AbstractPasteImportInNattableManager_PasteRowsError);
+ buffer.append(getFirstNonOKStatus(rowStatus).getMessage());
+ buffer.append(Messages.AbstractPasteImportInNattableManager_PasteColumnsError);
+ buffer.append(getFirstNonOKStatus(columnStatus).getMessage());
+ new PasteImportStatusDialog(Display.getDefault().getActiveShell(), buffer.toString()).open();
+ } else {
+ //never possible
+ openPasteWithNoConfigurationDialog();
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @param status
+ * a status
+ * @return
+ * the first non ok status
+ */
+ private IStatus getFirstNonOKStatus(final IStatus status) {
+ if(status != null && !status.isOK()) {
+ for(final IStatus current : status.getChildren()) {
+ if(!current.isOK()) {
+ if(current.isMultiStatus()) {
+ return getFirstNonOKStatus(current);
+ } else {
+ return current;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * open the dialog used when the table has no paste configuration
+ *
+ * @return
+ */
+ private boolean openPasteWithNoConfigurationDialog() {
+ new PasteImportStatusDialog(Display.getDefault().getActiveShell(), Messages.AbstractPasteImportInNattableManager_NoPasteConfiguration2, MessageDialog.INFORMATION).open();
+ return true;
+ }
+
+ /**
+ *
+ * @param manager
+ * the table manager
+ * @param pasteStatus
+ * the paste status
+ * @param pasteHelper
+ * the paste helper
+ * @return
+ * <code>true</code> if the paste can be done
+ */
+ private boolean pasteColumn(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper) {
+ //TODO
+ return false;
+ }
+
+ /**
+ *
+ * @param manager
+ * the table manager
+ * @param pasteStatus
+ * the paste status
+ * @param pasteHelper
+ * the paste helper
+ * @return
+ * <code>true</code> if the paste can be done
+ */
+ private boolean pasteRow(final INattableModelManager manager, final PasteEnablementStatus pasteStatus, final CSVPasteHelper pasteHelper) {
+ final Reader reader = createReader();
+ final IStatus status = verifyColumnCountOnFirstLine(manager, reader);
+ try {
+ reader.close();
+ } catch (IOException e) {
+ Activator.log.error(e);
+ }
+ if(status.isOK()) {
+ paste(manager, pasteStatus, useProgressMonitorDialog, createReader(), getDataSize());
+ } else {
+ new PasteImportStatusDialog(Display.getDefault().getActiveShell(), status.getMessage()).open();
+ return false;
+ }
+ return true;
+ }
+
+
+ /**
+ *
+ * @param tableManager
+ * the table manager
+ * @param reader
+ * the reader to use to do parsing
+ * @return
+ * a status indicating if the first line of the file allows to do the paste
+ */
+ private IStatus verifyColumnCountOnFirstLine(final INattableModelManager tableManager, final Reader reader) {
+ CSVParser parser = this.pasteHelper.createParser(reader);
+ //we verify the nb of columns
+ final RowIterator rowIter = parser.parse();
+ int nbCell = 0;
+ if(rowIter.hasNext()) {
+ final CellIterator cellIter = rowIter.next();
+ while(cellIter.hasNext()) {
+ cellIter.next();
+ nbCell++;
+ }
+ }
+ final int axisCount = tableManager.getColumnCount();
+ if(axisCount == nbCell) {
+ return new Status(IStatus.OK, Activator.PLUGIN_ID, Messages.AbstractPasteImportInNattableManager_NumberOfColumnsAreEquals);
+ } else {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.AbstractPasteImportInNattableManager_NumberOfColumnsAreNotEquals, nbCell, axisCount));
+ }
+ }
+
+
+
+ /**
+ *
+ * @param manager
+ * the table manager
+ * @param status
+ * the status
+ * @param useProgressMonitorDialog
+ * if <code>true</code> a progress monitor will be used
+ * @param reader
+ * the reader used to import data in the table.
+ * @param totalSize
+ * the full size of the elements to import
+ */
+ private void paste(final INattableModelManager manager, final PasteEnablementStatus status, final boolean useProgressMonitorDialog, final Reader reader, final long totalSize) {
+ PasteEObjectAxisInNattableCommandProvider commandProvider = null;
+ switch(status.getPasteMode()) {
+ case PASTE_EOBJECT_ROW:
+ commandProvider = new PasteEObjectAxisInNattableCommandProvider(manager, false, reader, this.pasteHelper, totalSize);
+ break;
+ case PASTE_EOBJECT_COLUMN:
+ commandProvider = new PasteEObjectAxisInNattableCommandProvider(manager, true, reader, this.pasteHelper, totalSize);
+ break;
+ default:
+ break;
+ }
+ //TODO : ask for the element to paste (column or row)!
+ if(commandProvider != null) {
+ commandProvider.executePasteFromStringCommand(useProgressMonitorDialog);
+ }
+ }
+
+ /**
+ *
+ * @param tableManager
+ * the table manager used to calculate the enablement of the paste
+ * @return
+ * the status for the paste
+ */
+ private PasteEnablementStatus findPasteModeFromTableConfiguration(final INattableModelManager tableManager) {
+ final MultiStatus pasteRowsStatus = canPasteAxis_verifyPasteConfiguration(tableManager, false);
+ final MultiStatus pasteColumnsStatus = canPasteAxis_verifyPasteConfiguration(tableManager, true);
+ final PasteEnablementStatus pasteStatus = new PasteEnablementStatus(pasteColumnsStatus, pasteRowsStatus);
+ return pasteStatus;
+ }
+
+ /**
+ *
+ * @param tableManager
+ * teh table manager
+ * @param columnAxis
+ * if <code>true</code> this method tests the paste configuration for the columns, if not, it tests the paste configuration for the rows
+ * @return
+ * a multi status with information on all verified point in the table configuration or <code>null</code> when there is no table
+ * configuration
+ */
+ private static MultiStatus canPasteAxis_verifyPasteConfiguration(final INattableModelManager tableManager, final boolean columnAxis) {
+ final IPasteConfiguration conf = (IPasteConfiguration)AxisConfigurationUtils.getIAxisConfigurationUsedInTable(tableManager.getTable(), NattableaxisconfigurationPackage.eINSTANCE.getPasteEObjectConfiguration(), columnAxis);
+ final String pluginId = Activator.PLUGIN_ID;
+ final String axisName = columnAxis ? Messages.AbstractPasteImportInNattableManager_column : Messages.AbstractPasteImportInNattableManager_row;
+ MultiStatus status = null;
+ if(conf instanceof PasteEObjectConfiguration) {
+ status = new MultiStatus(pluginId, IStatus.OK, NLS.bind(Messages.AbstractPasteImportInNattableManager_EnablementStatusForPasteInTheTable, axisName), null);
+ status.add(new Status(IStatus.OK, pluginId, NLS.bind(Messages.AbstractPasteImportInNattableManager_TheTableHasAConfigurationToPaste, axisName)));
+ if(status.isOK()) {
+ final PasteEObjectConfiguration pasteConfiguration = (PasteEObjectConfiguration)conf;
+ status.add(PasteConfigurationUtils.hasConsistentPasteEObjectConfiguration(pasteConfiguration));
+
+ //verify that the table context have the required feature
+ if(status.isOK()) {
+ final EStructuralFeature containmentFeature = pasteConfiguration.getPasteElementContainementFeature();
+ if(tableManager.getTable().getContext().eClass().getEAllStructuralFeatures().contains(containmentFeature)) {
+ status.add(new Status(IStatus.OK, pluginId, Messages.AbstractPasteImportInNattableManager_TheContextOfTheTableHasTheContainmentFeatureDefinedForThePaste));
+ } else {
+ status.add(new Status(IStatus.ERROR, pluginId, Messages.AbstractPasteImportInNattableManager_TheContextOfTheTableHasNotTheContainmentFeatureDefinedForThePaste));
+ }
+
+ //verify that the elements to create are supported by the axis manager
+ if(status.isOK()) {
+ final String elementId = pasteConfiguration.getPastedElementId();
+ if(CreatableEObjectAxisUtils.getCreatableElementIds(tableManager, columnAxis).contains(elementId)) {
+ status.add(new Status(IStatus.OK, pluginId, NLS.bind(Messages.AbstractPasteImportInNattableManager_TheTableCanCreateElement, elementId, axisName)));
+ } else {
+ status.add(new Status(IStatus.OK, pluginId, NLS.bind(Messages.AbstractPasteImportInNattableManager_TheTableCantCreateElement, elementId, axisName)));
+ }
+ }
+ }
+ }
+ }
+ return status;
+ }
+
+ /**
+ *
+ * @return
+ * a new reader
+ */
+ protected abstract Reader createReader();
+
+ /**
+ *
+ * @return
+ * the size of the copied data
+ */
+ protected abstract long getDataSize();
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/ImportAxisInNattableManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/ImportAxisInNattableManager.java
new file mode 100644
index 00000000000..aa65257b2a7
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/ImportAxisInNattableManager.java
@@ -0,0 +1,62 @@
+package org.eclipse.papyrus.infra.nattable.manager;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.Reader;
+
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.utils.CSVPasteHelper;
+
+
+public class ImportAxisInNattableManager extends AbstractPasteImportInNattableManager {
+
+ /**
+ * the file to import
+ */
+ private File file;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param tableManager
+ * @param pasteHelper
+ * @param fileToImport
+ * @param useProgressMonitorDialog
+ */
+ public ImportAxisInNattableManager(INattableModelManager tableManager, CSVPasteHelper pasteHelper, final File fileToImport, boolean useProgressMonitorDialog) {
+ super(tableManager, pasteHelper, useProgressMonitorDialog);
+ this.file = fileToImport;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.AbstractPasteImportInNattableManager#createReader()
+ *
+ * @return
+ */
+ @Override
+ protected Reader createReader() {
+ FileReader reader = null;
+ try {
+ reader = new FileReader(file);
+ } catch (FileNotFoundException e) {
+ Activator.log.error(e);
+ }
+ return reader;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.AbstractPasteImportInNattableManager#getDataSize()
+ *
+ * @return
+ */
+ @Override
+ protected long getDataSize() {
+ return this.file.length();
+ }
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/PasteAxisInNattableManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/PasteAxisInNattableManager.java
new file mode 100644
index 00000000000..1ceeb35bcbc
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/PasteAxisInNattableManager.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.manager;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.utils.CSVPasteHelper;
+
+/**
+ *
+ * This class allows to paste axis from string
+ *
+ */
+public class PasteAxisInNattableManager extends AbstractPasteImportInNattableManager {
+
+ /**
+ * the text to paste
+ */
+ private final String pastedText;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param tableManager
+ * @param pasteHelper
+ * @param useProgressMonitorDialog
+ * @param pastedText
+ */
+ public PasteAxisInNattableManager(final INattableModelManager tableManager, final CSVPasteHelper pasteHelper, final boolean useProgressMonitorDialog, final String pastedText) {
+ super(tableManager, pasteHelper, useProgressMonitorDialog);
+ this.pastedText = pastedText;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.AbstractPasteImportInNattableManager#createReader()
+ *
+ * @return
+ */
+ @Override
+ protected Reader createReader() {
+ return new StringReader(this.pastedText);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.nattable.manager.AbstractPasteImportInNattableManager#getDataSize()
+ *
+ * @return
+ */
+ @Override
+ protected long getDataSize() {
+ return this.pastedText.length();
+ }
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/PasteInTableManager.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/PasteInTableManager.java
deleted file mode 100644
index b063d60a3e8..00000000000
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/manager/PasteInTableManager.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2013 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.nattable.manager;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IPasteConfiguration;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.PasteEObjectConfiguration;
-import org.eclipse.papyrus.infra.nattable.provider.PasteEObjectAxisInTableCommandProvider;
-import org.eclipse.papyrus.infra.nattable.utils.AxisConfigurationUtils;
-import org.eclipse.papyrus.infra.nattable.utils.CreatableEObjectAxisUtils;
-import org.eclipse.papyrus.infra.nattable.utils.PasteConfigurationUtils;
-import org.eclipse.papyrus.infra.nattable.utils.PasteModeEnumeration;
-import org.eclipse.papyrus.infra.nattable.utils.TableClipboardUtils;
-
-/**
- *
- * This class manager the paste into the table
- *
- */
-public class PasteInTableManager {
-
- /**
- *
- * @param evaluationContext
- * the evaluation context
- * @param tableManager
- * the table manager
- * @return
- * the paste mode
- */
- public PasteModeEnumeration getPasteMode(final Object evaluationContext, final INattableModelManager tableManager) {
- return getPasteMode(tableManager);
- }
-
-
-
- /**
- *
- * @param tableManager
- * the table manager
- * @param pasteMode
- * the paste mode
- * @param useProgressMonitorDialog
- * if <code>true</code> we will use a progress monitor to do the paste
- */
- public void paste(final INattableModelManager tableManager, final PasteModeEnumeration pasteMode, boolean useProgressMonitorDialog) {
- switch(pasteMode) {
- case PASTE_EOBJECT_COLUMN:
- case PASTE_EOBJECT_ROW:
- case PASTE_EOBJECT_ROW_OR_COLUMN:
- PasteEObjectAxisInTableCommandProvider commandProvider = new PasteEObjectAxisInTableCommandProvider(tableManager, pasteMode);
- commandProvider.executePasteFromStringCommand(useProgressMonitorDialog);
- break;
- default:
- break;
- }
- }
-
- /**
- *
- * @param tableManager
- * the table manager
- * @return
- * a java enumeration literal indicating the way to do the paste
- */
- private static final PasteModeEnumeration getPasteMode(final INattableModelManager tableManager) {
- PasteModeEnumeration result = PasteModeEnumeration.CANT_PASTE;
- boolean canPasteColumns = canPasteAxis(tableManager, true);
- boolean canPasteRows = canPasteAxis(tableManager, false);
- if(canPasteColumns && canPasteRows) {
- result = PasteModeEnumeration.PASTE_EOBJECT_ROW_OR_COLUMN;
- } else if(canPasteColumns) {
- result = PasteModeEnumeration.PASTE_EOBJECT_COLUMN;
- } else if(canPasteRows) {
- result = PasteModeEnumeration.PASTE_EOBJECT_ROW;
- }
- return result;
- }
-
-
- /**
- *
- * @param tableManager
- * the table manager
- * @return
- * <code>true</code> if the contents of the clipboard contains the same number of columns than the table manager displays
- */
- private static boolean canPasteAxis(final INattableModelManager tableManager, boolean columnAxis) {
- final IPasteConfiguration conf = (IPasteConfiguration)AxisConfigurationUtils.getIAxisConfigurationUsedInTable(tableManager.getTable(), NattableaxisconfigurationPackage.eINSTANCE.getPasteEObjectConfiguration(), columnAxis);
- boolean result = conf instanceof PasteEObjectConfiguration;
- PasteEObjectConfiguration pasteConfiguration = (PasteEObjectConfiguration)conf;
- result = result && PasteConfigurationUtils.hasConsistentPasteEObjectConfiguration(pasteConfiguration);
-
- //verify that the table context have the required feature
- if(result) {
- final EStructuralFeature containmentFeature = pasteConfiguration.getPasteElementContainementFeature();
- result = result && tableManager.getTable().getContext().eClass().getEAllStructuralFeatures().contains(containmentFeature);
- }
- //verify that the elements to create are supported by the axis manager
- if(result) {
- final String elementId = pasteConfiguration.getPastedElementId();
- result = result && CreatableEObjectAxisUtils.getCreatableElementIds(tableManager, columnAxis).contains(elementId);
- }
- if(result) {
- final String[] axis;
- final int axisCount;
- if(columnAxis) {
- axis = TableClipboardUtils.getColumnsFromClipboard();
- axisCount = tableManager.getRowCount();
- } else {
- axis = TableClipboardUtils.getRowsFromClipboard();
- axisCount = tableManager.getColumnCount();
- }
-
- if(axis != null && axis.length > 0) {
- int nbAxis = TableClipboardUtils.getCells(axis[0]).length;
- result = axisCount == nbAxis;
- }
- }
- return result;
- }
-
-}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
index d532d8149ad..2ee63196322 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/Messages.java
@@ -31,6 +31,42 @@ public class Messages extends NLS {
public static String AbstractCreateNattableEditorHandler_PapyrusTableCreation;
+ public static String AbstractPasteImportInNattableManager_column;
+
+ public static String AbstractPasteImportInNattableManager_EnablementStatusForPasteInTheTable;
+
+ public static String AbstractPasteImportInNattableManager_INVERTED_MESSAGE;
+
+ public static String AbstractPasteImportInNattableManager_NoPasteConfiguration;
+
+ public static String AbstractPasteImportInNattableManager_NoPasteConfiguration2;
+
+ public static String AbstractPasteImportInNattableManager_NumberOfColumnsAreEquals;
+
+ public static String AbstractPasteImportInNattableManager_NumberOfColumnsAreNotEquals;
+
+ public static String AbstractPasteImportInNattableManager_PasteColumnsError;
+
+ public static String AbstractPasteImportInNattableManager_PasteRowsError;
+
+ public static String AbstractPasteImportInNattableManager_row;
+
+ public static String AbstractPasteImportInNattableManager_TheContextOfTheTableHasNotTheContainmentFeatureDefinedForThePaste;
+
+ public static String AbstractPasteImportInNattableManager_TheContextOfTheTableHasTheContainmentFeatureDefinedForThePaste;
+
+ public static String AbstractPasteImportInNattableManager_TheTableCanCreateElement;
+
+ public static String AbstractPasteImportInNattableManager_TheTableCantCreateElement;
+
+ public static String AbstractPasteImportInNattableManager_TheTableHasAConfigurationToPaste;
+
+ public static String AbstractPasteImportInNattableManager_TheUserChosesToPasteColumns;
+
+ public static String AbstractPasteImportInNattableManager_TheUserChosesToPasteRows;
+
+ public static String AbstractPasteImportInNattableManager_WhatAreYouPasting;
+
public static String AbstractSaveCurrentAxisProvidersHandler_0;
public static String AbstractSaveCurrentAxisProvidersHandler_1;
@@ -131,8 +167,38 @@ public class Messages extends NLS {
public static String TableTesterRegistry_TheClassCantBeLoaded;
+ public static String TextDelimiter_DoubleQuote;
+
+ public static String TextDelimiter_Quote;
+
public static String ICellManager_NotAvailable;
+ public static String ImportCSVConfigurationPage_SelectTheTextDelimiter;
+
+ public static String ImportCSVConfigurationPage_Separators;
+
+ public static String ImportCSVConfigurationPage_TheCellSeparatorIsNotDefined;
+
+ public static String ImportCSVConfigurationPage_TheCellSeparatorMustBeExcatlyOneChar;
+
+ public static String ImportFilePage_BeSureThatYourImportFileHasTheSameNumberOfColumns;
+
+ public static String ImportFilePage_SelectTheFileToImport;
+
+ public static String ImportFilePage_TheImportedElementWillBeAddedTo;
+
+ public static String ImportFilePage_YourFileWillBeImported;
+
+ public static String ImportTableErrorPage_PleaseOpenAPapyrusEditor;
+
+ public static String ImportTableWizard_ConfigureImport;
+
+ public static String ImportTableWizard_ImportTable;
+
+ public static String ImportTableWizard_ImportTableError;
+
+ public static String ImportTableWizard_ImportTableFromFileInPapyrusModel;
+
public static String AbstractUMLTableEFacetEditor_UMLTableCreationErrorMessage;
public static String ColumnsToShowDialog_AdditionalFeatures;
@@ -169,6 +235,20 @@ public class Messages extends NLS {
public static String LoadCurrentAxisProvidersDialog_3;
+ public static String PasteConfigurationUtils_ContainementFeatureIsNotAReference;
+
+ public static String PasteConfigurationUtils_ContainmentFeatureIsNotAReferenceContainment;
+
+ public static String PasteConfigurationUtils_ContainmentFeatureIsNull;
+
+ public static String PasteConfigurationUtils_CreatesElementsAreNotCompatibleWithContainmentFeature;
+
+ public static String PasteConfigurationUtils_ElementIdNotDefined;
+
+ public static String PasteConfigurationUtils_ElementTypeCantBeFound;
+
+ public static String PasteConfigurationUtils_PasteConfigurationIsConsistent;
+
public static String PasteEObjectAxisInTableCommandProvider_AddingElementToTheTable;
public static String PasteEObjectAxisInTableCommandProvider_CommandCreationHasBeenCancelled;
@@ -189,6 +269,10 @@ public class Messages extends NLS {
public static String PasteEObjectAxisInTableCommandProvider_PasteRows;
+ public static String PasteImportStatusDialog_ImportPasteDialogTitle;
+
+ public static String PasteImportStatusDialog_PasteConfigurationMessage;
+
public static String PasteInPapyrusTableCommandProvider_0;
public static String PasteInPapyrusTableCommandProvider_1;
@@ -224,6 +308,15 @@ public class Messages extends NLS {
public static String PasteInTableHandler_PasteCreation;
public static String PasteInTableHandler_ThePasteCommandCantBeExecuted;
+ public static String PasteSeparator_Comma;
+
+ public static String PasteSeparator_Other;
+
+ public static String PasteSeparator_Semicolon;
+
+ public static String PasteSeparator_Space;
+
+ public static String PasteSeparator_Tabulation;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
index 44cadf7b763..4c646b3cda0 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/messages/messages.properties
@@ -2,6 +2,24 @@ AbstractAxisManager_InputDialogMessage=The real name for the header is: \n\t %s
AbstractAxisManager_InputDialogTitle=Edit Header Alias Dialog
AbstractCreateNattableEditorHandler_EnterTheNameForTheNewTable=Enter the name for the new table
AbstractCreateNattableEditorHandler_PapyrusTableCreation=Papyrus Table Creation
+AbstractPasteImportInNattableManager_column=column
+AbstractPasteImportInNattableManager_EnablementStatusForPasteInTheTable=Enablement status for paste {0} in the table
+AbstractPasteImportInNattableManager_INVERTED_MESSAGE=The axis of your table are inverted. This case is not yet managed. You must have elements as rows and features as columns.
+AbstractPasteImportInNattableManager_NoPasteConfiguration=Neither of the row paste configuration and column paste configuration allows to create elements in the table\n.
+AbstractPasteImportInNattableManager_NoPasteConfiguration2=Your table has no paste configuration
+AbstractPasteImportInNattableManager_NumberOfColumnsAreEquals=The number of columns by rows is the same as the number of columns in the table
+AbstractPasteImportInNattableManager_NumberOfColumnsAreNotEquals=The number of columns by rows is not the same as the number of columns in the table.\n You are trying to paste {0} columns in a table which has {1} columns
+AbstractPasteImportInNattableManager_PasteColumnsError=\n Paste column error:\n\t
+AbstractPasteImportInNattableManager_PasteRowsError=\n Paste row error:\n\t
+AbstractPasteImportInNattableManager_row=row
+AbstractPasteImportInNattableManager_TheContextOfTheTableHasNotTheContainmentFeatureDefinedForThePaste=The context of the table doesn't have the containment feature defined for the paste
+AbstractPasteImportInNattableManager_TheContextOfTheTableHasTheContainmentFeatureDefinedForThePaste=The context of the table has the containment feature defined for the paste
+AbstractPasteImportInNattableManager_TheTableCanCreateElement=The table can create {0} as {1}
+AbstractPasteImportInNattableManager_TheTableCantCreateElement=The table can't create {0} as {1}
+AbstractPasteImportInNattableManager_TheTableHasAConfigurationToPaste=The table has a configuration to paste {0}.
+AbstractPasteImportInNattableManager_TheUserChosesToPasteColumns=The user has chosen to paste columns.
+AbstractPasteImportInNattableManager_TheUserChosesToPasteRows=The user has chosen to paste rows.
+AbstractPasteImportInNattableManager_WhatAreYouPasting=I can't find if you are pasting rows elements or columns elements.\n Press "Yes" to paste rows and "No" to paste columns.
AbstractSaveCurrentAxisProvidersHandler_0=Enter name and description
AbstractSaveCurrentAxisProvidersHandler_1=Name:
AbstractSaveCurrentAxisProvidersHandler_2=Description:
@@ -54,7 +72,22 @@ ProblemLabelProvider_StringsValuesCanBeResolved={0} string(s) values can't be re
TableLabelProvider_ErrorGettingIconForTable=Error getting icon image for tables:
TableTesterRegistry_SeveralTesterAreRegisteredWithTheSameId=Several classes are registered for the id {0}
TableTesterRegistry_TheClassCantBeLoaded=Class registrered with id {0} can't be loaded
+TextDelimiter_DoubleQuote=double quote
+TextDelimiter_Quote=quote
ICellManager_NotAvailable=N/A
+ImportCSVConfigurationPage_SelectTheTextDelimiter=Select the text delimiter used in your file.
+ImportCSVConfigurationPage_Separators=Separators
+ImportCSVConfigurationPage_TheCellSeparatorIsNotDefined=The cell separator is not defined.
+ImportCSVConfigurationPage_TheCellSeparatorMustBeExcatlyOneChar=The cell separator must be exactly 1 character.
+ImportFilePage_BeSureThatYourImportFileHasTheSameNumberOfColumns=Be sure that your imported file has the same number of columns than the current table
+ImportFilePage_SelectTheFileToImport=Select the file to import
+ImportFilePage_TheImportedElementWillBeAddedTo=The imported element will be added to:
+ImportFilePage_YourFileWillBeImported=Your import will be done in the table:
+ImportTableErrorPage_PleaseOpenAPapyrusEditor=Please open a Papyrus table editor before to do the import.
+ImportTableWizard_ConfigureImport=Configure Import
+ImportTableWizard_ImportTable=Import Table
+ImportTableWizard_ImportTableError=Import Table Error
+ImportTableWizard_ImportTableFromFileInPapyrusModel=Import Table From File In Papyrus Model
AbstractUMLTableEFacetEditor_UMLTableCreationErrorMessage=A UML Table can't be created with a non-UML element as context ({0})
ColumnsToShowDialog_AdditionalFeatures=Additional Features
ColumnsToShowDialog_AdvancedMode=Advanced Mode
@@ -73,6 +106,13 @@ LoadCurrentAxisProvidersDialog_0=Name
LoadCurrentAxisProvidersDialog_1=Description
LoadCurrentAxisProvidersDialog_2=Columns
LoadCurrentAxisProvidersDialog_3=\ (current)
+PasteConfigurationUtils_ContainementFeatureIsNotAReference=The containment feature for the pasted elements is not a reference.
+PasteConfigurationUtils_ContainmentFeatureIsNotAReferenceContainment=The containement feature is not a reference in containment.
+PasteConfigurationUtils_ContainmentFeatureIsNull=The containment feature for the pasted elements is null.
+PasteConfigurationUtils_CreatesElementsAreNotCompatibleWithContainmentFeature=The created elements ({0}) are not compatible with the containmment feature {1}.
+PasteConfigurationUtils_ElementIdNotDefined=The element id describing the kind of pasted element is not defined.
+PasteConfigurationUtils_ElementTypeCantBeFound=The element type for {0} can be found.
+PasteConfigurationUtils_PasteConfigurationIsConsistent=The paste configuration is consistent.
PasteEObjectAxisInTableCommandProvider_AddingElementToTheTable=Adding Elements To The table
PasteEObjectAxisInTableCommandProvider_CommandCreationHasBeenCancelled=Command creation has been cancelled
PasteEObjectAxisInTableCommandProvider_CreatingAnumberXonY=\ Creating {0} number {1}/{2}
@@ -83,6 +123,8 @@ PasteEObjectAxisInTableCommandProvider_PasteAction=Paste Action
PasteEObjectAxisInTableCommandProvider_PasteColumns=Paste Columns
PasteEObjectAxisInTableCommandProvider_PasteFromStringCommand=Paste from String Command
PasteEObjectAxisInTableCommandProvider_PasteRows=Paste Rows
+PasteImportStatusDialog_ImportPasteDialogTitle=Import/Paste In Table
+PasteImportStatusDialog_PasteConfigurationMessage=You can configure the Paste/Import using the Property View of the table.
PasteInPapyrusTableCommandProvider_0=The String {0} is not valid to create a {1}.
PasteInPapyrusTableCommandProvider_1=Paste Command In FlowPort Table
PasteInPapyrusTableCommandProvider_2=Create Paste Action
@@ -101,3 +143,8 @@ PasteInPapyrusTableCommandProvider_TheTextCantBeMappedOnAnExistingElement=The te
PasteInTableHandler_PasteCancelled=Paste Action Canceled
PasteInTableHandler_PasteCreation=Paste creation...
PasteInTableHandler_ThePasteCommandCantBeExecuted=The paste command can't be executed
+PasteSeparator_Comma=Comma
+PasteSeparator_Other=Other
+PasteSeparator_Semicolon=Semicolon
+PasteSeparator_Space=Space
+PasteSeparator_Tabulation=Tabulation
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CSVLexer.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CSVLexer.java
new file mode 100644
index 00000000000..77a12273808
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CSVLexer.java
@@ -0,0 +1,281 @@
+/**
+ * Copyright (c) 2014 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:
+ * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.nattable.parsers;
+
+import java.io.Reader;
+
+/**
+ * Represents a lexer for a CSV document
+ *
+ * Lexing rules are:
+ * LineEnding -> '\n' | '\r' | '\r\n'
+ * Separator -> what is given in parameter
+ * TextMarker -> what is given in parameter
+ * Whitespace -> (Unicode IsWhitespace character class) - (Separator | TextMarker | '\n' | '\r')
+ * Cell -> (. - Whitespace)*
+ * Cell -> TextMarker ( (.-TextMarker) | (TextMarker TextMarker)* ) TextMarker
+ *
+ * In these rules . represents any character and - represents the language difference operator.
+ * The last rule means that inside a quoted cell value the content can be anything except the quote character, in which case it must be doubled.
+ *
+ * @author Laurent Wouters
+ */
+public class CSVLexer {
+ /**
+ * Represents an error in this lexer
+ */
+ public static final int TOKEN_ERROR = -1;
+ /**
+ * Token type of cells' value in a CSV
+ */
+ public static final int TOKEN_VALUE = 0;
+ /**
+ * Token type of cells' separator
+ */
+ public static final int TOKEN_SEPARATOR = 1;
+ /**
+ * Token type of new line markers
+ */
+ public static final int TOKEN_NEW_ROW = 2;
+ /**
+ * Token type for the end of input marker
+ */
+ public static final int TOKEN_EOF = 3;
+
+ /**
+ * Size of the buffer used to build the tokens
+ */
+ private static final int BUFFER_SIZE = 1024;
+
+ private RewindableTextStream input; // the input stream
+ private char separator; // The cell separator character
+ private char textMarker; // The raw text beginning and end character
+ private char[] builder; // The buffer used to build the tokens
+ private int lastTokenType; // The type of the last matched token
+ private String lastTokenValue; // The value of the last matched token
+
+ /**
+ * Initializes this lexer
+ *
+ * @param input
+ * The input text reader
+ * @param valueSeparator
+ * The character that separates values in rows
+ * @param textMarker
+ * The character that marks the beginning and end of raw text
+ */
+ public CSVLexer(Reader input, char valueSeparator, char textMarker) {
+ this.input = new RewindableTextStream(input);
+ this.separator = valueSeparator;
+ this.textMarker = textMarker;
+ this.builder = new char[BUFFER_SIZE];
+ this.lastTokenType = TOKEN_ERROR;
+ this.lastTokenValue = null;
+ }
+
+ /**
+ * Gets the type of the last matched token
+ *
+ * @return The type of the last matched token
+ */
+ public int getTokenType() {
+ return lastTokenType;
+ }
+
+ /**
+ * Gets the value of the last matched token
+ *
+ * @return The value of the last matched token
+ */
+ public String getTokenValue() {
+ return lastTokenValue;
+ }
+
+ /**
+ * Gets the next token in the input
+ *
+ * @return The next token
+ */
+ public String next() {
+ // ignore all whitespaces
+ char c = input.read();
+ if (input.isAtEnd())
+ return getTokenEOF();
+ while (isWhitespace(c)) {
+ c = input.read();
+ if (input.isAtEnd())
+ return getTokenEOF();
+ }
+
+ // Here c is not whitespace and we are not at the end
+ if (c == separator)
+ return getTokenSeparator();
+ if (c == textMarker)
+ return onTextMarkerChar();
+ if (c == '\r' || c == '\n')
+ return onLineEndingChar(c);
+
+ // Here we are on normal data
+ int length = 1;
+ builder[0] = c;
+ while (true) {
+ c = input.read();
+ if (input.isAtEnd())
+ break;
+ if (c == separator || c == '\r' || c == '\n') {
+ input.rewind(1);
+ break;
+ }
+ builder[length] = c;
+ length++;
+ }
+
+ // we matched the data
+ // Now, trim the trailing white spaces
+ while (length > 0 && isWhitespace(builder[length - 1])) {
+ length--;
+ }
+
+ return getTokenValue(length);
+ }
+
+ /**
+ * Determines whether the given character is a white space that can be skipped
+ *
+ * @param c
+ * The character
+ * @return <code>true</code> if the character can be skipped
+ */
+ private boolean isWhitespace(char c) {
+ if (c == separator || c == textMarker || c == '\n' || c == '\r')
+ return false;
+ return Character.isWhitespace(c);
+ }
+
+ /**
+ * Lexes the line ending token beginning with the given character
+ *
+ * @param c
+ * The beginning character
+ * @return The matched token
+ */
+ private String onLineEndingChar(char c) {
+ if (c == '\n')
+ return getTokenNewRow();
+ // This was a '\r' character
+ // Check for windows line ending style
+ char n = input.read();
+ if (input.isAtEnd())
+ return getTokenNewRow();
+ if (n != '\n')
+ input.rewind(1);
+ return getTokenNewRow();
+ }
+
+ /**
+ * Lexes the raw text between marks
+ *
+ * @return The matched token
+ */
+ private String onTextMarkerChar() {
+ int length = 0;
+ while (true) {
+ char c = input.read();
+ if (input.isAtEnd())
+ return getTokenError();
+ if (c != textMarker) {
+ builder[length] = c;
+ length++;
+ } else {
+ // get the following char
+ c = input.read();
+ if (c == textMarker) {
+ // This is a double marker
+ builder[length] = c;
+ length++;
+ } else {
+ // This was the end of the quoted text
+ if (!input.isAtEnd())
+ input.rewind(1);
+ return getTokenValue(length);
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets an error token
+ *
+ * @return An error token
+ */
+ private String getTokenError() {
+ lastTokenType = TOKEN_ERROR;
+ lastTokenValue = null;
+ return null;
+ }
+
+ /**
+ * Gets an end of input marker token
+ *
+ * @return An end of input marker token
+ */
+ private String getTokenEOF() {
+ lastTokenType = TOKEN_EOF;
+ lastTokenValue = null;
+ return null;
+ }
+
+ /**
+ * Gets a cell separator token
+ *
+ * @return A cell separator token
+ */
+ private String getTokenSeparator() {
+ lastTokenType = TOKEN_SEPARATOR;
+ lastTokenValue = null;
+ return null;
+ }
+
+ /**
+ * Gets a new row token
+ *
+ * @return A new row token
+ */
+ private String getTokenNewRow() {
+ lastTokenType = TOKEN_NEW_ROW;
+ lastTokenValue = null;
+ return null;
+ }
+
+ /**
+ * Gets a token representing a cell's value
+ *
+ * @param length
+ * Length of the value
+ * @return A token
+ */
+ private String getTokenValue(int length) {
+ lastTokenType = TOKEN_VALUE;
+ lastTokenValue = new String(builder, 0, length);
+ return lastTokenValue;
+ }
+
+ /**
+ *
+ * @return
+ * the number of read characters
+ */
+ public long getReadCharacters() {
+ return this.input.getReadCharacters();
+ }
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CSVParser.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CSVParser.java
new file mode 100644
index 00000000000..80ac5876d9e
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CSVParser.java
@@ -0,0 +1,219 @@
+/**
+ * Copyright (c) 2014 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:
+ * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.nattable.parsers;
+
+import java.io.Reader;
+
+/**
+ * Represents a parser of CSV document
+ * This parser implements the following grammar:
+ * Document -> Row (LineEnding Row)* EOF
+ * Row -> ( Cell (Separator Cell)* )?
+ *
+ * An empty document is matched as having a single row with no cell.
+ * A line ending just before the EOF also represents an empty row.
+ *
+ * @author Laurent Wouters
+ */
+public class CSVParser {
+ private CSVLexer lexer; // the input lexer
+ private RowIterator output; // the ouput iterators
+
+ /**
+ * Initializes this parser
+ *
+ * @param input
+ * The input to parse
+ * @param valueSeparator
+ * The character that separates values in rows
+ * @param textMarker
+ * The character that marks the beginning and end of raw text
+ */
+ public CSVParser(Reader input, char valueSeparator, char textMarker) {
+ this.lexer = new CSVLexer(input, valueSeparator, textMarker);
+ this.output = new Document();
+ }
+
+ /**
+ * Parses the input and gets an iterator over the rows
+ *
+ * @return An iterator over the document's rows
+ */
+ public RowIterator parse() {
+ return output;
+ }
+
+ /**
+ *
+ * @return
+ * the number of read characters
+ */
+ public long getReadCharacters() {
+ return this.lexer.getReadCharacters();
+ }
+
+ /**
+ * Represents a row in a CSV document as an iterator over the value of its cells
+ * This class uses a small state machine to matches the tokens against the following regular expression:
+ * Row -> (Cell (Separator Cell)* )? End
+ * Cell is a cell's value token in the lexer
+ * Separator is a separator token in the lexer
+ * End can be either the Error, EOF, or Line ending tokens
+ *
+ * @author Laurent Wouters
+ */
+ private class Row extends CellIterator {
+ private static final int STATE_INIT = 0;
+ private static final int STATE_CELL = 1;
+ private static final int STATE_SEPARATOR = 2;
+ private static final int STATE_END = 3;
+
+ private String next; // value of the next cell in this row
+ private int state; // current state in the state machine
+
+ /**
+ * Initializes this row
+ */
+ public Row() {
+ state = 0;
+ findNext();
+ }
+
+ /**
+ * Executes the transitions on the initial state
+ */
+ public void onStateInit() {
+ next = lexer.next();
+ int type = lexer.getTokenType();
+ if (type == CSVLexer.TOKEN_VALUE) {
+ state = STATE_CELL;
+ } else if (type == CSVLexer.TOKEN_SEPARATOR) {
+ next = ""; //$NON-NLS-1$
+ state = STATE_SEPARATOR;
+ } else {
+ next = null;
+ state = STATE_END;
+ }
+ }
+
+ /**
+ * Executes the transitions on the OnCell state
+ */
+ private void onStateCell() {
+ next = lexer.next();
+ int type = lexer.getTokenType();
+ if (type == CSVLexer.TOKEN_SEPARATOR) {
+ onStateSeparator();
+ } else {
+ next = null;
+ state = STATE_END;
+ }
+ }
+
+ /**
+ * Executes the transitions on the OnSeparator state
+ */
+ private void onStateSeparator() {
+ next = lexer.next();
+ int type = lexer.getTokenType();
+ if (type == CSVLexer.TOKEN_VALUE) {
+ state = STATE_CELL;
+ } else if (type == CSVLexer.TOKEN_SEPARATOR) {
+ next = ""; //$NON-NLS-1$
+ state = STATE_SEPARATOR;
+ } else {
+ next = ""; //$NON-NLS-1$
+ state = STATE_END;
+ }
+ }
+
+ /**
+ * Executes the transitions on the final state
+ */
+ private void onStateEnd() {
+ next = null;
+ }
+
+ /**
+ * Executes the state machine
+ */
+ private void findNext() {
+ switch (state) {
+ case STATE_INIT:
+ onStateInit();
+ break;
+ case STATE_CELL:
+ onStateCell();
+ break;
+ case STATE_SEPARATOR:
+ onStateSeparator();
+ break;
+ default:
+ onStateEnd();
+ break;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#hasNext()
+ */
+ @Override
+ public boolean hasNext() {
+ return (next != null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#next()
+ */
+ @Override
+ public String next() {
+ String value = next;
+ findNext();
+ return value;
+ }
+ }
+
+ /**
+ * Represents a CSV document as an iterator over its rows
+ *
+ * @author Laurent Wouters
+ *
+ */
+ private class Document extends RowIterator {
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#hasNext()
+ */
+ @Override
+ public boolean hasNext() {
+ return (lexer.getTokenType() != CSVLexer.TOKEN_EOF);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#next()
+ */
+ @Override
+ public CellIterator next() {
+ return new Row();
+ }
+ }
+
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CellIterator.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CellIterator.java
new file mode 100644
index 00000000000..ac3c920c24d
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/CellIterator.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2014 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:
+ * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.nattable.parsers;
+
+import java.util.Iterator;
+
+/**
+ * Represents an iterator over cells in a single row in a CSV document
+ *
+ * @author Laurent Wouters
+ */
+public abstract class CellIterator implements Iterator<String> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/RewindableTextStream.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/RewindableTextStream.java
new file mode 100644
index 00000000000..defc90eb9fd
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/RewindableTextStream.java
@@ -0,0 +1,145 @@
+/**
+ * Copyright (c) 2014 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:
+ * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.nattable.parsers;
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * Represents a stream of characters that can be rewound
+ *
+ * @author Laurent Wouters
+ */
+public class RewindableTextStream {
+
+ private static final int BUFFER_SIZE = 1024; // Size of the buffer used to read from the input
+
+ private static final int RING_SIZE = 1024; // Size of the ring storing read characters that can be rewound
+
+ private Reader reader; // Encapsulated text reader
+
+ private char[] buffer; // First stage buffer for batch reading of the stream
+
+ private int bufferStart; // Index where the next character shall be read in the buffer
+
+ private int bufferLength; // Current length of the buffer
+
+ private boolean atEnd; // Marker of the end of input
+
+ private char[] ring; // Ring memory of this reader storing the already read characters
+
+ private int ringStart; // Start index of the ring where to read characters
+
+ private int ringNextEntry; // Index for inserting new characters in the ring
+
+ private long counter;
+
+ /**
+ * Initializes this stream
+ *
+ * @param reader
+ * The underlying text reader
+ */
+ public RewindableTextStream(Reader reader) {
+ this.reader = reader;
+ this.buffer = new char[BUFFER_SIZE];
+ this.bufferStart = 0;
+ this.bufferLength = 0;
+ this.ring = new char[RING_SIZE];
+ this.ringStart = 0;
+ this.ringNextEntry = 0;
+ this.counter = 0;
+ }
+
+ /**
+ * Determines whether the end of the input has been reached
+ *
+ * @return <code>true</code> if the end of the input has been reached
+ */
+ public boolean isAtEnd() {
+ return atEnd;
+ }
+
+ /**
+ * Goes back into the stream of the given number of characters
+ *
+ * @param count
+ * The number of characters to rewind
+ */
+ public void rewind(int count) {
+ ringStart -= count;
+ counter -= count;
+ if(ringStart < 0) {
+ ringStart += RING_SIZE;
+ }
+ }
+
+ /**
+ * Reads the next character in the stream
+ *
+ * @return The next character
+ */
+ public char read() {
+ if(atEnd) {
+ return 0;
+ }
+ counter++;
+ if(ringStart != ringNextEntry) {
+ atEnd = false;
+ char value = ring[ringStart++];
+ if(ringStart == RING_SIZE) {
+ ringStart = 0;
+ }
+ return value;
+ }
+ return readBuffer();
+ }
+
+ /**
+ * Reads the next character from the input
+ *
+ * @return The next character in the stream
+ */
+ private char readBuffer() {
+ if(bufferStart == bufferLength) {
+ bufferLength = -1;
+ try {
+ bufferLength = reader.read(buffer, 0, BUFFER_SIZE);
+ } catch (IOException e) {
+ //nothing to report
+ }
+ bufferStart = 0;
+ if(bufferLength <= 0) {
+ atEnd = true;
+ return 0;
+ }
+ }
+ atEnd = false;
+ char c = buffer[bufferStart++];
+ ring[ringNextEntry++] = c;
+ if(ringNextEntry == RING_SIZE) {
+ ringNextEntry = 0;
+ }
+ ringStart = ringNextEntry;
+ return c;
+ }
+
+ /**
+ *
+ * @return
+ * the number of read characters
+ */
+ public long getReadCharacters() {
+ return this.counter;
+ }
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/RowIterator.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/RowIterator.java
new file mode 100644
index 00000000000..13f4e24c591
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/parsers/RowIterator.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2014 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:
+ * Laurent Wouters laurent.wouters@cea.fr - Initial API and implementation
+ *
+ */
+package org.eclipse.papyrus.infra.nattable.parsers;
+
+import java.util.Iterator;
+
+/**
+ * Represents an iterator over rows in a CSV document
+ *
+ * @author Laurent Wouters
+ */
+public abstract class RowIterator implements Iterator<CellIterator> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/paste/PasteSeparator.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/paste/PasteSeparator.java
new file mode 100644
index 00000000000..ccae0c0bbae
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/paste/PasteSeparator.java
@@ -0,0 +1,101 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.paste;
+
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+
+
+/**
+ *
+ * Enumeration for cell delimiters in CSV files
+ *
+ */
+public enum PasteSeparator {
+ /**
+ * tabulation value
+ */
+ TABULATION('\t', Messages.PasteSeparator_Tabulation),
+
+ /**
+ * semicolon value
+ */
+ SEMICOLON(';', Messages.PasteSeparator_Semicolon),
+
+ /**
+ * Comma value
+ */
+ COMMA(',', Messages.PasteSeparator_Comma),
+ /**
+ * space value
+ */
+ SPACE(' ', Messages.PasteSeparator_Space),
+
+ /**
+ * other value
+ */
+ OTHER(Messages.PasteSeparator_Other);
+
+ /**
+ * the separator itself
+ */
+ private final char separator;
+
+ /**
+ * the name of the separator
+ */
+ private final String name;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param name
+ */
+ private PasteSeparator(final String name) {
+ this(Character.MIN_VALUE, name);//MIN_VALUE is a value as other one!
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param separator
+ * @param name
+ */
+ private PasteSeparator(char separator, String name) {
+ this.separator = separator;
+ this.name = name;
+ }
+
+ /**
+ *
+ * @return
+ * the separator to use
+ */
+ public char getSeparator() {
+ if(this == OTHER) {
+ throw new UnsupportedOperationException();
+ }
+ return separator;
+ }
+
+ /**
+ *
+ * @return
+ * the name of the separator
+ */
+ public String getName() {
+ return name;
+ }
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/paste/TextDelimiter.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/paste/TextDelimiter.java
new file mode 100644
index 00000000000..f284171fbc0
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/paste/TextDelimiter.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.paste;
+
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+
+/**
+ *
+ * Enumeration for text delimiters
+ *
+ */
+public enum TextDelimiter {
+
+ /**
+ * the single quote
+ */
+ SINGLE_QUOTE('\'', Messages.TextDelimiter_Quote),
+
+ /**
+ * the double quote
+ */
+ DOUBLE_QUOTE('"', Messages.TextDelimiter_DoubleQuote);
+
+ /**
+ * the delimiter itself
+ */
+ private final char delimiter;
+
+ /**
+ * the name of the delimiter
+ */
+ private final String name;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param delimiter
+ * @param name
+ */
+ private TextDelimiter(char delimiter, String name) {
+ this.delimiter = delimiter;
+ this.name = name;
+ }
+
+ /**
+ *
+ * @return
+ * the separator to use
+ */
+ public char getDelimiter() {
+ return delimiter;
+ }
+
+ /**
+ *
+ * @return
+ * the name of the separator
+ */
+ public String getName() {
+ return name;
+ }
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java
new file mode 100644
index 00000000000..6dc82b8469e
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInNattableCommandProvider.java
@@ -0,0 +1,840 @@
+package org.eclipse.papyrus.infra.nattable.provider;
+
+/*****************************************************************************
+ * Copyright (c) 2013 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
+ *
+ *****************************************************************************/
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.commands.CheckedOperationHistory;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.manager.cell.CellManagerFactory;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.model.nattable.NattablePackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.NattableaxisconfigurationPackage;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.PasteEObjectConfiguration;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattablecell.Cell;
+import org.eclipse.papyrus.infra.nattable.parsers.CSVParser;
+import org.eclipse.papyrus.infra.nattable.parsers.CellIterator;
+import org.eclipse.papyrus.infra.nattable.parsers.RowIterator;
+import org.eclipse.papyrus.infra.nattable.paste.IValueSetter;
+import org.eclipse.papyrus.infra.nattable.paste.PastePostActionRegistry;
+import org.eclipse.papyrus.infra.nattable.utils.AxisConfigurationUtils;
+import org.eclipse.papyrus.infra.nattable.utils.CSVPasteHelper;
+import org.eclipse.papyrus.infra.nattable.utils.Constants;
+import org.eclipse.papyrus.infra.nattable.utils.TableEditingDomainUtils;
+import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
+import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.tools.converter.AbstractStringValueConverter;
+
+/**
+ * Paste command manager for the paste in the table
+ *
+ * @author VL222926
+ *
+ */
+
+public class PasteEObjectAxisInNattableCommandProvider {
+
+ private static final int MIN_AXIS_FOR_PROGRESS_MONITOR = 5;
+
+ /**
+ * the containment feature to use
+ */
+ private EStructuralFeature containmentFeature;
+
+ /**
+ * the type to create
+ */
+ private IElementType typeToCreate;
+
+ /**
+ * the table manager
+ */
+ private INattableModelManager tableManager;
+
+ /**
+ * the paste mode
+ */
+ // private PasteEnablementStatus pasteMode;
+
+ /**
+ * if true, we are pasting in detached mode
+ */
+ private boolean detachedMode;
+
+ /**
+ * the list of the post actions do do
+ */
+ private List<String> postActions;
+
+ /**
+ * the list of the axis to paste
+ */
+ // private final String[] axisToPaste;
+
+ /**
+ * the paste helper
+ */
+ private final CSVPasteHelper pasteHelper;
+
+ /**
+ * the converter map
+ */
+ private Map<Class<? extends AbstractStringValueConverter>, AbstractStringValueConverter> existingConverters;
+
+ private static final String PASTE_ACTION_TASK_NAME = Messages.PasteEObjectAxisInTableCommandProvider_PasteAction;
+
+ private static final String PASTE_ROWS_JOB_NAME = Messages.PasteEObjectAxisInTableCommandProvider_PasteRows;
+
+ private static final String PASTE_COLUMNS_JOB_NAME = Messages.PasteEObjectAxisInTableCommandProvider_PasteColumns;
+
+ private static final String PASTE_COMMAND_HAS_BEEN_CANCELLED = Messages.PasteEObjectAxisInTableCommandProvider_CommandCreationHasBeenCancelled;
+
+ private static final String PASTE_COMMAND_CANT_BE_EXECUTED = "The Paste command can't be executed"; //$NON-NLS-1$
+
+ private static final String PASTE_COMMAND_NAME = Messages.PasteEObjectAxisInTableCommandProvider_PasteFromStringCommand;
+
+ private static final String CREATING_ELEMENT_A_NUMBER_X_Y = Messages.PasteEObjectAxisInTableCommandProvider_CreatingAnumberXonY;
+
+ protected final boolean pasteColumn;
+
+ private final int nbOperationsToDo;
+
+
+ //we refresh the dialog each X read char
+ private int refreshEachReadChar = 1000;
+
+ /**
+ * if <code>true</code> the command can't be created and executed
+ */
+ private boolean isDisposed = false;
+
+ /**
+ * the reader to parse
+ */
+ private final Reader reader;
+
+ /**
+ * the parser to use
+ */
+ private CSVParser parser;
+
+ int factor;
+
+ private Table table;
+
+ final TransactionalEditingDomain tableEditingDomain;
+
+ final TransactionalEditingDomain contextEditingDomain;
+
+ final EObject tableContext;
+
+ List<Object> secondAxis;
+
+ public PasteEObjectAxisInNattableCommandProvider(INattableModelManager tableManager, boolean pasteColumn, Reader reader, CSVPasteHelper pasteHelper2, long totalSize) {
+ this.tableManager = tableManager;
+ // this.pasteMode = status;
+ this.existingConverters = new HashMap<Class<? extends AbstractStringValueConverter>, AbstractStringValueConverter>();
+ this.pasteHelper = pasteHelper2;
+ this.reader = reader;
+ this.pasteColumn = pasteColumn;
+ this.table = tableManager.getTable();
+ this.tableContext = table.getContext();
+ tableEditingDomain = TableEditingDomainUtils.getTableEditingDomain(table);
+ contextEditingDomain = TableEditingDomainUtils.getTableContextEditingDomain(table);
+ //TODO improve refresh and progress monitor...
+ long div = -1;
+ if(totalSize > Integer.MAX_VALUE) {
+ div = totalSize / Integer.MAX_VALUE;
+ if(div > Integer.MAX_VALUE) {
+ div = 2 * div;
+ }
+ this.factor = (int)div;
+ this.nbOperationsToDo = (int)(totalSize / div);
+ } else {
+ this.factor = 1;
+ this.nbOperationsToDo = (int)totalSize;
+ }
+ parser = this.pasteHelper.createParser(reader);
+ init();
+ }
+
+ /**
+ * inits the field of this class
+ */
+ private void init() {
+ PasteEObjectConfiguration configuration = null;
+ if(this.pasteColumn) {
+ configuration = (PasteEObjectConfiguration)AxisConfigurationUtils.getIAxisConfigurationUsedInTable(this.table, NattableaxisconfigurationPackage.eINSTANCE.getPasteEObjectConfiguration(), true);
+ this.secondAxis = tableManager.getRowElementsList();
+ } else {
+
+ configuration = (PasteEObjectConfiguration)AxisConfigurationUtils.getIAxisConfigurationUsedInTable(this.table, NattableaxisconfigurationPackage.eINSTANCE.getPasteEObjectConfiguration(), false);
+ this.secondAxis = tableManager.getColumnElementsList();
+ }
+ if(configuration != null) {
+ this.containmentFeature = configuration.getPasteElementContainementFeature();
+ this.typeToCreate = ElementTypeRegistry.getInstance().getType(configuration.getPastedElementId());
+ this.postActions = configuration.getPostActions();
+ this.detachedMode = configuration.isDetachedMode();
+ }
+ }
+
+ /**
+ *
+ * @param useProgressMonitor
+ * boolean indicating that we must do the paste with a progress monitor
+ * TODO : post actions are not yet supported in the in the detached mode
+ */
+ public void executePasteFromStringCommand(final boolean useProgressMonitor) {
+ if(this.pasteColumn) {//not yet supported
+ return;
+ }
+ if(this.isDisposed) {
+ throw new RuntimeException("The command provider is disposed");
+ }
+ final String pasteJobName;
+ if(this.pasteColumn) {
+ pasteJobName = PASTE_COLUMNS_JOB_NAME;
+ } else {
+ pasteJobName = PASTE_ROWS_JOB_NAME;
+ }
+ if(this.detachedMode) {
+ executePasteFromStringCommandInDetachedMode(useProgressMonitor, pasteJobName);
+ } else {
+ executePasteFromStringCommandInAttachedMode(useProgressMonitor, pasteJobName);
+ }
+ }
+
+
+ /**
+ *
+ * @param useProgressMonitor
+ * boolean indicating that we must do the paste with a progress monitor
+ */
+ private void executePasteFromStringCommandInDetachedMode(final boolean useProgressMonitor, final String pasteJobName) {
+ //the map used to share objects between the paste action and the cell value managers
+ final Map<Object, Object> sharedMap = new HashMap<Object, Object>();
+ //the map used to store useful information for the paste
+ sharedMap.put(Constants.PASTED_ELEMENT_CONTAINER_KEY, tableContext);
+ sharedMap.put(Constants.REFERENCES_TO_SET_KEY, new ArrayList<IValueSetter>());
+ sharedMap.put(Constants.CELLS_TO_ADD_KEY, new ArrayList<Cell>());
+
+ if(!useProgressMonitor) {
+ final ICommand pasteCommand = getPasteFromStringCommandInDetachedMode(contextEditingDomain, tableEditingDomain, new NullProgressMonitor(), sharedMap);
+ try {
+ CheckedOperationHistory.getInstance().execute(pasteCommand, new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ Activator.log.error(e);
+ }
+ sharedMap.clear();
+ } else {
+ //we create a job in order to don't freeze the UI
+ final Job job = new Job(pasteJobName) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ final ICommand pasteCommand = getPasteFromStringCommandInDetachedMode(contextEditingDomain, tableEditingDomain, monitor, sharedMap);
+ if(pasteCommand == null) {
+ return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, PASTE_COMMAND_HAS_BEEN_CANCELLED);
+ }
+ //we execute the paste command
+ if(pasteCommand.canExecute()) {
+ try {
+ CheckedOperationHistory.getInstance().execute(pasteCommand, monitor, null);
+ } catch (ExecutionException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "An exception occured during the paste", e); //$NON-NLS-1$
+ } finally {
+ sharedMap.clear();
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ } else {
+ sharedMap.clear();
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, PASTE_COMMAND_CANT_BE_EXECUTED);
+ }
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ }
+ }
+
+ /**
+ *
+ * @param useProgressMonitor
+ * boolean indicating that we must do the paste with a progress monitor
+ */
+ private void executePasteFromStringCommandInAttachedMode(final boolean useProgressMonitor, final String pasteJobName) {
+ if(!useProgressMonitor) {
+ final ICommand pasteCommand = getPasteFromStringCommandInAttachedMode(contextEditingDomain, tableEditingDomain, new NullProgressMonitor());
+ try {
+ CheckedOperationHistory.getInstance().execute(pasteCommand, new NullProgressMonitor(), null);
+ } catch (ExecutionException e) {
+ Activator.log.error(e);
+ }
+ } else {
+ //we create a job in order to don't freeze the UI
+ final Job job = new Job(pasteJobName) {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ final ICommand pasteCommand = getPasteFromStringCommandInAttachedMode(contextEditingDomain, tableEditingDomain, monitor);
+ if(pasteCommand == null) {
+ return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, PASTE_COMMAND_HAS_BEEN_CANCELLED);
+ }
+ //we execute the paste command
+ if(pasteCommand.canExecute()) {
+ try {
+ CheckedOperationHistory.getInstance().execute(pasteCommand, monitor, null);
+ } catch (ExecutionException e) {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "An exception occured during the paste", e); //$NON-NLS-1$
+ }
+ monitor.done();
+ return Status.OK_STATUS;
+ } else {
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, PASTE_COMMAND_CANT_BE_EXECUTED);
+ }
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ }
+ }
+
+ private ICommand getPasteRowFromStringCommandInDetachedMode(final TransactionalEditingDomain contextEditingDomain, final TransactionalEditingDomain tableEditingDomain, final IProgressMonitor progressMonitor, final Map<Object, Object> sharedMap) {
+ if(progressMonitor != null) {
+ progressMonitor.beginTask(PASTE_ACTION_TASK_NAME, this.nbOperationsToDo);//+1 to add the created elements to the table
+ }
+ //the list of the created elements
+ final List<Object> createdElements = new ArrayList<Object>();
+
+ //2.2 create the creation request and find the command provider
+ final EClass eClassToCreate = this.typeToCreate.getEClass();
+ final EFactory eFactory = eClassToCreate.getEPackage().getEFactoryInstance();
+
+ //2.3 create the axis
+ int nbCreatedElements = 0;
+
+ //we refresh the dialog each X read char
+ long readChar = 0;
+ long previousreadChar = 0;
+ final RowIterator rowIter = this.parser.parse();
+ while(rowIter.hasNext()) {
+ final CellIterator cellIter = rowIter.next();
+ if(!cellIter.hasNext()) {
+ continue;//to avoid blank line
+ }
+ if((progressMonitor != null) && progressMonitor.isCanceled()) {
+ //the user click on the cancel button
+ return null;
+ }
+
+ readChar = readChar + (parser.getReadCharacters() - previousreadChar);
+ previousreadChar = parser.getReadCharacters();
+
+
+ if(progressMonitor != null && readChar > refreshEachReadChar) {
+ readChar = 0;
+ progressMonitor.subTask(NLS.bind("{0} {1} have been created.", new Object[]{ nbCreatedElements, typeToCreate.getEClass().getName() }));
+ progressMonitor.worked(refreshEachReadChar);
+ }
+ nbCreatedElements++;
+
+ //2.3.3 we create the element itself
+ final EObject createdElement = eFactory.create(eClassToCreate);
+
+ createdElements.add(createdElement);
+ nbCreatedElements++;
+ for(final String currentPostActions : this.postActions) {
+ PastePostActionRegistry.INSTANCE.doPostAction(this.tableManager, currentPostActions, tableContext, createdElement, sharedMap, null);//TODO : remove this parameter
+ }
+
+ //2.3.4 we set these properties values
+ final Iterator<Object> secondAxisIterator = secondAxis.iterator();
+ while(secondAxisIterator.hasNext() && cellIter.hasNext()) {
+ final Object currentAxis = secondAxisIterator.next();
+ final String valueAsString = cellIter.next();
+ final Object columnObject;
+ final Object rowObject;
+ if(this.pasteColumn) {
+ columnObject = createdElement;
+ rowObject = currentAxis;
+ } else {
+ columnObject = currentAxis;
+ rowObject = createdElement;
+ }
+
+
+ boolean isEditable = CellManagerFactory.INSTANCE.isCellEditable(columnObject, rowObject, sharedMap);
+ if(isEditable) {
+ final AbstractStringValueConverter converter = CellManagerFactory.INSTANCE.getOrCreateStringValueConverterClass(columnObject, rowObject, tableManager, existingConverters, this.pasteHelper.getMultiValueSeparator());
+ CellManagerFactory.INSTANCE.setStringValue(columnObject, rowObject, valueAsString, converter, tableManager, sharedMap);
+ }
+ }
+
+ //TODO : do something to say that the number of cell is not correct!
+ while(cellIter.hasNext()) {
+ cellIter.next();//required!
+ }
+ }
+
+ //2.4 we add the created elements to the table
+ final AbstractTransactionalCommand pasteCommand = new AbstractTransactionalCommand(tableEditingDomain, PASTE_COMMAND_NAME, null) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ //initialize lists
+ final Collection<String> postActions = getPostActions();
+ @SuppressWarnings("unchecked")
+ final List<Cell> cells = (List<Cell>)sharedMap.get(Constants.CELLS_TO_ADD_KEY);
+ @SuppressWarnings("unchecked")
+ final List<IValueSetter> valueToSet = (List<IValueSetter>)sharedMap.get(Constants.REFERENCES_TO_SET_KEY);
+
+ int nbTasks = 1; //to add created elements to the model
+ nbTasks = nbTasks + 1; //to add createds elements to the table
+ nbTasks = nbTasks + postActions.size();//to do post actions after the attachment to the model
+ nbTasks = nbTasks + 1; //to attach the cells to the model
+ nbTasks = nbTasks + valueToSet.size(); //to set the references values
+
+ if(progressMonitor != null) {
+ if(progressMonitor.isCanceled()) {
+ localDispose();
+ return CommandResult.newCancelledCommandResult();
+ }
+ progressMonitor.beginTask(Messages.PasteEObjectAxisInTableCommandProvider_FinishingThePaste, nbTasks);
+ }
+
+ //1. Add the elements to the context
+ AddCommand.create(contextEditingDomain, tableContext, containmentFeature, createdElements).execute();
+
+ if(progressMonitor != null) {
+ if(progressMonitor.isCanceled()) {
+ return CommandResult.newCancelledCommandResult();
+ }
+ progressMonitor.worked(1);
+ progressMonitor.subTask(Messages.PasteEObjectAxisInTableCommandProvider_AddingElementToTheTable);
+ }
+
+ Command cmd = null;
+ if(pasteColumn) {
+ cmd = tableManager.getAddColumnElementCommand(createdElements); //TODO remove one of these 2 lines
+ } else {
+ cmd = tableManager.getAddRowElementCommand(createdElements);
+ }
+ if(cmd != null) {//could be null
+ cmd.execute();
+ }
+
+ if(progressMonitor != null) {
+ if(progressMonitor.isCanceled()) {
+ return CommandResult.newCancelledCommandResult();
+ }
+ progressMonitor.worked(1);
+ progressMonitor.subTask(Messages.PasteEObjectAxisInTableCommandProvider_DoingAdditionalActions);
+ }
+
+
+ for(final String currentPostActions : postActions) {
+ PastePostActionRegistry.INSTANCE.concludePostAction(tableManager, currentPostActions, sharedMap);
+ progressMonitor.worked(1);
+ }
+
+
+ if(progressMonitor != null) {
+ if(progressMonitor.isCanceled()) {
+ return CommandResult.newCancelledCommandResult();
+ }
+ progressMonitor.worked(1);
+ progressMonitor.subTask(Messages.PasteEObjectAxisInTableCommandProvider_LinkingReferencesToTheModel);
+ }
+
+ //we set the references
+
+ if(valueToSet.size() > 0) {
+ for(final IValueSetter current : valueToSet) {
+ current.doSetValue(contextEditingDomain);
+ if(progressMonitor != null) {
+ if(progressMonitor.isCanceled()) {
+ return CommandResult.newCancelledCommandResult();
+ }
+ progressMonitor.worked(1);
+ }
+ }
+ }
+
+ //the cells must be attached at the end (in order to update properly the cell map in the table manager
+ if(progressMonitor != null) {
+ if(progressMonitor.isCanceled()) {
+ return CommandResult.newCancelledCommandResult();
+ }
+ progressMonitor.worked(1);
+ }
+
+ //add the created cells to the table
+ AddCommand.create(tableEditingDomain, table, NattablePackage.eINSTANCE.getTable_Cells(), cells).execute();
+
+ if(progressMonitor != null) {
+ progressMonitor.done();
+ }
+ localDispose();
+ return CommandResult.newOKCommandResult();
+ }
+ };
+
+ return pasteCommand;
+ }
+
+
+ /**
+ *
+ *
+ * @param sharedMap
+ * a map used to share objects and informations during the paste between this class and the cell value manager
+ * @param commandCreationCancelProvider
+ * the creation command progress monitor
+ * @param commandExecutionProgressMonitor
+ * the command execution progress monitor
+ * @return
+ * the command to use to finish the paste (the main part of the paste is directly done here)
+ */
+ private ICommand getPasteFromStringCommandInDetachedMode(final TransactionalEditingDomain contextEditingDomain, final TransactionalEditingDomain tableEditingDomain, final IProgressMonitor progressMonitor, final Map<Object, Object> sharedMap) {
+ if(!this.pasteColumn) {
+ return getPasteRowFromStringCommandInDetachedMode(contextEditingDomain, tableEditingDomain, progressMonitor, sharedMap);
+ } else {
+ // return getPasteColumnFromStringCommandInDetachedMode(contextEditingDomain, tableEditingDomain, progressMonitor, sharedMap);
+ }
+ return null;
+ }
+
+
+
+ /**
+ *
+ * @param commandCreationCancelProvider
+ * the creation command progress monitor
+ * @param commandExecutionProgressMonitor
+ * the command execution progress monitor
+ * @return
+ */
+ private ICommand getPasteColumnFromStringInAttachedModeCommand(final TransactionalEditingDomain contextEditingDomain, final TransactionalEditingDomain tableEditingDomain, final IProgressMonitor progressMonitor) {
+ //initialize the progress monitor
+ if(progressMonitor != null) {
+ progressMonitor.beginTask(PASTE_ACTION_TASK_NAME, this.nbOperationsToDo);
+ }
+
+ //2.2 create the creation request and find the command provider
+ final CreateElementRequest createRequest = new CreateElementRequest(contextEditingDomain, this.tableContext, this.typeToCreate, (EReference)this.containmentFeature);
+ final IElementEditService tableContextCommandProvider = ElementEditServiceUtils.getCommandProvider(tableContext);
+
+ final ICommand pasteAllCommand = new AbstractTransactionalCommand(contextEditingDomain, PASTE_COMMAND_NAME, null) {
+
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param monitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ long readChar = 0;
+ long previousreadChar = 0;
+
+ final RowIterator rowIter = parser.parse();
+ int nbCreatedElements = 0;
+ while(rowIter.hasNext()) {
+ final CellIterator cellIter = rowIter.next();
+ if(!cellIter.hasNext()) {
+ continue;//to avoid blank line
+ }
+ if(progressMonitor != null && progressMonitor.isCanceled()) {
+ progressMonitor.done();
+ localDispose();
+ return CommandResult.newCancelledCommandResult();
+ }
+ readChar = readChar + (parser.getReadCharacters() - previousreadChar);
+ previousreadChar = parser.getReadCharacters();
+ if(progressMonitor != null && readChar > refreshEachReadChar) {
+ readChar = 0;
+ progressMonitor.subTask(NLS.bind("{0} {1} have been created.", new Object[]{ typeToCreate.getEClass().getName(), nbCreatedElements }));
+ progressMonitor.worked(refreshEachReadChar);
+ }
+ nbCreatedElements++;
+ final ICommand commandCreation = tableContextCommandProvider.getEditCommand(createRequest);
+ if(commandCreation.canExecute()) {
+ //1. we create the element
+ commandCreation.execute(monitor, info);
+ //we execute the creation command
+
+ //2. we add it to the table
+ final CommandResult res = commandCreation.getCommandResult();
+ commandCreation.dispose();
+
+ final Object createdElement = (EObject)res.getReturnValue();
+ final Command addCommand;
+ if(pasteColumn) {
+ addCommand = tableManager.getAddColumnElementCommand(Collections.singleton(createdElement));
+ } else {
+ addCommand = tableManager.getAddRowElementCommand(Collections.singleton(createdElement));
+ }
+ if(addCommand != null) {//can be null
+ addCommand.execute();
+ addCommand.dispose();
+ }
+
+ //3. we set the values
+ final Iterator<?> secondAxisIterator = secondAxis.iterator();
+ while(secondAxisIterator.hasNext() && cellIter.hasNext()) {
+ final Object currentAxis = secondAxisIterator.next();
+ final String valueAsString = cellIter.next();
+ final Object columnObject;
+ final Object rowObject;
+ if(pasteColumn) {
+ columnObject = createdElement;
+ rowObject = currentAxis;
+ } else {
+ columnObject = currentAxis;
+ rowObject = createdElement;
+ }
+
+
+ boolean isEditable = CellManagerFactory.INSTANCE.isCellEditable(columnObject, rowObject);
+
+ if(isEditable) {
+ final AbstractStringValueConverter converter = CellManagerFactory.INSTANCE.getOrCreateStringValueConverterClass(columnObject, rowObject, tableManager, existingConverters, pasteHelper.getMultiValueSeparator());
+ final Command setValueCommand = CellManagerFactory.INSTANCE.getSetStringValueCommand(contextEditingDomain, columnObject, rowObject, valueAsString, converter, tableManager);
+ if(setValueCommand != null && setValueCommand.canExecute()) {
+ setValueCommand.execute();
+ setValueCommand.dispose();
+ }
+ }
+ }
+ //TODO inform the user
+ while(cellIter.hasNext()) {
+ cellIter.next();//required
+ }
+ }
+ }
+ progressMonitor.done();
+ localDispose();
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ return pasteAllCommand;
+ }
+
+
+ /**
+ *
+ * @param commandCreationCancelProvider
+ * the creation command progress monitor
+ * @param commandExecutionProgressMonitor
+ * the command execution progress monitor
+ * @return
+ */
+ private ICommand getPasteRowFromStringInAttachedModeCommand(final TransactionalEditingDomain contextEditingDomain, final TransactionalEditingDomain tableEditingDomain, final IProgressMonitor progressMonitor) {
+ //initialize the progress monitor
+ if(progressMonitor != null) {
+ progressMonitor.beginTask(PASTE_ACTION_TASK_NAME, this.nbOperationsToDo);
+ }
+
+ //2.2 create the creation request and find the command provider
+ final CreateElementRequest createRequest = new CreateElementRequest(contextEditingDomain, this.tableContext, this.typeToCreate, (EReference)this.containmentFeature);
+ final IElementEditService tableContextCommandProvider = ElementEditServiceUtils.getCommandProvider(tableContext);
+
+ final ICommand pasteAllCommand = new AbstractTransactionalCommand(contextEditingDomain, PASTE_COMMAND_NAME, null) {
+
+
+ /**
+ *
+ * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
+ * org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param monitor
+ * @param info
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ long readChar = 0;
+ long previousreadChar = 0;
+
+ final RowIterator rowIter = parser.parse();
+ int nbCreatedElements = 0;
+ while(rowIter.hasNext()) {
+ final CellIterator cellIter = rowIter.next();
+ if(!cellIter.hasNext()) {
+ continue;//to avoid blank line
+ }
+ if(progressMonitor != null && progressMonitor.isCanceled()) {
+ progressMonitor.done();
+ localDispose();
+ return CommandResult.newCancelledCommandResult();
+ }
+ readChar = readChar + (parser.getReadCharacters() - previousreadChar);
+ previousreadChar = parser.getReadCharacters();
+ if(progressMonitor != null && readChar > refreshEachReadChar) {
+ readChar = 0;
+ progressMonitor.subTask(NLS.bind("{0} {1} have been created.", new Object[]{ typeToCreate.getEClass().getName(), nbCreatedElements }));
+ progressMonitor.worked(refreshEachReadChar);
+ }
+ nbCreatedElements++;
+ final ICommand commandCreation = tableContextCommandProvider.getEditCommand(createRequest);
+ if(commandCreation.canExecute()) {
+ //1. we create the element
+ commandCreation.execute(monitor, info);
+ //we execute the creation command
+
+ //2. we add it to the table
+ final CommandResult res = commandCreation.getCommandResult();
+ commandCreation.dispose();
+
+ final Object createdElement = (EObject)res.getReturnValue();
+ final Command addCommand;
+ if(pasteColumn) {
+ addCommand = tableManager.getAddColumnElementCommand(Collections.singleton(createdElement));
+ } else {
+ addCommand = tableManager.getAddRowElementCommand(Collections.singleton(createdElement));
+ }
+ if(addCommand != null) {//can be null
+ addCommand.execute();
+ addCommand.dispose();
+ }
+
+ //3. we set the values
+ final Iterator<?> secondAxisIterator = secondAxis.iterator();
+ while(secondAxisIterator.hasNext() && cellIter.hasNext()) {
+ final Object currentAxis = secondAxisIterator.next();
+ final String valueAsString = cellIter.next();
+ final Object columnObject;
+ final Object rowObject;
+ if(pasteColumn) {
+ columnObject = createdElement;
+ rowObject = currentAxis;
+ } else {
+ columnObject = currentAxis;
+ rowObject = createdElement;
+ }
+
+
+ boolean isEditable = CellManagerFactory.INSTANCE.isCellEditable(columnObject, rowObject);
+
+ if(isEditable) {
+ final AbstractStringValueConverter converter = CellManagerFactory.INSTANCE.getOrCreateStringValueConverterClass(columnObject, rowObject, tableManager, existingConverters, pasteHelper.getMultiValueSeparator());
+ final Command setValueCommand = CellManagerFactory.INSTANCE.getSetStringValueCommand(contextEditingDomain, columnObject, rowObject, valueAsString, converter, tableManager);
+ if(setValueCommand != null && setValueCommand.canExecute()) {
+ setValueCommand.execute();
+ setValueCommand.dispose();
+ }
+ }
+ }
+ //TODO inform the user
+ while(cellIter.hasNext()) {
+ cellIter.next();//required
+ }
+ }
+ }
+ progressMonitor.done();
+ localDispose();
+ return CommandResult.newOKCommandResult();
+ }
+ };
+ return pasteAllCommand;
+ }
+
+ /**
+ *
+ * @param commandCreationCancelProvider
+ * the creation command progress monitor
+ * @param commandExecutionProgressMonitor
+ * the command execution progress monitor
+ * @return
+ */
+ private ICommand getPasteFromStringCommandInAttachedMode(final TransactionalEditingDomain contextEditingDomain, final TransactionalEditingDomain tableEditingDomain, final IProgressMonitor progressMonitor) {
+ if(this.pasteColumn) {
+ // return getPasteCFromStringInAttachedModeCommand(contextEditingDomain, tableEditingDomain, progressMonitor);
+ } else {
+ return getPasteRowFromStringInAttachedModeCommand(contextEditingDomain, tableEditingDomain, progressMonitor);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @return
+ * the list of the post actions to do
+ */
+ private Collection<String> getPostActions() {
+ return this.postActions;
+ }
+
+ /**
+ * dispose fields of the class
+ */
+ private void localDispose() {
+ this.isDisposed = true;
+ this.tableManager = null;
+ this.typeToCreate = null;
+ this.containmentFeature = null;
+ for(final AbstractStringValueConverter current : existingConverters.values()) {
+ current.dispose();
+ }
+ this.existingConverters.clear();
+ try {
+ this.reader.close();
+ } catch (IOException e) {
+ Activator.log.error(e);
+ }
+ }
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java
index 1b0f206265f..468704320ed 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/provider/PasteEObjectAxisInTableCommandProvider.java
@@ -72,7 +72,7 @@ import org.eclipse.papyrus.infra.tools.converter.AbstractStringValueConverter;
* @author VL222926
*
*/
-
+//use PasteEObjectAxisInNattableCommandProvider, will be removed when the new paste api will allows to paste columns
public class PasteEObjectAxisInTableCommandProvider {
private static final int MIN_AXIS_FOR_PROGRESS_MONITOR = 5;
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CSVPasteHelper.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CSVPasteHelper.java
new file mode 100644
index 00000000000..94c18dc8408
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CSVPasteHelper.java
@@ -0,0 +1,97 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.utils;
+
+import java.io.Reader;
+
+import org.eclipse.papyrus.infra.nattable.parsers.CSVParser;
+import org.eclipse.papyrus.infra.nattable.paste.PasteSeparator;
+import org.eclipse.papyrus.infra.nattable.paste.TextDelimiter;
+
+/**
+ *
+ * This class provides utils method to split a string to do a paste in the table
+ *
+ */
+public class CSVPasteHelper {
+
+ /**
+ * the default separator used for columns
+ */
+ public static final char DEFAULT_CLIPBOARD_COLUMN_SEPARATOR = PasteSeparator.TABULATION.getSeparator();
+
+ /**
+ * the default separator used for multivalue
+ */
+ public static final String DEFAULT_MULTI_VALUE_SEPARATOR = ","; //$NON-NLS-1$
+
+ public static final char DEFAULT_TEXT_MARKER = TextDelimiter.DOUBLE_QUOTE.getDelimiter();
+
+ private final char textMarker;
+
+ private final char cellSeparator;
+
+ private final String multiValueSeparator;
+
+
+ /**
+ *
+ * Constructor.
+ * The default constructor initialize the class with {@value #DEFAULT_CLIPBOARD_COLUMN_SEPARATOR}, {@value #DEFAULT_TEXT_MARKER},
+ * {@value #DEFAULT_MULTI_VALUE_SEPARATOR}
+ */
+ public CSVPasteHelper() {
+ this(DEFAULT_CLIPBOARD_COLUMN_SEPARATOR, DEFAULT_TEXT_MARKER, DEFAULT_MULTI_VALUE_SEPARATOR);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param cellSeparator
+ * the column separator to use
+ * @param textMarked
+ * the row separator to use
+ * @param textMarker
+ * the multi value separator to use
+ */
+ public CSVPasteHelper(final char cellSeparator, final char textMarker, final String multiValueSeparator) {
+ this.cellSeparator = cellSeparator;
+ this.textMarker = textMarker;
+ this.multiValueSeparator = multiValueSeparator;
+ }
+
+ /**
+ *
+ * @param reader
+ * a reader
+ * @return
+ * create a parser from the reader
+ */
+ public CSVParser createParser(final Reader reader) {
+ return new CSVParser(reader, this.cellSeparator, textMarker);
+ }
+
+
+ /**
+ *
+ * @return
+ * the separator used for multivalue
+ */
+ public String getMultiValueSeparator() {
+ return multiValueSeparator;
+ }
+
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CellHelper.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CellHelper.java
index 92f4533e536..0e94f8de916 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CellHelper.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/CellHelper.java
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.utils;
import java.util.Collections;
@@ -39,14 +52,20 @@ public class CellHelper {
}
/**
- * Create the string problems if required
+ * Create the string problems if required.
*
* @param tableManager
+ * the table manager
* @param columnElement
+ * the column element
* @param rowElement
+ * the row element
* @param pastedText
+ * the pasted text
* @param valueContainer
+ * the value container
* @param sharedMap
+ * the shared map
*/
public static final void createStringResolutionProblem(final INattableModelManager tableManager, final Object columnElement, final Object rowElement, final String pastedText, final ConvertedValueContainer<?> valueContainer, final Map<?, ?> sharedMap) {
final IStatus status = valueContainer.getStatus();
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtils.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtils.java
index bbd3d6aeae1..1b7a086cf0f 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtils.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteConfigurationUtils.java
@@ -13,11 +13,17 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.nattable.utils;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.PasteEObjectConfiguration;
@@ -39,26 +45,38 @@ public class PasteConfigurationUtils {
* @param pasteConfiguration
* a paste configuration
* @return
- * <code>true</code> if the paste configuration is consistent
+ * a status describing the consistence of the paste configuration
*/
- public static boolean hasConsistentPasteEObjectConfiguration(final PasteEObjectConfiguration pasteConfiguration) {
- boolean result = false;
- if(pasteConfiguration != null) {
- final EStructuralFeature feature = pasteConfiguration.getPasteElementContainementFeature();
- if(feature instanceof EReference) {
- final String elementId = pasteConfiguration.getPastedElementId();
- if(elementId != null && !elementId.equals("")) { //$NON-NLS-1$
- final IElementType elementType = ElementTypeRegistry.getInstance().getType(elementId);
- if(elementType != null) {
- final EClass elementTypeMetaclass = elementType.getEClass();
- final EClass containmentFeatureEClass = (EClass)feature.getEType();
- result = elementTypeMetaclass == containmentFeatureEClass || containmentFeatureEClass.isSuperTypeOf(elementTypeMetaclass);
+ public static IStatus hasConsistentPasteEObjectConfiguration(final PasteEObjectConfiguration pasteConfiguration) {
+ Assert.isNotNull(pasteConfiguration);
+ final String pluginId = Activator.PLUGIN_ID;
+ final EStructuralFeature feature = pasteConfiguration.getPasteElementContainementFeature();
+ if(feature == null) {
+ return new Status(IStatus.ERROR, pluginId, Messages.PasteConfigurationUtils_ContainmentFeatureIsNull);
+ } else if(feature instanceof EReference) {
+ if(!((EReference)feature).isContainment()) {
+ return new Status(IStatus.ERROR, pluginId, Messages.PasteConfigurationUtils_ContainmentFeatureIsNotAReferenceContainment);
+ }
+ final String elementId = pasteConfiguration.getPastedElementId();
+ if(elementId != null && !elementId.equals("")) { //$NON-NLS-1$
+ final IElementType elementType = ElementTypeRegistry.getInstance().getType(elementId);
+ if(elementType != null) {
+ final EClass elementTypeMetaclass = elementType.getEClass();
+ final EClass containmentFeatureEClass = (EClass)feature.getEType();
+ boolean knownFeature = elementTypeMetaclass == containmentFeatureEClass || containmentFeatureEClass.isSuperTypeOf(elementTypeMetaclass);
+ if(knownFeature) {
+ return new Status(IStatus.OK, pluginId, Messages.PasteConfigurationUtils_PasteConfigurationIsConsistent);
+ } else {
+ return new Status(IStatus.ERROR, pluginId, NLS.bind(Messages.PasteConfigurationUtils_CreatesElementsAreNotCompatibleWithContainmentFeature, elementId, containmentFeatureEClass.getName()));
}
+ } else {
+ return new Status(IStatus.ERROR, pluginId, NLS.bind(Messages.PasteConfigurationUtils_ElementTypeCantBeFound, elementId));
}
+ } else {
+ return new Status(IStatus.ERROR, pluginId, Messages.PasteConfigurationUtils_ElementIdNotDefined);
}
+ } else {
+ return new Status(IStatus.ERROR, pluginId, Messages.PasteConfigurationUtils_ContainementFeatureIsNotAReference);
}
- return result;
}
-
-
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteEnablementStatus.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteEnablementStatus.java
new file mode 100644
index 00000000000..e3cd487c2cd
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteEnablementStatus.java
@@ -0,0 +1,98 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.utils;
+
+import org.eclipse.core.runtime.MultiStatus;
+
+/**
+ *
+ * This class is used to store the tests about the paste capability of the table
+ *
+ */
+public class PasteEnablementStatus {
+
+ /**
+ * the result of the tests to paste rows in the table
+ */
+ private MultiStatus rowStatus;
+
+ /**
+ * the result of the test to paste columns in the table
+ */
+ private MultiStatus columnStatus;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param columnStatus
+ * the paste column status
+ * @param rowStatus
+ * the paste row status
+ */
+ public PasteEnablementStatus(final MultiStatus columnStatus, final MultiStatus rowStatus) {
+ this.rowStatus = rowStatus;
+ this.columnStatus = columnStatus;
+ }
+
+ /**
+ *
+ * @return
+ * the paste mode according to the row and column status
+ */
+ public PasteModeEnumeration getPasteMode() {
+ if(this.rowStatus == null && this.columnStatus == null) {
+ return PasteModeEnumeration.PASTE_NO_CONFIGURATION;
+ }
+ if(this.rowStatus != null && this.columnStatus != null) {
+ if(this.columnStatus.isOK() && this.rowStatus.isOK()) {
+ return PasteModeEnumeration.PASTE_EOBJECT_ROW_OR_COLUMN;
+ }
+ if(this.columnStatus.isOK() && !this.rowStatus.isOK()) {
+ return PasteModeEnumeration.PASTE_EOBJECT_COLUMN;
+ }
+ if(!this.columnStatus.isOK() && this.rowStatus.isOK()) {
+ return PasteModeEnumeration.PASTE_EOBJECT_ROW;
+ }
+ }
+ if(this.rowStatus != null && this.rowStatus.isOK() && this.columnStatus == null) {
+ return PasteModeEnumeration.PASTE_EOBJECT_ROW;
+ }
+ if(this.columnStatus != null && this.rowStatus == null && this.columnStatus.isOK()) {
+ return PasteModeEnumeration.PASTE_EOBJECT_COLUMN;
+ }
+ return PasteModeEnumeration.CANT_PASTE;
+ }
+
+ /**
+ *
+ * @return
+ * the column status
+ */
+ public MultiStatus getColumnStatus() {
+ return this.columnStatus;
+ }
+
+ /**
+ *
+ * @return
+ * the row status
+ */
+ public MultiStatus getRowStatus() {
+ return this.rowStatus;
+ }
+
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelper.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelper.java
new file mode 100644
index 00000000000..7b817be03e4
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteHelper.java
@@ -0,0 +1,154 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.utils;
+
+/**
+ *
+ * This class provides utils method to split a string to do a paste in the table
+ *
+ */
+public class PasteHelper {
+
+ /**
+ * the default separator used for row
+ */
+ public static final String DEFAULT_ROW_SEPARATOR = "\n"; //$NON-NLS-1"
+
+ /**
+ * the default separator used for columns
+ */
+ public static final String DEFAULT_COLUMN_SEPARATOR = "\t";//$NON-NLS-1"
+
+ /**
+ * the default separator used for multivalue
+ */
+ public static final String DEFAULT_MULTI_VALUE_SEPARATOR = ","; //$NON-NLS-1$
+
+
+ private final String rowSeparator;
+
+ private final String columnSeparator;
+
+ private final String multiValueSeparator;
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public PasteHelper() {
+ this(DEFAULT_COLUMN_SEPARATOR, DEFAULT_ROW_SEPARATOR, DEFAULT_MULTI_VALUE_SEPARATOR);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param columnSeparator
+ * the column separator to use
+ * @param rowSeparator
+ * the row separator to use
+ * @param multiValueSeparator
+ * the multi value separator to use
+ */
+ public PasteHelper(final String columnSeparator, final String rowSeparator, final String multiValueSeparator) {
+ this.columnSeparator = columnSeparator;
+ this.rowSeparator = rowSeparator;
+ this.multiValueSeparator = multiValueSeparator;
+ }
+
+ /**
+ *
+ * @param axisAsString
+ * an full axis represented by a String
+ *
+ *
+ * @return
+ * the cells using the specified cell separator
+ */
+
+ public String[] getCellsAsStringFromAxis(final String axisAsString) {
+ return axisAsString.split(this.columnSeparator);
+ }
+
+ /**
+ *
+ * @param fullContents
+ * the string to split
+ *
+ * @return
+ * the rows
+ */
+ public final String[] getRows(final String fullContents) {
+ final String[] rows = fullContents.split(this.rowSeparator);
+ return rows;
+ }
+
+ /**
+ *
+ * @param fullContents
+ * @param rowSeparator
+ * @param columnSeparator
+ * @return
+ * an array of the pasted columns
+ */
+ //TODO refactor me the paste in column should be the same as the paste in row!
+ public final String[] getColumns(final String fullContents) {
+ final String[] rows = fullContents.split(rowSeparator);
+ if(rows.length > 0) {
+ int nbColumn = rows[0].split(columnSeparator).length;
+ String[] columns = new String[nbColumn];
+ for(int columnIndex = 0; columnIndex < nbColumn; columnIndex++) {
+ columns[columnIndex] = "";
+ }
+
+ for(int rowIndex = 0; rowIndex < rows.length; rowIndex++) {
+ String row = rows[rowIndex];
+ String[] currentColumns = row.split(columnSeparator);
+ for(int columnIndex = 0; columnIndex < nbColumn; columnIndex++) {
+ if(currentColumns.length != 0) {
+ columns[columnIndex] += currentColumns[columnIndex];
+ } else {
+ columns[columnIndex] += ""; //$NON-NLS-1$
+ }
+ if(rowIndex < rows.length + 1) {
+ columns[columnIndex] += columnSeparator;
+ } else {
+ columns[columnIndex] += rowSeparator;
+ }
+ }
+ }
+ return columns;
+
+ }
+ return null;
+ }
+
+
+ public String getRowSeparator() {
+ return rowSeparator;
+ }
+
+
+ public String getColumnSeparator() {
+ return columnSeparator;
+ }
+
+
+ public String getMultiValueSeparator() {
+ return multiValueSeparator;
+ }
+
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteModeEnumeration.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteModeEnumeration.java
index 9e125d6f200..0de03bab0e8 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteModeEnumeration.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/PasteModeEnumeration.java
@@ -34,10 +34,13 @@ public enum PasteModeEnumeration {
*/
PASTE_EOBJECT_ROW_OR_COLUMN,
/**
- * paste is not possible
+ * configuration exist but the configuration is not valid
*/
- CANT_PASTE;
-
+ CANT_PASTE,
+ /**
+ * the table have any configuration for paste
+ */
+ PASTE_NO_CONFIGURATION;
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java
index ab07cdb6f56..9405967efa9 100644
--- a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/utils/TableClipboardUtils.java
@@ -33,16 +33,22 @@ public class TableClipboardUtils {
/**
* row separator in the clipboard contents
*/
+ @Deprecated
+ //use the value defined in PasteHelpers
public static final String AXIS_SEPARATOR = "\n"; //$NON-NLS-1$
/**
* column separator in the clipboard contents
*/
+ @Deprecated
+ //use the value defined into PasteHelper
public static final String CELL_SEPARATOR = "\t"; //$NON-NLS-1$
/**
* the separator used for multivalue
*/
+ @Deprecated
+ //use the value defined into PasteHelper
public static final String MULTI_VALUE_SEPARATOR = ","; //$NON-NLS-1$
private TableClipboardUtils() {
@@ -55,6 +61,8 @@ public class TableClipboardUtils {
* a table represented by a String
* @return the rows for this table
*/
+ @Deprecated
+ //use PasteHelper
public static final String[] getRows(final String fullContents) {
final String[] rows = fullContents.split(AXIS_SEPARATOR);
return rows;
@@ -65,6 +73,8 @@ public class TableClipboardUtils {
* @return
* the rows as string extractzed from the clipboad
*/
+ @Deprecated
+ //use PasteHelper
public static final String[] getRowsFromClipboard() {
final String clipboardContent = getClipboardContents();
if(clipboardContent != null && !clipboardContent.isEmpty()) {
@@ -78,6 +88,8 @@ public class TableClipboardUtils {
* @return
* the columns as string extractzed from the clipboad
*/
+ @Deprecated
+ //use PasteHelper
public static final String[] getColumnsFromClipboard() {
final String clipboardContent = getClipboardContents();
if(clipboardContent != null && !clipboardContent.isEmpty()) {
@@ -123,10 +135,21 @@ public class TableClipboardUtils {
/**
*
+ * @return
+ * the contents of the clipboard
+ */
+ public static final String getClipboardContentsAsString() {
+ return getClipboardContents();
+ }
+
+ /**
+ *
* @param row
* a row represented by a String
* @return the cells for this row
*/
+ @Deprecated
+ //Use PasteHelpers#getCellsAsStringFromAxis
public static final String[] getCells(final String row) {
return row.split(CELL_SEPARATOR);
}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ImportTableWizard.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ImportTableWizard.java
new file mode 100644
index 00000000000..d84a8e4a7b1
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/ImportTableWizard.java
@@ -0,0 +1,142 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.wizard;
+
+import java.io.File;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.manager.ImportAxisInNattableManager;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.paste.PasteSeparator;
+import org.eclipse.papyrus.infra.nattable.paste.TextDelimiter;
+import org.eclipse.papyrus.infra.nattable.utils.CSVPasteHelper;
+import org.eclipse.papyrus.infra.nattable.wizard.pages.ImportCSVConfigurationPage;
+import org.eclipse.papyrus.infra.nattable.wizard.pages.ImportFilePage;
+import org.eclipse.papyrus.infra.nattable.wizard.pages.ImportInvertedTableErrorPage;
+import org.eclipse.papyrus.infra.nattable.wizard.pages.ImportTableErrorPage;
+import org.eclipse.papyrus.infra.widgets.util.FileUtil;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ *
+ * This wizard allows to import a table in the Papyrus nattable editor
+ *
+ */
+public class ImportTableWizard extends Wizard implements IImportWizard {
+
+ /**
+ * the import page
+ */
+ private ImportFilePage importPage;
+
+ /**
+ * the page used to configure the CSV import
+ */
+ private ImportCSVConfigurationPage csvConfigurationPage;
+
+ /**
+ * the nattable model manager to use for the import
+ */
+ private INattableModelManager manager;
+
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public ImportTableWizard() {
+ setWindowTitle(Messages.ImportTableWizard_ImportTableFromFileInPapyrusModel);
+ String pluginId = Activator.PLUGIN_ID;
+ String path = "icons/importTablePapyrusWizban.png"; //$NON-NLS-1$
+ ImageDescriptor desc = org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImageDescriptor(pluginId, path);
+ setDefaultPageImageDescriptor(desc);
+ }
+
+ /**
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ *
+ * @param workbench
+ * @param selection
+ */
+ @Override
+ public void init(final IWorkbench workbench, final IStructuredSelection selection) {
+ this.manager = getNattableModelManager(workbench, selection);
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ *
+ */
+ @Override
+ public void addPages() {
+ final String pageTitle = Messages.ImportTableWizard_ImportTable;
+ final ImageDescriptor desc = null;
+ if(manager != null) {
+ if(manager.getTable().isInvertAxis()) {
+ addPage(new ImportInvertedTableErrorPage(Messages.ImportTableWizard_ImportTableError, pageTitle, desc));
+ } else {
+ this.importPage = new ImportFilePage(pageTitle, pageTitle, desc, this.manager);
+ addPage(this.importPage);
+ this.csvConfigurationPage = new ImportCSVConfigurationPage(pageTitle, Messages.ImportTableWizard_ConfigureImport, desc, PasteSeparator.SEMICOLON, TextDelimiter.DOUBLE_QUOTE);
+ addPage(this.csvConfigurationPage);
+ }
+ } else {
+ addPage(new ImportTableErrorPage(Messages.ImportTableWizard_ImportTableError, pageTitle, desc));
+ }
+ }
+
+
+ /**
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ *
+ * @return
+ */
+ @Override
+ public boolean performFinish() {
+ //the import file
+ final File file = FileUtil.getFile(this.importPage.getFilePath());
+ final CSVPasteHelper pasteHelper = new CSVPasteHelper(this.csvConfigurationPage.getSeparator(), this.csvConfigurationPage.getTextDelimiter(), ","); //$NON-NLS-1$
+ final ImportAxisInNattableManager pasteManager = new ImportAxisInNattableManager(this.manager, pasteHelper, file, true);
+ return pasteManager.doPaste();
+ }
+
+ /**
+ *
+ * @param workbench
+ * the current workbench
+ * @param selection
+ * the current selection
+ * @return
+ * the nattable manager to use to do the import
+ */
+ private INattableModelManager getNattableModelManager(final IWorkbench workbench, final IStructuredSelection selection) {
+ final IEditorPart editorPart = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editorPart != null) {
+ return (INattableModelManager)editorPart.getAdapter(INattableModelManager.class);
+ }
+ return null;
+ }
+
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportCSVConfigurationPage.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportCSVConfigurationPage.java
new file mode 100644
index 00000000000..67edaefecd7
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportCSVConfigurationPage.java
@@ -0,0 +1,218 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.wizard.pages;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.nattable.paste.PasteSeparator;
+import org.eclipse.papyrus.infra.nattable.paste.TextDelimiter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+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.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * The page to configure the separator used in the CSV file
+ *
+ * @author VL222926
+ *
+ */
+public class ImportCSVConfigurationPage extends WizardPage {
+
+ /**
+ * the paste separator
+ */
+ private PasteSeparator separator;
+
+ /**
+ * the text delimiter
+ */
+ private TextDelimiter textDelimiter;
+
+ /**
+ * the specific seaprator
+ */
+ private char[] textChar = null;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param pageName
+ * the name of the import page
+ * @param title
+ * the title of the page
+ * @param titleImage
+ * the image for this page
+ * @param tableManager
+ * the table manager where the import will be done
+ */
+ public ImportCSVConfigurationPage(final String pageName, final String title, final ImageDescriptor titleImage, final PasteSeparator defaultSeparator, final TextDelimiter defaultDelimiter) {
+ super(pageName, title, titleImage);
+ setDescription(Messages.ImportFilePage_SelectTheFileToImport);
+ this.separator = defaultSeparator;
+ this.textDelimiter = defaultDelimiter;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ */
+ @Override
+ public void createControl(final Composite parent1) {
+ final Composite pageComposite = new Composite(parent1, SWT.NONE);
+ setControl(pageComposite);
+ pageComposite.setLayout(new GridLayout(2, true));
+ final Group separatorGroup = new Group(pageComposite, SWT.NONE);
+ separatorGroup.setText(Messages.ImportCSVConfigurationPage_Separators);
+ separatorGroup.setLayout(new GridLayout(2, false));
+
+ for(final PasteSeparator current : PasteSeparator.values()) {
+ final Button button = new Button(separatorGroup, SWT.RADIO);
+ button.setText(current.getName());
+ button.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if(button.isEnabled()) {
+ separator = current;
+ }
+ setPageComplete(validate());
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //nothing to do
+ }
+ });
+ button.setSelection(current == separator);
+ final GridData data = new GridData();
+ if(current == PasteSeparator.OTHER) {
+ final Text text = new Text(separatorGroup, SWT.BORDER);
+ text.addKeyListener(new org.eclipse.swt.events.KeyListener() {
+
+ @Override
+ public void keyReleased(KeyEvent e) {
+ textChar = text.getTextChars();
+ setPageComplete(validate());
+ }
+
+ @Override
+ public void keyPressed(KeyEvent e) {
+ //nothing to do
+ }
+ });
+ button.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ text.setEnabled(button.getSelection());
+ setPageComplete(validate());
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ text.setEnabled(this.separator == PasteSeparator.OTHER);
+ } else {
+ data.horizontalSpan = 2;
+ }
+ button.setLayoutData(data);
+ }
+
+ final Composite textDelimiterComp = new Composite(pageComposite, SWT.NONE);
+ textDelimiterComp.setLayout(new GridLayout(2, false));
+ textDelimiterComp.setLayoutData(new GridData());
+ final Label label2 = new Label(textDelimiterComp, SWT.NONE);
+ label2.setText(Messages.ImportCSVConfigurationPage_SelectTheTextDelimiter);
+ final Combo combo = new Combo(textDelimiterComp, SWT.DROP_DOWN | SWT.READ_ONLY);
+
+ for(int i = 0; i < TextDelimiter.values().length; i++) {
+ final TextDelimiter current = TextDelimiter.values()[i];
+ combo.add(String.valueOf(current.getDelimiter()), i);
+ if(this.textDelimiter == current) {
+ combo.select(i);
+ }
+ }
+ combo.addSelectionListener(new SelectionListener() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ textDelimiter = TextDelimiter.values()[combo.getSelectionIndex()];
+ setPageComplete(validate());
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ //nothing to do
+ }
+ });
+
+ setPageComplete(validate());
+ }
+
+ /**
+ *
+ * @return
+ */
+ private boolean validate() {
+ if(this.separator == PasteSeparator.OTHER) {
+ if(this.textChar == null || this.textChar.length == 0) {
+ setErrorMessage(Messages.ImportCSVConfigurationPage_TheCellSeparatorIsNotDefined);
+ return false;
+ } else if(this.textChar.length > 1) {
+ setErrorMessage(Messages.ImportCSVConfigurationPage_TheCellSeparatorMustBeExcatlyOneChar);
+ return false;
+ }
+ }
+ setErrorMessage(null);
+ return true;
+ }
+
+ /**
+ *
+ * @return
+ * the selected separator
+ */
+ public char getSeparator() {
+ if(this.separator == PasteSeparator.OTHER) {
+ return textChar[0];
+ }
+ return this.separator.getSeparator();
+ }
+
+ /**
+ *
+ * @return
+ * the selected text delimiter
+ */
+ public char getTextDelimiter() {
+ return this.textDelimiter.getDelimiter();
+ }
+
+
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportFilePage.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportFilePage.java
new file mode 100644
index 00000000000..a4fe02f4c67
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportFilePage.java
@@ -0,0 +1,184 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.wizard.pages;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.nattable.Activator;
+import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
+import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
+import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
+import org.eclipse.papyrus.infra.widgets.editors.StringFileSelector;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ *
+ * Import page
+ *
+ */
+public class ImportFilePage extends WizardPage {
+
+ /**
+ * allowed file to import table
+ */
+ private static final String[] allowedFiles = new String[]{ "*.csv" }; //$NON-NLS-1$
+
+ /**
+ * the selected file path
+ */
+ private String selectedFilePath;
+
+ /**
+ * the table manager where the import will be done
+ */
+ private final INattableModelManager tableManager;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param pageName
+ * the name of the import page
+ * @param title
+ * the title of the page
+ * @param titleImage
+ * the image for this page
+ * @param tableManager
+ * the table manager where the import will be done
+ */
+ public ImportFilePage(final String pageName, final String title, final ImageDescriptor titleImage, final INattableModelManager tableManager) {
+ super(pageName, title, titleImage);
+ setDescription(Messages.ImportFilePage_SelectTheFileToImport);
+ this.tableManager = tableManager;
+ this.selectedFilePath = null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ *
+ * @param parent
+ */
+ @Override
+ public void createControl(final Composite parent) {
+ final Composite localComposite = new Composite(parent, SWT.NONE);
+ setControl(localComposite);
+ final ILabelProvider labelProvider = getLabelProvider();
+ Composite localParent = new Composite(localComposite, SWT.NONE);
+ final Label label = new Label(localParent, SWT.NONE);
+ label.setText(Messages.ImportFilePage_YourFileWillBeImported);
+ final CLabel cLabel = new CLabel(localParent, SWT.NONE);
+ cLabel.setText(tableManager.getTableName());
+
+ final Label label2 = new Label(localParent, SWT.NONE);
+ label2.setText(Messages.ImportFilePage_TheImportedElementWillBeAddedTo);
+ final CLabel cLabel2 = new CLabel(localParent, SWT.NONE);
+ cLabel2.setText(labelProvider.getText(tableManager.getTable().getContext()));
+ cLabel2.setImage(labelProvider.getImage(tableManager.getTable().getContext()));
+
+
+ cLabel.setImage(labelProvider.getImage(this.tableManager.getTable()));
+
+ localParent.setLayout(new GridLayout(2, true));
+ final StringFileSelector selector = new StringFileSelector(localComposite, SWT.NONE);
+ selector.setAllowFileSystem(true);
+ selector.setAllowWorkspace(true);
+ selector.setFilterExtensions(allowedFiles);
+
+ localComposite.setLayout(new GridLayout(1, true));
+ selector.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ selector.getText().setEditable(false);
+ selector.addCommitListener(new ICommitListener() {
+
+ @Override
+ public void commit(final AbstractEditor editor) {
+ final Object value = selector.getValue();
+ if(value instanceof String && ((String)value).length() > 0) {
+ setFilePath((String)value);
+ setPageComplete(isPageComplete());
+ }
+ }
+ });
+
+ final CLabel warningLabel = new CLabel(localComposite, SWT.NONE);
+ warningLabel.setText(Messages.ImportFilePage_BeSureThatYourImportFileHasTheSameNumberOfColumns);
+ warningLabel.setImage(org.eclipse.papyrus.infra.widgets.Activator.getDefault().getImage(Activator.PLUGIN_ID, "/icons/warning.gif")); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @return
+ * the label provider to use or <code>null</code> if not found
+ */
+ protected ILabelProvider getLabelProvider() {
+ LabelProviderService labelService = null;
+ try {
+ labelService = ServiceUtilsForEObject.getInstance().getService(LabelProviderService.class, tableManager.getTable());
+
+ } catch (ServiceException e) {
+ Activator.log.error("Label Provider Service Not Found", e); //$NON-NLS-1$
+ }
+ if(labelService != null) {
+ return labelService.getLabelProvider();
+ }
+ return null;
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
+ *
+ * @return
+ */
+ @Override
+ public boolean isPageComplete() {
+ return getFilePath() != null;
+ }
+
+
+ /**
+ *
+ * @return
+ * the selected file
+ */
+ public String getFilePath() {
+ return this.selectedFilePath;
+ }
+
+ /**
+ *
+ * @param filePath
+ * find the file from the filePath and set it
+ */
+ protected void setFilePath(final String filePath) {
+ if(filePath == null || filePath.length() == 0) {
+ this.selectedFilePath = null;
+ } else {
+ this.selectedFilePath = filePath;
+ }
+
+ }
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportInvertedTableErrorPage.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportInvertedTableErrorPage.java
new file mode 100644
index 00000000000..94b5c759cf3
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportInvertedTableErrorPage.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.wizard.pages;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ *
+ * @author VL222926
+ *
+ */
+public class ImportInvertedTableErrorPage extends WizardPage {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param pageName
+ * the page name
+ * @param title
+ * the title of the page
+ * @param titleImage
+ * the image of the page
+ */
+ public ImportInvertedTableErrorPage(final String pageName, final String title, final ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ /**
+ * Create contents of the wizard.
+ *
+ * @param parent
+ */
+ public void createControl(final Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText("Inverted Table are not yet managed"); //$NON-NLS-1$
+ setControl(label);
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
+ *
+ * @return
+ */
+ @Override
+ public boolean isPageComplete() {
+ return false;
+ }
+
+}
diff --git a/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportTableErrorPage.java b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportTableErrorPage.java
new file mode 100644
index 00000000000..ca968688449
--- /dev/null
+++ b/extraplugins/table/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/wizard/pages/ImportTableErrorPage.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2014 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.nattable.wizard.pages;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.papyrus.infra.nattable.messages.Messages;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ *
+ * @author VL222926
+ *
+ */
+public class ImportTableErrorPage extends WizardPage {
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param pageName
+ * the page name
+ * @param title
+ * the title of the page
+ * @param titleImage
+ * the image of the page
+ */
+ public ImportTableErrorPage(final String pageName, final String title, final ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ /**
+ * Create contents of the wizard.
+ *
+ * @param parent
+ */
+ public void createControl(final Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(Messages.ImportTableErrorPage_PleaseOpenAPapyrusEditor);
+ setControl(label);
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
+ *
+ * @return
+ */
+ @Override
+ public boolean isPageComplete() {
+ return super.isPageComplete();
+ }
+
+}

Back to the top