summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Le Menez2014-07-21 10:51:45 (EDT)
committerCamille Letavernier2014-07-21 11:27:27 (EDT)
commit835c776ad5a8acb5ac7f2eaac1e749df349f33e8 (patch)
tree7ec8763f3f7aa469379737fbfdc5325ae6f9a8fe
parent6ae9febed4a2832ad8efc6c48e8eed38501aef1a (diff)
downloadorg.eclipse.papyrus-835c776ad5a8acb5ac7f2eaac1e749df349f33e8.zip
org.eclipse.papyrus-835c776ad5a8acb5ac7f2eaac1e749df349f33e8.tar.gz
org.eclipse.papyrus-835c776ad5a8acb5ac7f2eaac1e749df349f33e8.tar.bz2
Bug 43988 [Table] Papyrus must provide hierarchical tablesrefs/changes/93/30193/2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=439888 - created the custom editor and modified the plugin.xml - amended the tests Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/custom-src/org/eclipse/papyrus/infra/nattable/model/editor/customeditors/CustomNattablestyleEditor.java80
-rw-r--r--plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/plugin.xml4
-rwxr-xr-xtests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/resources/My.nattablestyle2
-rw-r--r--tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/src/org/eclipse/papyrus/infra/nattable/model/editor/tests/tests/EditorsTests.java7
4 files changed, 91 insertions, 2 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/custom-src/org/eclipse/papyrus/infra/nattable/model/editor/customeditors/CustomNattablestyleEditor.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/custom-src/org/eclipse/papyrus/infra/nattable/model/editor/customeditors/CustomNattablestyleEditor.java
new file mode 100755
index 0000000..31a250a
--- /dev/null
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/custom-src/org/eclipse/papyrus/infra/nattable/model/editor/customeditors/CustomNattablestyleEditor.java
@@ -0,0 +1,80 @@
+package org.eclipse.papyrus.infra.nattable.model.editor.customeditors;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.papyrus.infra.nattable.model.nattable.nattableproblem.presentation.NattableproblemEditor;
+import org.eclipse.papyrus.infra.nattable.model.nattable.presentation.NattableEditorPlugin;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+
+public class CustomNattablestyleEditor extends NattableproblemEditor {
+
+ /**
+ * This is for implementing {@link IEditorPart} and simply saves the model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ *
+ * @generated NOT
+ */
+ @Override
+ public void doSave(IProgressMonitor progressMonitor) {
+ // Save only resources that have actually changed.
+ //
+ final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+ saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
+ saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED);
+ saveOptions.put(XMIResource.OPTION_SAVE_TYPE_INFORMATION, true);
+ // Do the work within an operation because this is a long running activity that modifies the workbench.
+ //
+ WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
+
+ // This is the method that gets invoked when the operation runs.
+ //
+ @Override
+ public void execute(IProgressMonitor monitor) {
+ // Save the resources to the file system.
+ //
+ boolean first = true;
+ for(Resource resource : getEditingDomain().getResourceSet().getResources()) {
+ if((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !getEditingDomain().isReadOnly(resource)) {
+ try {
+ long timeStamp = resource.getTimeStamp();
+ resource.save(saveOptions);
+ if(resource.getTimeStamp() != timeStamp) {
+ savedResources.add(resource);
+ }
+ } catch (Exception exception) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ first = false;
+ }
+ }
+ }
+ };
+
+ this.updateProblemIndication = false;
+ try {
+ // This runs the options, and shows progress.
+ //
+ new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
+
+ // Refresh the necessary state.
+ //
+ ((BasicCommandStack)this.editingDomain.getCommandStack()).saveIsDone();
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ } catch (Exception exception) {
+ // Something went wrong that shouldn't.
+ //
+ NattableEditorPlugin.INSTANCE.log(exception);
+ }
+ this.updateProblemIndication = true;
+ updateProblemIndication();
+ }
+}
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/plugin.xml b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/plugin.xml
index 5785a1d..266f1b8 100644
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/plugin.xml
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor/plugin.xml
@@ -33,13 +33,13 @@
</extension>
<extension point="org.eclipse.ui.editors">
- <!-- @generated nattable -->
+ <!-- @generated NOT nattable -->
<editor
id="org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.presentation.NattablestyleEditorID"
name="%_UI_NattablestyleEditor_label"
icon="icons/full/obj16/NattablestyleModelFile.gif"
extensions="nattablestyle"
- class="org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.presentation.NattablestyleEditor"
+ class="org.eclipse.papyrus.infra.nattable.model.editor.customeditors.CustomNattablestyleEditor"
contributorClass="org.eclipse.papyrus.infra.nattable.model.nattable.nattablestyle.presentation.NattablestyleActionBarContributor">
</editor>
</extension>
diff --git a/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/resources/My.nattablestyle b/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/resources/My.nattablestyle
new file mode 100755
index 0000000..d56d7bb
--- /dev/null
+++ b/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/resources/My.nattablestyle
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nattablestyle:CellTextStyle xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:nattablestyle="http://www.eclipse.org/papyrus/nattable/model/table/nattablestyle"/>
diff --git a/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/src/org/eclipse/papyrus/infra/nattable/model/editor/tests/tests/EditorsTests.java b/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/src/org/eclipse/papyrus/infra/nattable/model/editor/tests/tests/EditorsTests.java
index de1d208..2a4133f 100644
--- a/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/src/org/eclipse/papyrus/infra/nattable/model/editor/tests/tests/EditorsTests.java
+++ b/tests/junit/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable.model.editor.tests/src/org/eclipse/papyrus/infra/nattable/model/editor/tests/tests/EditorsTests.java
@@ -27,6 +27,7 @@ import org.eclipse.papyrus.infra.nattable.model.editor.customeditors.CustomNatta
import org.eclipse.papyrus.infra.nattable.model.editor.customeditors.CustomNattableconfigurationEditor;
import org.eclipse.papyrus.infra.nattable.model.editor.customeditors.CustomNattablelabelproviderEditor;
import org.eclipse.papyrus.infra.nattable.model.editor.customeditors.CustomNattableproblemEditor;
+import org.eclipse.papyrus.infra.nattable.model.editor.customeditors.CustomNattablestyleEditor;
import org.eclipse.papyrus.infra.nattable.model.editor.customeditors.CustomNattabletesterEditor;
import org.eclipse.papyrus.infra.nattable.model.editor.tests.Activator;
import org.eclipse.papyrus.junit.utils.EditorUtils;
@@ -158,6 +159,12 @@ public class EditorsTests extends AbstractPapyrusTest {
Assert.assertTrue(editor instanceof CustomNattableproblemEditor);
}
+ @Test
+ public void testOpenNattableStyleEditor() throws Exception {
+ IEditorPart editor = openFile("testTableConfiguration", "My.nattablestyle", getBundle()); //$NON-NLS-1$ //$NON-NLS-2$
+ Assert.assertTrue(editor instanceof CustomNattablestyleEditor);
+ }
+
protected String getSourcePath() {
return "/resources/"; //$NON-NLS-1$
}