Bug 500598 - CleanDialog should offer filter option and Select All and
Deselect all instead of checkbox (clean all)
* changes buttons label string
* adds filter
* adds buttons to (de)select all
* adds "always clean all" checkbox
Change-Id: I87aaf96f9a447a9b7aee59872168faf8cc7576e2
Signed-off-by: David Weiser <david.weiser@vogella.com>
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java
index b6b9a10..bc327df 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java
@@ -991,13 +991,14 @@
public static String CleanDialog_buildCleanManual;
public static String CleanDialog_title;
public static String CleanDialog_clean_button_label;
- public static String CleanDialog_cleanAllButton;
- public static String CleanDialog_cleanSelectedButton;
+ public static String CleanDialog_selectAllButton;
+ public static String CleanDialog_deselectedAllButton;
public static String CleanDialog_buildNowButton;
public static String CleanDialog_globalBuildButton;
public static String CleanDialog_buildSelectedProjectsButton;
public static String CleanDialog_cleanSelectedTaskName;
public static String CleanDialog_cleanAllTaskName;
+ public static String CleanDialog_alwaysCleanAllButton;
public static String IDEEncoding_EncodingJob;
public static String IDEEditorsPreferencePage_WorkbenchPreference_viewsRelatedLink;
public static String IDEEditorsPreferencePage_WorkbenchPreference_FileEditorsRelatedLink;
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java
index 4e03877..a67e6df 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java
@@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.ui.internal.ide.dialogs;
+import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
+
import java.util.Arrays;
import java.util.List;
@@ -36,8 +38,6 @@
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
@@ -45,7 +45,9 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.BuildAction;
import org.eclipse.ui.actions.GlobalBuildAction;
@@ -85,11 +87,12 @@
private static final String DIALOG_ORIGIN_Y = "DIALOG_Y_ORIGIN"; //$NON-NLS-1$
private static final String DIALOG_WIDTH = "DIALOG_WIDTH"; //$NON-NLS-1$
private static final String DIALOG_HEIGHT = "DIALOG_HEIGHT"; //$NON-NLS-1$
- private static final String TOGGLE_SELECTED = "TOGGLE_SELECTED"; //$NON-NLS-1$
+ private static final String TOGGLE_SELECTED = "TOGGLE_SELECTED"; //$NON-NLS-1$
private static final String BUILD_NOW = "BUILD_NOW"; //$NON-NLS-1$
private static final String BUILD_ALL = "BUILD_ALL"; //$NON-NLS-1$
- private Button allButton, selectedButton, buildNowButton, globalBuildButton, projectBuildButton;
+ private Button selectAllButton, deselectAllButton, alwaysCleanButton, buildNowButton, globalBuildButton,
+ projectBuildButton;
private CheckboxTableViewer projectNames;
@@ -97,6 +100,9 @@
private IWorkbenchWindow window;
+ private Text filterText;
+ private String filterRegexPattern = ".*"; //$NON-NLS-1$
+
/**
* Gets the text of the clean dialog, depending on whether the
* workspace is currently in autobuild mode.
@@ -128,7 +134,7 @@
@Override
protected void buttonPressed(int buttonId) {
- final boolean cleanAll = allButton.getSelection();
+ final boolean cleanAll = alwaysCleanButton.getSelection();
final boolean buildAll = buildNowButton != null && buildNowButton.getSelection();
final boolean globalBuild = globalBuildButton != null && globalBuildButton.getSelection();
super.buttonPressed(buttonId);
@@ -186,34 +192,58 @@
GridLayout layout = new GridLayout();
layout.marginWidth = layout.marginHeight = 0;
layout.numColumns = 2;
- layout.makeColumnsEqualWidth = true;
+ layout.makeColumnsEqualWidth = false;
area.setLayout(layout);
area.setLayoutData(new GridData(GridData.FILL_BOTH));
- SelectionListener updateEnablement = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateEnablement();
- }
- };
- IDialogSettings settings = getDialogSettings(DIALOG_SETTINGS_SECTION);
- boolean selectSelectedButton= settings.getBoolean(TOGGLE_SELECTED);
+ IDialogSettings settings = getDialogSettings(DIALOG_SETTINGS_SECTION);
+
//first row
- allButton = new Button(area, SWT.RADIO);
- allButton.setText(IDEWorkbenchMessages.CleanDialog_cleanAllButton);
- allButton.setSelection(!selectSelectedButton);
- allButton.addSelectionListener(updateEnablement);
- selectedButton = new Button(area, SWT.RADIO);
- selectedButton.setText(IDEWorkbenchMessages.CleanDialog_cleanSelectedButton);
- selectedButton.setSelection(selectSelectedButton);
- selectedButton.addSelectionListener(updateEnablement);
+ filterText = new Text(area, SWT.SEARCH | SWT.ICON_CANCEL);
+ GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ filterText.setLayoutData(gd);
+ filterText.setFocus();
+ filterText.addModifyListener(e -> {
+ filterRegexPattern = ".*" + filterText.getText() + ".*"; //$NON-NLS-1$ //$NON-NLS-2$
+ projectNames.refresh();
+ });
- //second row
- createProjectSelectionTable(area);
+ selectAllButton = new Button(area, SWT.PUSH);
+ gd = new GridData(SWT.FILL, SWT.CENTER, false, false);
+ selectAllButton.setLayoutData(gd);
+ selectAllButton.setText(IDEWorkbenchMessages.CleanDialog_selectAllButton);
+ selectAllButton.addSelectionListener(widgetSelectedAdapter(e -> {
+ projectNames.setAllChecked(true);
+ selection = projectNames.getCheckedElements();
+ updateEnablement();
+ }));
- //third row
+ // third row
+ createProjectSelectionTable(area);
+
+ deselectAllButton = new Button(area, SWT.PUSH);
+ gd = new GridData(SWT.FILL, SWT.TOP, false, false);
+ deselectAllButton.setLayoutData(gd);
+ deselectAllButton.setText(IDEWorkbenchMessages.CleanDialog_deselectedAllButton);
+ deselectAllButton.addSelectionListener(widgetSelectedAdapter(e -> {
+ projectNames.setAllChecked(false);
+ selection = projectNames.getCheckedElements();
+ updateEnablement();
+ }));
+
+ // fourth row
+ alwaysCleanButton = new Button(area, SWT.CHECK);
+ alwaysCleanButton.setText(IDEWorkbenchMessages.CleanDialog_alwaysCleanAllButton);
+ alwaysCleanButton.setSelection(settings.getBoolean(TOGGLE_SELECTED));
+ alwaysCleanButton.addSelectionListener(widgetSelectedAdapter(e -> updateEnablement()));
+
+ new Label(area, SWT.NONE);
+
+ // fifth row
//only prompt for immediate build if autobuild is off
if (!ResourcesPlugin.getWorkspace().isAutoBuilding()) {
+ SelectionListener updateEnablement = widgetSelectedAdapter(e -> updateEnablement());
+
buildNowButton = new Button(parent, SWT.CHECK);
buildNowButton.setText(IDEWorkbenchMessages.CleanDialog_buildNowButton);
String buildNow = settings.get(BUILD_NOW);
@@ -238,13 +268,8 @@
projectBuildButton.setLayoutData(data);
projectBuildButton.setEnabled(buildNowButton.getSelection());
+ SelectionListener buildRadioSelected = widgetSelectedAdapter(e -> updateBuildRadioEnablement());
- SelectionListener buildRadioSelected = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateBuildRadioEnablement();
- }
- };
globalBuildButton.addSelectionListener(buildRadioSelected);
projectBuildButton.addSelectionListener(buildRadioSelected);
}
@@ -272,7 +297,8 @@
return false;
}
IProject project = (IProject) element;
- if (!project.isAccessible()) {
+ boolean isProjectNameMatchingPattern = project.getName().matches(filterRegexPattern);
+ if (!project.isAccessible() || !isProjectNameMatchingPattern) {
return false;
}
projectHolder[0] = project;
@@ -281,18 +307,16 @@
});
projectNames.setInput(ResourcesPlugin.getWorkspace().getRoot());
GridData data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 2;
+ data.horizontalSpan = 1;
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
data.heightHint = IDialogConstants.ENTRY_FIELD_WIDTH;
projectNames.getTable().setLayoutData(data);
projectNames.setCheckedElements(selection);
Object[] checked = projectNames.getCheckedElements();
- // reveal first checked project unless in "all projects" mode
- if (checked.length > 0 && !allButton.getSelection()) {
+ // reveal first checked project
+ if (checked.length > 0) {
projectNames.reveal(checked[0]);
}
- //table is disabled to start because all button is selected
- projectNames.getTable().setEnabled(selectedButton.getSelection());
projectNames.addCheckStateListener(event -> {
selection = projectNames.getCheckedElements();
updateEnablement();
@@ -320,12 +344,16 @@
}
/**
- * Updates the enablement of the dialog's ok button based
- * on the current choices in the dialog.
- */
+ * Updates the enablement of the dialog elements based on the current
+ * choices in the dialog.
+ */
protected void updateEnablement() {
- projectNames.getTable().setEnabled(selectedButton.getSelection());
- boolean enabled = allButton.getSelection() || selection.length > 0;
+ projectNames.getTable().setEnabled(!alwaysCleanButton.getSelection());
+ selectAllButton.setEnabled(!alwaysCleanButton.getSelection());
+ deselectAllButton.setEnabled(!alwaysCleanButton.getSelection());
+ filterText.setEnabled(!alwaysCleanButton.getSelection());
+
+ boolean enabled = selection.length > 0 || alwaysCleanButton.getSelection();
getButton(OK).setEnabled(enabled);
if (globalBuildButton != null) {
globalBuildButton.setEnabled(buildNowButton.getSelection());
@@ -411,7 +439,8 @@
if (globalBuildButton != null) {
settings.put(BUILD_ALL, globalBuildButton.getSelection());
}
- settings.put(TOGGLE_SELECTED, selectedButton.getSelection());
+
+ settings.put(TOGGLE_SELECTED, alwaysCleanButton.getSelection());
}
/**
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties
index 4986679..b0277f0 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties
@@ -1016,8 +1016,9 @@
CleanDialog_buildCleanManual=Clean discards all build results and states. The next time a build occurs the selected projects will be rebuilt from scratch.
CleanDialog_title=Clean
CleanDialog_clean_button_label=&Clean
-CleanDialog_cleanAllButton=Clean &all projects
-CleanDialog_cleanSelectedButton=Clean projects &selected below
+CleanDialog_selectAllButton=&Select All
+CleanDialog_deselectedAllButton=&Deselect All
+CleanDialog_alwaysCleanAllButton=Always clean all
CleanDialog_buildNowButton=Start a &build immediately
CleanDialog_globalBuildButton=Build the entire &workspace
CleanDialog_buildSelectedProjectsButton=Build only the selected &projects