[Importer] Improve proposal tree
* Use relative path
* Show strategy that will be used on a 2nd column
Signed-off-by: Mickael Istria <mistria@redhat.com>
Change-Id: I017232f2b3d9bd35e82d331ca5bbf0ef5666ab6d
diff --git a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/ImportProposalsWizardPage.java b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/ImportProposalsWizardPage.java
index f67239e..bbec13a 100644
--- a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/ImportProposalsWizardPage.java
+++ b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/ImportProposalsWizardPage.java
@@ -29,13 +29,16 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.PageChangedEvent;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.ViewerColumn;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardPage;
@@ -61,13 +64,14 @@
private EasymportJob currentJob;
private Label selectionSummary;
- private class FolderForProjectsLabelProvider extends LabelProvider implements IColorProvider {
- @Override
+ private class FolderForProjectsLabelProvider extends CellLabelProvider implements IColorProvider {
public String getText(Object o) {
- if (alreadyExistingProjects.contains(o)) {
- return super.getText(o)+ " (" + Messages.alreadyImportedAsProject_title + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ File file = (File)o;
+ String label = file.getAbsolutePath();
+ if (label.startsWith(currentJob.getRoot().getAbsolutePath())) {
+ label = label.substring(currentJob.getRoot().getParentFile().getAbsolutePath().length() + 1);
}
- return super.getText(o);
+ return label;
}
@Override
@@ -82,6 +86,48 @@
}
return null;
}
+
+ @Override
+ public void update(ViewerCell cell) {
+ cell.setText(getText(cell.getElement()));
+ Color color = getForeground(cell.getElement());
+ if (color != null) {
+ cell.setForeground(color);
+ }
+ }
+ }
+
+ private class ProjectConfiguratorLabelProvider extends CellLabelProvider implements IColorProvider {
+ public String getText(Object o) {
+ File file = (File)o;
+ String label = file.getAbsolutePath();
+ if (alreadyExistingProjects.contains(o)) {
+ return Messages.alreadyImportedAsProject_title;
+ }
+ return "todo";
+ }
+
+ @Override
+ public Color getBackground(Object o) {
+ return null;
+ }
+
+ @Override
+ public Color getForeground(Object o) {
+ if (alreadyExistingProjects.contains(o)) {
+ return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
+ }
+ return null;
+ }
+
+ @Override
+ public void update(ViewerCell cell) {
+ cell.setText(getText(cell.getElement()));
+ Color color = getForeground(cell.getElement());
+ if (color != null) {
+ cell.setForeground(color);
+ }
+ }
}
public ImportProposalsWizardPage(EasymportWizard wizard) {
@@ -136,12 +182,6 @@
}
});
- tree.setLabelProvider(new LabelProvider() {
- @Override
- public String getText(Object o) {
- return ((File)o).getAbsolutePath();
- }
- });
tree.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer v, Object o1, Object o2) {
@@ -158,7 +198,16 @@
}
}
});
- tree.setLabelProvider(new FolderForProjectsLabelProvider());
+
+ tree.getTree().setHeaderVisible(true);
+ ViewerColumn pathColumn = new TreeViewerColumn(tree, SWT.NONE);
+ pathColumn.setLabelProvider(new FolderForProjectsLabelProvider());
+ tree.getTree().getColumn(0).setText(Messages.folder);
+ tree.getTree().getColumn(0).setWidth(400);
+ ViewerColumn projectTypeColumn = new TreeViewerColumn(tree, SWT.NONE);
+ projectTypeColumn.setLabelProvider(new ProjectConfiguratorLabelProvider());
+ tree.getTree().getColumn(1).setText(Messages.importAs);
+ tree.getTree().getColumn(1).setWidth(250);
Composite selectionButtonsGroup = new Composite(res, SWT.NONE);
selectionButtonsGroup.setLayout(new GridLayout(1, false));
diff --git a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/Messages.java b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/Messages.java
index b382637..2efa919 100644
--- a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/Messages.java
+++ b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/Messages.java
@@ -56,6 +56,7 @@
public static String didntFindImportProposals_title;
public static String didntFindImportProposals_message;
public static String selectionSummary;
-
+ public static String folder;
+ public static String importAs;
}
diff --git a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/Messages.properties b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/Messages.properties
index 4a983c4..75176d2 100644
--- a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/Messages.properties
+++ b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/Messages.properties
@@ -38,7 +38,7 @@
EasymportWizardPage_progressBarTooltip=Crawling directory to detect and configure projects
EasymportWizardPage_relativePath=Relative Path
EasymportWizardPage_project=Project
-EasymportWizardPage_natures=Natures
+EasymportWizardPage_natures=Imported as
EasymportWizardPage_importErrors=Skipped {0} locations because of errors
EasymportWizardPage_error=Error
preliminaryDetection_Title=Import proposal
@@ -49,3 +49,5 @@
didntFindImportProposals_title=Didn't find any import proposal
didntFindImportProposals_message=No import proposal could be computed. So it's recommended that you import the root project and select the \"{0}\" checkbox.
selectionSummary=Found {0} projects, {1} selected for import
+folder=Folder
+importAs=Import as