diff options
author | Alexandra Schladebeck | 2012-10-19 10:05:14 +0000 |
---|---|---|
committer | Alexandra Schladebeck | 2012-10-19 10:05:14 +0000 |
commit | 2c6ca76fb62f4d31fbd233be8e4ff5b021d1ef72 (patch) | |
tree | 47c59ec95de3ec4de3a98f629fa8d759ae099f08 | |
parent | d9fc8b5ce74098457c2204a9fffa59cd20c14ceb (diff) | |
parent | 5c6847946f7b2140552d54c4471b907487af1980 (diff) | |
download | org.eclipse.jubula.core-2c6ca76fb62f4d31fbd233be8e4ff5b021d1ef72.tar.gz org.eclipse.jubula.core-2c6ca76fb62f4d31fbd233be8e4ff5b021d1ef72.tar.xz org.eclipse.jubula.core-2c6ca76fb62f4d31fbd233be8e4ff5b021d1ef72.zip |
Merge branch 'master' of ssh://gatekeeper.bredex.de:2407/jubula/org.eclipse.jubula.core
60 files changed, 979 insertions, 749 deletions
diff --git a/org.eclipse.jubula.client.core/META-INF/persistence.xml b/org.eclipse.jubula.client.core/META-INF/persistence.xml index c22457e25..69fa6b036 100644 --- a/org.eclipse.jubula.client.core/META-INF/persistence.xml +++ b/org.eclipse.jubula.client.core/META-INF/persistence.xml @@ -78,6 +78,12 @@ https://bugs.eclipse.org/bugs/show_bug.cgi?id=379221
-->
<property name="eclipselink.jpql.parser" value="org.eclipse.persistence.queries.ANTLRQueryBuilder"/> + <!-- Since writing of test results involves lots of insert/update statements a batch writing + might speed things up --> + <property name="eclipselink.jdbc.batch-writing" value="JDBC"/> + <!-- for very large batches the size might be increased from the default 100 to whatever + seems meaningful --> + <property name="eclipselink.jdbc.batch-writing.size" value="1000"/> </properties> </persistence-unit> diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java index 867bc832c..ee44ef6ea 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestExecution.java @@ -39,9 +39,9 @@ import org.eclipse.jubula.client.core.commands.DisplayManualTestStepResponseComm import org.eclipse.jubula.client.core.commands.EndTestExecutionResponseCommand; import org.eclipse.jubula.client.core.commands.TakeScreenshotResponseCommand; import org.eclipse.jubula.client.core.communication.AUTConnection; +import org.eclipse.jubula.client.core.communication.AutAgentConnection; import org.eclipse.jubula.client.core.communication.BaseConnection.NotConnectedException; import org.eclipse.jubula.client.core.communication.ConnectionException; -import org.eclipse.jubula.client.core.communication.AutAgentConnection; import org.eclipse.jubula.client.core.i18n.Messages; import org.eclipse.jubula.client.core.model.IAUTConfigPO.ActivationMethod; import org.eclipse.jubula.client.core.model.IAUTMainPO; @@ -1512,8 +1512,7 @@ public class TestExecution { m_currentCap); ITestDataPO date = tdManager.getCell(0, desc); - String varName = this.getValueForParam(date, m_currentCap, - desc); + String varName = getValueForParam(date, m_currentCap, desc); m_varStore.store(varName, m_varStore.getValue( LAST_ACTION_RETURN)); return null; diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestresultSummaryBP.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestresultSummaryBP.java index 3d3fd515f..a8d2dc708 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestresultSummaryBP.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/TestresultSummaryBP.java @@ -38,7 +38,6 @@ import org.eclipse.jubula.client.core.persistence.Persistor; import org.eclipse.jubula.tools.constants.AutConfigConstants; import org.eclipse.jubula.tools.constants.MonitoringConstants; import org.eclipse.jubula.tools.constants.StringConstants; -import org.eclipse.jubula.tools.constants.TestDataConstants; import org.eclipse.jubula.tools.i18n.CompSystemI18n; import org.eclipse.jubula.tools.i18n.I18n; import org.eclipse.jubula.tools.objects.event.TestErrorEvent; @@ -273,13 +272,7 @@ public class TestresultSummaryBP { List<TestResultParameter> parameters = node.getParameters(); if (parameters.size() >= index + 1) { final String value = parameters.get(index).getValue(); - if (value != null) { - if (value.length() == 0) { - paramValue = TestDataConstants.EMPTY_SYMBOL; - } else { - paramValue = value; - } - } + paramValue = StringUtils.defaultString(value); } parameter.setParameterValue(paramValue); keyword.addParameter(parameter); diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/UsedToolkitBP.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/UsedToolkitBP.java index 42f906e6b..ac8024e0e 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/UsedToolkitBP.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/UsedToolkitBP.java @@ -751,7 +751,7 @@ public class UsedToolkitBP { for (IReusedProjectPO reused : reusedProjects) { IProjectPO reusedProject; try { - reusedProject = ProjectPM.loadProject(reused); + reusedProject = ProjectPM.loadProjectFromMaster(reused); // If the project cannot be found in the db, then we cannot consider // it in our computations. if (reusedProject != null) { 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/ResultTreeBuilder.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ResultTreeBuilder.java index 406faa4fa..79805948c 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ResultTreeBuilder.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ResultTreeBuilder.java @@ -82,12 +82,6 @@ public class ResultTreeBuilder implements IExecStackModificationListener { CompSystemI18n.getString(cap.getComponentType())); }
/**
- * @return Returns the lastCap.
- */
- public TestResultNode getLastCap() {
- return m_lastCap;
- }
- /**
* @return Returns the rootNode.
*/
public TestResultNode getRootNode() {
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ResultTreeTracker.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ResultTreeTracker.java index 55df726d1..3635c485a 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ResultTreeTracker.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/model/ResultTreeTracker.java @@ -13,6 +13,7 @@ package org.eclipse.jubula.client.core.model; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang.StringUtils; import org.eclipse.jubula.client.core.businessprocess.ExternalTestDataBP; import org.eclipse.jubula.client.core.businessprocess.TestExecution; import org.eclipse.jubula.client.core.i18n.Messages; @@ -21,7 +22,6 @@ import org.eclipse.jubula.client.core.utils.ExecObject; import org.eclipse.jubula.client.core.utils.ModelParamValueConverter; import org.eclipse.jubula.client.core.utils.ParamValueConverter; import org.eclipse.jubula.tools.constants.StringConstants; -import org.eclipse.jubula.tools.constants.TestDataConstants; import org.eclipse.jubula.tools.exception.InvalidDataException; import org.eclipse.jubula.tools.exception.JBException; import org.eclipse.jubula.tools.i18n.CompSystemI18n; @@ -218,39 +218,52 @@ public class ResultTreeTracker implements IExecStackModificationListener { TestResultNode resultNode) { List<IParamDescriptionPO> parameterList = paramNode.getParameterList(); + for (IParamDescriptionPO desc : parameterList) { + + List<ExecObject> execList = + TestExecution.getInstance().getTrav().getExecStackAsList(); + ExecObject currentExecObj = execList.get(execList.size() - 1); + + resultNode.addParameter(new TestResultParameter( + desc.getName(), CompSystemI18n.getString(desc.getType()), + currentExecObj.getParameterValue(desc.getUniqueId()))); + } + } + + /** + * Adds the parameters from the given Test Step to the given result node. + * + * @param testStep The Test Step from which to copy the parameter info. + * @param resultNode The result node to which the parameter info will + * be copied. + */ + private void addParameters(ICapPO testStep, + TestResultNode resultNode) { + + List<IParamDescriptionPO> parameterList = testStep.getParameterList(); String value = null; for (IParamDescriptionPO desc : parameterList) { ITDManager tdManager = null; try { tdManager = m_externalTestDataBP.getExternalCheckedTDManager( - paramNode); + testStep); } catch (JBException e) { - log.error(Messages.TestDataNotAvailable + StringConstants.DOT, - e); + log.error( + Messages.TestDataNotAvailable + StringConstants.DOT, e); } TestExecution te = TestExecution.getInstance(); + List <ExecObject> stackList = new ArrayList<ExecObject>(te.getTrav().getExecStackAsList()); - int dataSetIndex = te.getTrav().getDataSetNumber(); - // Special handling for Test Case References that are repeated - // via Data Set. The test data manager for such References only has - // information about a single Data Set, so we need to ignore the - // actual current Data Set number. - if (tdManager.getDataSetCount() <= 1) { - dataSetIndex = 0; - } - // Special handling for Test Steps. Their test data manager has // information about multiple Data Sets, but we are only interested // in the first one. - if (paramNode instanceof ICapPO) { - dataSetIndex = 0; - } + int dataSetIndex = 0; if (tdManager.findColumnForParam(desc.getUniqueId()) == -1) { - IParameterInterfacePO referencedDataCube = paramNode + IParameterInterfacePO referencedDataCube = testStep .getReferencedDataCube(); if (referencedDataCube != null) { desc = referencedDataCube.getParameterForName(desc @@ -259,25 +272,19 @@ public class ResultTreeTracker implements IExecStackModificationListener { } ITestDataPO date = tdManager.getCell(dataSetIndex, desc); ParamValueConverter conv = new ModelParamValueConverter( - date.getValue(te.getLocale()), paramNode, te.getLocale(), desc); + date.getValue(te.getLocale()), testStep, te.getLocale(), desc); try { - value = - conv.getExecutionString(stackList, te.getLocale()); + value = conv.getExecutionString( + stackList, te.getLocale()); } catch (InvalidDataException e) { log.error(e.getMessage()); value = MessageIDs.getMessageObject(e.getErrorId()). getMessage(new Object[] {}); } - if (value != null) { - if (value.length() == 0) { - value = TestDataConstants.EMPTY_SYMBOL; - } - } else { - value = StringConstants.EMPTY; - } + resultNode.addParameter(new TestResultParameter( - desc.getName(), CompSystemI18n.getString(desc.getType()), - value)); + desc.getUniqueId(), desc.getType(), + StringUtils.defaultString(value))); } } 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.core/src/org/eclipse/jubula/client/core/persistence/ProjectPM.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/ProjectPM.java index bacb9be34..188b8f8e0 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/ProjectPM.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/ProjectPM.java @@ -50,6 +50,7 @@ import org.eclipse.jubula.toolkit.common.exception.ToolkitPluginException; import org.eclipse.jubula.toolkit.common.utils.ToolkitUtils; import org.eclipse.jubula.tools.constants.StringConstants; import org.eclipse.jubula.tools.exception.JBException; +import org.eclipse.jubula.tools.exception.JBFatalAbortException; import org.eclipse.jubula.tools.exception.ProjectDeletedException; import org.eclipse.jubula.tools.jarutils.IVersion; import org.eclipse.jubula.tools.messagehandling.MessageIDs; @@ -263,15 +264,51 @@ public class ProjectPM extends PersistenceManager { * IProjectPO is therefore detached from its session. * @param reused * The reused project information for this project. - * @return proj - * @throws JBException + * @return the ProjectPO or null if no project in db + * @throws JBException in case of general db access errors (db disconnect, shutdown, etc) */ public static synchronized IProjectPO loadProject(IReusedProjectPO reused) throws JBException { - EntityManager session = null; + EntityManager session = Persistor.instance().openSession(); + try { + return loadProjectInSession(reused, session); + } finally { + Persistor.instance().dropSessionWithoutLockRelease(session); + } + } + /** + * Loads the project from the master session. The returned + * IProjectPO MUST only be used in the master session or read only. + * @param reused + * The reused project information for this project. + * @return the ProjectPO or null if no project in db + * @throws JBException in case of general db access errors (db disconnect, shutdown, etc) + */ + public static synchronized IProjectPO loadProjectFromMaster( + IReusedProjectPO reused) throws JBException { + + EntityManager session = GeneralStorage.getInstance().getMasterSession(); + + return loadProjectInSession(reused, session); + } + + /** + * Loads the project in a session. This is shared code for detached in + * master session loading. + * @param reused + * The reused project information for this project. + * @param session + * Session context for db ops + * @return the ProjectPO or null if no project in db + * @throws JBFatalAbortException + * @throws OperationCanceledException + * @throws JBException in case of general db access errors (db disconnect, shutdown, etc) + */ + private static IProjectPO loadProjectInSession(IReusedProjectPO reused, + EntityManager session) throws JBFatalAbortException, + OperationCanceledException, JBException { try { - session = Persistor.instance().openSession(); Query query = session.createQuery("select project from ProjectPO as project" //$NON-NLS-1$ + " inner join fetch project.properties where project.guid = :guid" //$NON-NLS-1$ + " and project.properties.majorNumber = :majorNumber and project.properties.minorNumber = :minorNumber"); //$NON-NLS-1$ @@ -289,9 +326,7 @@ public class ProjectPM extends PersistenceManager { log.error(Messages.PersistenceLoadFailed, e); throw new JBException(e.getMessage(), MessageIDs.E_PERSISTENCE_LOAD_FAILED); - } finally { - Persistor.instance().dropSessionWithoutLockRelease(session); - } + } } /**
@@ -561,7 +596,7 @@ public class ProjectPM extends PersistenceManager { private static void findReusedProjects(Set<Long> reused, Set<IReusedProjectPO> check) throws JBException { for (IReusedProjectPO ru : check) { - IProjectPO ruP = loadProject(ru); + IProjectPO ruP = loadProjectFromMaster(ru); if (ruP != null) { // check for dangling reference if (reused.add(ruP.getId())) { findReusedProjects(reused, diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ExecObject.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ExecObject.java index ab7be4493..359d3ddde 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ExecObject.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ExecObject.java @@ -10,11 +10,12 @@ *******************************************************************************/ package org.eclipse.jubula.client.core.utils;
+import java.util.HashMap; +import java.util.Map; + import org.apache.commons.lang.builder.HashCodeBuilder; import org.eclipse.jubula.client.core.model.INodePO; -
-
/**
* object for stack
*
@@ -44,6 +45,9 @@ public class ExecObject { * this is used for handling the RETRY event handler.
*/
private int m_retryCount = 0;
+ + /** mapping from parameter identifiers to parameter values */ + private Map<String, String> m_parameters = new HashMap<String, String>(); /**
* constructor
@@ -174,6 +178,30 @@ public class ExecObject { public int getRetryCount() {
return m_retryCount;
}
-
+ + /** + * Sets the value for the parameter with the given identifier to + * <code>value</code> within the context of the receiver. If the receiver + * already has a value for the given identifier, it is overwritten by the + * new value. + * + * @param identifier The identifier for the parameter. + * See {@link IParamDescriptionPO#getUniqueId()}. + * @param value The new value to assign. + */
+ public void addParameter(String identifier, String value) { + m_parameters.put(identifier, value); + } + + /** + * + * @param parameterIdentifier The identifier for the parameter. See + * {@link IParamDescriptionPO#getUniqueId()}. + * @return the current value for the parameter with the given identifier + * within the context of the receiver. + */ + public String getParameterValue(String parameterIdentifier) { + return m_parameters.get(parameterIdentifier); + } }
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java index e1f682a2c..5c8a686b8 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/ParamValueConverter.java @@ -187,10 +187,11 @@ public abstract class ParamValueConverter { */ public String getExecutionString(List<ExecObject> stack, Locale locale) throws InvalidDataException { + StringBuilder builder = new StringBuilder(); for (IParamValueToken token : getTokens()) { builder.append(token.getExecutionString( - new ArrayList<ExecObject>(stack), locale)); + new ArrayList<ExecObject>(stack), locale)); } return builder.toString(); } diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java index 8c36f3e54..c6a294804 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/RefToken.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.jubula.client.core.utils; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.ListIterator; @@ -18,24 +17,21 @@ import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; -import org.eclipse.jubula.client.core.businessprocess.ExternalTestDataBP; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; import org.eclipse.jubula.client.core.businessprocess.TestCaseParamBP; -import org.eclipse.jubula.client.core.businessprocess.TestDataBP; import org.eclipse.jubula.client.core.i18n.Messages; import org.eclipse.jubula.client.core.model.INodePO; import org.eclipse.jubula.client.core.model.IParamDescriptionPO; import org.eclipse.jubula.client.core.model.IParamNodePO; import org.eclipse.jubula.client.core.model.IParameterInterfacePO; import org.eclipse.jubula.client.core.model.ISpecTestCasePO; -import org.eclipse.jubula.client.core.model.ITDManager; import org.eclipse.jubula.client.core.model.ITestDataCubePO; -import org.eclipse.jubula.client.core.model.ITestDataPO; import org.eclipse.jubula.client.core.model.ITestSuitePO; import org.eclipse.jubula.client.core.utils.ParamValueConverter.ConvValidationState; import org.eclipse.jubula.tools.constants.StringConstants; import org.eclipse.jubula.tools.exception.Assert; import org.eclipse.jubula.tools.exception.InvalidDataException; -import org.eclipse.jubula.tools.exception.JBException; import org.eclipse.jubula.tools.messagehandling.MessageIDs; @@ -290,60 +286,15 @@ public class RefToken extends AbstractParamValueToken { public String getExecutionString(List<ExecObject> stack, Locale locale) throws InvalidDataException { String refGuid = extractCore(getModelString()); - IParamNodePO execNode = null; ListIterator <ExecObject> it = stack.listIterator(stack.size()); - final String refName = extractCore(getGuiString()); while (it.hasPrevious()) { ExecObject obj = it.previous(); - if (obj.getExecNode() instanceof IParamNodePO) { - execNode = (IParamNodePO)obj.getExecNode(); - int dsNumber = obj.getNumberDs(); - for (IParamDescriptionPO parDesc - : execNode.getParameterList()) { - if (parDesc.getUniqueId().equals(refGuid)) { - ITDManager man = null; - try { - // FIXME zeb instantiating a new BP object every - // time means that we do absolutely *NO* - // caching of retrieved test data. figure - // out a way to allow caching in this - // situation. - man = new ExternalTestDataBP() - .getExternalCheckedTDManager(execNode); - } catch (JBException e) { - throwInvalidDataException(refName); - } - - // further reference? - ITestDataPO data = null; - - // FIXME Andreas : this is only a hack for a TC with multiple - // parameters with a mix of refs and fixed values!!! - if (dsNumber < man.getDataSetCount()) { - data = TestDataBP.instance().getTestData( - execNode, man, parDesc, dsNumber); - } else { - // FIXME Andreas : this is the data for the fixed value - data = TestDataBP.instance().getTestData( - execNode, man, parDesc, 0); - } - ParamValueConverter conv = new ModelParamValueConverter( - data.getValue(locale), - execNode, locale, getParamDescription()); - - // Look for the reference value further up (or down, - // actually) the execution stack. We initialize a new - // list here in order to avoid modifying the provided - // list, which was the cause of bug 375632. - List<ExecObject> reducedStack = - new ArrayList<ExecObject>(stack); - reducedStack.remove(reducedStack.size() - 1); - return conv.getExecutionString(reducedStack, locale); - } - } + String parameterValue = obj.getParameterValue(refGuid); + if (parameterValue != null) { + return parameterValue; } } - throwInvalidDataException(refName); + throwInvalidDataException(extractCore(getGuiString())); return null; } @@ -412,5 +363,31 @@ public class RefToken extends AbstractParamValueToken { m_modelString = modelString; } + /** + * + * {@inheritDoc} + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj == null || getClass() != obj.getClass()) { + return false; + } + + RefToken otherObj = (RefToken)obj; + + return new EqualsBuilder() + .append(getModelString(), otherObj.getModelString()) + .isEquals(); + } + /** + * + * {@inheritDoc} + */ + public int hashCode() { + return new HashCodeBuilder().append(getModelString()).toHashCode(); + } } diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/Traverser.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/Traverser.java index 090e25952..24eb1a372 100644 --- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/Traverser.java +++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/utils/Traverser.java @@ -22,6 +22,7 @@ import java.util.Vector; import org.apache.commons.collections.IteratorUtils; import org.apache.commons.collections.list.UnmodifiableList; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.Validate; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; @@ -38,6 +39,7 @@ import org.eclipse.jubula.client.core.model.IExecTestCasePO; import org.eclipse.jubula.client.core.model.INodePO; import org.eclipse.jubula.client.core.model.IParamDescriptionPO; import org.eclipse.jubula.client.core.model.IParamNodePO; +import org.eclipse.jubula.client.core.model.IParameterInterfacePO; import org.eclipse.jubula.client.core.model.ITDManager; import org.eclipse.jubula.client.core.model.ITestDataPO; import org.eclipse.jubula.client.core.model.ITestSuitePO; @@ -47,6 +49,7 @@ import org.eclipse.jubula.client.core.persistence.Persistor; import org.eclipse.jubula.tools.constants.StringConstants; import org.eclipse.jubula.tools.exception.Assert; import org.eclipse.jubula.tools.exception.IncompleteDataException; +import org.eclipse.jubula.tools.exception.InvalidDataException; import org.eclipse.jubula.tools.exception.JBException; import org.eclipse.jubula.tools.messagehandling.MessageIDs; import org.slf4j.Logger; @@ -441,6 +444,8 @@ public class Traverser { * @param node node, which was added to stack */ private void fireExecStackIncremented(INodePO node) { + addParameters(m_execStack.peek()); + Iterator<IExecStackModificationListener> it = m_execListenerList.iterator(); while (it.hasNext()) { @@ -505,6 +510,8 @@ public class Traverser { * event for next dataset iteration */ private void fireNextDataSetIteration() { + addParameters(m_execStack.peek()); + Iterator<IExecStackModificationListener> it = m_execListenerList.iterator(); while (it.hasNext()) { @@ -910,4 +917,81 @@ public class Traverser { return nodeList.get(m_execStack.peek().getIndex()); } + + /** + * Adds parameter values to the given execution object. If + * <code>execObject</code> already has parameters assigned, this method + * may overwrite them. + * + * @param execObject The execution object to which the parameters will + * be added. + */ + private void addParameters(ExecObject execObject) { + INodePO execNode = execObject.getExecNode(); + if (execNode instanceof IParamNodePO) { + IParamNodePO paramNode = (IParamNodePO)execNode; + List<IParamDescriptionPO> parameterList = + paramNode.getParameterList(); + String value = null; + for (IParamDescriptionPO desc : parameterList) { + String descriptionId = desc.getUniqueId(); + ITDManager tdManager = null; + try { + tdManager = + m_externalTestDataBP.getExternalCheckedTDManager( + paramNode); + } catch (JBException e) { + LOG.error( + Messages.TestDataNotAvailable + StringConstants.DOT, e); + } + TestExecution te = TestExecution.getInstance(); + + List <ExecObject> stackList = + new ArrayList<ExecObject>(getExecStackAsList()); + int dataSetIndex = getDataSetNumber(); + + // Special handling for Test Case References that are repeated + // via Data Set. The test data manager for such References only has + // information about a single Data Set, so we need to ignore the + // actual current Data Set number. + if (tdManager.getDataSetCount() <= 1) { + dataSetIndex = 0; + } + + // Special handling for Test Steps. Their test data manager has + // information about multiple Data Sets, but we are only interested + // in the first one. + if (paramNode instanceof ICapPO) { + dataSetIndex = 0; + } + + if (tdManager.findColumnForParam(desc.getUniqueId()) == -1) { + IParameterInterfacePO referencedDataCube = paramNode + .getReferencedDataCube(); + if (referencedDataCube != null) { + desc = referencedDataCube.getParameterForName(desc + .getName()); + } + } + ITestDataPO date = tdManager.getCell(dataSetIndex, desc); + ParamValueConverter conv = new ModelParamValueConverter( + date.getValue(te.getLocale()), paramNode, + te.getLocale(), desc); + try { + value = conv.getExecutionString( + stackList, te.getLocale()); + } catch (InvalidDataException e) { + LOG.error(e.getMessage()); + value = MessageIDs.getMessageObject(e.getErrorId()). + getMessage(new Object[] {}); + } + + // It's important to use 'descriptionId' here instead of + // 'desc.getUniqueId()', as 'desc' may have changed between + // its definition and here. + execObject.addParameter(descriptionId, + StringUtils.defaultString(value)); + } + } + } }
\ No newline at end of file diff --git a/org.eclipse.jubula.client.ui.rcp/plugin.xml b/org.eclipse.jubula.client.ui.rcp/plugin.xml index 755c16091..cc97dbd0e 100644 --- a/org.eclipse.jubula.client.ui.rcp/plugin.xml +++ b/org.eclipse.jubula.client.ui.rcp/plugin.xml @@ -1219,14 +1219,6 @@ <command commandId="org.eclipse.jubula.client.ui.commands.monitoring.OpenMonitoringReport" style="push" /> - <command - commandId="org.eclipse.ui.file.export" - label="Export" - style="push"> - <parameter - name="exportWizardId" - value="org.eclipse.jubula.client.ui.rcp.exportWizard.ExportTestResultDetailsWizard" /> - </command> </menuContribution> <menuContribution locationURI="popup:ComponentNameBrowserContextMenuID"> <command @@ -1656,17 +1648,6 @@ </command> </menuContribution> <menuContribution - allPopups="false" - locationURI="popup:org.eclipse.jubula.client.ui.views.TestresultSummaryView?after=additions"> - <command - commandId="org.eclipse.ui.file.export" - style="push"> - <parameter - name="exportWizardId" - value="org.eclipse.jubula.client.ui.rcp.exportWizard.ExportTestResultDetailsWizard" /> - </command> - </menuContribution> - <menuContribution allPopups="false" locationURI="popup:org.eclipse.jubula.client.ui.rcp.views.TestSuiteBrowser?before=defaultTestSuiteBrowserMarker"> <menu @@ -2644,6 +2625,24 @@ </iterate> </enabledWhen> </handler> + <handler + class="org.eclipse.jubula.client.ui.rcp.handlers.ExportTestResultsHandler" + commandId="org.eclipse.jubula.client.ui.commands.ExportTestResults"> + <enabledWhen> + <iterate + ifEmpty="false" + operator="or"> + <and> + <instanceof + value="org.eclipse.jubula.client.core.model.ITestResultSummaryPO"> + </instanceof> + <test + property="org.eclipse.jubula.client.ui.propertytester.TestResultSummary.hasTestResultDetails"> + </test> + </and> + </iterate> + </enabledWhen> + </handler> </extension> <extension point="org.eclipse.ui.commandImages"> <image diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/ProblemsBP.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/ProblemsBP.java index 8c713017f..08369d15f 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/ProblemsBP.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/ProblemsBP.java @@ -809,7 +809,8 @@ public class ProblemsBP implements ICompletenessCheckListener, for (IReusedProjectPO reused : project.getUsedProjects()) { boolean reusedProjectExists = false; try { - reusedProjectExists = (ProjectPM.loadProject(reused) != null); + reusedProjectExists = + (ProjectPM.loadProjectFromMaster(reused) != null); } catch (JBException e) { // Error while loading project; Project does not exist // Do nothing @@ -835,7 +836,7 @@ public class ProblemsBP implements ICompletenessCheckListener, for (IReusedProjectPO reused : project.getUsedProjects()) { IProjectPO reusedProject = null; try { - reusedProject = ProjectPM.loadProject(reused); + reusedProject = ProjectPM.loadProjectFromMaster(reused); if (reusedProject != null) { // not in DB List<Locale> reusedLangList = reusedProject.getLangHelper() .getLanguageList(); 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/AbstractTestCaseEditor.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/AbstractTestCaseEditor.java index 34fe2852f..d58a5dbf6 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/AbstractTestCaseEditor.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/editors/AbstractTestCaseEditor.java @@ -340,7 +340,6 @@ public abstract class AbstractTestCaseEditor extends AbstractJBEditor getEditorHelper().resetEditableState(); getEditorHelper().setDirty(false); - reOpenEditor(getEditorHelper().getEditSupport().getOriginal()); } catch (IncompatibleTypeException pmce) { handlePMCompNameException(pmce); } catch (PMException e) { 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/ExportTestResultsHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ExportTestResultsHandler.java new file mode 100644 index 000000000..0b69fb83b --- /dev/null +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ExportTestResultsHandler.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * 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.handlers; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ParameterizedCommand; +import org.eclipse.jubula.client.ui.rcp.wizards.ExportTestResultDetailsWizard; +import org.eclipse.jubula.client.ui.utils.CommandHelper; +import org.eclipse.ui.IWorkbenchCommandConstants; + +/** + * Handler for exporting details for one or more Test Result Summaries. + * + * @created Oct 5, 2012 + */ +public class ExportTestResultsHandler extends AbstractHandler { + + /** + * + * {@inheritDoc} + */ + public Object execute(ExecutionEvent event) { + + Command exportTestResultDetailsCommand = + CommandHelper.getCommandService().getCommand( + IWorkbenchCommandConstants.FILE_EXPORT); + Map<String, String> parameters = new HashMap<String, String>(); + parameters.put(IWorkbenchCommandConstants.FILE_EXPORT_PARM_WIZARDID, + ExportTestResultDetailsWizard.ID); + + return CommandHelper.executeParameterizedCommand( + ParameterizedCommand.generateCommand( + exportTestResultDetailsCommand, parameters)); + + } + +} 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/views/dataset/AbstractDataSetPage.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/dataset/AbstractDataSetPage.java index 4b231b196..6518aae17 100644 --- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/dataset/AbstractDataSetPage.java +++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/dataset/AbstractDataSetPage.java @@ -1625,7 +1625,9 @@ public abstract class AbstractDataSetPage extends Page getParamInterfaceObj(), getParamName(), this, SWT.NONE); control.addKeyListener(m_keyListener); control.setFocus(); - control.addFocusListener(m_focusListener); + // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=390800 +// control.addFocusListener(m_focusListener); + // end https://bugs.eclipse.org/bugs/show_bug.cgi?id=390800 control.addListener(SWT.Selection, m_listener); m_oldValue = getRow().getText(getColumn()); TextControlBP.setText(m_oldValue, control); @@ -1664,6 +1666,12 @@ public abstract class AbstractDataSetPage extends Page private void activateEditor() { if (canModify()) { m_editor.setEditor(createEditor()); + // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=390800 + Control editorCtrl = m_editor.getEditor(); + if ((editorCtrl != null) && !editorCtrl.isDisposed()) { + editorCtrl.addFocusListener(m_focusListener); + } + // end https://bugs.eclipse.org/bugs/show_bug.cgi?id=390800 TextControlBP.selectAll(m_editor.getEditor()); } } @@ -1733,23 +1741,28 @@ public abstract class AbstractDataSetPage extends Page * Handles the CR keys */ private void handleCR() { - writeData(); - TableItem rowItem = getRow(); - final int col = getColumn(); - rowItem.setText(col, TextControlBP.getText( - m_editor.getEditor())); - m_editor.getEditor().dispose(); - final int row = getTable().indexOf(getRow()); - if (getTable().getColumnCount() > (col + 1)) { - setSelection(row, col + 1); - getTable().setSelection(row); - setFocus(); - } else if (getTable().getItemCount() - > (row + 1)) { - setSelection(row + 1, 1); - getTable().setSelection(row + 1); - } else { - getAddButton().setFocus(); + final Control editorControl = m_editor.getEditor(); + if (!editorControl.isDisposed()) { + writeData(); + } + // writeData() may actually dispose the control during error + // handling, a new check is needed! + if (!editorControl.isDisposed()) { + TableItem rowItem = getRow(); + final int col = getColumn(); + rowItem.setText(col, TextControlBP.getText(editorControl)); + editorControl.dispose(); + final int row = getTable().indexOf(getRow()); + if (getTable().getColumnCount() > (col + 1)) { + setSelection(row, col + 1); + getTable().setSelection(row); + setFocus(); + } else if (getTable().getItemCount() > (row + 1)) { + setSelection(row + 1, 1); + getTable().setSelection(row + 1); + } else { + getAddButton().setFocus(); + } } } } 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} */ diff --git a/org.eclipse.jubula.client.ui/icons/exportTestResults.gif b/org.eclipse.jubula.client.ui/icons/exportTestResults.gif Binary files differnew file mode 100644 index 000000000..d1bb0405c --- /dev/null +++ b/org.eclipse.jubula.client.ui/icons/exportTestResults.gif diff --git a/org.eclipse.jubula.client.ui/plugin.properties b/org.eclipse.jubula.client.ui/plugin.properties index 550b9fb84..e164ba3ad 100644 --- a/org.eclipse.jubula.client.ui/plugin.properties +++ b/org.eclipse.jubula.client.ui/plugin.properties @@ -8,6 +8,7 @@ AddComment=Edit Comment DatabaseConnectionPreferencePageName=Database Connections Expand=E&xpand +ExportTestResultsCommandName=Export Test Results FindSpecTestCase=Show Specification ImageView=Image View JubulaReporting=Functional Test Reporting diff --git a/org.eclipse.jubula.client.ui/plugin.xml b/org.eclipse.jubula.client.ui/plugin.xml index b0adbcfd1..42eb8cfca 100644 --- a/org.eclipse.jubula.client.ui/plugin.xml +++ b/org.eclipse.jubula.client.ui/plugin.xml @@ -38,6 +38,17 @@ </command> <command commandId="org.eclipse.ui.file.refresh" style="push"> </command> + <command + commandId="org.eclipse.jubula.client.ui.commands.ExportTestResults" + style="push"> + </command> + </menuContribution> + <menuContribution + locationURI="popup:org.eclipse.jubula.client.ui.views.TestresultSummaryView?after=additions"> + <command + commandId="org.eclipse.jubula.client.ui.commands.ExportTestResults" + style="push"> + </command> </menuContribution> <menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions"> @@ -108,6 +119,10 @@ commandId="org.eclipse.jubula.client.ui.commands.monitoring.OpenMonitoringReport" icon="icons/metrik.png"> </image> + <image + commandId="org.eclipse.jubula.client.ui.commands.ExportTestResults" + icon="icons/exportTestResults.gif"> + </image> </extension> <extension point="org.eclipse.core.expressions.propertyTesters"> <propertyTester @@ -243,6 +258,10 @@ id="org.eclipse.jubula.client.ui.commands.monitoring.OpenMonitoringReport" name="Open Monitoring Report"> </command> + <command + id="org.eclipse.jubula.client.ui.commands.ExportTestResults" + name="%ExportTestResultsCommandName"> + </command> </extension> <extension point="org.eclipse.ui.preferencePages"> diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestResultParametersDecorator.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestResultParametersDecorator.java index 883eea5d3..8321f5d92 100644 --- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestResultParametersDecorator.java +++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/provider/labelprovider/decorators/TestResultParametersDecorator.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.jubula.client.ui.provider.labelprovider.decorators; +import org.apache.commons.lang.StringUtils; import org.eclipse.jface.viewers.IDecoration; import org.eclipse.jubula.client.core.model.TestResultNode; import org.eclipse.jubula.client.core.model.TestResultParameter; @@ -36,10 +37,9 @@ public class TestResultParametersDecorator extends TestResultNode testResult = (TestResultNode)element; StringBuilder paramValueBuilder = new StringBuilder(); for (TestResultParameter parameter : testResult.getParameters()) { - String value = parameter.getValue(); - if (value != null) { - paramValueBuilder.append(value).append(SEPARATOR); - } + paramValueBuilder + .append(StringUtils.defaultString(parameter.getValue())) + .append(SEPARATOR); } if (paramValueBuilder.length() > 0) { int builderLength = paramValueBuilder.length(); diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java index 4944cdbb6..2d77ebcd5 100644 --- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java +++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/views/TestresultSummaryView.java @@ -625,8 +625,10 @@ public class TestresultSummaryView extends ViewPart implements //save sorting IMemento sortChild = memento.createChild(TAG_SORT); TableColumn sortCol = table.getSortColumn(); - sortChild.putString(TAG_SORT_COL, sortCol.getText()); - sortChild.putInteger(TAG_SORT_DIRECTION, table.getSortDirection()); + if (sortCol != null) { + sortChild.putString(TAG_SORT_COL, sortCol.getText()); + sortChild.putInteger(TAG_SORT_DIRECTION, table.getSortDirection()); + } } /** @@ -679,7 +681,7 @@ public class TestresultSummaryView extends ViewPart implements String sortHeader = sortChild.getString(TAG_SORT_COL); for (int i = 0; i < table.getColumnCount(); i++) { TableColumn tblCol = table.getColumn(i); - if (sortHeader.equals(tblCol.getText())) { + if (tblCol.getText().equals(sortHeader)) { //set sort column table.setSortColumn(tblCol); //set sort direction diff --git a/org.eclipse.jubula.documentation/install/en/tex/Installation/Components/CONTENT.tex b/org.eclipse.jubula.documentation/install/en/tex/Installation/Components/CONTENT.tex index 139481fb8..13689163c 100644 --- a/org.eclipse.jubula.documentation/install/en/tex/Installation/Components/CONTENT.tex +++ b/org.eclipse.jubula.documentation/install/en/tex/Installation/Components/CONTENT.tex @@ -1,4 +1,4 @@ -\input{Installation/Components/content} +\input{Installation/Components/installcomponents} diff --git a/org.eclipse.jubula.documentation/install/en/tex/Installation/Components/content.tex b/org.eclipse.jubula.documentation/install/en/tex/Installation/Components/installcomponents.tex index 360a0fb1f..360a0fb1f 100644 --- a/org.eclipse.jubula.documentation/install/en/tex/Installation/Components/content.tex +++ b/org.eclipse.jubula.documentation/install/en/tex/Installation/Components/installcomponents.tex diff --git a/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Metrics/CONTENT.tex b/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Metrics/CONTENT.tex index 973442fc5..108143645 100644 --- a/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Metrics/CONTENT.tex +++ b/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Metrics/CONTENT.tex @@ -1 +1 @@ -\input{Tasks/Metrics/content} +\input{Tasks/Metrics/contents} diff --git a/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Metrics/content.tex b/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Metrics/contents.tex index 298225640..298225640 100644 --- a/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Metrics/content.tex +++ b/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Metrics/contents.tex diff --git a/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Teststyle/CONTENT.tex b/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Teststyle/CONTENT.tex index 654933c1d..2cf549cc6 100644 --- a/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Teststyle/CONTENT.tex +++ b/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Teststyle/CONTENT.tex @@ -1,3 +1,3 @@ \input{Tasks/Teststyle/intro} -\input{Tasks/Teststyle/content} +\input{Tasks/Teststyle/contents} diff --git a/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Teststyle/content.tex b/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Teststyle/contents.tex index fa1cde825..fa1cde825 100644 --- a/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Teststyle/content.tex +++ b/org.eclipse.jubula.documentation/manual/en/tex/Tasks/Teststyle/contents.tex diff --git a/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedIndices/action-VerifySelectedIndices.tex b/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedIndices/action-VerifySelectedIndices.tex index 302973a49..c9c485f0f 100644 --- a/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedIndices/action-VerifySelectedIndices.tex +++ b/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedIndices/action-VerifySelectedIndices.tex @@ -1,5 +1,5 @@ % CAP description for List --> Verify Selected Indices
\begin{itemize}
-\item Use this action to test whether an item a list is currently selected.
+\item Use this action to test whether an item in a list is currently selected.
\item The item you want to test is given using its index.
\end{itemize}
diff --git a/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedValue/action-VerifySelectedValue.tex b/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedValue/action-VerifySelectedValue.tex index d9346c551..36eb2cbc3 100644 --- a/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedValue/action-VerifySelectedValue.tex +++ b/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedValue/action-VerifySelectedValue.tex @@ -1,5 +1,5 @@ % CAP description for List --> Verify Selected Value(s)
\begin{itemize}
-\item Use this action to test whether an item a list is currently selected.
+\item Use this action to test whether an item in a list is currently selected.
\item The item you want to test is given using its value (name).
\end{itemize}
diff --git a/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedValue/param-Text.tex b/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedValue/param-Text.tex index 22edafea5..9fbe01de7 100644 --- a/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedValue/param-Text.tex +++ b/org.eclipse.jubula.documentation/reference/en/tex/Action/Descriptions/Concrete/List/VerifySelectedValue/param-Text.tex @@ -1,8 +1,7 @@ % CAP description for List --> Verify Selected Value(s) --> Text \begin{itemize} -\item Enter the name(s) of the items you want to check. -\item For example, if you want to check that \bxcaption{England} and \bxcaption{Germany} are selected, enter \bxshell{England,Germany}. -\item Separate items using commas {\tt ','} +\item Enter the name of the item you want to check. +\item For example, if you want to check that \bxcaption{England} and \bxcaption{Germany} are selected, enter \bxshell{England} in one Data Set and \bxshell{Germany} in the next. \end{itemize}
\ No newline at end of file |