diff options
| author | Vikas Chandra | 2021-12-23 18:06:28 +0000 |
|---|---|---|
| committer | Vikas Chandra | 2021-12-24 12:50:00 +0000 |
| commit | f84a4905bf99339c098062879a11cbb4fa7f37ea (patch) | |
| tree | 64d9c41f962ae60a09093304c5915d17f115ea38 | |
| parent | 6bae1aacec49bc95586e9d47b3d2a4f6eab6e536 (diff) | |
| download | eclipse.pde.ui-f84a4905bf99339c098062879a11cbb4fa7f37ea.tar.gz eclipse.pde.ui-f84a4905bf99339c098062879a11cbb4fa7f37ea.tar.xz eclipse.pde.ui-f84a4905bf99339c098062879a11cbb4fa7f37ea.zip | |
Bug 577668 - Add Expand and collapse buttons to Target editorI20211226-1800I20211225-1800I20211224-1800
Change-Id: Ic5582e53c6b9bf51bc1c58be76a2c5fc0fbeead0
Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
Reviewed-on: https://git.eclipse.org/r/c/pde/eclipse.pde.ui/+/189113
Tested-by: PDE Bot <pde-bot@eclipse.org>
3 files changed, 71 insertions, 3 deletions
diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java index bedd853aa1..13fe2314f3 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/Messages.java @@ -61,6 +61,8 @@ public class Messages extends NLS { public static String BundleContainerTable_Btn_Text_Remove; public static String BundleContainerTable_Btn_Text_Update; public static String BundleContainerTable_Btn_Text_Reload; + public static String BundleContainerTable_Btn_Text_ExpandAll; + public static String BundleContainerTable_Btn_Text_CollapseAll; public static String BundleContainerTable_8; public static String BundleContainerTable_9; public static String BundleContainerTable_10; diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java index e64edb6818..380d33b969 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/TargetLocationsGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2020 IBM Corporation and others. + * Copyright (c) 2009, 2021 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -38,8 +38,7 @@ import org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor; import org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionContentPage; import org.eclipse.pde.ui.target.ITargetLocationHandler; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.*; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; @@ -90,6 +89,7 @@ public class TargetLocationsGroup { private Button fRemoveButton; private Button fUpdateButton; private Button fReloadButton; + private Button fExpandCollapseButton; private Button fShowContentButton; private ITargetDefinition fTarget; @@ -191,6 +191,7 @@ public class TargetLocationsGroup { fUpdateButton.setToolTipText(Messages.TargetLocationsGroup_update); fReloadButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Reload, SWT.PUSH); fReloadButton.setToolTipText(Messages.TargetLocationsGroup_reload); + fExpandCollapseButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_Btn_Text_ExpandAll, SWT.PUSH); fShowContentButton = toolkit.createButton(comp, Messages.TargetLocationsGroup_1, SWT.CHECK); @@ -229,6 +230,7 @@ public class TargetLocationsGroup { fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Remove, null); fUpdateButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Update, null); fReloadButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_Reload, null); + fExpandCollapseButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_Btn_Text_ExpandAll, null); fShowContentButton = SWTFactory.createCheckButton(comp, Messages.TargetLocationsGroup_1, null, false, 2); @@ -278,8 +280,45 @@ public class TargetLocationsGroup { fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); createContextMenu(fTreeViewer.getTree()); + fTreeViewer.getTree().addMouseListener(new MouseListener() { + @Override + public void mouseDoubleClick(MouseEvent e) { + setExpandCollapseState(); + } + @Override + public void mouseDown(MouseEvent e) { + } + @Override + public void mouseUp(MouseEvent e) { + setExpandCollapseState(); + } + + }); + fTreeViewer.getTree().addKeyListener(new KeyListener() { + + @Override + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent e) { + setExpandCollapseState(); + } + + }); } + private void setExpandCollapseState() { + if (fTreeViewer == null) + return; + if (fTreeViewer.getVisibleExpandedElements().length == 0) { + fExpandCollapseButton.setText(Messages.BundleContainerTable_Btn_Text_ExpandAll); + } else { + fExpandCollapseButton.setText(Messages.BundleContainerTable_Btn_Text_CollapseAll); + } + + } private void createContextMenu(Tree tree) { fCopySelectionAction = new CopyTreeSelectionAction(tree); @@ -319,11 +358,17 @@ public class TargetLocationsGroup { fReloadButton.setEnabled(true); SWTFactory.setButtonDimensionHint(fReloadButton); + fExpandCollapseButton.addSelectionListener(widgetSelectedAdapter(e -> toggleCollapse())); + fExpandCollapseButton.setLayoutData(new GridData()); + fExpandCollapseButton.setEnabled(true); + SWTFactory.setButtonDimensionHint(fExpandCollapseButton); + fShowContentButton.addSelectionListener(widgetSelectedAdapter(e -> { ((TargetLocationContentProvider) fTreeViewer.getContentProvider()) .setShowLocationContent(fShowContentButton.getSelection()); fTreeViewer.refresh(); fTreeViewer.expandAll(); + fExpandCollapseButton.setText(Messages.BundleContainerTable_Btn_Text_CollapseAll); })); fShowContentButton.setLayoutData(new GridData()); SWTFactory.setButtonDimensionHint(fShowContentButton); @@ -338,7 +383,10 @@ public class TargetLocationsGroup { */ public void setInput(ITargetDefinition target) { fTarget = target; + boolean isCollapsed = fTreeViewer.getVisibleExpandedElements().length == 0; fTreeViewer.setInput(fTarget); + if (isCollapsed) + fTreeViewer.collapseAll(); updateButtons(); } @@ -461,6 +509,9 @@ public class TargetLocationsGroup { fRemoveButton.setData(BUTTON_STATE, DeleteButtonState.NONE); fUpdateButton.setEnabled(false); fEditButton.setEnabled(false); + if(fTreeViewer !=null) { + setExpandCollapseState(); + } return; } boolean canRemove = false; @@ -512,6 +563,19 @@ public class TargetLocationsGroup { } + private void toggleCollapse() { + if (fTreeViewer == null) + return; + if (fTreeViewer.getVisibleExpandedElements().length == 0) { + fTreeViewer.expandAll(); + fExpandCollapseButton.setText(Messages.BundleContainerTable_Btn_Text_CollapseAll); + } else { + fTreeViewer.collapseAll(); + fExpandCollapseButton.setText(Messages.BundleContainerTable_Btn_Text_ExpandAll); + } + + } + /** * Informs the reporter for this table that something has changed and is * dirty. diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties index 7a26c3b212..75d1156a9f 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/shared/target/messages.properties @@ -54,6 +54,8 @@ BundleContainerTable_Btn_Text_Edit=&Edit... BundleContainerTable_Btn_Text_Remove=&Remove BundleContainerTable_Btn_Text_Update=&Update BundleContainerTable_Btn_Text_Reload=Re&load +BundleContainerTable_Btn_Text_ExpandAll=Ex&pand All +BundleContainerTable_Btn_Text_CollapseAll=&Collapse All BundleContainerTable_8=Unspecified Site # Styled label section describing number of plug-ins in the location |
