Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2019-10-15 08:07:19 +0000
committerSarika Sinha2019-10-15 08:21:10 +0000
commit645ef1bda6a975fcdf23cc96ee616ec469f55d7f (patch)
tree5461f1282a8b4f6b30b7cdd338d9073ecbefa5ad /org.eclipse.debug.ui/ui/org/eclipse
parent328ede8151787d91885389f35e43534148b4e2b6 (diff)
downloadeclipse.platform.debug-645ef1bda6a975fcdf23cc96ee616ec469f55d7f.tar.gz
eclipse.platform.debug-645ef1bda6a975fcdf23cc96ee616ec469f55d7f.tar.xz
eclipse.platform.debug-645ef1bda6a975fcdf23cc96ee616ec469f55d7f.zip
Bug 498365 - Add collapse all to Debug ViewI20191015-1800
Change-Id: I0c1febb5633fe00e2892664cdcb4778a1ef8d474 Signed-off-by: Sarika Sinha <sarika.sinha@in.ibm.com>
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchCollapseAllAction.java116
1 files changed, 116 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchCollapseAllAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchCollapseAllAction.java
new file mode 100644
index 000000000..fcd2067a4
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchCollapseAllAction.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2019 IBM Corporation and others.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.actions;
+
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchesListener2;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
+import org.eclipse.debug.internal.ui.views.launch.LaunchView;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.handlers.CollapseAllHandler;
+
+/**
+ * CollapseAllAction for Debug Launch view
+ */
+public class LaunchCollapseAllAction extends AbstractRemoveAllActionDelegate implements ILaunchesListener2 {
+
+ private IViewPart fView;
+ private TreeModelViewer fViewer;
+
+ @Override
+ public void init(IViewPart view) {
+ fView = view;
+ LaunchView debugView = getView().getAdapter(LaunchView.class);
+ if (debugView != null) {
+ debugView.setAction(getActionId(), getAction());
+ }
+ Viewer viewer = ((LaunchView) getView()).getViewer();
+ if (viewer instanceof TreeModelViewer) {
+ fViewer = (TreeModelViewer) viewer;
+ }
+ super.init(view);
+ }
+
+ private IViewPart getView() {
+ return fView;
+ }
+
+ private String getActionId() {
+ return CollapseAllHandler.COMMAND_ID;
+ }
+
+
+ @Override
+ public void run(IAction action) {
+ if (!(getView() instanceof LaunchView)) {
+ return;
+ }
+ if (fViewer != null) {
+ try {
+ fViewer.getControl().setRedraw(false);
+ fViewer.collapseAll();
+ } finally {
+ fViewer.getControl().setRedraw(true);
+ }
+ }
+ }
+
+ @Override
+ protected void initialize() {
+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
+ }
+
+ @Override
+ protected boolean isEnabled() {
+ if (!(getView() instanceof LaunchView)) {
+ return false;
+ }
+ if (fViewer != null && fViewer.getInput() != null) {
+ ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
+ if (launches != null && launches.length > 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void launchesRemoved(ILaunch[] launches) {
+ update();
+ }
+
+ @Override
+ public void launchesAdded(ILaunch[] launches) {
+ update();
+ }
+
+ @Override
+ public void launchesChanged(ILaunch[] launches) {
+ // nothing to do
+ }
+
+ @Override
+ public void launchesTerminated(ILaunch[] launches) {
+ // nothing to do
+ }
+}

Back to the top