mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 22:35:43 +02:00
fixed progress display (%), allow cancel during import, remember column ordering, don't try to refresh while importing executables.
This commit is contained in:
parent
1d4f6f9b9f
commit
0c5bdcfb6c
8 changed files with 212 additions and 237 deletions
|
@ -15,6 +15,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
@ -38,7 +39,8 @@ public class ExecutablesManager extends PlatformObject {
|
|||
private List<IExecutableProvider> executableProviders = Collections.synchronizedList(new ArrayList<IExecutableProvider>());
|
||||
private List<IExecutableImporter> executableImporters = Collections.synchronizedList(new ArrayList<IExecutableImporter>());
|
||||
private boolean refreshNeeded = true;
|
||||
|
||||
private boolean tempDisableRefresh = false;
|
||||
|
||||
private Job refreshJob = new Job("Get Executables") {
|
||||
|
||||
@Override
|
||||
|
@ -95,6 +97,10 @@ public class ExecutablesManager extends PlatformObject {
|
|||
}
|
||||
|
||||
public IStatus refreshExecutables(IProgressMonitor monitor) {
|
||||
if (tempDisableRefresh) {
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
ArrayList<Executable> oldList = executables;
|
||||
executables = new ArrayList<Executable>();
|
||||
synchronized (executableProviders) {
|
||||
|
@ -139,13 +145,24 @@ public class ExecutablesManager extends PlatformObject {
|
|||
}
|
||||
|
||||
public void importExecutables(String[] fileNames, IProgressMonitor monitor) {
|
||||
synchronized (executableImporters) {
|
||||
monitor.beginTask("Import Executables", executableImporters.size());
|
||||
for (IExecutableImporter importer : executableImporters) {
|
||||
importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
|
||||
try {
|
||||
synchronized (executableImporters) {
|
||||
tempDisableRefresh = true;
|
||||
|
||||
monitor.beginTask("Import Executables", executableImporters.size());
|
||||
for (IExecutableImporter importer : executableImporters) {
|
||||
importer.importExecutables(fileNames, new SubProgressMonitor(monitor, 1));
|
||||
if (monitor.isCanceled()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
} finally {
|
||||
tempDisableRefresh = false;
|
||||
}
|
||||
|
||||
refreshExecutables(monitor);
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
public ISourceFileRemapping[] getSourceFileRemappings() {
|
||||
|
@ -168,5 +185,13 @@ public class ExecutablesManager extends PlatformObject {
|
|||
public boolean refreshNeeded() {
|
||||
return refreshNeeded;
|
||||
}
|
||||
|
||||
public boolean executableExists(IPath exePath) {
|
||||
for (Executable executable : executables) {
|
||||
if (executable.getPath().equals(exePath))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -60,7 +60,7 @@ public class StandardExecutableImporter implements IExecutableImporter {
|
|||
path = new File(path).getCanonicalPath();
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
if (!executableExists(path)) {
|
||||
if (!ExecutablesManager.getExecutablesManager().executableExists(Path.fromOSString(path))) {
|
||||
if (!checkProject) {
|
||||
// See if the default project exists
|
||||
String defaultProjectName = "Executables";
|
||||
|
@ -92,7 +92,7 @@ public class StandardExecutableImporter implements IExecutableImporter {
|
|||
store = store.getChild(newProjectHandle.getName());
|
||||
for (String deleteName : ignoreList) {
|
||||
IFileStore projFile = store.getChild(deleteName);
|
||||
projFile.delete(EFS.NONE, monitor);
|
||||
projFile.delete(EFS.NONE, null);
|
||||
}
|
||||
exeProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, null, DEBUG_PROJECT_ID);
|
||||
} catch (OperationCanceledException e) {
|
||||
|
@ -107,19 +107,13 @@ public class StandardExecutableImporter implements IExecutableImporter {
|
|||
importExecutable(exeProject, path);
|
||||
}
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
private boolean executableExists(String path) {
|
||||
Executable[] executables = ExecutablesManager.getExecutablesManager().getExecutables();
|
||||
for (Executable executable : executables) {
|
||||
if (executable.getPath().toOSString().equals(path))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void importExecutable(IProject exeProject, String path) {
|
||||
|
||||
IPath location = Path.fromOSString(path);
|
||||
|
|
|
@ -11,12 +11,14 @@
|
|||
|
||||
package org.eclipse.cdt.debug.internal.ui.views.executables;
|
||||
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.ViewerComparator;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeColumn;
|
||||
|
||||
/**
|
||||
|
@ -32,7 +34,7 @@ abstract class BaseViewer extends TreeViewer {
|
|||
protected TreeColumn typeColumn;
|
||||
|
||||
private static final int NUM_COLUMNS = 7;
|
||||
int column_order[] = new int[NUM_COLUMNS];
|
||||
int column_sort_order[] = new int[NUM_COLUMNS];
|
||||
|
||||
private ExecutablesView executablesView;
|
||||
|
||||
|
@ -45,12 +47,10 @@ abstract class BaseViewer extends TreeViewer {
|
|||
}
|
||||
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
column_order[selector] *= -1;
|
||||
ViewerComparator comparator = getViewerComparator(selector);
|
||||
setComparator(comparator);
|
||||
executablesView.getMemento().putInteger(ExecutablesView.P_ORDER_VALUE_SF, column_order[selector]);
|
||||
executablesView.getMemento().putInteger(ExecutablesView.P_ORDER_TYPE_SF, selector);
|
||||
setColumnSorting((TreeColumn) e.getSource(), column_order[selector]);
|
||||
setComparator(getViewerComparator(selector));
|
||||
getTree().setSortColumn((TreeColumn) e.getSource());
|
||||
getTree().setSortDirection(column_sort_order[selector] == ExecutablesView.ASCENDING ? SWT.UP : SWT.DOWN);
|
||||
column_sort_order[selector] *= -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,6 +58,11 @@ abstract class BaseViewer extends TreeViewer {
|
|||
public BaseViewer(ExecutablesView view, Composite parent, int style) {
|
||||
super(parent, style);
|
||||
executablesView = view;
|
||||
|
||||
// default all columns sort order to ascending
|
||||
for (int i=0; i<NUM_COLUMNS; i++) {
|
||||
column_sort_order[i] = ExecutablesView.ASCENDING;
|
||||
}
|
||||
}
|
||||
|
||||
public ExecutablesView getExecutablesView() {
|
||||
|
@ -74,11 +79,90 @@ abstract class BaseViewer extends TreeViewer {
|
|||
}
|
||||
}
|
||||
|
||||
protected void setColumnSorting(TreeColumn column, int order) {
|
||||
getTree().setSortColumn(column);
|
||||
getTree().setSortDirection(order == ExecutablesView.ASCENDING ? SWT.UP : SWT.DOWN);
|
||||
protected void saveColumnSettings(Preferences preferences) {
|
||||
Tree tree = getTree();
|
||||
|
||||
// save the column order
|
||||
String columnOrder = ""; //$NON-NLS-1$
|
||||
for (int index : tree.getColumnOrder()) {
|
||||
columnOrder += ","; //$NON-NLS-1$
|
||||
columnOrder += Integer.toString(index);
|
||||
}
|
||||
// trim the leading comma
|
||||
columnOrder = columnOrder.substring(1);
|
||||
preferences.setValue(getColumnOrderKey(), columnOrder);
|
||||
|
||||
// save which column was sorted and in which direction
|
||||
TreeColumn sortedColumn = tree.getSortColumn();
|
||||
for (int i=0; i<tree.getColumnCount(); i++) {
|
||||
if (sortedColumn.equals(tree.getColumn(i))) {
|
||||
preferences.setValue(getSortedColumnIndexKey(), i);
|
||||
preferences.setValue(getSortedColumnDirectionKey(), tree.getSortDirection());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// save the visible state of each columns (1 is visible, 0 is not)
|
||||
String visibleColumns = ""; //$NON-NLS-1$
|
||||
for (int i=0; i<tree.getColumnCount(); i++) {
|
||||
if (tree.getColumn(i).getWidth() > 0) {
|
||||
visibleColumns += ",1"; //$NON-NLS-1$
|
||||
} else {
|
||||
visibleColumns += ",0"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
// trim the leading comma
|
||||
visibleColumns = visibleColumns.substring(1);
|
||||
preferences.setValue(getVisibleColumnsKey(), visibleColumns);
|
||||
}
|
||||
|
||||
protected void restoreColumnSettings(Preferences preferences) {
|
||||
Tree tree = getTree();
|
||||
|
||||
// restore the column order
|
||||
String columnOrder = preferences.getString(getColumnOrderKey());
|
||||
if (columnOrder.length() > 0) {
|
||||
String[] columns = columnOrder.split(","); //$NON-NLS-1$
|
||||
int[] columnNumbers = new int[columns.length];
|
||||
for (int i=0; i<columns.length; i++) {
|
||||
columnNumbers[i] = Integer.parseInt(columns[i]);
|
||||
}
|
||||
tree.setColumnOrder(columnNumbers);
|
||||
}
|
||||
|
||||
// restore the sorted column
|
||||
int sortedColumnIndex = preferences.getInt(getSortedColumnIndexKey());
|
||||
int sortedColumnDirection = preferences.getInt(getSortedColumnDirectionKey());
|
||||
tree.setSortColumn(tree.getColumn(sortedColumnIndex));
|
||||
tree.setSortDirection(sortedColumnDirection == 0 ? SWT.UP : sortedColumnDirection);
|
||||
|
||||
setComparator(getViewerComparator(sortedColumnIndex));
|
||||
|
||||
// remember the sort order for the column
|
||||
column_sort_order[sortedColumnIndex] = sortedColumnDirection == SWT.UP ? ExecutablesView.ASCENDING : ExecutablesView.DESCENDING;
|
||||
|
||||
// restore the visible state of each columns (1 is visible, 0 is not)
|
||||
String visibleColumns = preferences.getString(getVisibleColumnsKey());
|
||||
if (visibleColumns.length() <= 0) {
|
||||
visibleColumns = getDefaultVisibleColumnsValue();
|
||||
}
|
||||
String[] columns = visibleColumns.split(","); //$NON-NLS-1$
|
||||
for (int i=0; i<columns.length; i++) {
|
||||
if (columns[i].equals("0")) {
|
||||
tree.getColumn(i).setWidth(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected ViewerComparator getViewerComparator(int sortType);
|
||||
|
||||
abstract protected String getColumnOrderKey();
|
||||
|
||||
abstract protected String getSortedColumnIndexKey();
|
||||
|
||||
abstract protected String getSortedColumnDirectionKey();
|
||||
|
||||
abstract protected String getVisibleColumnsKey();
|
||||
|
||||
}
|
||||
abstract protected String getDefaultVisibleColumnsValue();
|
||||
}
|
||||
|
|
|
@ -68,23 +68,16 @@ public class ExecutablesView extends ViewPart {
|
|||
* the list of visible columns.
|
||||
*/
|
||||
|
||||
public static final String P_ORDER_TYPE_EXE = "orderTypeEXE"; //$NON-NLS-1$
|
||||
public static final String P_ORDER_VALUE_EXE = "orderValueEXE"; //$NON-NLS-1$
|
||||
public static final String P_ORDER_TYPE_SF = "orderTypeSF"; //$NON-NLS-1$
|
||||
public static final String P_ORDER_VALUE_SF = "orderValueSF"; //$NON-NLS-1$
|
||||
public static final String P_VISIBLE_COLUMNS = "visibleColumns"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Constants for the columns.
|
||||
*/
|
||||
|
||||
public final static int NAME = 0x0;
|
||||
public final static int PROJECT = 0x1;
|
||||
public final static int LOCATION = 0x2;
|
||||
public final static int ORG_LOCATION = 0x3;
|
||||
public final static int SIZE = 0x4;
|
||||
public final static int MODIFIED = 0x5;
|
||||
public final static int TYPE = 0x6;
|
||||
public final static int SIZE = 0x3;
|
||||
public final static int MODIFIED = 0x4;
|
||||
public final static int TYPE = 0x5;
|
||||
public final static int ORG_LOCATION = 0x6;
|
||||
|
||||
/**
|
||||
* Constants for the column sort order.
|
||||
|
@ -130,7 +123,6 @@ public class ExecutablesView extends ViewPart {
|
|||
/**
|
||||
* Not all the columns are visible by default. Here are the ones that are.
|
||||
*/
|
||||
private String defaultVisibleColumns = Messages.ExecutablesView_DefaultColumns;
|
||||
private TreeColumn[] allColumns = new TreeColumn[columnNames.length];
|
||||
|
||||
/**
|
||||
|
@ -261,6 +253,8 @@ public class ExecutablesView extends ViewPart {
|
|||
allColumns[10] = sourceFilesViewer.modifiedColumn;
|
||||
allColumns[11] = sourceFilesViewer.typeColumn;
|
||||
|
||||
readSettings();
|
||||
|
||||
createActions();
|
||||
|
||||
// When the selection changes in the executables list
|
||||
|
@ -279,13 +273,7 @@ public class ExecutablesView extends ViewPart {
|
|||
}
|
||||
});
|
||||
|
||||
// Initialize the list of visible columns
|
||||
if (memento.getString(P_VISIBLE_COLUMNS).length() > 0) {
|
||||
String[] visibleColumns = memento.getString(P_VISIBLE_COLUMNS).split(","); //$NON-NLS-1$
|
||||
setVisibleColumns(visibleColumns);
|
||||
} else {
|
||||
setVisibleColumns(defaultVisibleColumns.split(",")); //$NON-NLS-1$
|
||||
}
|
||||
executablesViewer.packColumns();
|
||||
sourceFilesViewer.packColumns();
|
||||
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(container, EXECUTABLES_VIEW_CONTEXT);
|
||||
|
@ -296,14 +284,6 @@ public class ExecutablesView extends ViewPart {
|
|||
for (int i = 0; i < columnNames.length; i++) {
|
||||
makeColumnVisible(visibleNames.contains(columnNames[i]), allColumns[i]);
|
||||
}
|
||||
|
||||
StringBuffer visibleColumns = new StringBuffer();
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (i > 0)
|
||||
visibleColumns.append(","); //$NON-NLS-1$
|
||||
visibleColumns.append(ids[i]);
|
||||
}
|
||||
memento.putString(P_VISIBLE_COLUMNS, visibleColumns.toString());
|
||||
}
|
||||
|
||||
private void makeColumnVisible(boolean visible, TreeColumn column) {
|
||||
|
@ -423,52 +403,22 @@ public class ExecutablesView extends ViewPart {
|
|||
else
|
||||
this.memento = memento;
|
||||
super.init(site, memento);
|
||||
readSettings();
|
||||
}
|
||||
|
||||
private Preferences getViewPreferences() {
|
||||
return CDebugUIPlugin.getDefault().getPluginPreferences();
|
||||
}
|
||||
|
||||
private void initializeMemento() {
|
||||
memento.putInteger(P_ORDER_VALUE_EXE, DESCENDING);
|
||||
memento.putInteger(P_ORDER_TYPE_EXE, NAME);
|
||||
memento.putInteger(P_ORDER_VALUE_SF, DESCENDING);
|
||||
memento.putInteger(P_ORDER_TYPE_SF, NAME);
|
||||
memento.putString(P_VISIBLE_COLUMNS, defaultVisibleColumns);
|
||||
}
|
||||
|
||||
private void readSettings() {
|
||||
Preferences p = getViewPreferences();
|
||||
if (p == null) {
|
||||
initializeMemento();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
int order = p.getInt(P_ORDER_VALUE_EXE);
|
||||
memento.putInteger(P_ORDER_VALUE_EXE, order == 0 ? DESCENDING : order);
|
||||
memento.putInteger(P_ORDER_TYPE_EXE, p.getInt(P_ORDER_TYPE_EXE));
|
||||
order = p.getInt(P_ORDER_VALUE_SF);
|
||||
memento.putInteger(P_ORDER_VALUE_SF, order == 0 ? DESCENDING : order);
|
||||
memento.putInteger(P_ORDER_TYPE_SF, p.getInt(P_ORDER_TYPE_SF));
|
||||
memento.putString(P_VISIBLE_COLUMNS, p.getString(P_VISIBLE_COLUMNS));
|
||||
} catch (NumberFormatException e) {
|
||||
memento.putInteger(P_ORDER_TYPE_EXE, NAME);
|
||||
memento.putInteger(P_ORDER_VALUE_EXE, DESCENDING);
|
||||
memento.putInteger(P_ORDER_TYPE_SF, NAME);
|
||||
memento.putInteger(P_ORDER_VALUE_SF, DESCENDING);
|
||||
}
|
||||
Preferences prefs = getViewPreferences();
|
||||
getExecutablesViewer().restoreColumnSettings(prefs);
|
||||
getSourceFilesViewer().restoreColumnSettings(prefs);
|
||||
}
|
||||
|
||||
private void writeSettings() {
|
||||
Preferences preferences = getViewPreferences();
|
||||
int order = memento.getInteger(P_ORDER_VALUE_EXE).intValue();
|
||||
preferences.setValue(P_ORDER_VALUE_EXE, order == 0 ? DESCENDING : order);
|
||||
preferences.setValue(P_ORDER_TYPE_EXE, memento.getInteger(P_ORDER_TYPE_EXE).intValue());
|
||||
order = memento.getInteger(P_ORDER_VALUE_SF).intValue();
|
||||
preferences.setValue(P_ORDER_VALUE_SF, order == 0 ? DESCENDING : order);
|
||||
preferences.setValue(P_ORDER_TYPE_SF, memento.getInteger(P_ORDER_TYPE_SF).intValue());
|
||||
preferences.setValue(P_VISIBLE_COLUMNS, memento.getString(P_VISIBLE_COLUMNS));
|
||||
Preferences prefs = getViewPreferences();
|
||||
getExecutablesViewer().saveColumnSettings(prefs);
|
||||
getSourceFilesViewer().saveColumnSettings(prefs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -493,8 +443,4 @@ public class ExecutablesView extends ViewPart {
|
|||
super.dispose();
|
||||
}
|
||||
|
||||
public IMemento getMemento() {
|
||||
return memento;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,12 @@ import org.eclipse.ui.progress.UIJob;
|
|||
*/
|
||||
public class ExecutablesViewer extends BaseViewer implements IExecutablesChangeListener {
|
||||
|
||||
private static final String P_COLUMN_ORDER_KEY_EXE = "columnOrderKeyEXE"; //$NON-NLS-1$
|
||||
private static final String P_SORTED_COLUMN_INDEX_KEY_EXE = "sortedColumnIndexKeyEXE"; //$NON-NLS-1$
|
||||
private static final String P_COLUMN_SORT_DIRECTION_KEY_EXE = "columnSortDirectionKeyEXE"; //$NON-NLS-1$
|
||||
private static final String P_VISIBLE_COLUMNS_KEY_EXE = "visibleColumnsKeyEXE"; //$NON-NLS-1$
|
||||
|
||||
|
||||
/**
|
||||
* Handles dropping executable files into the view
|
||||
*/
|
||||
|
@ -85,7 +91,6 @@ public class ExecutablesViewer extends BaseViewer implements IExecutablesChangeL
|
|||
executablesView.getSite().setSelectionProvider(this);
|
||||
|
||||
createColumns();
|
||||
initializeSorter();
|
||||
|
||||
setInput(ExecutablesManager.getExecutablesManager());
|
||||
|
||||
|
@ -143,89 +148,20 @@ public class ExecutablesViewer extends BaseViewer implements IExecutablesChangeL
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize column ordering and sorting
|
||||
*/
|
||||
private void initializeSorter() {
|
||||
byte orderType = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_TYPE_EXE).byteValue();
|
||||
switch (orderType) {
|
||||
case ExecutablesView.NAME:
|
||||
column_order[ExecutablesView.NAME] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_EXE).intValue();
|
||||
column_order[ExecutablesView.PROJECT] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
case ExecutablesView.PROJECT:
|
||||
column_order[ExecutablesView.PROJECT] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_EXE).intValue();
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
case ExecutablesView.LOCATION:
|
||||
column_order[ExecutablesView.LOCATION] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_EXE).intValue();
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.PROJECT] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
case ExecutablesView.SIZE:
|
||||
column_order[ExecutablesView.SIZE] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_EXE).intValue();
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.PROJECT] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
case ExecutablesView.MODIFIED:
|
||||
column_order[ExecutablesView.MODIFIED] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_EXE).intValue();
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.PROJECT] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
default:
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.PROJECT] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
}
|
||||
|
||||
ViewerComparator comparator = getViewerComparator(orderType);
|
||||
setComparator(comparator);
|
||||
if (orderType == ExecutablesView.NAME)
|
||||
setColumnSorting(nameColumn, column_order[ExecutablesView.NAME]);
|
||||
else if (orderType == ExecutablesView.PROJECT)
|
||||
setColumnSorting(projectColumn, column_order[ExecutablesView.PROJECT]);
|
||||
else if (orderType == ExecutablesView.LOCATION)
|
||||
setColumnSorting(locationColumn, column_order[ExecutablesView.LOCATION]);
|
||||
else if (orderType == ExecutablesView.SIZE)
|
||||
setColumnSorting(projectColumn, column_order[ExecutablesView.SIZE]);
|
||||
else if (orderType == ExecutablesView.MODIFIED)
|
||||
setColumnSorting(locationColumn, column_order[ExecutablesView.MODIFIED]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ViewerComparator getViewerComparator(int sortType) {
|
||||
if (sortType == ExecutablesView.PROJECT) {
|
||||
return new ExecutablesViewerComparator(sortType, column_order[ExecutablesView.PROJECT]) {
|
||||
return new ExecutablesViewerComparator(sortType, column_sort_order[ExecutablesView.PROJECT]) {
|
||||
@SuppressWarnings("unchecked") //$NON-NLS-1$
|
||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||
Executable entry1 = (Executable) e1;
|
||||
Executable entry2 = (Executable) e2;
|
||||
return getComparator().compare(entry1.getProject().getName(), entry2.getProject().getName())
|
||||
* column_order[ExecutablesView.PROJECT];
|
||||
* column_sort_order[ExecutablesView.PROJECT];
|
||||
}
|
||||
};
|
||||
}
|
||||
return new ExecutablesViewerComparator(sortType, column_order[sortType]);
|
||||
return new ExecutablesViewerComparator(sortType, column_sort_order[sortType]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -248,4 +184,29 @@ public class ExecutablesViewer extends BaseViewer implements IExecutablesChangeL
|
|||
refreshJob.schedule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getColumnOrderKey() {
|
||||
return P_COLUMN_ORDER_KEY_EXE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSortedColumnIndexKey() {
|
||||
return P_SORTED_COLUMN_INDEX_KEY_EXE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSortedColumnDirectionKey() {
|
||||
return P_COLUMN_SORT_DIRECTION_KEY_EXE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVisibleColumnsKey() {
|
||||
return P_VISIBLE_COLUMNS_KEY_EXE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultVisibleColumnsValue() {
|
||||
// default visible columns
|
||||
return "1,1,1,0,0,0"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ public class Messages extends NLS {
|
|||
public static String ExecutablesContentProvider_FetchingExecutables;
|
||||
public static String ExecutablesView_Columns;
|
||||
public static String ExecutablesView_ConfigureColumns;
|
||||
public static String ExecutablesView_DefaultColumns;
|
||||
public static String ExecutablesView_ExeData;
|
||||
public static String ExecutablesView_ExeLocation;
|
||||
public static String ExecutablesView_ExeName;
|
||||
|
|
|
@ -48,6 +48,12 @@ import org.eclipse.ui.progress.UIJob;
|
|||
*/
|
||||
public class SourceFilesViewer extends BaseViewer implements ISourceLookupParticipant {
|
||||
|
||||
private static final String P_COLUMN_ORDER_KEY_SF = "columnOrderKeySF"; //$NON-NLS-1$
|
||||
private static final String P_SORTED_COLUMN_INDEX_KEY_SF = "sortedColumnIndexKeySF"; //$NON-NLS-1$
|
||||
private static final String P_COLUMN_SORT_DIRECTION_KEY_SF = "columnSortDirectionKeySF"; //$NON-NLS-1$
|
||||
private static final String P_VISIBLE_COLUMNS_KEY_SF = "visibleColumnsKeySF"; //$NON-NLS-1$
|
||||
|
||||
|
||||
TreeColumn originalLocationColumn;
|
||||
private Tree sourceFilesTree;
|
||||
|
||||
|
@ -69,8 +75,6 @@ public class SourceFilesViewer extends BaseViewer implements ISourceLookupPartic
|
|||
}
|
||||
});
|
||||
|
||||
initializeSorter();
|
||||
|
||||
// We implement ISourceLookupParticipant so we can listen for changes to
|
||||
// source lookup as this viewer shows both original and remapped
|
||||
// locations
|
||||
|
@ -163,7 +167,7 @@ public class SourceFilesViewer extends BaseViewer implements ISourceLookupPartic
|
|||
|
||||
protected ViewerComparator getViewerComparator(int sortType) {
|
||||
if (sortType == ExecutablesView.ORG_LOCATION) {
|
||||
return new ExecutablesViewerComparator(sortType, column_order[ExecutablesView.ORG_LOCATION]) {
|
||||
return new ExecutablesViewerComparator(sortType, column_sort_order[ExecutablesView.ORG_LOCATION]) {
|
||||
|
||||
@SuppressWarnings("unchecked") //$NON-NLS-1$
|
||||
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||
|
@ -173,75 +177,13 @@ public class SourceFilesViewer extends BaseViewer implements ISourceLookupPartic
|
|||
Executable exe = (Executable) getInput();
|
||||
String originalLocation1 = exe.getOriginalLocation(entry1);
|
||||
String originalLocation2 = exe.getOriginalLocation(entry2);
|
||||
return getComparator().compare(originalLocation1, originalLocation2) * column_order[ExecutablesView.ORG_LOCATION];
|
||||
return getComparator().compare(originalLocation1, originalLocation2) * column_sort_order[ExecutablesView.ORG_LOCATION];
|
||||
}
|
||||
return super.compare(viewer, e1, e2);
|
||||
}
|
||||
};
|
||||
} else
|
||||
return new ExecutablesViewerComparator(sortType, column_order[sortType]);
|
||||
}
|
||||
|
||||
private void initializeSorter() {
|
||||
byte orderType = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_TYPE_SF).byteValue();
|
||||
switch (orderType) {
|
||||
case ExecutablesView.NAME:
|
||||
column_order[ExecutablesView.NAME] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_SF).intValue();
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.ORG_LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
case ExecutablesView.LOCATION:
|
||||
column_order[ExecutablesView.LOCATION] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_SF).intValue();
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.ORG_LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
case ExecutablesView.ORG_LOCATION:
|
||||
column_order[ExecutablesView.ORG_LOCATION] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_SF).intValue();
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
case ExecutablesView.SIZE:
|
||||
column_order[ExecutablesView.SIZE] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_SF).intValue();
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.ORG_LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
case ExecutablesView.MODIFIED:
|
||||
column_order[ExecutablesView.MODIFIED] = getExecutablesView().getMemento().getInteger(ExecutablesView.P_ORDER_VALUE_SF).intValue();
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.ORG_LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
break;
|
||||
default:
|
||||
column_order[ExecutablesView.MODIFIED] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.NAME] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.SIZE] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.ORG_LOCATION] = ExecutablesView.DESCENDING;
|
||||
column_order[ExecutablesView.TYPE] = ExecutablesView.DESCENDING;
|
||||
}
|
||||
|
||||
ViewerComparator comparator = getViewerComparator(orderType);
|
||||
setComparator(comparator);
|
||||
if (orderType == ExecutablesView.NAME)
|
||||
setColumnSorting(nameColumn, column_order[ExecutablesView.NAME]);
|
||||
else if (orderType == ExecutablesView.LOCATION)
|
||||
setColumnSorting(locationColumn, column_order[ExecutablesView.LOCATION]);
|
||||
else if (orderType == ExecutablesView.ORG_LOCATION)
|
||||
setColumnSorting(originalLocationColumn, column_order[ExecutablesView.ORG_LOCATION]);
|
||||
return new ExecutablesViewerComparator(sortType, column_sort_order[sortType]);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
|
@ -273,4 +215,29 @@ public class SourceFilesViewer extends BaseViewer implements ISourceLookupPartic
|
|||
refreshJob.schedule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getColumnOrderKey() {
|
||||
return P_COLUMN_ORDER_KEY_SF;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSortedColumnIndexKey() {
|
||||
return P_SORTED_COLUMN_INDEX_KEY_SF;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSortedColumnDirectionKey() {
|
||||
return P_COLUMN_SORT_DIRECTION_KEY_SF;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVisibleColumnsKey() {
|
||||
return P_VISIBLE_COLUMNS_KEY_SF;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultVisibleColumnsValue() {
|
||||
// default visible columns
|
||||
return "1,1,0,0,0,0"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
ExecutablesContentProvider_FetchingExecutables=Fetching executables
|
||||
ExecutablesView_Columns=Columns
|
||||
ExecutablesView_ConfigureColumns=Configure Columns
|
||||
ExecutablesView_DefaultColumns=Executable Name,Executable Project,Executable Location,Source File Name,Source File Location
|
||||
ExecutablesView_ExeData=Executable Date
|
||||
ExecutablesView_ExeLocation=Executable Location
|
||||
ExecutablesView_ExeName=Executable Name
|
||||
|
|
Loading…
Add table
Reference in a new issue