From 82b1a286d264961295b059fae19980f05a6ff544 Mon Sep 17 00:00:00 2001 From: Bogdan Gheorghe Date: Wed, 30 Mar 2005 19:47:40 +0000 Subject: [PATCH] Patch for Devin Steffler: IndexViewer update --- .../icons/indexer_view/grouped_all.gif | Bin 0 -> 822 bytes .../icons/indexer_view/grouped_decl.gif | Bin 0 -> 821 bytes .../icons/indexer_view/grouped_ref.gif | Bin 0 -> 822 bytes .../icons/indexer_view/grouped_type.gif | Bin 0 -> 819 bytes .../icons/indexer_view/stats.gif | Bin 0 -> 107 bytes .../IndexerView/FilterIndexerViewDialog.java | 269 ++++++++++++++++-- .../tests/IndexerView/IndexerNodeParent.java | 10 +- .../cdt/ui/tests/IndexerView/IndexerView.java | 32 ++- .../IndexerView/IndexerViewPluginImages.java | 10 + .../IndexerView/OpenIndexerViewAction.java | 2 - 10 files changed, 296 insertions(+), 27 deletions(-) create mode 100644 core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_all.gif create mode 100644 core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_decl.gif create mode 100644 core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_ref.gif create mode 100644 core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_type.gif create mode 100644 core/org.eclipse.cdt.ui.tests/icons/indexer_view/stats.gif diff --git a/core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_all.gif b/core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_all.gif new file mode 100644 index 0000000000000000000000000000000000000000..0f5b4f1844b6e9ef4190bb6a9c9b151e796a0d19 GIT binary patch literal 822 zcmZ?wbhEHbWM|-D_|Cxa|Nnmmh6aXFFd70QG6Zx$z6Rw51`cTkMh+f@4G9g+tc(IG V8379qHgm}G&G9f?c%Xs78UPG!4-EhS literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_decl.gif b/core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_decl.gif new file mode 100644 index 0000000000000000000000000000000000000000..02861a89a1fedcfe99381ae320f4a61563110c5a GIT binary patch literal 821 zcmZ?wbhEHbWM|-D_|Cxa|Nnmmh6aXFFd70QG6Zx$z6Rw51`a6(Mh+Pbg9gVYMg|!j U3xkD++IYmZrg#)2I51cP0PLI%R{#J2 literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_ref.gif b/core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_ref.gif new file mode 100644 index 0000000000000000000000000000000000000000..936ad6e3d41a6644b63b05bb777acf84dadf675c GIT binary patch literal 822 zcmZ?wbhEHbWM|-D_|Cxa|Nnmmh6aXFFd70QG6Zx$z6Rw51`cTkMh+PbgNB0)%z{h- VJ3b^FYGo0Ws<|;i;a~%UH2@Io53B$H literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_type.gif b/core/org.eclipse.cdt.ui.tests/icons/indexer_view/grouped_type.gif new file mode 100644 index 0000000000000000000000000000000000000000..efc48fbde4c03f5c17ab1b3bccf507224ed7c298 GIT binary patch literal 819 zcmZ?wbhEHbWM|-D_|Cxa|Nnmmh6aXFFd70QG6Zx$z6Rw51`Y`ZMh+Pbg9gWD7G?pR R9Rdx9TKR>|R3ro#tO3xk3;6&5 literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui.tests/icons/indexer_view/stats.gif b/core/org.eclipse.cdt.ui.tests/icons/indexer_view/stats.gif new file mode 100644 index 0000000000000000000000000000000000000000..0c5f2085409de04f5dc5916c6693ed06d4f1d2f0 GIT binary patch literal 107 zcmZ?wbhEHb6krfwSi}GX|LyJf$H(uluiwAy)QA6I02EdH$->CMz{a2hQUX%Tz-*AQ z>(0M`sg{dn8bq?W7!Ib1x-94o5fwdT-f`i{p^s-O4^-dQ{&$J@n)-t7r6F_NnHa1A DC{ihS literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/FilterIndexerViewDialog.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/FilterIndexerViewDialog.java index 9593d3f90fb..87d53ddec35 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/FilterIndexerViewDialog.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/IndexerView/FilterIndexerViewDialog.java @@ -14,6 +14,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoMessages; @@ -31,6 +32,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; @@ -40,6 +42,15 @@ import org.eclipse.swt.widgets.Text; */ public class FilterIndexerViewDialog extends Dialog { + private static final int DECL_BUTTON_ID = 4; + private static final int REF_BUTTON_ID = 3; + private static final int TYPE_BUTTON_ID = 2; + private static final int ALL_BUTTON_ID = 1; + private static final String GROUPED_SELECTIONS_LABEL = "Grouped Selections:"; //$NON-NLS-1$ + private static final String ALL_BUTTON = "All"; //$NON-NLS-1$ + private static final String TYPE_BUTTON = "type"; //$NON-NLS-1$ + private static final String DECL_BUTTON = "Decl"; //$NON-NLS-1$ + private static final String REF_BUTTON = "Ref"; //$NON-NLS-1$ private static final String BLANK_STRING = ""; //$NON-NLS-1$ private static final String PAGE_SIZE_ = "Page Size:"; //$NON-NLS-1$ private static final String TYPESELECTIONDIALOG_FILTERLABEL = "TypeSelectionDialog.filterLabel"; //$NON-NLS-1$ @@ -51,6 +62,7 @@ public class FilterIndexerViewDialog extends Dialog { private String pageSize = BLANK_STRING; //$NON-NLS-1$ Text pageSizeText = null; protected Collection fFilterMatcher = new HashSet(); + protected Collection groupedButtonSelections = new HashSet(); private String message = "Filter Indexer Results (. = any character, .* = any string):"; //$NON-NLS-1$ @@ -127,18 +139,27 @@ public class FilterIndexerViewDialog extends Dialog { private String projName = null; - private static final int[] fAllTypes = { ENTRY_REF, ENTRY_TYPE_REF, - ENTRY_FUNCTION_REF, ENTRY_FUNCTION_DECL, // ENTRY_TYPE_DECL, - ENTRY_CONSTRUCTOR_REF, ENTRY_CONSTRUCTOR_DECL, ENTRY_NAMESPACE_REF, - ENTRY_NAMESPACE_DECL, ENTRY_FIELD_REF, ENTRY_FIELD_DECL, - ENTRY_ENUMTOR_REF, ENTRY_ENUMTOR_DECL, ENTRY_METHOD_REF, - ENTRY_METHOD_DECL, ENTRY_MACRO_DECL, ENTRY_INCLUDE_REF, - ENTRY_SUPER_REF, ENTRY_TYPE_DECL_T, ENTRY_TYPE_DECL_C, - ENTRY_TYPE_DECL_V, ENTRY_TYPE_DECL_S, ENTRY_TYPE_DECL_E, - ENTRY_TYPE_DECL_U, ENTRY_TYPE_DECL_D, ENTRY_TYPE_DECL_F, - ENTRY_TYPE_DECL_G, ENTRY_TYPE_DECL_H, ENTRY_TYPE_DECL_I }; - + // this also determines the order that the buttons are displayed + private static final int[] fAllTypes = { // ENTRY_TYPE_DECL, + ENTRY_REF, ENTRY_SUPER_REF, ENTRY_MACRO_DECL, + ENTRY_FUNCTION_DECL, ENTRY_NAMESPACE_DECL, ENTRY_CONSTRUCTOR_DECL, + ENTRY_FUNCTION_REF, ENTRY_NAMESPACE_REF, ENTRY_CONSTRUCTOR_REF, + ENTRY_FIELD_DECL, ENTRY_ENUMTOR_DECL, ENTRY_METHOD_DECL, + ENTRY_FIELD_REF, ENTRY_ENUMTOR_REF, ENTRY_METHOD_REF, + ENTRY_TYPE_REF, ENTRY_TYPE_DECL_T, ENTRY_TYPE_DECL_C, + ENTRY_TYPE_DECL_V, ENTRY_TYPE_DECL_S, ENTRY_TYPE_DECL_E, + ENTRY_TYPE_DECL_U, ENTRY_TYPE_DECL_D, ENTRY_TYPE_DECL_F, + ENTRY_TYPE_DECL_G, ENTRY_TYPE_DECL_H, ENTRY_TYPE_DECL_I, + ENTRY_INCLUDE_REF }; + private Set fKnownTypes = new HashSet(fAllTypes.length); + + // keep track of the buttons to programmatically change their state + protected Button[] buttons = new Button[fAllTypes.length]; + protected Button allButton = null; + protected Button typeButton = null; + protected Button declButton = null; + protected Button refButton = null; protected FilterIndexerViewDialog(Shell parentShell, IndexerNodeParent root, String projName) { super(parentShell); @@ -190,6 +211,7 @@ public class FilterIndexerViewDialog extends Dialog { createMessageArea(composite); createFilterText(composite); createTypeFilterArea(composite); + createGroupedArea(composite); createPageSizeArea(composite); return composite; @@ -334,6 +356,7 @@ public class FilterIndexerViewDialog extends Dialog { final Integer fTypeObject = typeObject; Button checkbox = new Button(composite, SWT.CHECK); checkbox.setFont(composite.getFont()); + checkbox.setText(name); checkbox.setImage(icon); checkbox.setSelection(fFilterMatcher.contains(fTypeObject)); checkbox.addSelectionListener(new SelectionAdapter() { @@ -351,6 +374,8 @@ public class FilterIndexerViewDialog extends Dialog { Label label = new Label(composite, SWT.LEFT); label.setFont(composite.getFont()); label.setText(name); + + buttons = (Button[])ArrayUtil.append(Button.class, buttons, checkbox); } private Image getTypeIcon(int type) @@ -444,19 +469,198 @@ public class FilterIndexerViewDialog extends Dialog { if (fKnownTypes.contains(typeObject)) createTypeCheckbox(upperRow, typeObject); } + } - Composite lowerRow = new Composite(parent, SWT.NONE); - GridLayout lowerLayout = new GridLayout(1, true); - lowerLayout.verticalSpacing = 2; - lowerLayout.marginHeight = 0; + private void createGroupedArea(Composite parent) { + createLabel(parent, GROUPED_SELECTIONS_LABEL); + + Composite upperRow = new Composite(parent, SWT.NONE); + GridLayout upperLayout = new GridLayout(8, true); + upperLayout.verticalSpacing = 2; + upperLayout.marginHeight = 0; upperLayout.marginWidth = 0; - lowerRow.setLayout(lowerLayout); + upperRow.setLayout(upperLayout); - Composite composite = new Composite(lowerRow, SWT.NONE); - GridLayout layout = new GridLayout(2, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - composite.setLayout(layout); + allButton = new Button(upperRow, SWT.CHECK); + allButton.setFont(upperRow.getFont()); + allButton.setText(ALL_BUTTON); + allButton.setImage(IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_GROUPED_ALL)); + allButton.setSelection(groupedButtonSelections.contains(new Integer(ALL_BUTTON_ID))); + allButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + if (e.widget instanceof Button) { + Button aCheckbox = (Button) e.widget; + boolean isChecked = aCheckbox.getSelection(); + + Event event = new Event(); + + // select/deselect all of the buttons in the buttons array + for(int i=0; i= 0) { + if (isChecked) buttons[i].setSelection(true); + else buttons[i].setSelection(false); + event.widget = buttons[i]; + buttons[i].notifyListeners(SWT.Selection, event); + } + } + } + + if (isChecked) groupedButtonSelections.add(new Integer(TYPE_BUTTON_ID)); + else groupedButtonSelections.remove(new Integer(TYPE_BUTTON_ID)); + + checkAllButton(); + } + } + }); + + label = new Label(upperRow, SWT.LEFT); + label.setFont(upperRow.getFont()); + label.setText(TYPE_BUTTON); + + declButton = new Button(upperRow, SWT.CHECK); + declButton.setFont(upperRow.getFont()); + declButton.setText(DECL_BUTTON); + declButton.setImage(IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_GROUPED_DECL)); + declButton.setSelection(groupedButtonSelections.contains(new Integer(DECL_BUTTON_ID))); + declButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + if (e.widget instanceof Button) { + Button aCheckbox = (Button) e.widget; + boolean isChecked = aCheckbox.getSelection(); + + Event event = new Event(); + + // select/deselect all of the buttons in the buttons array + for(int i=0; i= 0) { + if (isChecked) buttons[i].setSelection(true); + else buttons[i].setSelection(false); + event.widget = buttons[i]; + buttons[i].notifyListeners(SWT.Selection, event); + } + } + } + + if (isChecked) groupedButtonSelections.add(new Integer(DECL_BUTTON_ID)); + else groupedButtonSelections.remove(new Integer(DECL_BUTTON_ID)); + + checkAllButton(); + } + } + }); + + label = new Label(upperRow, SWT.LEFT); + label.setFont(upperRow.getFont()); + label.setText(DECL_BUTTON); + + refButton = new Button(upperRow, SWT.CHECK); + refButton.setFont(upperRow.getFont()); + refButton.setText(REF_BUTTON); + refButton.setImage(IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_GROUPED_REF)); + refButton.setSelection(groupedButtonSelections.contains(new Integer(REF_BUTTON_ID))); + refButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + if (e.widget instanceof Button) { + Button aCheckbox = (Button) e.widget; + boolean isChecked = aCheckbox.getSelection(); + + Event event = new Event(); + + // select/deselect all of the buttons in the buttons array + for(int i=0; i= 0) { + if (isChecked) buttons[i].setSelection(true); + else buttons[i].setSelection(false); + event.widget = buttons[i]; + buttons[i].notifyListeners(SWT.Selection, event); + } + } + } + + if (isChecked) groupedButtonSelections.add(new Integer(REF_BUTTON_ID)); + else groupedButtonSelections.remove(new Integer(REF_BUTTON_ID)); + + checkAllButton(); + } + } + }); + + label = new Label(upperRow, SWT.LEFT); + label.setFont(upperRow.getFont()); + label.setText(REF_BUTTON); + } + + void checkAllButton() { + // alter the state of allButton if everything is checked or not + boolean isChecked=true; + for(int i=0; i