aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWim Jongman2010-03-03 16:42:18 (EST)
committerStefan Lay2010-03-05 10:24:53 (EST)
commit589c30c2e9eb14550cc6063d2a801d2cc9b8bfb5 (patch)
tree4e4d693667d5dbedf5f8c69f40ee391d31ecb882
parent4d88f03ad6b97e43712a856f08bc6b45f6ac868b (diff)
downloadegit-589c30c2e9eb14550cc6063d2a801d2cc9b8bfb5.zip
egit-589c30c2e9eb14550cc6063d2a801d2cc9b8bfb5.tar.gz
egit-589c30c2e9eb14550cc6063d2a801d2cc9b8bfb5.tar.bz2
Changed project import page checkboxtable into a filtered tree.refs/changes/69/269/5
With large repositories it is difficult to get a subset of projects because the import projects tree could not be filtered. Now the import projects uses a filtered tree which is commonly used inside Eclipse. - The tree can be filtered with *text like syntax. - If a project is selected it always stays in the view even if it does not match the filter. - If projects are deselected with the "deselect all" button they can be removed from the view if it does not match the filter string. This is done by calling setinput again. This is not done for individual deselections because that did not look right and I am not sure about the setinput overhead on really large repositories I have tested this with the following repositories: git://github.com/smilebase/org.eclipse.mylyn.github.git git://github.com/aptana/studio.git git://ecf1.osuosl.org/home/gitcvs and the egit and jgit repositories It was noticed that some of the aptana and ecf projects (notably the feature projects) were not attached to teaming after import. This is probably not caused by this change. Change-Id: I6fb40104863323aaf66ea355f3574e08fa775b17 Signed-off-by: Wim Jongman <wim.jongman@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/clone/GitProjectsImportPage.java111
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties1
3 files changed, 84 insertions, 32 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index 7f9c5a2..983f0f9 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -17,6 +17,10 @@ import org.eclipse.osgi.util.NLS;
* duplicating strings.
*/
public class UIText extends NLS {
+
+ /** */
+ public static String WizardProjectsImportPage_filterText;
+
/** */
public static String WizardProjectsImportPage_ImportProjectsTitle;
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 6ff3c57..7ca2102 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
@@ -5,6 +5,7 @@ package org.eclipse.egit.ui.internal.clone;
* Copyright (C) 2007, Martin Oberhuber (martin.oberhuber@windriver.com)
* 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>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -42,24 +43,29 @@ import org.eclipse.egit.ui.UIText;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
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.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;
+import org.eclipse.ui.dialogs.PatternFilter;
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
import org.eclipse.ui.internal.ide.StatusUtil;
import org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage;
@@ -192,10 +198,12 @@ public class GitProjectsImportPage extends WizardPage {
}
}
- private CheckboxTreeViewer projectsList;
+ private TreeViewer projectsList;
private ProjectRecord[] selectedProjects = new ProjectRecord[0];
+ final private HashSet<Object> checkedItems = new HashSet<Object>();
+
private IProject[] wsProjects;
// The last selected path to minimize searches
@@ -281,6 +289,8 @@ public class GitProjectsImportPage extends WizardPage {
*/
private void createProjectsList(Composite workArea) {
+ checkedItems.clear();
+
Label title = new Label(workArea, SWT.NONE);
title.setText(UIText.WizardProjectsImportPage_ProjectsListTitle);
@@ -294,7 +304,24 @@ public class GitProjectsImportPage extends WizardPage {
listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
- projectsList = new CheckboxTreeViewer(listComposite, SWT.BORDER);
+ PatternFilter filter = new PatternFilter() {
+
+ @Override
+ public boolean isElementVisible(Viewer viewer, Object element) {
+
+ if (checkedItems.contains(element)) {
+ return true;
+ }
+
+ return super.isElementVisible(viewer, element);
+ }
+
+ };
+
+ FilteredTree filteredTree = new FilteredTree(listComposite, SWT.CHECK
+ | SWT.BORDER, filter, true);
+ filteredTree.setInitialText(UIText.WizardProjectsImportPage_filterText);
+ projectsList = filteredTree.getViewer();
GridData listData = new GridData(GridData.GRAB_HORIZONTAL
| GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
projectsList.getControl().setLayoutData(listData);
@@ -367,6 +394,23 @@ 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.setLabelProvider(new LabelProvider() {
/*
* (non-Javadoc)
@@ -375,23 +419,17 @@ public class GitProjectsImportPage extends WizardPage {
* org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
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();
}
});
- projectsList.addCheckStateListener(new ICheckStateListener() {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged
- * (org.eclipse.jface.viewers.CheckStateChangedEvent)
- */
- public void checkStateChanged(CheckStateChangedEvent event) {
- setPageComplete(projectsList.getCheckedElements().length > 0);
- }
- });
-
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(listComposite);
@@ -416,8 +454,13 @@ public class GitProjectsImportPage extends WizardPage {
selectAll.setText(UIText.WizardProjectsImportPage_selectAll);
selectAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- projectsList.setCheckedElements(selectedProjects);
- setPageComplete(projectsList.getCheckedElements().length > 0);
+ checkedItems.clear();
+ // only the root has children
+ for (final TreeItem item : projectsList.getTree().getItems()) {
+ item.setChecked(true);
+ checkedItems.add(item.getData());
+ }
+ setPageComplete(true);
}
});
Dialog.applyDialogFont(selectAll);
@@ -434,8 +477,12 @@ public class GitProjectsImportPage extends WizardPage {
* .swt.events.SelectionEvent)
*/
public void widgetSelected(SelectionEvent e) {
-
- projectsList.setCheckedElements(new Object[0]);
+ checkedItems.clear();
+ // only the root has children
+ for (final TreeItem item : projectsList.getTree().getItems()) {
+ item.setChecked(false);
+ }
+ projectsList.setInput(this); // filter away selected projects
setPageComplete(false);
}
});
@@ -481,7 +528,8 @@ public class GitProjectsImportPage extends WizardPage {
}
/**
- * Update the list of projects based on path.
+ * Update the list of projects based on path. This will not check any
+ * projects.
*
* @param path
*/
@@ -491,8 +539,7 @@ public class GitProjectsImportPage extends WizardPage {
setMessage(UIText.WizardProjectsImportPage_ImportProjectsDescription);
selectedProjects = new ProjectRecord[0];
projectsList.refresh(true);
- projectsList.setCheckedElements(selectedProjects);
- setPageComplete(projectsList.getCheckedElements().length > 0);
+ setPageComplete(checkedItems.size() > 0);
lastPath = path;
return;
}
@@ -541,6 +588,7 @@ public class GitProjectsImportPage extends WizardPage {
while (filesIterator.hasNext()) {
File file = filesIterator.next();
selectedProjects[index] = new ProjectRecord(file);
+ checkedItems.add(selectedProjects[index]);
index++;
}
} else {
@@ -557,14 +605,13 @@ public class GitProjectsImportPage extends WizardPage {
}
projectsList.refresh(true);
- projectsList.setCheckedElements(getValidProjects());
if (getValidProjects().length < selectedProjects.length) {
setMessage(UIText.WizardProjectsImportPage_projectsInWorkspace,
WARNING);
} else {
setMessage(UIText.WizardProjectsImportPage_ImportProjectsDescription);
}
- setPageComplete(projectsList.getCheckedElements().length > 0);
+ setPageComplete(checkedItems.size() > 0);
}
/**
@@ -579,7 +626,8 @@ public class GitProjectsImportPage extends WizardPage {
* @return boolean <code>true</code> if the operation was completed.
*/
private boolean collectProjectFilesFromDirectory(Collection<File> files,
- File directory, Set<String> directoriesVisited, IProgressMonitor monitor) {
+ File directory, Set<String> directoriesVisited,
+ IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
@@ -645,7 +693,7 @@ public class GitProjectsImportPage extends WizardPage {
* successful.
*/
boolean createProjects() {
- final Object[] selected = projectsList.getCheckedElements();
+ final Object[] selected = checkedItems.toArray();
WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
@@ -745,7 +793,7 @@ public class GitProjectsImportPage extends WizardPage {
*
* @return CheckboxTreeViewer the viewer containing all the projects found
*/
- public CheckboxTreeViewer getProjectsList() {
+ public TreeViewer getProjectsList() {
return projectsList;
}
@@ -781,8 +829,7 @@ public class GitProjectsImportPage extends WizardPage {
validProjects.add(selectedProjects[i]);
}
}
- return validProjects
- .toArray(new ProjectRecord[validProjects.size()]);
+ return validProjects.toArray(new ProjectRecord[validProjects.size()]);
}
/**
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 5bdabee..ca1c132 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -21,6 +21,7 @@ WizardProjectsImportPage_SelectDialogTitle = Select root directory of the projec
WizardProjectImportPage_errorMessage = Creation Problems
WizardProjectsImportPage_CreateProjectsTask = Creating Projects
WizardProjectsImportPage_enableGit = Enable &Git Team operations on imported projects
+WizardProjectsImportPage_filterText = type filter text to filter unselected projects
SharingWizard_windowTitle=Configure Git Repository
SharingWizard_failed=Failed to initialize Git team provider.