aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Schmitt2010-05-12 05:30:54 (EDT)
committerMatthias Sohn2010-05-12 05:38:00 (EDT)
commit23e4fb93d940d1c255cd7ee264f2124f6b3d82bf (patch)
treec3b592f15d8d8a450487acdc10091370225df976
parent796e58c0c00f45d77f7eefcc3acdbd8deed45293 (diff)
downloadegit-23e4fb93d940d1c255cd7ee264f2124f6b3d82bf.zip
egit-23e4fb93d940d1c255cd7ee264f2124f6b3d82bf.tar.gz
egit-23e4fb93d940d1c255cd7ee264f2124f6b3d82bf.tar.bz2
Removed checkedItems field from GitProjectsImportPagerefs/changes/31/531/3
The checkedItems field has been removed from GitProjectsImportPage, and a getCheckedProjects method has been added instead, which computes the set of checked projects based on information available from the UI widgets. This fixes at least one bug that was affecting my work: unchecking projects by using the spacebar didn't work, because there was no KeyListener in place to update the checkedItems field. This lead to the project being unchecked in the UI, but still considered checked by the wizard page, and upon clicking Finish, the wizard would try to import all of those unchecked projects. [ms]: - split off extraction of ProjectRecord into separate change - ported change to current master - added Ryan's copyright Bug: 308284 Change-Id: I5c0889e9f6e95c2c62d96195623499802ce701a1 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Ryan Schmitt <ryan.schmitt@boeing.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java72
1 files changed, 26 insertions, 46 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java
index e9363cf..cdc8671 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java
@@ -6,6 +6,7 @@ package org.eclipse.egit.ui.internal.clone;
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
* Copyright (C) 2010, Wim Jongman <wim.jongman@remainsoftware.com>
+ * Copyright (C) 2010, Ryan Schmitt <ryan.schmitt@boeing.com>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -49,18 +50,14 @@ import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.dialogs.FilteredTree;
@@ -83,8 +80,6 @@ public class GitProjectsImportPage extends WizardPage {
private ProjectRecord[] selectedProjects = new ProjectRecord[0];
- final private HashSet<Object> checkedItems = new HashSet<Object>();
-
private IProject[] wsProjects;
// The last selected path to minimize searches
@@ -131,9 +126,6 @@ public class GitProjectsImportPage extends WizardPage {
* @param workArea
*/
private void createProjectsList(Composite workArea) {
-
- checkedItems.clear();
-
Label title = new Label(workArea, SWT.NONE);
title.setText(UIText.WizardProjectsImportPage_ProjectsListTitle);
@@ -152,9 +144,8 @@ public class GitProjectsImportPage extends WizardPage {
@Override
public boolean isElementVisible(Viewer viewer, Object element) {
- if (checkedItems.contains(element)) {
+ if (getCheckedProjects().contains(element))
return true;
- }
return super.isElementVisible(viewer, element);
}
@@ -213,32 +204,14 @@ public class GitProjectsImportPage extends WizardPage {
});
- projectsList.getTree().addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- if (e.widget instanceof Tree) {
- TreeItem item = ((Tree) e.widget).getItem(new Point(e.x,
- e.y));
- if (item != null) {
- if (item.getChecked())
- checkedItems.add(item.getData());
- else
- checkedItems.remove(item.getData());
- setPageComplete(!checkedItems.isEmpty());
- }
- }
+ projectsList.getTree().addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ checkPageComplete();
}
});
projectsList.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
- // Need to set the checked item state. FIXME This is clumsy.
- for (final TreeItem item : projectsList.getTree().getItems()) {
- if (checkedItems.contains(item.getData()))
- item.setChecked(true);
- else
- item.setChecked(false);
- }
return ((ProjectRecord) element).getProjectLabel();
}
});
@@ -267,12 +240,9 @@ public class GitProjectsImportPage extends WizardPage {
selectAll.setText(UIText.WizardProjectsImportPage_selectAll);
selectAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- checkedItems.clear();
// only the root has children
- for (final TreeItem item : projectsList.getTree().getItems()) {
+ for (final TreeItem item : projectsList.getTree().getItems())
item.setChecked(true);
- checkedItems.add(item.getData());
- }
setPageComplete(true);
}
});
@@ -283,11 +253,8 @@ public class GitProjectsImportPage extends WizardPage {
deselectAll.setText(UIText.WizardProjectsImportPage_deselectAll);
deselectAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- checkedItems.clear();
- // only the root has children
- for (final TreeItem item : projectsList.getTree().getItems()) {
+ for (final TreeItem item : projectsList.getTree().getItems())
item.setChecked(false);
- }
projectsList.setInput(this); // filter away selected projects
setPageComplete(false);
}
@@ -331,7 +298,7 @@ public class GitProjectsImportPage extends WizardPage {
if (path == null || path.length() == 0) {
selectedProjects = new ProjectRecord[0];
projectsList.refresh(true);
- setPageComplete(checkedItems.size() > 0);
+ checkPageComplete();
lastPath = path;
setErrorMessage(UIText.GitProjectsImportPage_NoProjectsMessage);
return;
@@ -371,12 +338,10 @@ public class GitProjectsImportPage extends WizardPage {
selectedProjects = new ProjectRecord[files.size()];
int index = 0;
monitor.worked(50);
- monitor
- .subTask(UIText.WizardProjectsImportPage_ProcessingMessage);
+ monitor.subTask(UIText.WizardProjectsImportPage_ProcessingMessage);
while (filesIterator.hasNext()) {
File file = filesIterator.next();
selectedProjects[index] = new ProjectRecord(file);
- checkedItems.add(selectedProjects[index]);
index++;
}
@@ -403,7 +368,7 @@ public class GitProjectsImportPage extends WizardPage {
setMessage(UIText.WizardProjectsImportPage_ImportProjectsDescription);
}
enableSelectAllButtons();
- setPageComplete(checkedItems.size() > 0);
+ checkPageComplete();
}
private void enableSelectAllButtons() {
@@ -496,7 +461,7 @@ public class GitProjectsImportPage extends WizardPage {
* successful.
*/
boolean createProjects() {
- final Object[] selected = checkedItems.toArray();
+ final Object[] selected = getCheckedProjects().toArray();
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
@@ -640,4 +605,19 @@ public class GitProjectsImportPage extends WizardPage {
return false;
}
+ /**
+ * @return All the currently checked projects in the projectsList tree
+ */
+ private HashSet<Object> getCheckedProjects() {
+ HashSet<Object> ret = new HashSet<Object>();
+ for (TreeItem item : projectsList.getTree().getItems())
+ if (item.getChecked())
+ ret.add(item.getData());
+
+ return ret;
+ }
+
+ private void checkPageComplete() {
+ setPageComplete(!getCheckedProjects().isEmpty());
+ }
}