Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2014-09-10 08:09:01 +0000
committerMarvin Mueller2014-09-11 06:04:13 +0000
commite239ee47f125bbe0d4c090d1b1790419bde486ac (patch)
treecb396570a33cf67e1e1924eb5aedf22d7760e714 /org.eclipse.jubula.client.wiki.ui
parent9e8a39357a9d5ec0fca19d9ba89e7ccd3c9adad7 (diff)
downloadorg.eclipse.jubula.core-e239ee47f125bbe0d4c090d1b1790419bde486ac.tar.gz
org.eclipse.jubula.core-e239ee47f125bbe0d4c090d1b1790419bde486ac.tar.xz
org.eclipse.jubula.core-e239ee47f125bbe0d4c090d1b1790419bde486ac.zip
Sprint task - Using description from spec in description editor if editing reference
Diffstat (limited to 'org.eclipse.jubula.client.wiki.ui')
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java8
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java5
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/utils/DescriptionUtil.java45
-rw-r--r--org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java27
4 files changed, 60 insertions, 25 deletions
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java
index f5e043de8..54c61422b 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/dialogs/DescriptionEditDialog.java
@@ -11,6 +11,7 @@
package org.eclipse.jubula.client.wiki.ui.dialogs;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.TitleAreaDialog;
@@ -21,6 +22,7 @@ import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.ui.utils.DelayableTimer;
import org.eclipse.jubula.client.wiki.ui.i18n.Messages;
+import org.eclipse.jubula.client.wiki.ui.utils.DescriptionUtil;
import org.eclipse.jubula.client.wiki.ui.utils.ProjectMarkupUtil;
import org.eclipse.jubula.client.wiki.ui.Activator;
import org.eclipse.mylyn.wikitext.ui.editor.MarkupSourceViewer;
@@ -67,7 +69,11 @@ public class DescriptionEditDialog extends TitleAreaDialog {
super(parentShell);
setShellStyle(getShellStyle() | SWT.RESIZE);
m_workNode = workNode;
- m_description = new Document(workNode.getDescription());
+ String description = workNode.getDescription();
+ if (StringUtils.isBlank(description)) {
+ description = DescriptionUtil.getReferenceDescription(workNode);
+ }
+ m_description = new Document(description);
}
/**
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java
index 972505879..56b87cf80 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/handlers/EditDescriptionHandler.java
@@ -24,6 +24,7 @@ import org.eclipse.jubula.client.ui.rcp.controllers.IEditorOperation;
import org.eclipse.jubula.client.ui.rcp.editors.AbstractJBEditor;
import org.eclipse.jubula.client.ui.utils.DialogUtils;
import org.eclipse.jubula.client.wiki.ui.dialogs.DescriptionEditDialog;
+import org.eclipse.jubula.client.wiki.ui.utils.DescriptionUtil;
import org.eclipse.ui.handlers.HandlerUtil;
/**
*
@@ -73,7 +74,9 @@ public class EditDescriptionHandler extends AbstractSelectionBasedHandler {
return;
}
if (StringUtils.equals(workNode.getDescription(),
- dialog.getDescription())) {
+ dialog.getDescription())
+ || StringUtils.equals(dialog.getDescription(),
+ DescriptionUtil.getReferenceDescription(workNode))) {
return;
}
workNode.setDescription(dialog.getDescription());
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/utils/DescriptionUtil.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/utils/DescriptionUtil.java
new file mode 100644
index 000000000..06888acae
--- /dev/null
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/utils/DescriptionUtil.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.wiki.ui.utils;
+
+import org.eclipse.jubula.client.core.model.IExecTestCasePO;
+import org.eclipse.jubula.client.core.model.INodePO;
+import org.eclipse.jubula.client.core.model.IRefTestSuitePO;
+/**
+ *
+ * @author BREDEX GmbH
+ */
+public class DescriptionUtil {
+
+ /** this is a util class*/
+ private DescriptionUtil() {
+ // private util class
+ }
+
+ /**
+ * gets the description of the referenced {@link ISpecTestCasePO} or {@link ITestSuitePO}
+ * @param node the {@link IExecTestCasePO} or {@link IRefTestSuitePO}
+ * @return the description of the corresponding {@link ISpecTestCasePO} or {@link ITestSuitePO},
+ * may be null
+ */
+ public static String getReferenceDescription(INodePO node) {
+ String description = null;
+ if (node instanceof IExecTestCasePO) {
+ IExecTestCasePO exec = (IExecTestCasePO) node;
+ description = exec.getSpecTestCase().getDescription();
+ }
+ if (node instanceof IRefTestSuitePO) {
+ IRefTestSuitePO refTestSuite = (IRefTestSuitePO) node;
+ description = refTestSuite.getTestSuite().getDescription();
+ }
+ return description;
+ }
+}
diff --git a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
index 4e86c087c..d529119bd 100644
--- a/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
+++ b/org.eclipse.jubula.client.wiki.ui/src/org/eclipse/jubula/client/wiki/ui/views/DescriptionView.java
@@ -20,11 +20,10 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jubula.client.core.events.DataChangedEvent;
import org.eclipse.jubula.client.core.events.DataEventDispatcher;
import org.eclipse.jubula.client.core.events.DataEventDispatcher.IDataChangedListener;
-import org.eclipse.jubula.client.core.model.IExecTestCasePO;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.IProjectPropertiesPO;
-import org.eclipse.jubula.client.core.model.IRefTestSuitePO;
import org.eclipse.jubula.client.wiki.ui.i18n.Messages;
+import org.eclipse.jubula.client.wiki.ui.utils.DescriptionUtil;
import org.eclipse.jubula.client.wiki.ui.utils.ProjectMarkupUtil;
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;
import org.eclipse.swt.SWT;
@@ -158,26 +157,7 @@ public class DescriptionView extends ViewPart implements IDataChangedListener {
setDescriptionForBrowser(m_selectedNode);
}
}
-
- /**
- * gets the description of the referenced {@link ISpecTestCasePO} or {@link ITestSuitePO}
- * @param node the {@link IExecTestCasePO} or {@link IRefTestSuitePO}
- * @return the description of the corresponding {@link ISpecTestCasePO} or {@link ITestSuitePO},
- * may be null
- */
- private String getReferenceDescription(INodePO node) {
- String description = null;
- if (node instanceof IExecTestCasePO) {
- IExecTestCasePO exec = (IExecTestCasePO) node;
- description = exec.getSpecTestCase().getDescription();
- }
- if (node instanceof IRefTestSuitePO) {
- IRefTestSuitePO refTestSuite = (IRefTestSuitePO) node;
- description = refTestSuite.getTestSuite().getDescription();
- }
- return description;
- }
-
+
/**
*
* @param element the object to check if there is a description
@@ -185,7 +165,8 @@ public class DescriptionView extends ViewPart implements IDataChangedListener {
private void setDescriptionForBrowser(INodePO element) {
String description = m_selectedNode.getDescription();
if (StringUtils.isBlank(description)) {
- description = getReferenceDescription(m_selectedNode);
+ description = DescriptionUtil
+ .getReferenceDescription(m_selectedNode);
}
if (StringUtils.isNotBlank(description)) {
m_browser.setText(m_markupParser.parseToHtml(description));

Back to the top