Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarvin Mueller2017-12-11 09:22:07 -0500
committerMarvin Mueller2017-12-11 09:50:59 -0500
commit281c28a96f69bf3a4a7c99fe0ae46f9549b35f87 (patch)
treefdbc2c1719ce5e8a98b68e33197ce5f8cf7118e4
parent00e77d725efc1453df8e091640bd3e0ea9a7c7de (diff)
downloadorg.eclipse.jubula.core-281c28a96f69bf3a4a7c99fe0ae46f9549b35f87.tar.gz
org.eclipse.jubula.core-281c28a96f69bf3a4a7c99fe0ae46f9549b35f87.tar.xz
org.eclipse.jubula.core-281c28a96f69bf3a4a7c99fe0ae46f9549b35f87.zip
After Refreshing the project TCB and TSB hold their expanded state
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestCaseBrowser.java24
-rw-r--r--org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java17
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/TreeViewContainerGUIController.java2
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExpandBranchHandler.java94
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java1
-rw-r--r--org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties1
6 files changed, 119 insertions, 20 deletions
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestCaseBrowser.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestCaseBrowser.java
index 3aea9aef0..32fc7415f 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestCaseBrowser.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestCaseBrowser.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.jubula.client.ui.rcp.views;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.GroupMarker;
@@ -231,10 +234,25 @@ public class TestCaseBrowser extends AbstractJBTreeView
*/
protected void rebuildTree() {
IProjectPO activeProject = GeneralStorage.getInstance().getProject();
+ Object[] expandedElements = getTreeViewer().getExpandedElements();
+ List<Object> objectsToExpand = new ArrayList<>();
+ for (Object object : expandedElements) {
+ if (object instanceof IPersistentObject) {
+ IPersistentObject cat = (IPersistentObject) object;
+ Object find = GeneralStorage.getInstance().getMasterSession()
+ .find(object.getClass(), cat.getId());
+ objectsToExpand.add(find);
+ }
+ }
if (activeProject != null) {
- getTreeViewer().setInput(
- new INodePO[] {activeProject.getSpecObjCont()});
- getTreeViewer().expandToLevel(DEFAULT_EXPANSION);
+ getTreeViewer()
+ .setInput(new INodePO[] { activeProject.getSpecObjCont() });
+ if (objectsToExpand.size() > 0) {
+ getTreeViewer().setExpandedElements(objectsToExpand
+ .toArray(new Object[objectsToExpand.size()]));
+ } else {
+ getTreeViewer().expandToLevel(DEFAULT_EXPANSION);
+ }
} else {
getTreeViewer().setInput(null);
}
diff --git a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java
index 646ee5ba2..6077b631e 100644
--- a/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java
+++ b/org.eclipse.jubula.client.ui.rcp/src/org/eclipse/jubula/client/ui/rcp/views/TestSuiteBrowser.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.jubula.client.ui.rcp.views;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
@@ -226,7 +229,21 @@ public class TestSuiteBrowser extends AbstractJBTreeView implements
* {@inheritDoc}
*/
protected void rebuildTree() {
+ Object[] expandedElements = getTreeViewer().getExpandedElements();
+ List<Object> objectsToExpand = new ArrayList<>();
+ for (Object object : expandedElements) {
+ if (object instanceof IPersistentObject) {
+ IPersistentObject cat = (IPersistentObject) object;
+ Object find = GeneralStorage.getInstance().getMasterSession()
+ .find(object.getClass(), cat.getId());
+ objectsToExpand.add(find);
+ }
+ }
setViewerInput();
+ if (objectsToExpand.size() > 0) {
+ getTreeViewer().setExpandedElements(objectsToExpand
+ .toArray(new Object[objectsToExpand.size()]));
+ }
}
/**
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/TreeViewContainerGUIController.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/TreeViewContainerGUIController.java
index 08da9fe68..d129c7d41 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/TreeViewContainerGUIController.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/controllers/TreeViewContainerGUIController.java
@@ -72,7 +72,7 @@ public class TreeViewContainerGUIController {
IStructuredSelection selection =
(IStructuredSelection) tv.getSelection();
for (Object obj: selection.toArray()) {
- tv.expandToLevel(obj, AbstractTreeViewer.ALL_LEVELS);
+ tv.expandToLevel(obj, 10);
}
}
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExpandBranchHandler.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExpandBranchHandler.java
index 0177c4a9b..682d6a6ec 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExpandBranchHandler.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/handlers/ExpandBranchHandler.java
@@ -1,23 +1,31 @@
/*******************************************************************************
- * Copyright (c) 2017 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
+ * Copyright (c) 2017 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
+ * Contributors: BREDEX GmbH - initial API and implementation and/or initial
+ * documentation
*******************************************************************************/
package org.eclipse.jubula.client.ui.handlers;
+import java.lang.reflect.InvocationTargetException;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jubula.client.ui.controllers.TreeViewContainerGUIController;
+import org.eclipse.jubula.client.ui.i18n.Messages;
import org.eclipse.jubula.client.ui.views.IMultiTreeViewerContainer;
import org.eclipse.jubula.client.ui.views.ITreeViewerContainer;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -26,20 +34,74 @@ import org.eclipse.ui.handlers.HandlerUtil;
*/
public class ExpandBranchHandler extends AbstractHandler {
+ /** the logger */
+ private static Logger log =
+ LoggerFactory.getLogger(ExpandBranchHandler.class);
+
/**
- * {@inheritDoc}
+ * Since expanding the Branch can cost quite some time it is run in a
+ * process
*/
- public Object execute(ExecutionEvent event) {
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- TreeViewer activeTreeViewer = null;
- if (part instanceof IMultiTreeViewerContainer) {
- activeTreeViewer = ((IMultiTreeViewerContainer) part)
- .getActiveTreeViewer();
- } else if (part instanceof ITreeViewerContainer) {
- activeTreeViewer = ((ITreeViewerContainer) part).getTreeViewer();
+ private class ExpandBranchRunnable implements IRunnableWithProgress {
+ /** the event */
+ private ExecutionEvent m_execEvent;
+
+ /**
+ * @param event the {@link ExecutionEvent} to get the {@link TreeViewer}
+ * from
+ */
+ public ExpandBranchRunnable(ExecutionEvent event) {
+ m_execEvent = event;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void run(IProgressMonitor monitor) {
+ monitor.beginTask(Messages.ExpandBranchMessage,
+ IProgressMonitor.UNKNOWN);
+ IWorkbenchPart part = HandlerUtil.getActivePart(m_execEvent);
+ TreeViewer activeTreeViewer = null;
+ if (part instanceof IMultiTreeViewerContainer) {
+ activeTreeViewer = ((IMultiTreeViewerContainer) part)
+ .getActiveTreeViewer();
+ } else if (part instanceof ITreeViewerContainer) {
+ activeTreeViewer =
+ ((ITreeViewerContainer) part).getTreeViewer();
+ }
+ expandTree(activeTreeViewer);
+ }
+
+ /**
+ * executes the action in the ui Thread
+ *
+ * @param activeTreeViewer the {@link TreeViewer} to expand
+ */
+ private void expandTree(final TreeViewer activeTreeViewer) {
+ Display.getDefault().syncExec(new Runnable() {
+ /**
+ * {@inheritDoc}
+ */
+ public void run() {
+ TreeViewContainerGUIController
+ .expandBranch(activeTreeViewer);
+ }
+ });
}
+ }
- TreeViewContainerGUIController.expandBranch(activeTreeViewer);
+ /**
+ * {@inheritDoc}
+ */
+ public Object execute(final ExecutionEvent event) {
+ try {
+ PlatformUI.getWorkbench().getProgressService().run(true, false,
+ new ExpandBranchRunnable(event));
+ } catch (InvocationTargetException e) {
+ log.error("Error during expanding tree", e); //$NON-NLS-1$
+ } catch (InterruptedException e) {
+ log.error("Error during expanding tree", e); //$NON-NLS-1$
+ }
return null;
}
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
index d90cdbc37..f89a26e57 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/Messages.java
@@ -67,6 +67,7 @@ public class Messages extends NLS {
public static String EnterCommentDialogTitleLabel;
public static String ErrorFetchingTestResultInformation;
public static String ErrorOccurredWhileExecutingCommand;
+ public static String ExpandBranchMessage;
public static String InputElementHasInvalidTypeReturningEmptyArray;
public static String JobFilterSummaryView;
public static String NoEditorInputCouldBeCreated;
diff --git a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
index 9ecebb9b2..8c07d877c 100644
--- a/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
+++ b/org.eclipse.jubula.client.ui/src/org/eclipse/jubula/client/ui/i18n/messages.properties
@@ -53,6 +53,7 @@ EnterCommentDialogTitle=Enter a Comment
EnterCommentDialogTitleLabel=Title\:
ErrorFetchingTestResultInformation=Error occurred while fetching Test Result information
ErrorOccurredWhileExecutingCommand=Error occurred while executing command
+ExpandBranchMessage=Expanding Tree branch
InputElementHasInvalidTypeReturningEmptyArray=Input element has invalid type. Returning empty array.
JobFilterSummaryView=Filtering Summary View...
NoEditorInputCouldBeCreated=No editor input could be created.

Back to the top