Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZeb Ford-Reitz2012-09-24 14:47:55 +0000
committerZeb Ford-Reitz2012-09-24 15:00:47 +0000
commitf9d8e3d329fd7c71130ad17d6e77f67253024df3 (patch)
treebdedc7f1980c229cf58aa8d859b59b338bd3171d
parentd75bd2da441bc4e38a5f3fae35cedfadba6eb076 (diff)
downloadorg.eclipse.jubula.core-f9d8e3d329fd7c71130ad17d6e77f67253024df3.tar.gz
org.eclipse.jubula.core-f9d8e3d329fd7c71130ad17d6e77f67253024df3.tar.xz
org.eclipse.jubula.core-f9d8e3d329fd7c71130ad17d6e77f67253024df3.zip
Fixes http://bugs.eclipse.org/387995#c5 part A.v1.3.0.201209241505
As I noticed that this behavior is also demonstrated by many other dialogs in Jubula, I have also fixed these as well. I fixed the problem by introducing the concept of an Editor Operation, which is an operation that is executed within the context of an editor, with setup and cleanup performed before and after, respectively, as necessary. While fixing this bug, I also noticed some variables and methods that are no longer used (specifically, anything having to do with INodePO.isReused()). I removed these methods and variables, as they are no longer needed and they were making code for certain situations (which apparently also no longer occur) unnecessarily complex.
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CapPO.java8
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ExecTestCasePO.java17
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java5
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ISpecTestCasePO.java4
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java6
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/SpecTestCasePO.java24
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java28
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/IEditorOperation.java28
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/JBEditorHelper.java33
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/TestCaseEditor.java1
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AbstractEditParametersHandler.java43
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddExistingEventHandlerHandler.java20
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataCategoryHandler.java83
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataManagerHandler.java37
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditParametersHandler.java46
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditTDMParametersHandler.java41
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MergeLogicalNameHandler.java35
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewLogicalNameHandler.java31
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewTestCaseHandlerTCEditor.java120
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/OMNewCategoryHandler.java102
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/RenameLogicalNameHandler.java64
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ReplaceWithTestCaseHandler.java36
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerOMEditor.java72
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerTCEditor.java20
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/existing/testcase/ReferenceExistingTestCase.java56
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/newcap/NewCAP.java40
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameCategoryHandlerOMEditor.java52
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCategoryInEditorHandler.java68
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCubeInEditorHandler.java48
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/wizards/ImportTestDataSetsWizard.java15
30 files changed, 603 insertions, 580 deletions
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CapPO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CapPO.java
index 14f682fbd..ec460a730 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CapPO.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/CapPO.java
@@ -389,14 +389,6 @@ class CapPO extends ParamNodePO implements ICapPO {
m_metaComponentType = metaComponentType;
}
- /** {@inheritDoc}
- * @see org.eclipse.jubula.client.core.model.NodePO#isInterfaceLocked()
- */
- @Transient
- public Boolean isReused() {
- return getParentNode().isReused();
- }
-
/**
* {@inheritDoc}
*/
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ExecTestCasePO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ExecTestCasePO.java
index c31cfafd6..94ce5780f 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ExecTestCasePO.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ExecTestCasePO.java
@@ -39,7 +39,6 @@ import org.eclipse.jubula.client.core.i18n.Messages;
import org.eclipse.jubula.client.core.persistence.NodePM;
import org.eclipse.jubula.client.core.persistence.ProjectPM;
import org.eclipse.jubula.tools.constants.StringConstants;
-import org.eclipse.jubula.tools.exception.Assert;
import org.eclipse.jubula.tools.exception.JBException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.persistence.annotations.BatchFetch;
@@ -653,22 +652,6 @@ class ExecTestCasePO extends TestCasePO implements
}
}
- /** {@inheritDoc}
- * @see org.eclipse.jubula.client.core.model.NodePO#isInterfaceLocked()
- */
- @Transient
- public Boolean isReused() {
- if (getParentNode() != null) {
- return getParentNode().isReused();
- }
- // could be happens, if the given ExecTestCase was fetched per database statement
- // parent will be set only in memory
- Assert.notReached(
- Messages.UnexpectedErrorBecauseExecTestCaseHasNoParent
- + StringConstants.DOT);
- return null;
- }
-
/**
* {@inheritDoc}
*/
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java
index 363cd1944..295f8520b 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/INodePO.java
@@ -53,11 +53,6 @@ public interface INodePO extends ITimestampPO {
public abstract void setComment(String comment);
/**
- * @return if Node respectively parentNode of Node is already reused
- */
- public abstract Boolean isReused();
-
- /**
* adds a childnode to an existent node
* creation of reference to the parent node
* @param childNode
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ISpecTestCasePO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ISpecTestCasePO.java
index 7ba725b0b..e0c51cccc 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ISpecTestCasePO.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ISpecTestCasePO.java
@@ -18,10 +18,6 @@ import org.eclipse.jubula.client.core.persistence.ISpecPersistable;
*/
public interface ISpecTestCasePO extends ITestCasePO, ISpecPersistable,
IEventHandlerContainer, IModifiableParameterInterfacePO {
- /**
- * @param isReused the isReused to set
- */
- public abstract void setIsReused(Boolean isReused);
/**
* @return the isInterfaceLocked
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java
index 7d1b5548f..841e9551b 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/NodePO.java
@@ -507,12 +507,6 @@ abstract class NodePO implements INodePO {
}
/**
- * @return if parameter of Node may be modified or not
- */
- @Transient
- public abstract Boolean isReused();
-
- /**
*
* {@inheritDoc}
*/
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/SpecTestCasePO.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/SpecTestCasePO.java
index b542121b7..21844b804 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/SpecTestCasePO.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/SpecTestCasePO.java
@@ -21,7 +21,6 @@ import org.apache.commons.lang.Validate;
import org.eclipse.jubula.client.core.businessprocess.IParamNameMapper;
import org.eclipse.jubula.client.core.i18n.Messages;
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
-import org.eclipse.jubula.client.core.persistence.NodePM;
import org.eclipse.jubula.client.core.persistence.PersistenceUtil;
import org.eclipse.jubula.client.core.persistence.ProjectPM;
import org.eclipse.jubula.client.core.utils.FindNodeParentOperation;
@@ -57,12 +56,6 @@ class SpecTestCasePO extends TestCasePO implements ISpecTestCasePO {
private Boolean m_isInterfaceLocked = false;
/**
- * <code>m_isReused</code> flag for lock of parameter(s)modification
- */
- private transient Boolean m_isReused = null;
-
-
- /**
* only for Persistence (JPA / EclipseLink)
*/
SpecTestCasePO() {
@@ -248,25 +241,8 @@ class SpecTestCasePO extends TestCasePO implements ISpecTestCasePO {
public void setInterfaceLocked(Boolean isInterfaceLocked) {
m_isInterfaceLocked = isInterfaceLocked;
}
-
- /**
- * @return the isInterfaceLocked
- */
- @Transient
- public Boolean isReused() {
- setIsReused(NodePM.isReused(this,
- GeneralStorage.getInstance().getMasterSession()));
- return m_isReused;
- }
/**
- * @param isReused the isReused to set
- */
- public void setIsReused(Boolean isReused) {
- m_isReused = isReused;
- }
-
- /**
* Adds a parameter to the parameter list to call for each parameter of
* specTestCase.
*
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java
index c0386a889..4eb21026b 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java
@@ -597,34 +597,6 @@ public class NodePM extends PersistenceManager {
}
/**
- * validates, if given SpecTestCase is reused in any other SpecTestcase
- * reusage in a testsuite is unconsidered
- * @param specTc SpecTestCase to validate the reusage
- * @param s session to use
- * @return result of validation
- */
- public static boolean isReused(ISpecTestCasePO specTc, EntityManager s) {
- boolean result = false;
- Long id = specTc.getId();
- Long parentProj = specTc.getParentProjectId();
- if (id != null) {
- if (parentProj == null) {
- parentProj = GeneralStorage.getInstance().getProject().getId();
- }
- Query query = s.createNativeQuery(
- "select ID from Node where ID IN " + //$NON-NLS-1$
- "(select parent from Node_List where Child IN " + //$NON-NLS-1$
- "(select ID from Node where PARENT_PROJ = " + parentProj + //$NON-NLS-1$
- " AND SPEC_TC_GUID = " + //$NON-NLS-1$
- "(select GUID from Node where id= " + id + "))) AND " + //$NON-NLS-1$ //$NON-NLS-2$
- "classid=\'S\'"); //$NON-NLS-1$
- List list = query.setMaxResults(1).getResultList();
- result = !(list.isEmpty());
- }
- return result;
- }
-
- /**
* Returns test cases that reference the test case given information.
* Only returns test cases that are <em>NOT</em> in the same project
* as the given test case.
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/IEditorOperation.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/IEditorOperation.java
new file mode 100644
index 000000000..fb4b70cad
--- /dev/null
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/controllers/IEditorOperation.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2012 BREDEX GmbH.
+ * 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:
+ * BREDEX GmbH - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.jubula.client.ui.rcp.controllers;
+
+import org.eclipse.jubula.client.core.model.IPersistentObject;
+
+/**
+ *
+ * @author BREDEX GmbH
+ * @created Sept 24, 2012
+ */
+public interface IEditorOperation {
+
+ /**
+ *
+ * @param workingPo The object on which to operate.
+ */
+ public void run(IPersistentObject workingPo);
+
+}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/JBEditorHelper.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/JBEditorHelper.java
index 19fab02a1..8876e4289 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/JBEditorHelper.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/JBEditorHelper.java
@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.apache.commons.lang.Validate;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jubula.client.core.businessprocess.IComponentNameMapper;
import org.eclipse.jubula.client.core.events.DataChangedEvent;
@@ -31,6 +32,7 @@ import org.eclipse.jubula.client.core.persistence.PMAlreadyLockedException;
import org.eclipse.jubula.client.core.persistence.PMDirtyVersionException;
import org.eclipse.jubula.client.core.persistence.PMException;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.rcp.events.GuiEventDispatcher;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
@@ -89,9 +91,11 @@ public class JBEditorHelper implements ILockedObjects,
/**
* Constructor
*
- * @param editor The editor that will be assisted by this helper.
+ * @param editor The editor that will be assisted by this helper. May not
+ * be <code>null</code>.
*/
public JBEditorHelper(IJBEditor editor) {
+ Validate.notNull(editor);
m_editor = editor;
}
@@ -459,4 +463,31 @@ public class JBEditorHelper implements ILockedObjects,
return m_clipboard;
}
+ /**
+ * Performs the given <code>operation</code> within the context of the
+ * receiver's editor. The operation is "wrapped" between a request for an
+ * editable state and a reset of editable state (if the editor is not marked
+ * as dirty by the end of the operation. The operation is executed in the
+ * same thread in which this method is called.
+ *
+ * @param operation The operation to perform.
+ */
+ public void doEditorOperation(IEditorOperation operation) {
+ if (requestEditableState() == EditableState.OK) {
+ try {
+ operation.run(getEditSupport().getWorkVersion());
+ } finally {
+ if (!m_editor.isDirty()) {
+ try {
+ resetEditableState();
+ getEditSupport().reloadEditSession();
+ } catch (PMException e) {
+ PMExceptionHandler.handlePMExceptionForEditor(
+ e, m_editor);
+ }
+ }
+ }
+
+ }
+ }
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/TestCaseEditor.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/TestCaseEditor.java
index 405469440..439349a45 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/TestCaseEditor.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/TestCaseEditor.java
@@ -419,7 +419,6 @@ public class TestCaseEditor extends AbstractTestCaseEditor
*/
public void reOpenEditor(IPersistentObject node) throws PMException {
m_objectMappingManager.clear();
- ((ISpecTestCasePO)node).setIsReused(null);
super.reOpenEditor(node);
if (node instanceof ISpecTestCasePO) {
CAPRecordedCommand.setRecSpecTestCase((ISpecTestCasePO)node);
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AbstractEditParametersHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AbstractEditParametersHandler.java
index 164530882..d69288443 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AbstractEditParametersHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AbstractEditParametersHandler.java
@@ -17,6 +17,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
+import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jubula.client.core.businessprocess.AbstractParamInterfaceBP;
import org.eclipse.jubula.client.core.businessprocess.ParamNameBPDecorator;
import org.eclipse.jubula.client.core.businessprocess.TestCaseParamBP;
@@ -25,14 +26,13 @@ import org.eclipse.jubula.client.core.model.IParamDescriptionPO;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
import org.eclipse.jubula.client.ui.handlers.AbstractHandler;
-import org.eclipse.jubula.client.ui.rcp.Plugin;
import org.eclipse.jubula.client.ui.rcp.dialogs.AbstractEditParametersDialog.Parameter;
-import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
+import org.eclipse.jubula.client.ui.rcp.editors.IJBEditor;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.tools.constants.StringConstants;
import org.eclipse.jubula.tools.exception.Assert;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -42,29 +42,29 @@ import org.eclipse.ui.IWorkbenchPart;
public abstract class AbstractEditParametersHandler extends AbstractHandler {
/**
- * @return a valid AbstractGDEditor in the editable state; null if editing
- * is not possible
+ *
+ * @param event The execution event containing the context in which the
+ * receiver was executed.
+ * @return the editor on which the receiver should operate.
*/
- protected AbstractJBEditor getEditorInEditableState() {
- final IWorkbenchPart activePart = Plugin.getActivePart();
- if (activePart == null) {
- return null;
- }
- final Object adapter = activePart.getAdapter(AbstractJBEditor.class);
- if (adapter != null) {
- final AbstractJBEditor editor = (AbstractJBEditor)adapter;
- final JBEditorHelper.EditableState state = editor.getEditorHelper()
- .getEditableState();
- if (state == JBEditorHelper.EditableState.OK
- || editor.getEditorHelper().requestEditableState()
- == JBEditorHelper.EditableState.OK) {
- return editor;
+ protected IJBEditor getEditor(ExecutionEvent event) {
+ // Use activePart rather than activeEditor because we want to make sure
+ // that the editor is the active part. It is possible, for example, for
+ // an editor to be the active editor (editor label is rendered with
+ // a different background color than the labels for the other editors)
+ // even though it is *not* the active part because a view is currently
+ // active (view's label is highlighted).
+ final IWorkbenchPart activeEditor = HandlerUtil.getActivePart(event);
+ if (activeEditor != null) {
+ final Object adapter =
+ activeEditor.getAdapter(IJBEditor.class);
+ if (adapter != null) {
+ return (IJBEditor)adapter;
}
}
return null;
}
-
-
+
/**
* Gets the new index of the Parameter with the given paramDesc.
* @param paramDesc the paramDesc
@@ -231,4 +231,5 @@ public abstract class AbstractEditParametersHandler extends AbstractHandler {
return editParameters(paramIntObj, parameters, false, mapper,
paramInterfaceBP);
}
+
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddExistingEventHandlerHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddExistingEventHandlerHandler.java
index 6edee80ed..89658c9d4 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddExistingEventHandlerHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddExistingEventHandlerHandler.java
@@ -21,13 +21,14 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jubula.client.core.model.IEventExecTestCasePO;
import org.eclipse.jubula.client.core.model.INodePO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.handlers.AbstractHandler;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.TestCaseTreeDialog;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
import org.eclipse.jubula.client.ui.rcp.editors.TestCaseEditor;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
@@ -41,6 +42,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -74,15 +76,17 @@ public class AddExistingEventHandlerHandler extends AbstractHandler {
/** {@inheritDoc} */
public Object executeImpl(ExecutionEvent event) {
- IEditorPart editor = Plugin.getActiveEditor();
+ IEditorPart editor = HandlerUtil.getActiveEditor(event);
Assert.verify(editor instanceof TestCaseEditor,
Messages.WrongEditorType + StringConstants.EXCLAMATION_MARK);
- TestCaseEditor testCaseEditor =
- (TestCaseEditor) editor;
- if (JBEditorHelper.EditableState.OK == testCaseEditor.getEditorHelper()
- .requestEditableState()) {
- openTestCasePopUp(testCaseEditor);
- }
+ final TestCaseEditor testCaseEditor = (TestCaseEditor)editor;
+ testCaseEditor.getEditorHelper().doEditorOperation(
+ new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ openTestCasePopUp(testCaseEditor);
+ }
+ });
+
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataCategoryHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataCategoryHandler.java
index d5a007930..ec3d5e098 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataCategoryHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataCategoryHandler.java
@@ -18,15 +18,16 @@ import org.eclipse.jubula.client.core.constants.InitialValueConstants;
import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ITestDataCategoryPO;
import org.eclipse.jubula.client.core.model.PoMaker;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.handlers.AbstractHandler;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.InputDialog;
import org.eclipse.jubula.client.ui.rcp.editors.CentralTestDataEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.ui.IWorkbenchPart;
@@ -41,47 +42,51 @@ public class AddNewTestDataCategoryHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public Object executeImpl(ExecutionEvent event) {
+ public Object executeImpl(final ExecutionEvent event) {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof CentralTestDataEditor) {
CentralTestDataEditor ctdEditor = (CentralTestDataEditor)activePart;
- if (ctdEditor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
- return null;
- }
-
- ITestDataCategoryPO rootCategory =
- (ITestDataCategoryPO)ctdEditor.getEditorHelper()
- .getEditSupport().getWorkVersion();
-
- final ITestDataCategoryPO categoryParent = getParent(
- HandlerUtil.getCurrentSelection(event), rootCategory);
-
- InputDialog dialog = new InputDialog(
- getActiveShell(),
- Messages.CreateNewCategoryActionCatTitle,
- InitialValueConstants.DEFAULT_CATEGORY_NAME,
- Messages.CreateNewCategoryActionCatMessage,
- Messages.CreateNewCategoryActionCatLabel,
- Messages.CreateNewCategoryActionCatError,
- Messages.CreateNewCategoryActionDoubleCatName,
- IconConstants.NEW_CAT_DIALOG_STRING,
- Messages.CreateNewCategoryActionNewCategory, false);
-
- dialog.setHelpAvailable(true);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- Plugin.getHelpSystem().setHelp(dialog.getShell(),
- ContextHelpIds.NEW_TEST_DATA_CATEGORY);
- dialog.open();
- if (Window.OK == dialog.getReturnCode()) {
- ITestDataCategoryPO category =
- PoMaker.createTestDataCategoryPO(dialog.getName());
- categoryParent.addCategory(category);
- DataEventDispatcher.getInstance().fireDataChangedListener(
- category, DataState.Added,
- UpdateState.onlyInEditor);
- }
+ ctdEditor.getEditorHelper().doEditorOperation(
+ new IEditorOperation() {
+
+ public void run(IPersistentObject workingPo) {
+ ITestDataCategoryPO rootCategory =
+ (ITestDataCategoryPO)workingPo;
+
+ ITestDataCategoryPO categoryParent = getParent(
+ HandlerUtil.getCurrentSelection(event),
+ rootCategory);
+
+ InputDialog dialog = new InputDialog(
+ getActiveShell(),
+ Messages.CreateNewCategoryActionCatTitle,
+ InitialValueConstants.DEFAULT_CATEGORY_NAME,
+ Messages.CreateNewCategoryActionCatMessage,
+ Messages.CreateNewCategoryActionCatLabel,
+ Messages.CreateNewCategoryActionCatError,
+ Messages.CreateNewCategoryActionDoubleCatName,
+ IconConstants.NEW_CAT_DIALOG_STRING,
+ Messages.CreateNewCategoryActionNewCategory,
+ false);
+
+ dialog.setHelpAvailable(true);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ Plugin.getHelpSystem().setHelp(dialog.getShell(),
+ ContextHelpIds.NEW_TEST_DATA_CATEGORY);
+ dialog.open();
+ if (Window.OK == dialog.getReturnCode()) {
+ ITestDataCategoryPO category =
+ PoMaker.createTestDataCategoryPO(
+ dialog.getName());
+ categoryParent.addCategory(category);
+ DataEventDispatcher.getInstance()
+ .fireDataChangedListener(
+ category, DataState.Added,
+ UpdateState.onlyInEditor);
+ }
+ }
+ });
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataManagerHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataManagerHandler.java
index 187614544..780ecea32 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataManagerHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/AddNewTestDataManagerHandler.java
@@ -20,16 +20,17 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ITestDataCategoryPO;
import org.eclipse.jubula.client.core.model.ITestDataCubePO;
import org.eclipse.jubula.client.core.model.PoMaker;
import org.eclipse.jubula.client.core.persistence.EditSupport;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.EnterTestDataManagerDialog;
import org.eclipse.jubula.client.ui.rcp.dialogs.NewTestDataManagerDialog;
import org.eclipse.jubula.client.ui.rcp.editors.CentralTestDataEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
@@ -44,24 +45,30 @@ public class AddNewTestDataManagerHandler extends AbstractHandler {
/**
* {@inheritDoc}
*/
- public Object execute(ExecutionEvent event) {
+ public Object execute(final ExecutionEvent event) {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof CentralTestDataEditor) {
- CentralTestDataEditor ctdEditor = (CentralTestDataEditor)activePart;
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (ctdEditor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
- return null;
- }
+ final CentralTestDataEditor ctdEditor =
+ (CentralTestDataEditor)activePart;
- // Show dialog
- String newName = openDialog(HandlerUtil.getActiveShell(event),
- getSetOfUsedNames(ctdEditor));
-
- if (newName != null) {
- performOperation(ctdEditor, newName, selection);
- }
+ ctdEditor.getEditorHelper().doEditorOperation(
+ new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ ISelection selection =
+ HandlerUtil.getCurrentSelection(event);
+
+ // Show dialog
+ String newName = openDialog(
+ HandlerUtil.getActiveShell(event),
+ getSetOfUsedNames(ctdEditor));
+
+ if (newName != null) {
+ performOperation(ctdEditor, newName, selection);
+ }
+ }
+ });
}
+
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditParametersHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditParametersHandler.java
index 690c6a9dd..0070e4b20 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditParametersHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditParametersHandler.java
@@ -16,11 +16,12 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.window.Window;
import org.eclipse.jubula.client.core.businessprocess.TestCaseParamBP;
import org.eclipse.jubula.client.core.events.DataEventDispatcher;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.AbstractEditParametersDialog.Parameter;
import org.eclipse.jubula.client.ui.rcp.dialogs.EditParametersDialog;
-import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
+import org.eclipse.jubula.client.ui.rcp.editors.IJBEditor;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
@@ -33,25 +34,21 @@ public class EditParametersHandler extends AbstractEditParametersHandler {
* {@inheritDoc}
*/
public Object executeImpl(ExecutionEvent event) {
- final AbstractJBEditor editor = getEditorInEditableState();
+ final IJBEditor editor = getEditor(event);
if (editor != null) {
- final JBEditorHelper.EditableState state = editor.getEditorHelper()
- .getEditableState();
- final ISpecTestCasePO workTC = (ISpecTestCasePO)editor
- .getEditorHelper().getEditSupport().getWorkVersion();
- final EditParametersDialog dialog = new EditParametersDialog(
- getActiveShell(), workTC);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- dialog.open();
- if (Window.OK == dialog.getReturnCode()) {
- performChanges(editor, state, workTC, dialog);
- } else {
- if (state == JBEditorHelper.EditableState.NotChecked) {
- workTC.setIsReused(null);
- editor.getEditorHelper().resetEditableState();
+ editor.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ final ISpecTestCasePO workTC =
+ (ISpecTestCasePO)workingPo;
+ final EditParametersDialog dialog =
+ new EditParametersDialog(getActiveShell(), workTC);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ if (dialog.open() == Window.OK) {
+ performChanges(editor, workTC, dialog);
+ }
}
- }
+ });
}
return null;
}
@@ -59,13 +56,11 @@ public class EditParametersHandler extends AbstractEditParametersHandler {
/**
* Performs the changes done in the EditParametersDialog
* @param editor the TestCaseEditor
- * @param state the EditableState
* @param workTC the working ISpecTestCasePO
* @param dialog the EditParametersDialog
*/
- private static void performChanges(AbstractJBEditor editor,
- JBEditorHelper.EditableState state, ISpecTestCasePO workTC,
- EditParametersDialog dialog) {
+ private static void performChanges(IJBEditor editor,
+ ISpecTestCasePO workTC, EditParametersDialog dialog) {
final List<Parameter> parameters = dialog.getParameters();
final boolean isInterfaceLocked = dialog.isInterfaceLocked();
@@ -78,11 +73,6 @@ public class EditParametersHandler extends AbstractEditParametersHandler {
DataEventDispatcher.getInstance()
.fireParamChangedListener();
DataEventDispatcher.getInstance().firePropertyChanged(false);
- } else {
- if (state == JBEditorHelper.EditableState.NotChecked) {
- workTC.setIsReused(null);
- editor.getEditorHelper().resetEditableState();
- }
}
}
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditTDMParametersHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditTDMParametersHandler.java
index 769ec961c..cec079ffb 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditTDMParametersHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/EditTDMParametersHandler.java
@@ -20,12 +20,13 @@ import org.eclipse.jubula.client.core.businessprocess.ParameterInterfaceBP;
import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ITestDataCubePO;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.AbstractEditParametersDialog;
import org.eclipse.jubula.client.ui.rcp.dialogs.AbstractEditParametersDialog.Parameter;
import org.eclipse.jubula.client.ui.rcp.dialogs.EditParametersTDMDialog;
-import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
+import org.eclipse.jubula.client.ui.rcp.editors.IJBEditor;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -56,32 +57,26 @@ public class EditTDMParametersHandler extends AbstractEditParametersHandler {
return null;
}
-
+
/** {@inheritDoc} */
public Object executeImpl(ExecutionEvent event) {
- AbstractJBEditor editor = getEditorInEditableState();
- if (editor != null) {
- ITestDataCubePO tdc = getSelectedTestDataManager(event);
- if (tdc != null) {
- final JBEditorHelper.EditableState state = editor
- .getEditorHelper().getEditableState();
- final AbstractEditParametersDialog dialog =
- new EditParametersTDMDialog(getActiveShell(), tdc);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- dialog.open();
- if (Window.OK == dialog.getReturnCode()) {
- performChanges(editor, tdc, dialog);
- } else {
- if (state == JBEditorHelper.EditableState.NotChecked) {
- editor.getEditorHelper().resetEditableState();
+ final ITestDataCubePO tdc = getSelectedTestDataManager(event);
+ if (tdc != null) {
+ final IJBEditor editor = getEditor(event);
+ editor.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ final AbstractEditParametersDialog dialog =
+ new EditParametersTDMDialog(getActiveShell(), tdc);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ if (dialog.open() == Window.OK) {
+ performChanges(editor, tdc, dialog);
}
}
- }
+ });
}
return null;
}
-
/**
* @param editor
* the current editor
@@ -90,7 +85,7 @@ public class EditTDMParametersHandler extends AbstractEditParametersHandler {
* @param dialog
* the edit parameters dialog
*/
- private void performChanges(AbstractJBEditor editor, ITestDataCubePO tdc,
+ private void performChanges(IJBEditor editor, ITestDataCubePO tdc,
AbstractEditParametersDialog dialog) {
final List<Parameter> parameters = dialog.getParameters();
boolean isModified = editParameters(tdc, parameters, editor
@@ -103,8 +98,6 @@ public class EditTDMParametersHandler extends AbstractEditParametersHandler {
ded.firePropertyChanged(false);
ded.fireDataChangedListener(tdc,
DataState.StructureModified, UpdateState.onlyInEditor);
- } else {
- editor.getEditorHelper().resetEditableState();
}
}
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MergeLogicalNameHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MergeLogicalNameHandler.java
index ec1fa1e2a..639ed3fc6 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MergeLogicalNameHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/MergeLogicalNameHandler.java
@@ -16,8 +16,9 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jubula.client.core.model.IComponentNamePO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.editors.IJBEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
import org.eclipse.jubula.tools.messagehandling.MessageIDs;
import org.eclipse.ui.IWorkbenchPart;
@@ -36,30 +37,26 @@ public class MergeLogicalNameHandler extends AbstractMergeComponentNameHandler {
public Object executeImpl(ExecutionEvent event) {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof IJBEditor) {
- IJBEditor editor = (IJBEditor)activePart;
+ final IJBEditor editor = (IJBEditor)activePart;
if (editor.isDirty()) {
ErrorHandlingUtil.createMessageDialog(MessageIDs.I_SAVE_EDITOR);
return null;
}
-
- // Get model objects from selection
- Set<IComponentNamePO> compNames = getComponentNames(getSelection());
- // Dialog
- IComponentNamePO selectedCompNamePo = openDialog(compNames);
-
- if (selectedCompNamePo == null) {
- // cancel operation
- return null;
- }
-
- if (editor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
-
- return null;
- }
+ editor.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ // Get model objects from selection
+ Set<IComponentNamePO> compNames =
+ getComponentNames(getSelection());
- performOperation(editor, compNames, selectedCompNamePo);
+ // Dialog
+ IComponentNamePO selectedCompNamePo = openDialog(compNames);
+
+ if (selectedCompNamePo != null) {
+ performOperation(editor, compNames, selectedCompNamePo);
+ }
+ }
+ });
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewLogicalNameHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewLogicalNameHandler.java
index ecfa07ea3..b71af7055 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewLogicalNameHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewLogicalNameHandler.java
@@ -20,11 +20,12 @@ import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
import org.eclipse.jubula.client.core.model.IObjectMappingAssoziationPO;
import org.eclipse.jubula.client.core.model.IObjectMappingPO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.PoMaker;
import org.eclipse.jubula.client.core.persistence.IncompatibleTypeException;
import org.eclipse.jubula.client.core.persistence.PMException;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
import org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingMultiPageEditor;
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
import org.eclipse.ui.IWorkbenchPart;
@@ -45,21 +46,21 @@ public class NewLogicalNameHandler extends AbstractNewComponentNameHandler {
public Object executeImpl(ExecutionEvent event) {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof ObjectMappingMultiPageEditor) {
- ObjectMappingMultiPageEditor omEditor =
+ final ObjectMappingMultiPageEditor omEditor =
(ObjectMappingMultiPageEditor)activePart;
- IComponentNameMapper compNameMapper =
- omEditor.getEditorHelper().getEditSupport().getCompMapper();
- // Show dialog
- String newName = openDialog(compNameMapper);
- if (newName != null) {
- if (omEditor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
-
- return null;
- }
-
- performOperation(omEditor, newName);
- }
+ omEditor.getEditorHelper().doEditorOperation(
+ new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ IComponentNameMapper compNameMapper =
+ omEditor.getEditorHelper().getEditSupport()
+ .getCompMapper();
+ // Show dialog
+ String newName = openDialog(compNameMapper);
+ if (newName != null) {
+ performOperation(omEditor, newName);
+ }
+ }
+ });
}
return null;
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewTestCaseHandlerTCEditor.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewTestCaseHandlerTCEditor.java
index 782221ead..afd05b569 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewTestCaseHandlerTCEditor.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/NewTestCaseHandlerTCEditor.java
@@ -20,6 +20,7 @@ import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
import org.eclipse.jubula.client.core.model.IExecTestCasePO;
import org.eclipse.jubula.client.core.model.INodePO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ISpecObjContPO;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
import org.eclipse.jubula.client.core.persistence.PMException;
@@ -27,9 +28,9 @@ import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.rcp.dialogs.InputDialog;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
import org.eclipse.jubula.client.ui.rcp.editors.TestCaseEditor;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
@@ -42,72 +43,75 @@ import org.eclipse.jubula.tools.exception.ProjectDeletedException;
public class NewTestCaseHandlerTCEditor extends AbstractNewHandler {
/** {@inheritDoc} */
public Object executeImpl(ExecutionEvent event) {
- TestCaseEditor tce = (TestCaseEditor)Plugin.getActiveEditor();
+ final TestCaseEditor tce = (TestCaseEditor)Plugin.getActiveEditor();
if (!(tce.getTreeViewer().getSelection()
instanceof IStructuredSelection)) {
return null;
}
- if (JBEditorHelper.EditableState.OK == tce.getEditorHelper()
- .requestEditableState()) {
- INodePO selectedNode = (INodePO)((IStructuredSelection)tce
- .getTreeViewer().getSelection()).getFirstElement();
- final ISpecTestCasePO editorNode = (ISpecTestCasePO)tce
- .getEditorHelper().getEditSupport().getWorkVersion();
- InputDialog dialog = new InputDialog(getActiveShell(),
- Messages.NewTestCaseActionTCTitle,
- InitialValueConstants.DEFAULT_TEST_CASE_NAME,
- Messages.NewTestCaseActionTCMessage,
- Messages.RenameActionTCLabel,
- Messages.RenameActionTCError,
- Messages.NewTestCaseActionDoubleTCName,
- IconConstants.NEW_TC_DIALOG_STRING,
- Messages.NewTestCaseActionTCShell, false);
-
- dialog.setHelpAvailable(true);
- dialog.create();
- Plugin.getHelpSystem().setHelp(dialog.getShell(),
- ContextHelpIds.DIALOG_TC_ADD_NEW);
- DialogUtils.setWidgetNameForModalDialog(dialog);
- dialog.open();
- ISpecTestCasePO newSpecTC = null;
- if (Window.OK == dialog.getReturnCode()) {
- String tcName = dialog.getName();
- INodePO parent = ISpecObjContPO.TCB_ROOT_NODE;
- try {
- newSpecTC = TestCaseBP.createNewSpecTestCase(tcName,
- parent, null);
- DataEventDispatcher.getInstance().fireDataChangedListener(
- newSpecTC, DataState.Added, UpdateState.all);
- } catch (PMException e) {
- PMExceptionHandler.handlePMExceptionForMasterSession(e);
- } catch (ProjectDeletedException e) {
- PMExceptionHandler.handleGDProjectDeletedException();
- }
- }
- if (newSpecTC != null) {
- Integer index = null;
- if (selectedNode instanceof IExecTestCasePO) {
- index = getPositionToInsert(
- editorNode, (IExecTestCasePO)selectedNode);
+
+ tce.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ INodePO selectedNode = (INodePO)((IStructuredSelection)tce
+ .getTreeViewer().getSelection()).getFirstElement();
+ final ISpecTestCasePO editorNode = (ISpecTestCasePO)workingPo;
+ InputDialog dialog = new InputDialog(getActiveShell(),
+ Messages.NewTestCaseActionTCTitle,
+ InitialValueConstants.DEFAULT_TEST_CASE_NAME,
+ Messages.NewTestCaseActionTCMessage,
+ Messages.RenameActionTCLabel,
+ Messages.RenameActionTCError,
+ Messages.NewTestCaseActionDoubleTCName,
+ IconConstants.NEW_TC_DIALOG_STRING,
+ Messages.NewTestCaseActionTCShell, false);
+
+ dialog.setHelpAvailable(true);
+ dialog.create();
+ Plugin.getHelpSystem().setHelp(dialog.getShell(),
+ ContextHelpIds.DIALOG_TC_ADD_NEW);
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ dialog.open();
+ ISpecTestCasePO newSpecTC = null;
+ if (Window.OK == dialog.getReturnCode()) {
+ String tcName = dialog.getName();
+ INodePO parent = ISpecObjContPO.TCB_ROOT_NODE;
+ try {
+ newSpecTC = TestCaseBP.createNewSpecTestCase(tcName,
+ parent, null);
+ DataEventDispatcher.getInstance()
+ .fireDataChangedListener(
+ newSpecTC, DataState.Added, UpdateState.all);
+ } catch (PMException e) {
+ PMExceptionHandler.handlePMExceptionForMasterSession(e);
+ } catch (ProjectDeletedException e) {
+ PMExceptionHandler.handleGDProjectDeletedException();
+ }
}
+ if (newSpecTC != null) {
+ Integer index = null;
+ if (selectedNode instanceof IExecTestCasePO) {
+ index = getPositionToInsert(
+ editorNode, (IExecTestCasePO)selectedNode);
+ }
- try {
- ISpecTestCasePO workNewSpecTC = (ISpecTestCasePO) tce
- .getEditorHelper().getEditSupport()
- .createWorkVersion(newSpecTC);
- IExecTestCasePO newExecTC = TestCaseBP
- .addReferencedTestCase(tce.getEditorHelper()
- .getEditSupport(), editorNode,
- workNewSpecTC, index);
+ try {
+ ISpecTestCasePO workNewSpecTC = (ISpecTestCasePO) tce
+ .getEditorHelper().getEditSupport()
+ .createWorkVersion(newSpecTC);
+ IExecTestCasePO newExecTC = TestCaseBP
+ .addReferencedTestCase(tce.getEditorHelper()
+ .getEditSupport(), editorNode,
+ workNewSpecTC, index);
- tce.getEditorHelper().setDirty(true);
- DataEventDispatcher.getInstance().fireDataChangedListener(
- newExecTC, DataState.Added, UpdateState.all);
- } catch (PMException e) {
- PMExceptionHandler.handlePMExceptionForEditor(e, tce);
+ tce.getEditorHelper().setDirty(true);
+ DataEventDispatcher.getInstance()
+ .fireDataChangedListener(
+ newExecTC, DataState.Added, UpdateState.all);
+ } catch (PMException e) {
+ PMExceptionHandler.handlePMExceptionForEditor(e, tce);
+ }
}
}
- }
+ });
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/OMNewCategoryHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/OMNewCategoryHandler.java
index e48013baa..da8e6f087 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/OMNewCategoryHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/OMNewCategoryHandler.java
@@ -23,13 +23,14 @@ import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
import org.eclipse.jubula.client.core.model.IComponentNamePO;
import org.eclipse.jubula.client.core.model.IObjectMappingAssoziationPO;
import org.eclipse.jubula.client.core.model.IObjectMappingCategoryPO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.PoMaker;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.InputDialog;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
import org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingMultiPageEditor;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
@@ -66,7 +67,7 @@ public class OMNewCategoryHandler extends AbstractSelectionBasedHandler {
*/
private void createNewCategory(Object selElement,
final ObjectMappingMultiPageEditor editor,
- ISelectionProvider selectionProvider) {
+ final ISelectionProvider selectionProvider) {
IObjectMappingCategoryPO category = null;
if (selElement instanceof IObjectMappingCategoryPO) {
@@ -79,56 +80,61 @@ public class OMNewCategoryHandler extends AbstractSelectionBasedHandler {
(IComponentNamePO)selElement);
}
final IObjectMappingCategoryPO node = category;
- InputDialog dialog =
- new InputDialog(getActiveShell(),
- Messages.OMNewCategoryActionTitle,
- Messages.OMNewCategoryActionName,
- Messages.OMNewCategoryActionMessage,
- Messages.OMNewCategoryActionLabel,
- Messages.OMNewCategoryActionError1,
- Messages.OMNewCategoryActionDoubleCatName,
- IconConstants.NEW_CAT_DIALOG_STRING,
- Messages.OMNewCategoryActionShell,
- false) {
-
- /**
- * @return False, if the input name already exists.
- */
- protected boolean isInputAllowed() {
- return !editor.getOmEditorBP().existCategory(
- node, getInputFieldText());
- }
- };
if (node != null) {
- dialog.setHelpAvailable(true);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- Plugin.getHelpSystem().setHelp(dialog.getShell(),
- ContextHelpIds.DIALOG_OM_CAT_NEW);
- dialog.open();
- if (dialog.getReturnCode() == Window.OK) {
- if (editor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
- return;
- }
+ editor.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ InputDialog dialog =
+ new InputDialog(getActiveShell(),
+ Messages.OMNewCategoryActionTitle,
+ Messages.OMNewCategoryActionName,
+ Messages.OMNewCategoryActionMessage,
+ Messages.OMNewCategoryActionLabel,
+ Messages.OMNewCategoryActionError1,
+ Messages.OMNewCategoryActionDoubleCatName,
+ IconConstants.NEW_CAT_DIALOG_STRING,
+ Messages.OMNewCategoryActionShell,
+ false) {
+
+ /**
+ * @return False, if the input name already
+ * exists.
+ */
+ protected boolean isInputAllowed() {
+ return !editor.getOmEditorBP()
+ .existCategory(node,
+ getInputFieldText());
+ }
+ };
+ dialog.setHelpAvailable(true);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ Plugin.getHelpSystem().setHelp(dialog.getShell(),
+ ContextHelpIds.DIALOG_OM_CAT_NEW);
- IObjectMappingCategoryPO newCategory =
- PoMaker.createObjectMappingCategoryPO(dialog.getName());
- node.addCategory(newCategory);
- editor.getEditorHelper().setDirty(true);
+ if (dialog.open() == Window.OK) {
+ IObjectMappingCategoryPO newCategory =
+ PoMaker.createObjectMappingCategoryPO(
+ dialog.getName());
+ node.addCategory(newCategory);
+ editor.getEditorHelper().setDirty(true);
- DataEventDispatcher.getInstance().fireDataChangedListener(
- node, DataState.StructureModified,
- UpdateState.onlyInEditor);
- DataEventDispatcher.getInstance().fireDataChangedListener(
- newCategory, DataState.Added,
- UpdateState.onlyInEditor);
- StructuredSelection newSel =
- new StructuredSelection(newCategory);
- if (selectionProvider != null) {
- selectionProvider.setSelection(newSel);
+ DataEventDispatcher.getInstance()
+ .fireDataChangedListener(
+ node, DataState.StructureModified,
+ UpdateState.onlyInEditor);
+ DataEventDispatcher.getInstance()
+ .fireDataChangedListener(
+ newCategory, DataState.Added,
+ UpdateState.onlyInEditor);
+ StructuredSelection newSel =
+ new StructuredSelection(newCategory);
+ if (selectionProvider != null) {
+ selectionProvider.setSelection(newSel);
+ }
+ }
}
- }
+ });
+
}
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/RenameLogicalNameHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/RenameLogicalNameHandler.java
index db2e74b94..aa4707af7 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/RenameLogicalNameHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/RenameLogicalNameHandler.java
@@ -19,7 +19,9 @@ import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
import org.eclipse.jubula.client.core.model.IComponentNamePO;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
+import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
import org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingMultiPageEditor;
import org.eclipse.jubula.client.ui.rcp.handlers.rename.AbstractRenameComponentNameHandler;
import org.eclipse.ui.IEditorPart;
@@ -36,41 +38,49 @@ public class RenameLogicalNameHandler
extends AbstractRenameComponentNameHandler {
/** {@inheritDoc} */
- public Object executeImpl(ExecutionEvent event) {
- IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
+ public Object executeImpl(final ExecutionEvent event) {
+ final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor instanceof ObjectMappingMultiPageEditor) {
ObjectMappingMultiPageEditor omEditor =
(ObjectMappingMultiPageEditor)activeEditor;
final IComponentNameMapper compNamesMapper =
omEditor.getEditorHelper().getEditSupport().getCompMapper();
- IComponentNamePO compName = getSelectedComponentName();
+ final IComponentNamePO compName = getSelectedComponentName();
if (compName != null) {
- String newName = getNewName(event, compNamesMapper, compName);
- if (newName != null
- && omEditor.getEditorHelper().requestEditableState()
- == EditableState.OK) {
-
- rename(omEditor.getEditorHelper().getEditSupport()
- .getCompMapper(),
- compName.getGuid(),
- newName);
-
- omEditor.getEditorHelper().setDirty(true);
+ final JBEditorHelper editorHelper = omEditor.getEditorHelper();
+ editorHelper.doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ String newName =
+ getNewName(event, compNamesMapper, compName);
+ if (newName != null) {
+
+ rename(
+ editorHelper.getEditSupport().getCompMapper(),
+ compName.getGuid(),
+ newName);
+
+ editorHelper.setDirty(true);
- DataEventDispatcher.getInstance().fireDataChangedListener(
- compName, DataState.Renamed, UpdateState.onlyInEditor);
+ DataEventDispatcher.getInstance()
+ .fireDataChangedListener(compName,
+ DataState.Renamed,
+ UpdateState.onlyInEditor);
- // Issue a selection event to update properties view, if open.
- ISelectionProvider selectionProvider =
- activeEditor.getSite().getSelectionProvider();
- if (selectionProvider != null) {
- ISelection currentSelection =
- selectionProvider.getSelection();
- selectionProvider.setSelection(
- StructuredSelection.EMPTY);
- selectionProvider.setSelection(currentSelection);
+ // Issue a selection event to update properties
+ // view, if open.
+ ISelectionProvider selectionProvider =
+ activeEditor.getSite().getSelectionProvider();
+ if (selectionProvider != null) {
+ ISelection currentSelection =
+ selectionProvider.getSelection();
+ selectionProvider.setSelection(
+ StructuredSelection.EMPTY);
+ selectionProvider.setSelection(
+ currentSelection);
+ }
+ }
}
- }
+ });
}
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ReplaceWithTestCaseHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ReplaceWithTestCaseHandler.java
index b2b7d0286..73bcbd61f 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ReplaceWithTestCaseHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ReplaceWithTestCaseHandler.java
@@ -15,9 +15,10 @@ import java.util.List;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jubula.client.core.model.IExecTestCasePO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.editors.AbstractTestCaseEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
import org.eclipse.jubula.client.ui.rcp.wizards.refactor.ReplaceTCRWizard;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.jubula.client.ui.utils.DialogUtils.SizeType;
@@ -35,22 +36,23 @@ public class ReplaceWithTestCaseHandler extends AbstractSelectionBasedHandler {
public Object executeImpl(ExecutionEvent event) {
final AbstractTestCaseEditor tce =
(AbstractTestCaseEditor)HandlerUtil.getActiveEditor(event);
- if (tce.getEditorHelper().requestEditableState()
- == JBEditorHelper.EditableState.OK) {
- List<IExecTestCasePO> listOfExecsToReplace =
- getSelection().toList();
- WizardDialog dialog = new WizardDialog(getActiveShell(),
- new ReplaceTCRWizard(tce, listOfExecsToReplace)) {
- /** {@inheritDoc} */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- DialogUtils.adjustShellSizeRelativeToClientSize(newShell,
- .6f, .6f, SizeType.SIZE);
- }
- };
- dialog.setHelpAvailable(true);
- dialog.open();
- }
+ tce.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ List<IExecTestCasePO> listOfExecsToReplace =
+ getSelection().toList();
+ WizardDialog dialog = new WizardDialog(getActiveShell(),
+ new ReplaceTCRWizard(tce, listOfExecsToReplace)) {
+ /** {@inheritDoc} */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ DialogUtils.adjustShellSizeRelativeToClientSize(
+ newShell, .6f, .6f, SizeType.SIZE);
+ }
+ };
+ dialog.setHelpAvailable(true);
+ dialog.open();
+ }
+ });
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerOMEditor.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerOMEditor.java
index a8ae92c8b..0b832413d 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerOMEditor.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerOMEditor.java
@@ -20,9 +20,10 @@ import org.eclipse.jubula.client.core.businessprocess.TestExecution;
import org.eclipse.jubula.client.core.model.IComponentNamePO;
import org.eclipse.jubula.client.core.model.IObjectMappingAssoziationPO;
import org.eclipse.jubula.client.core.model.IObjectMappingCategoryPO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.ui.constants.Constants;
import org.eclipse.jubula.client.ui.rcp.Plugin;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingMultiPageEditor;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.rcp.sourceprovider.AbstractJBSourceProvider;
@@ -48,41 +49,42 @@ public class DeleteTreeItemHandlerOMEditor
if (!(activePart instanceof ObjectMappingMultiPageEditor)) {
return null;
}
- IStructuredSelection selection = getSelection();
- ObjectMappingMultiPageEditor editor =
+
+ final ObjectMappingMultiPageEditor editor =
(ObjectMappingMultiPageEditor)activePart;
- if (editor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
- return null;
- }
- Class classType = null;
- for (Object obj : selection.toArray()) {
- //selectionitems must be same type
- if (classType == null) {
- classType = obj.getClass();
- }
- if (obj.getClass() != classType) {
- return null;
- }
- }
- Object lastParent = null;
- if (selection.size() == 1) {
- lastParent = deleteSingleElement(
- selection.getFirstElement(), editor);
- } else if (selection.size() > 1) {
- boolean delete = false;
- delete = MessageDialog.openConfirm(getActiveShell(),
- Messages.DeleteTreeItemActionOMEditorOMTitle,
- Messages.DeleteTreeItemActionOMEditorOMText3);
- if (delete) {
- lastParent = deleteMultipleElements(
- selection.toArray(), editor);
- }
- }
-
- if (lastParent != null) {
- refreshViewer(editor, lastParent);
- }
+ editor.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ IStructuredSelection selection = getSelection();
+ Class classType = null;
+ for (Object obj : selection.toArray()) {
+ //selectionitems must be same type
+ if (classType == null) {
+ classType = obj.getClass();
+ }
+ if (obj.getClass() != classType) {
+ return;
+ }
+ }
+ Object lastParent = null;
+ if (selection.size() == 1) {
+ lastParent = deleteSingleElement(
+ selection.getFirstElement(), editor);
+ } else if (selection.size() > 1) {
+ boolean delete = false;
+ delete = MessageDialog.openConfirm(getActiveShell(),
+ Messages.DeleteTreeItemActionOMEditorOMTitle,
+ Messages.DeleteTreeItemActionOMEditorOMText3);
+ if (delete) {
+ lastParent = deleteMultipleElements(
+ selection.toArray(), editor);
+ }
+ }
+
+ if (lastParent != null) {
+ refreshViewer(editor, lastParent);
+ }
+ }
+ });
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerTCEditor.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerTCEditor.java
index 0843f5630..3d48d6e5c 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerTCEditor.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/delete/DeleteTreeItemHandlerTCEditor.java
@@ -20,11 +20,12 @@ import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
import org.eclipse.jubula.client.core.model.INodePO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.persistence.PMException;
import org.eclipse.jubula.client.core.persistence.PersistenceManager;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -44,15 +45,16 @@ public class DeleteTreeItemHandlerTCEditor
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof AbstractJBEditor) {
- AbstractJBEditor tce = (AbstractJBEditor)activePart;
- IStructuredSelection structuredSelection = getSelection();
- if (confirmDelete(structuredSelection)) {
- if (tce.getEditorHelper().requestEditableState()
- != JBEditorHelper.EditableState.OK) {
- return null;
+ final AbstractJBEditor tce = (AbstractJBEditor)activePart;
+ tce.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ IStructuredSelection structuredSelection = getSelection();
+ if (confirmDelete(structuredSelection)) {
+ deleteNodesFromEditor(
+ structuredSelection.toList(), tce);
+ }
}
- deleteNodesFromEditor(structuredSelection.toList(), tce);
- }
+ });
}
return null;
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/existing/testcase/ReferenceExistingTestCase.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/existing/testcase/ReferenceExistingTestCase.java
index 182b9faf4..3665656e7 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/existing/testcase/ReferenceExistingTestCase.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/existing/testcase/ReferenceExistingTestCase.java
@@ -23,21 +23,23 @@ import org.eclipse.jubula.client.core.businessprocess.db.TestCaseBP;
import org.eclipse.jubula.client.core.events.InteractionEventDispatcher;
import org.eclipse.jubula.client.core.model.IExecTestCasePO;
import org.eclipse.jubula.client.core.model.INodePO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
import org.eclipse.jubula.client.core.persistence.PMException;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.rcp.dialogs.TestCaseTreeDialog;
import org.eclipse.jubula.client.ui.rcp.editors.AbstractTestCaseEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
import org.eclipse.jubula.client.ui.rcp.editors.NodeEditorInput;
import org.eclipse.jubula.client.ui.rcp.handlers.NewTestCaseHandlerTCEditor;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.swt.SWT;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -51,32 +53,34 @@ public class ReferenceExistingTestCase
*/
public Object executeImpl(ExecutionEvent event) {
final AbstractTestCaseEditor tce =
- (AbstractTestCaseEditor)Plugin.getActiveEditor();
- if (tce.getEditorHelper().requestEditableState()
- == JBEditorHelper.EditableState.OK) {
- final INodePO editorNode = (INodePO)tce.getEditorHelper()
- .getEditSupport().getWorkVersion();
- final INodePO node = (INodePO) getSelection().getFirstElement();
- if (node == null) { // check for existing selection
- return null;
- }
- ISelectionListener listener = getSelectionListener(tce, editorNode,
- node);
- ISpecTestCasePO specTC = null;
- if (editorNode instanceof ISpecTestCasePO) {
- specTC = (ISpecTestCasePO)editorNode;
+ (AbstractTestCaseEditor)HandlerUtil.getActiveEditor(event);
+
+ tce.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ final INodePO editorNode = (INodePO)workingPo;
+ final INodePO node = (INodePO) getSelection().getFirstElement();
+ if (node == null) { // check for existing selection
+ return;
+ }
+ ISelectionListener listener =
+ getSelectionListener(tce, editorNode, node);
+ ISpecTestCasePO specTC = null;
+ if (editorNode instanceof ISpecTestCasePO) {
+ specTC = (ISpecTestCasePO)editorNode;
+ }
+ TestCaseTreeDialog dialog = new TestCaseTreeDialog(
+ getActiveShell(), specTC, SWT.MULTI);
+ dialog.addSelectionListener(listener);
+ dialog.setHelpAvailable(true);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ Plugin.getHelpSystem().setHelp(dialog.getShell(),
+ ContextHelpIds.TESTCASE_ADD_EXISTING);
+ dialog.open();
+ dialog.removeSelectionListener(listener);
}
- TestCaseTreeDialog dialog = new TestCaseTreeDialog(
- getActiveShell(), specTC, SWT.MULTI);
- dialog.addSelectionListener(listener);
- dialog.setHelpAvailable(true);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- Plugin.getHelpSystem().setHelp(dialog.getShell(),
- ContextHelpIds.TESTCASE_ADD_EXISTING);
- dialog.open();
- dialog.removeSelectionListener(listener);
- }
+ });
+
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/newcap/NewCAP.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/newcap/NewCAP.java
index ca9927b97..fa2bfdab5 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/newcap/NewCAP.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/newcap/NewCAP.java
@@ -22,18 +22,19 @@ import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
import org.eclipse.jubula.client.core.model.ICapPO;
import org.eclipse.jubula.client.core.model.INodePO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
import org.eclipse.jubula.client.core.persistence.IncompatibleTypeException;
import org.eclipse.jubula.client.core.persistence.PMException;
import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler;
-import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.rcp.dialogs.NewCAPDialog;
import org.eclipse.jubula.client.ui.rcp.editors.AbstractTestCaseEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -45,26 +46,27 @@ public class NewCAP extends AbstractSelectionBasedHandler {
* {@inheritDoc}
*/
public Object executeImpl(ExecutionEvent event) {
- IWorkbenchPart activePart = Plugin.getActivePart();
+ IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof AbstractTestCaseEditor) {
- AbstractTestCaseEditor tse = (AbstractTestCaseEditor)activePart;
- if (tse.getEditorHelper().requestEditableState()
- == JBEditorHelper.EditableState.OK) {
- ISpecTestCasePO workTC = (ISpecTestCasePO)tse.getEditorHelper()
- .getEditSupport().getWorkVersion();
- IStructuredSelection selection = getSelection();
- INodePO selectedNodeGUI = (INodePO)selection.getFirstElement();
- if (selectedNodeGUI != null) { // using the CTRL modifier, you
- // may get a click without a selection
- ISpecTestCasePO specTcGUI = null;
- int posistionToAdd = workTC.indexOf(selectedNodeGUI);
- while (!(selectedNodeGUI instanceof ISpecTestCasePO)) {
- selectedNodeGUI = selectedNodeGUI.getParentNode();
+ final AbstractTestCaseEditor tce =
+ (AbstractTestCaseEditor)activePart;
+ tce.getEditorHelper().doEditorOperation(new IEditorOperation() {
+
+ public void run(IPersistentObject workingPo) {
+ ISpecTestCasePO workTC = (ISpecTestCasePO)workingPo;
+ IStructuredSelection selection = getSelection();
+ INodePO selectedNode = (INodePO)selection.getFirstElement();
+ if (selectedNode != null) {
+ ISpecTestCasePO specTcGUI = null;
+ int posistionToAdd = workTC.indexOf(selectedNode);
+ while (!(selectedNode instanceof ISpecTestCasePO)) {
+ selectedNode = selectedNode.getParentNode();
+ }
+ specTcGUI = (ISpecTestCasePO)selectedNode;
+ addCap(specTcGUI, workTC, posistionToAdd, tce);
}
- specTcGUI = (ISpecTestCasePO)selectedNodeGUI;
- addCap(specTcGUI, workTC, posistionToAdd, tse);
}
- }
+ });
}
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameCategoryHandlerOMEditor.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameCategoryHandlerOMEditor.java
index a15fe945a..b01e507c8 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameCategoryHandlerOMEditor.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameCategoryHandlerOMEditor.java
@@ -17,12 +17,13 @@ import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
import org.eclipse.jubula.client.core.model.IObjectMappingCategoryPO;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.rcp.Plugin;
import org.eclipse.jubula.client.ui.rcp.businessprocess.OMEditorBP;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.InputDialog;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
import org.eclipse.jubula.client.ui.rcp.editors.ObjectMappingMultiPageEditor;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
@@ -57,38 +58,39 @@ public class RenameCategoryHandlerOMEditor
* @param sel The current selection.
*
*/
- protected void dialogPopUp(ObjectMappingMultiPageEditor editor,
- IStructuredSelection sel) {
- IObjectMappingCategoryPO category =
- (IObjectMappingCategoryPO)sel.getFirstElement();
- InputDialog dialog = createDialog(category, editor.getOmEditorBP());
- if (dialog != null) {
- dialog.setHelpAvailable(true);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- Plugin.getHelpSystem().setHelp(dialog.getShell(),
- ContextHelpIds.DIALOG_RENAME);
- dialog.open();
- if (dialog.getReturnCode() == Window.OK) {
- if (editor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
- return;
- }
- if (!category.getName().equals(dialog.getName())) {
- category.setName(dialog.getName());
- editor.getEditorHelper().setDirty(true);
- DataEventDispatcher.getInstance().fireDataChangedListener(
- category, DataState.Renamed, UpdateState.onlyInEditor);
+ protected void dialogPopUp(final ObjectMappingMultiPageEditor editor,
+ final IStructuredSelection sel) {
+ editor.getEditorHelper().doEditorOperation(new IEditorOperation() {
+
+ public void run(IPersistentObject workingPo) {
+ IObjectMappingCategoryPO category =
+ (IObjectMappingCategoryPO)sel.getFirstElement();
+ InputDialog dialog =
+ createDialog(category, editor.getOmEditorBP());
+ dialog.setHelpAvailable(true);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ Plugin.getHelpSystem().setHelp(dialog.getShell(),
+ ContextHelpIds.DIALOG_RENAME);
+ if (dialog.open() == Window.OK) {
+ if (!category.getName().equals(dialog.getName())) {
+ category.setName(dialog.getName());
+ editor.getEditorHelper().setDirty(true);
+ DataEventDispatcher.getInstance()
+ .fireDataChangedListener(category,
+ DataState.Renamed,
+ UpdateState.onlyInEditor);
+ }
}
}
- }
+ });
}
/**
* @param category the corresponding object mapping category.
* @param editorBp The business process to use for checking the existence
* of a category.
- * @return a new InputDialog.
+ * @return a new InputDialog. Never <code>null</code>.
*/
private InputDialog createDialog(final IObjectMappingCategoryPO category,
final OMEditorBP editorBp) {
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCategoryInEditorHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCategoryInEditorHandler.java
index c5bd14fc2..9b39bd994 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCategoryInEditorHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCategoryInEditorHandler.java
@@ -15,14 +15,15 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ITestDataCategoryPO;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.constants.IconConstants;
import org.eclipse.jubula.client.ui.handlers.AbstractSelectionBasedHandler;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.InputDialog;
import org.eclipse.jubula.client.ui.rcp.editors.CentralTestDataEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.ui.IWorkbenchPart;
@@ -40,7 +41,7 @@ public class RenameTestDataCategoryInEditorHandler
* {@inheritDoc}
*/
public Object executeImpl(ExecutionEvent event) {
- ITestDataCategoryPO toRename =
+ final ITestDataCategoryPO toRename =
getFirstElement(ITestDataCategoryPO.class);
if (toRename == null) {
return null;
@@ -49,36 +50,41 @@ public class RenameTestDataCategoryInEditorHandler
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof CentralTestDataEditor) {
- CentralTestDataEditor editor = (CentralTestDataEditor)activePart;
- InputDialog dialog = new InputDialog(getActiveShell(),
- Messages.RenameCategoryActionOMEditorTitle,
- toRename.getName(),
- Messages.RenameCategoryActionOMEditorMessage,
- Messages.RenameCategoryActionOMEditorLabel,
- Messages.RenameCategoryActionOMEditorError1,
- Messages.RenameCategoryActionOMEditorDoubleCatName,
- IconConstants.RENAME_CAT_DIALOG_STRING,
- Messages.RenameCategoryActionOMEditorShell,
- false);
-
- dialog.setHelpAvailable(true);
- dialog.create();
- DialogUtils.setWidgetNameForModalDialog(dialog);
- Plugin.getHelpSystem().setHelp(dialog.getShell(),
- ContextHelpIds.DIALOG_RENAME);
- dialog.open();
- if (dialog.getReturnCode() == Window.OK) {
- if (editor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
- return null;
- }
- if (!toRename.getName().equals(dialog.getName())) {
- toRename.setName(dialog.getName());
- editor.getEditorHelper().setDirty(true);
- DataEventDispatcher.getInstance().fireDataChangedListener(
- toRename, DataState.Renamed, UpdateState.onlyInEditor);
+ final CentralTestDataEditor editor =
+ (CentralTestDataEditor)activePart;
+ editor.getEditorHelper().doEditorOperation(new IEditorOperation() {
+
+ public void run(IPersistentObject workingPo) {
+ InputDialog dialog = new InputDialog(getActiveShell(),
+ Messages.RenameCategoryActionOMEditorTitle,
+ toRename.getName(),
+ Messages.RenameCategoryActionOMEditorMessage,
+ Messages.RenameCategoryActionOMEditorLabel,
+ Messages.RenameCategoryActionOMEditorError1,
+ Messages.RenameCategoryActionOMEditorDoubleCatName,
+ IconConstants.RENAME_CAT_DIALOG_STRING,
+ Messages.RenameCategoryActionOMEditorShell,
+ false);
+
+ dialog.setHelpAvailable(true);
+ dialog.create();
+ DialogUtils.setWidgetNameForModalDialog(dialog);
+ Plugin.getHelpSystem().setHelp(dialog.getShell(),
+ ContextHelpIds.DIALOG_RENAME);
+
+ if (dialog.open() == Window.OK) {
+ if (!toRename.getName().equals(dialog.getName())) {
+ toRename.setName(dialog.getName());
+ editor.getEditorHelper().setDirty(true);
+ DataEventDispatcher.getInstance()
+ .fireDataChangedListener(
+ toRename, DataState.Renamed,
+ UpdateState.onlyInEditor);
+ }
+ }
}
- }
+ });
+
}
return null;
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCubeInEditorHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCubeInEditorHandler.java
index b8d1d0885..e16ce6723 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCubeInEditorHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/rename/RenameTestDataCubeInEditorHandler.java
@@ -18,13 +18,14 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.DataState;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.UpdateState;
+import org.eclipse.jubula.client.core.model.IPersistentObject;
import org.eclipse.jubula.client.core.model.ITestDataCubePO;
import org.eclipse.jubula.client.ui.constants.ContextHelpIds;
import org.eclipse.jubula.client.ui.rcp.Plugin;
+import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.dialogs.EnterTestDataManagerDialog;
import org.eclipse.jubula.client.ui.rcp.dialogs.RenameTestDataManagerDialog;
import org.eclipse.jubula.client.ui.rcp.editors.CentralTestDataEditor;
-import org.eclipse.jubula.client.ui.rcp.editors.JBEditorHelper.EditableState;
import org.eclipse.jubula.client.ui.rcp.handlers.AddNewTestDataManagerHandler;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.swt.widgets.Shell;
@@ -42,31 +43,34 @@ public class RenameTestDataCubeInEditorHandler extends
/**
* {@inheritDoc}
*/
- public Object executeImpl(ExecutionEvent event) {
+ public Object executeImpl(final ExecutionEvent event) {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof CentralTestDataEditor) {
- IStructuredSelection structuredSelection = getSelection();
- CentralTestDataEditor editor = (CentralTestDataEditor)activePart;
- if (editor.getEditorHelper().requestEditableState()
- != EditableState.OK) {
- return null;
- }
-
- Object firstElement = structuredSelection.getFirstElement();
- if (firstElement instanceof ITestDataCubePO) {
- ITestDataCubePO tdc = (ITestDataCubePO)firstElement;
- String newName = getNewTestDataCubeName(tdc, editor, event);
- if (newName != null) {
- tdc.setName(newName);
- editor.getEditorHelper().setDirty(true);
- DataEventDispatcher ded = DataEventDispatcher.getInstance();
- ded.fireDataChangedListener(tdc,
- DataState.Renamed, UpdateState.onlyInEditor);
- ded.fireParamChangedListener();
- ded.firePropertyChanged(false);
+ final CentralTestDataEditor editor =
+ (CentralTestDataEditor)activePart;
+ editor.getEditorHelper().doEditorOperation(new IEditorOperation() {
+ public void run(IPersistentObject workingPo) {
+ IStructuredSelection structuredSelection = getSelection();
+ Object firstElement = structuredSelection.getFirstElement();
+ if (firstElement instanceof ITestDataCubePO) {
+ ITestDataCubePO tdc = (ITestDataCubePO)firstElement;
+ String newName =
+ getNewTestDataCubeName(tdc, editor, event);
+ if (newName != null) {
+ tdc.setName(newName);
+ editor.getEditorHelper().setDirty(true);
+ DataEventDispatcher ded =
+ DataEventDispatcher.getInstance();
+ ded.fireDataChangedListener(tdc, DataState.Renamed,
+ UpdateState.onlyInEditor);
+ ded.fireParamChangedListener();
+ ded.firePropertyChanged(false);
+ }
+ }
}
- }
+ });
}
+
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/wizards/ImportTestDataSetsWizard.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/wizards/ImportTestDataSetsWizard.java
index 247498993..e82ed7459 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/wizards/ImportTestDataSetsWizard.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/wizards/ImportTestDataSetsWizard.java
@@ -12,6 +12,8 @@ package org.eclipse.jubula.client.ui.rcp.wizards;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jubula.client.core.persistence.PMException;
+import org.eclipse.jubula.client.ui.rcp.controllers.PMExceptionHandler;
import org.eclipse.jubula.client.ui.rcp.editors.CentralTestDataEditor;
import org.eclipse.jubula.client.ui.rcp.i18n.Messages;
import org.eclipse.jubula.client.ui.rcp.wizards.pages.ImportXLSTestdataWizardPage;
@@ -67,6 +69,19 @@ public class ImportTestDataSetsWizard extends Wizard implements IImportWizard {
return m_importCSVData.finish(m_selection, m_ctde);
}
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (m_ctde != null && !m_ctde.isDirty()) {
+ try {
+ m_ctde.getEditorHelper().resetEditableState();
+ m_ctde.getEditorHelper().getEditSupport().reloadEditSession();
+ } catch (PMException e) {
+ PMExceptionHandler.handlePMExceptionForEditor(e, m_ctde);
+ }
+ }
+ }
+
/**
* {@inheritDoc}
*/

Back to the top