Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java
new file mode 100644
index 0000000000..956c7dee2c
--- /dev/null
+++ b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others. 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: IBM Corporation - initial API and implementation
+ ****************************************************************************/
+
+
+package org.eclipse.wst.xml.ui.internal.tabletree;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.wst.xml.internal.ui.XMLEditorPluginImageHelper;
+import org.eclipse.wst.xml.internal.ui.XMLEditorPluginImages;
+import org.eclipse.wst.xml.ui.util.XMLCommonResources;
+
+
+
+public class ViewerExpandCollapseAction extends Action {
+
+ protected boolean isExpandAction;
+ protected AbstractTreeViewer viewer = null;
+
+ public ViewerExpandCollapseAction(boolean isExpandAction) {
+ this.isExpandAction = isExpandAction;
+ if (isExpandAction) {
+ ImageDescriptor e_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_ETOOL_EXPANDALL);
+ ImageDescriptor d_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_DTOOL_EXPANDALL);
+
+ setImageDescriptor(e_imageDescriptor);
+ setDisabledImageDescriptor(d_imageDescriptor);
+ setToolTipText(XMLCommonResources.getInstance().getString("_UI_INFO_EXPAND_ALL")); //$NON-NLS-1$
+ } else {
+ ImageDescriptor e_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_ETOOL_COLLAPSEALL);
+ ImageDescriptor d_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_DTOOL_COLLAPSEALL);
+
+ setImageDescriptor(e_imageDescriptor);
+ setDisabledImageDescriptor(d_imageDescriptor);
+ setToolTipText(XMLCommonResources.getInstance().getString("_UI_INFO_COLLAPSE_ALL")); //$NON-NLS-1$
+ }
+ }
+
+ public void setViewer(AbstractTreeViewer viewer) {
+ this.viewer = viewer;
+ }
+
+ public void run() {
+ if (viewer != null) {
+ // temporarily set the visibility to false
+ // this has a HUGE performance benefit
+ boolean isVisible = viewer.getControl().getVisible();
+ viewer.getControl().setVisible(false);
+
+ if (isExpandAction) {
+ viewer.expandAll();
+ } else {
+ viewer.collapseAll();
+ }
+
+ // restore the previous visibility state
+ //
+ viewer.getControl().setVisible(isVisible);
+ }
+ }
+}
+

Back to the top