Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2015-08-13 13:39:38 +0000
committerMarvin Mueller2015-08-13 13:41:01 +0000
commit3d516b25c1b4aa45e059fd7cc8d9d9769836de71 (patch)
treecacd182c852c9ac6c81f18e07ab44c4b3c69d79c
parent13a13ad318949121ed8f91ede0f586e8826c711c (diff)
downloadorg.eclipse.jubula.core-3d516b25c1b4aa45e059fd7cc8d9d9769836de71.tar.gz
org.eclipse.jubula.core-3d516b25c1b4aa45e059fd7cc8d9d9769836de71.tar.xz
org.eclipse.jubula.core-3d516b25c1b4aa45e059fd7cc8d9d9769836de71.zip
Sprint task - Allow Show specification also for reused projects
http://eclip.se/472028
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java17
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/TestCaseBP.java18
-rw-r--r--org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/persistence/NodePM.java24
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java46
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java11
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java26
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java8
-rw-r--r--org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/internal/i18n/jubulaI18n.properties2
8 files changed, 123 insertions, 29 deletions
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java
index e81c20aee..64434d42c 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/NodeBP.java
@@ -17,6 +17,7 @@ import javax.persistence.PersistenceException;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.lang.Validate;
+import org.apache.commons.lang.builder.EqualsBuilder;
import org.eclipse.jubula.client.core.i18n.Messages;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.IPersistentObject;
@@ -140,4 +141,20 @@ public class NodeBP {
}
return true;
}
+
+ /**
+ * @param nodePO
+ * the node to test
+ * @return true if editable --> belongs to current project; false otherwise
+ * or if nodePO == null
+ */
+ public static boolean belongsToCurrentProject(INodePO nodePO) {
+ if (nodePO != null) {
+ EqualsBuilder eb = new EqualsBuilder();
+ eb.append(nodePO.getParentProjectId(), GeneralStorage.getInstance()
+ .getProject().getId());
+ return eb.isEquals();
+ }
+ return false;
+ }
}
diff --git a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/TestCaseBP.java b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/TestCaseBP.java
index 24278a7bb..1b5bfa19d 100644
--- a/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/TestCaseBP.java
+++ b/org.eclipse.jubula.client.core/src/org/eclipse/jubula/client/core/businessprocess/db/TestCaseBP.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.jubula.client.core.businessprocess.db;
-import org.apache.commons.lang.builder.EqualsBuilder;
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;
@@ -20,7 +19,6 @@ import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
import org.eclipse.jubula.client.core.model.NodeMaker;
import org.eclipse.jubula.client.core.persistence.EditSupport;
-import org.eclipse.jubula.client.core.persistence.GeneralStorage;
import org.eclipse.jubula.client.core.persistence.NodePM;
import org.eclipse.jubula.client.core.persistence.PMAlreadyLockedException;
import org.eclipse.jubula.client.core.persistence.PMDirtyVersionException;
@@ -186,20 +184,4 @@ public class TestCaseBP extends NodeBP {
NodePM.addAndPersistChildNode(parent, specTC, pos);
return specTC;
}
-
- /**
- * @param specTc
- * the spec test case to test
- * @return true if editable --> belongs to current project; false otherwise
- * or if specTc == null
- */
- public static boolean belongsToCurrentProject(ISpecTestCasePO specTc) {
- if (specTc != null) {
- EqualsBuilder eb = new EqualsBuilder();
- eb.append(specTc.getParentProjectId(), GeneralStorage.getInstance()
- .getProject().getId());
- return eb.isEquals();
- }
- return false;
- }
}
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 433a1ba50..cea634e5c 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
@@ -988,6 +988,30 @@ public class NodePM extends PersistenceManager {
return null;
}
+
+ /**
+ * Finds a node within the project with the given ID.
+ * @param nodeGuid The GUID of the node
+ * @return the {@inheritDoc INodePO} with the given GUID, or <code>null</code> if
+ * the {@link INodePO} cannot be found
+ */
+ public static synchronized INodePO getNode(String nodeGuid) {
+ EntityManager session = GeneralStorage.getInstance().getMasterSession();
+ Validate.notNull(session);
+
+ Query specTcQuery = session.createQuery("select node from NodePO node where node.guid = :guid"); //$NON-NLS-1$
+ specTcQuery.setParameter("guid", nodeGuid); //$NON-NLS-1$
+
+ try {
+ Object result = specTcQuery.getSingleResult();
+ if (result instanceof INodePO) {
+ return (INodePO)result;
+ }
+ } catch (NoResultException nre) {
+ // No result found. Fall through to return null.
+ }
+ return null;
+ }
/**
* Loads a bag of Nodes into the given session and returns the loaded
* Nodes.
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java
index 082e8e24b..1a9b1a631 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/businessprocess/UINodeBP.java
@@ -23,6 +23,7 @@ import org.eclipse.jubula.client.core.model.IExecTestCasePO;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
import org.eclipse.jubula.client.core.model.ITestCasePO;
+import org.eclipse.jubula.client.core.model.ITestSuitePO;
import org.eclipse.jubula.client.core.model.NodeMaker;
import org.eclipse.jubula.client.core.model.TestResultNode;
import org.eclipse.jubula.client.core.persistence.GeneralStorage;
@@ -73,18 +74,17 @@ public class UINodeBP {
execTc = (IExecTestCasePO)firstElement;
} else if (firstElement instanceof TestResultNode) {
TestResultNode trNode = (TestResultNode)firstElement;
- INodePO nodePO = trNode.getNode();
+ INodePO nodePO = getExecFromTestResultNode(trNode);
if (nodePO instanceof ITestCasePO
&& !(nodePO instanceof IExecTestCasePO)) {
- nodePO = NodePM.getNode(GeneralStorage.getInstance()
- .getProject().getId(), nodePO.getGuid());
+ nodePO = NodePM.getNode(nodePO.getGuid());
}
while (!(nodePO instanceof IExecTestCasePO)) {
trNode = trNode.getParent();
if (trNode == null) {
return null;
}
- nodePO = trNode.getNode();
+ nodePO = getExecFromTestResultNode(trNode);
}
execTc = (IExecTestCasePO)nodePO;
}
@@ -93,6 +93,28 @@ public class UINodeBP {
}
return null;
}
+
+ /**
+ *
+ * @param structuredSel find the referenced {@link ITestSuitePO}
+ * @return a valid {@link ITestSuitePO} <code>null</code> if no reference
+ * could be found
+ */
+ public static ITestSuitePO getSpecTS(IStructuredSelection structuredSel) {
+ Object firstElement = structuredSel.getFirstElement();
+ if (firstElement instanceof TestResultNode) {
+ TestResultNode trNode = (TestResultNode)firstElement;
+ INodePO nodePO = trNode.getNode();
+ if (nodePO instanceof ITestSuitePO) {
+ return (ITestSuitePO) NodePM.getNode(
+ GeneralStorage.getInstance()
+ .getProject().getId(), nodePO.getGuid());
+ }
+ } else if (firstElement instanceof ITestSuitePO) {
+ return (ITestSuitePO) firstElement;
+ }
+ return null;
+ }
/**
* Tries to select a node with the given ID in the given TreeViewer.
@@ -154,4 +176,20 @@ public class UINodeBP {
tv.setSelection(oldSelection);
return null;
}
+
+ /**
+ * This method is getting the Node from {@link TestResultNode}.
+ * If this is a generated {@link ITestCasePO} than it is searched in the
+ * database for the correct node.
+ * @param trNode the testResult node
+ * @return an {@link INodePO} which can be of any kind and from any project
+ */
+ private static INodePO getExecFromTestResultNode(TestResultNode trNode) {
+ INodePO nodePO = trNode.getNode();
+ if (nodePO instanceof ITestCasePO
+ && nodePO.isGenerated()) {
+ nodePO = NodePM.getNode(nodePO.getGuid());
+ }
+ return nodePO;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java
index fe9aa56ef..698a6d665 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/ShowSpecificationHandler.java
@@ -12,8 +12,12 @@ package org.eclipse.jubula.client.ui.rcp.handlers;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
+import org.eclipse.jubula.client.core.model.ITestSuitePO;
+import org.eclipse.jubula.client.ui.constants.Constants;
+import org.eclipse.jubula.client.ui.rcp.Plugin;
import org.eclipse.jubula.client.ui.rcp.businessprocess.UINodeBP;
import org.eclipse.jubula.client.ui.rcp.controllers.MultipleTCBTracker;
+import org.eclipse.ui.IViewPart;
/**
@@ -28,6 +32,13 @@ public class ShowSpecificationHandler extends AbstractShowSpecificationHandler {
if (specTc != null) {
showSpecUINode(specTc, MultipleTCBTracker.getInstance()
.getMainTCB());
+ return null;
+ }
+ ITestSuitePO testSuite = UINodeBP.getSpecTS(getSelection());
+ if (testSuite != null) {
+ IViewPart view = Plugin.showView(Constants.TS_BROWSER_ID);
+ showSpecUINode(testSuite, view);
+
}
return null;
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java
index 64c24a41b..35288e8a5 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/AbstractOpenHandler.java
@@ -13,7 +13,7 @@ package org.eclipse.jubula.client.ui.rcp.handlers.open;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jubula.client.core.businessprocess.db.TestCaseBP;
+import org.eclipse.jubula.client.core.businessprocess.db.NodeBP;
import org.eclipse.jubula.client.core.model.IAUTMainPO;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.IPersistentObject;
@@ -71,20 +71,36 @@ public abstract class AbstractOpenHandler extends AbstractHandler {
protected boolean isEditableImpl(INodePO selected) {
return true;
}
-
+
+ /**
+ *
+ * @param testSuite the testsuite to open the editor for
+ */
+ protected void openEditorForSpecTS(ITestSuitePO testSuite) {
+ openEditorForSpec(testSuite);
+ }
/**
* @param specTc the spec to open the editor for
*/
protected void openEditorForSpecTC(ISpecTestCasePO specTc) {
- boolean isNodeEditable = TestCaseBP.belongsToCurrentProject(specTc);
+ openEditorForSpec(specTc);
+ }
+
+ /**
+ * This method is checking if the node belongs to the current project
+ * and if not is opening a dialog to show that this node is from a other project
+ * @param node the node to open.
+ */
+ private void openEditorForSpec(INodePO node) {
+ boolean isNodeEditable = NodeBP.belongsToCurrentProject(node);
if (isNodeEditable) {
- IEditorPart editor = openEditor(specTc);
+ IEditorPart editor = openEditor(node);
editor.getSite().getPage().activate(editor);
if (editor instanceof AbstractJBEditor) {
AbstractJBEditor jbEditor =
(AbstractJBEditor) editor;
jbEditor.setSelection(
- new StructuredSelection(specTc));
+ new StructuredSelection(node));
}
} else {
ErrorHandlingUtil.createMessageDialog(
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java
index f235670d7..e1db23826 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/handlers/open/OpenSpecificationHandler.java
@@ -14,6 +14,7 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jubula.client.core.model.ISpecTestCasePO;
+import org.eclipse.jubula.client.core.model.ITestSuitePO;
import org.eclipse.jubula.client.ui.rcp.businessprocess.UINodeBP;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -42,6 +43,11 @@ public class OpenSpecificationHandler extends AbstractOpenHandler {
*/
private void openSpecNode(IStructuredSelection structuredSel) {
ISpecTestCasePO specTc = UINodeBP.getSpecTC(structuredSel);
- openEditorForSpecTC(specTc);
+ if (specTc != null) {
+ openEditorForSpecTC(specTc);
+ } else {
+ ITestSuitePO testSuite = UINodeBP.getSpecTS(structuredSel);
+ openEditorForSpecTS(testSuite);
+ }
}
} \ No newline at end of file
diff --git a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/internal/i18n/jubulaI18n.properties b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/internal/i18n/jubulaI18n.properties
index 963a10a31..ed4ae4a01 100644
--- a/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/internal/i18n/jubulaI18n.properties
+++ b/org.eclipse.jubula.tools/src/org/eclipse/jubula/tools/internal/i18n/jubulaI18n.properties
@@ -398,7 +398,7 @@ InfoMessage.ENOUGH_EVENT_HANDLER=No more Event Handlers can be added.
InfoMessage.COULD_NOT_DELETE_ALL_TRACKED_CHANGES=It was not possible to delete the tracked changes for the following nodes. Check if they are currently blocked by another user.
InfoMessage.COULD_NOT_DELETE_ALL_TRACKED_CHANGES_MANY=It was not possible to delete the tracked changes for {1} nodes. The first {0} of them are the following. Check if they are currently blocked by another user.
InfoMessage.FILE_LOGGING_NOT_ENABLED=File logging is not enabled.\n\nPlease use the configuration tool to enable file logging and restart {0}.
-InfoMessage.I_NON_EDITABLE_NODE=This element has been specified in a reused project. Please open this project to view the specification of the element.
+InfoMessage.I_NON_EDITABLE_NODE=This element is not available, either it was removed or has been specified in a reused project.
InfoMessage.I_REUSED_TDC=The following selected Test Data Sets are reused\:{0} Only unused Test Data Sets can be deleted.
InfoMessage.LOCK_OBJ_1=The object "{0}" is currently in use by the editor "{1}".\nPlease save this editor before repeating the action.
InfoMessage.LOCK_OBJ_2=The object "{0}" is reused in Test Case "{1}".\nTest Case "{1}" is currently in use by the editor "{2}".\nPlease save this editor before repeating the action.

Back to the top