Java 类org.eclipse.jface.viewers.IElementComparer 实例源码
项目:Tarski
文件:MarkerFactory.java
/**
* @param selections
* @return
*/
public static String getQualifiedName(final ITreeSelection selections) {
final TreePath[] paths = selections.getPaths();
// Consider only not empty and single selection
if (selections.isEmpty() || selections.size() > 1) {
return null;
}
final TreePath path = paths[0];
IElementComparer comparer = null;
if (selections instanceof TreeSelection) {
comparer = ((TreeSelection) selections).getElementComparer();
}
System.out.println(path.hashCode(comparer));
for (int i = 1; i < path.getSegmentCount(); i++) {
if (path.getSegment(i) instanceof ResourceFactoryImpl) {
final EcoreResourceFactoryImpl eResourceFactory =
(EcoreResourceFactoryImpl) path.getSegment(i);
System.out
.println(eResourceFactory.getClass().getName() + ": " + eResourceFactory.toString());
} else if (path.getSegment(i) instanceof ENamedElement) {
final ENamedElement namedElement = (ENamedElement) path.getSegment(i);
System.out.println(namedElement.getClass().getName() + ": " + namedElement.getName());
} else {
System.out.println("?");
}
}
return null;
}
项目:DarwinSPL
文件:DwprofileOutlinePageTreeViewer.java
public DwprofileOutlinePageTreeViewer(Composite parent, int style) {
super(parent, style);
addFilter(typeFilter);
setComparer(new IElementComparer() {
public int hashCode(Object element) {
String s = toString(element);
if (s != null) {
return s.hashCode();
}
return element.hashCode();
}
public boolean equals(Object o1, Object o2) {
if (o1 instanceof EObject && o2 instanceof EObject) {
return new FlatEObjectComparer().equals((EObject) o1, (EObject) o2);
}
String s1 = toString(o1);
String s2 = toString(o2);
if (s1 != null) {
return s1.equals(s2);
}
return o1.equals(o2);
}
private String toString(Object o) {
if (o instanceof String) {
return (String) o;
}
if (o instanceof Resource) {
return ((Resource) o).getURI().toString();
}
return null;
}
});
}
项目:DarwinSPL
文件:HyexpressionOutlinePageTreeViewer.java
public HyexpressionOutlinePageTreeViewer(Composite parent, int style) {
super(parent, style);
addFilter(typeFilter);
setComparer(new IElementComparer() {
public int hashCode(Object element) {
String s = toString(element);
if (s != null) {
return s.hashCode();
}
return element.hashCode();
}
public boolean equals(Object o1, Object o2) {
if (o1 instanceof EObject && o2 instanceof EObject) {
return new FlatEObjectComparer().equals((EObject) o1, (EObject) o2);
}
String s1 = toString(o1);
String s2 = toString(o2);
if (s1 != null) {
return s1.equals(s2);
}
return o1.equals(o2);
}
private String toString(Object o) {
if (o instanceof String) {
return (String) o;
}
if (o instanceof Resource) {
return ((Resource) o).getURI().toString();
}
return null;
}
});
}
项目:DarwinSPL
文件:HyvalidityformulaOutlinePageTreeViewer.java
public HyvalidityformulaOutlinePageTreeViewer(Composite parent, int style) {
super(parent, style);
addFilter(typeFilter);
setComparer(new IElementComparer() {
public int hashCode(Object element) {
String s = toString(element);
if (s != null) {
return s.hashCode();
}
return element.hashCode();
}
public boolean equals(Object o1, Object o2) {
if (o1 instanceof EObject && o2 instanceof EObject) {
return new FlatEObjectComparer().equals((EObject) o1, (EObject) o2);
}
String s1 = toString(o1);
String s2 = toString(o2);
if (s1 != null) {
return s1.equals(s2);
}
return o1.equals(o2);
}
private String toString(Object o) {
if (o instanceof String) {
return (String) o;
}
if (o instanceof Resource) {
return ((Resource) o).getURI().toString();
}
return null;
}
});
}
项目:DarwinSPL
文件:HydatavalueOutlinePageTreeViewer.java
public HydatavalueOutlinePageTreeViewer(Composite parent, int style) {
super(parent, style);
addFilter(typeFilter);
setComparer(new IElementComparer() {
public int hashCode(Object element) {
String s = toString(element);
if (s != null) {
return s.hashCode();
}
return element.hashCode();
}
public boolean equals(Object o1, Object o2) {
if (o1 instanceof EObject && o2 instanceof EObject) {
return new FlatEObjectComparer().equals((EObject) o1, (EObject) o2);
}
String s1 = toString(o1);
String s2 = toString(o2);
if (s1 != null) {
return s1.equals(s2);
}
return o1.equals(o2);
}
private String toString(Object o) {
if (o instanceof String) {
return (String) o;
}
if (o instanceof Resource) {
return ((Resource) o).getURI().toString();
}
return null;
}
});
}
项目:DarwinSPL
文件:HymappingOutlinePageTreeViewer.java
public HymappingOutlinePageTreeViewer(Composite parent, int style) {
super(parent, style);
addFilter(typeFilter);
setComparer(new IElementComparer() {
public int hashCode(Object element) {
String s = toString(element);
if (s != null) {
return s.hashCode();
}
return element.hashCode();
}
public boolean equals(Object o1, Object o2) {
if (o1 instanceof EObject && o2 instanceof EObject) {
return new FlatEObjectComparer().equals((EObject) o1, (EObject) o2);
}
String s1 = toString(o1);
String s2 = toString(o2);
if (s1 != null) {
return s1.equals(s2);
}
return o1.equals(o2);
}
private String toString(Object o) {
if (o instanceof String) {
return (String) o;
}
if (o instanceof Resource) {
return ((Resource) o).getURI().toString();
}
return null;
}
});
}
项目:DarwinSPL
文件:HyconstraintsOutlinePageTreeViewer.java
public HyconstraintsOutlinePageTreeViewer(Composite parent, int style) {
super(parent, style);
addFilter(typeFilter);
setComparer(new IElementComparer() {
public int hashCode(Object element) {
String s = toString(element);
if (s != null) {
return s.hashCode();
}
return element.hashCode();
}
public boolean equals(Object o1, Object o2) {
if (o1 instanceof EObject && o2 instanceof EObject) {
return new FlatEObjectComparer().equals((EObject) o1, (EObject) o2);
}
String s1 = toString(o1);
String s2 = toString(o2);
if (s1 != null) {
return s1.equals(s2);
}
return o1.equals(o2);
}
private String toString(Object o) {
if (o instanceof String) {
return (String) o;
}
if (o instanceof Resource) {
return ((Resource) o).getURI().toString();
}
return null;
}
});
}
项目:DarwinSPL
文件:HymanifestOutlinePageTreeViewer.java
public HymanifestOutlinePageTreeViewer(Composite parent, int style) {
super(parent, style);
addFilter(typeFilter);
setComparer(new IElementComparer() {
public int hashCode(Object element) {
String s = toString(element);
if (s != null) {
return s.hashCode();
}
return element.hashCode();
}
public boolean equals(Object o1, Object o2) {
if (o1 instanceof EObject && o2 instanceof EObject) {
return new FlatEObjectComparer().equals((EObject) o1, (EObject) o2);
}
String s1 = toString(o1);
String s2 = toString(o2);
if (s1 != null) {
return s1.equals(s2);
}
return o1.equals(o2);
}
private String toString(Object o) {
if (o instanceof String) {
return (String) o;
}
if (o instanceof Resource) {
return ((Resource) o).getURI().toString();
}
return null;
}
});
}
项目:WP3
文件:MarkerFactory.java
/**
* @param selections
* @return
*/
public static String getQualifiedName(final ITreeSelection selections) {
final TreePath[] paths = selections.getPaths();
// Consider only not empty and single selection
if (selections.isEmpty() || selections.size() > 1) {
return null;
}
final TreePath path = paths[0];
IElementComparer comparer = null;
if (selections instanceof TreeSelection) {
comparer = ((TreeSelection) selections).getElementComparer();
}
System.out.println(path.hashCode(comparer));
for (int i = 1; i < path.getSegmentCount(); i++) {
if (path.getSegment(i) instanceof ResourceFactoryImpl) {
final EcoreResourceFactoryImpl eResourceFactory =
(EcoreResourceFactoryImpl) path.getSegment(i);
System.out
.println(eResourceFactory.getClass().getName() + ": " + eResourceFactory.toString());
} else if (path.getSegment(i) instanceof ENamedElement) {
final ENamedElement namedElement = (ENamedElement) path.getSegment(i);
System.out.println(namedElement.getClass().getName() + ": " + namedElement.getName());
} else {
System.out.println("?");
}
}
return null;
}
项目:team-explorer-everywhere
文件:CrossCollectionProjectTable.java
public CrossCollectionProjectTable(final Composite parent, final int style, boolean showAccountColumn) {
super(parent, (SWT.FULL_SELECTION | style), CrossCollectionProjectInfo.class, null);
this.showAccountColumn = showAccountColumn;
final TableColumnData[] columnData = new TableColumnData[2];
columnData[0] = new TableColumnData(
Messages.getString("CrossCollectionProjectTable.ProjectColumnHeader"), //$NON-NLS-1$
-1,
0.50F,
PROJECT_COLUMN);
if (showAccountColumn) {
columnData[1] = new TableColumnData(
Messages.getString("CrossCollectionProjectTable.AccountColumnHeader"), //$NON-NLS-1$
-1,
0.50F,
ACCOUNT_COLUMN);
} else {
columnData[1] = new TableColumnData(
Messages.getString("CrossCollectionProjectTable.CollectionColumnHeader"), //$NON-NLS-1$
-1,
0.50F,
COLLECTION_COLUMN);
}
setupTable(true, false, columnData);
setUseDefaultContentProvider();
setUseDefaultLabelProvider();
setEnableTooltips(false);
final TableViewerSorter sorter = new TableViewerSorter(getViewer());
sorter.setComparator(PROJECT_COLUMN, new Comparator<CrossCollectionProjectInfo>() {
@Override
public int compare(final CrossCollectionProjectInfo o1, final CrossCollectionProjectInfo o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
getViewer().setSorter(sorter);
getViewer().setComparer(new IElementComparer() {
@Override
public boolean equals(final Object a, final Object b) {
if (a instanceof CrossCollectionProjectInfo && b instanceof CrossCollectionProjectInfo) {
return ((CrossCollectionProjectInfo) a).getGUID().equals(
((CrossCollectionProjectInfo) b).getGUID());
}
return a.equals(b);
}
@Override
public int hashCode(final Object element) {
if (element instanceof CrossCollectionProjectInfo) {
return ((CrossCollectionProjectInfo) element).getGUID().hashCode();
}
return element.hashCode();
}
});
}
项目:team-explorer-everywhere
文件:CrossCollectionRepositoryTable.java
public CrossCollectionRepositoryTable(final Composite parent, final int style) {
super(parent, (SWT.FULL_SELECTION | style), CrossCollectionProjectInfo.class, null);
final TableColumnData[] columnData = new TableColumnData[] {
new TableColumnData(
Messages.getString("CrossCollectionRepositoryTable.RepositoryColumnHeader"), //$NON-NLS-1$
-1,
0.25F,
REPO_COLUMN),
new TableColumnData(
Messages.getString("CrossCollectionRepositoryTable.ProjectColumnHeader"), //$NON-NLS-1$
-1,
0.25F,
PROJECT_COLUMN),
new TableColumnData(
Messages.getString("CrossCollectionRepositoryTable.UriColumnHeader"), //$NON-NLS-1$
-1,
0.50F,
URI_COLUMN)
};
setupTable(true, false, columnData);
setUseDefaultContentProvider();
setUseDefaultLabelProvider();
setEnableTooltips(false);
/*
* Ensure the select all item sorts first.
*/
final TableViewerSorter sorter = new TableViewerSorter(getViewer());
sorter.setComparator(REPO_COLUMN, new Comparator<CrossCollectionRepositoryInfo>() {
@Override
public int compare(final CrossCollectionRepositoryInfo o1, final CrossCollectionRepositoryInfo o2) {
return o1.getRepositoryName().compareToIgnoreCase(o2.getRepositoryName());
}
});
getViewer().setSorter(sorter);
getViewer().setComparer(new IElementComparer() {
@Override
public boolean equals(final Object a, final Object b) {
if (a instanceof CrossCollectionRepositoryInfo && b instanceof CrossCollectionRepositoryInfo) {
return ((CrossCollectionRepositoryInfo) a).getRepositoryGUID().equals(
((CrossCollectionRepositoryInfo) b).getRepositoryGUID());
}
return a.equals(b);
}
@Override
public int hashCode(final Object element) {
if (element instanceof CrossCollectionRepositoryInfo) {
return ((CrossCollectionRepositoryInfo) element).getRepositoryGUID().hashCode();
}
return element.hashCode();
}
});
}
项目:javapasswordsafe
文件:PasswordSafeJFace.java
protected void addTreeView(final Composite aComposite) {
treeViewer = new TreeViewer(aComposite, SWT.BORDER);
treeViewer.setLabelProvider(new PasswordTreeLabelProvider());
treeViewer.setContentProvider(new PasswordTreeContentProvider());
treeViewer.setSorter(new ViewerSorter());
treeViewer.addDoubleClickListener(new ViewerDoubleClickListener());
final int operations = DND.DROP_COPY| DND.DROP_MOVE;
final Transfer[] transferTypes = new Transfer[]
{PwsEntryBeanTransfer.getInstance(), TextTransfer.getInstance()};
treeViewer.addDragSupport(operations, transferTypes , new TreeDragListener(treeViewer));
treeViewer.addDropSupport(operations, transferTypes, new TreeDropper(treeViewer));
treeViewer.setComparer(new IElementComparer() {
public boolean equals(final Object a, final Object b) {
if (a instanceof PwsEntryBean && b instanceof PwsEntryBean)
return ((PwsEntryBean) a).getStoreIndex() == (((PwsEntryBean) b)
.getStoreIndex());
else
return a.equals(b);
}
public int hashCode(final Object element) {
if (element instanceof PwsEntryBean)
return ((PwsEntryBean) element).getStoreIndex();
else
return element.hashCode();
}
});
tree = treeViewer.getTree();
tree.setHeaderVisible(true);
tree.setMenu(createPopupMenu(tree));
treeViewer.setInput(new Object());
viewer = treeViewer;
int column = 1;
addTreeColumn(column, "PasswordSafeJFace.Column.Title", "tree/title");//$NON-NLS-1$
column++;
addTreeColumn(column, "PasswordSafeJFace.Column.UserName", "tree/userName");//$NON-NLS-1$
final IPreferenceStore thePrefs = JFacePreferences.getPreferenceStore();
if (thePrefs.getBoolean(JpwPreferenceConstants.SHOW_NOTES_IN_LIST)) {
column++;
addTreeColumn(column, "PasswordSafeJFace.Column.Notes", "tree/notes");//$NON-NLS-1$
}
final TreeColumn[] columns = tree.getColumns();
for (int i = 0; i < columns.length; i++) {
// ps.getDefaultInt("bla");
// columns[i].setWidth(100);
columns[i].setMoveable(true);
}
// treeViewer.setExpandedState(arg0, arg1)
}
项目:eavp
文件:TableComponentComposite.java
/**
* Creates a new {@code TableViewer} to show a {@link TableComponent}.
*
* @param parent
* The containing {@code Composite}.
* @return The created JFace {@code TableViewer}.
*/
private TableViewer createTableViewer(Composite parent) {
// Create the TableViewer and the underlying Table Control.
TableViewer viewer = new TableViewer(this, SWT.BORDER | SWT.MULTI
| SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
// Set some properties for the table.
final Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
// Set up the content provider for the viewer. Now the viewer's input
// can be set.
viewer.setContentProvider(new TableComponentContentProvider());
// Enable tool tips for the Table's cells.
ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE);
// Add a selection listener to tell the TableComponent which rows are
// selected.
ISelectionChangedListener listener = new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// To delete rows (later), the TableComponent expects indices.
// Thus, we must keep track of selected indicies by updating the
// class' list.
// To select rows, the TableComponent expects an
// ArrayList<Integer> containing the row IDs, not indices. Thus,
// we must convert the int[] of indices into an
// ArrayList<Integer> of IDs to select.
int[] selected = table.getSelectionIndices();
List<Integer> rowIds = tableComponent.getRowIds();
ArrayList<Integer> rows = new ArrayList<Integer>(
selected.length);
selectedIndices.clear();
for (int i : selected) {
selectedIndices.add(i);
rows.add(rowIds.get(i));
}
tableComponent.setSelectedRows(rows);
// Enable/disable the remove action if the selection is
// non/empty.
removeRowAction.setEnabled(!event.getSelection().isEmpty());
return;
}
};
viewer.addSelectionChangedListener(listener);
// Use a custom comparer to just check references rather than calling
// equals(Object), which causes strange behavior when multiple rows have
// the same values.
viewer.setComparer(new IElementComparer() {
@Override
public boolean equals(Object a, Object b) {
return a == b;
}
@Override
public int hashCode(Object element) {
return element.hashCode();
}
});
return viewer;
}
项目:Eclipse-Postfix-Code-Completion
文件:PackageExplorerPart.java
private IElementComparer createElementComparer() {
if (getRootMode() == PROJECTS_AS_ROOTS)
return null;
else
return WorkingSetModel.COMPARER;
}
项目:Eclipse-Postfix-Code-Completion
文件:PackageViewerWrapper.java
@Override
public IElementComparer getComparer() {
return fViewer.getComparer();
}
项目:Eclipse-Postfix-Code-Completion
文件:PackageViewerWrapper.java
@Override
public void setComparer(IElementComparer comparer) {
fViewer.setComparer(comparer);
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:PackageExplorerPart.java
private IElementComparer createElementComparer() {
if (getRootMode() == PROJECTS_AS_ROOTS)
return null;
else
return WorkingSetModel.COMPARER;
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:PackageViewerWrapper.java
@Override
public IElementComparer getComparer() {
return fViewer.getComparer();
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:PackageViewerWrapper.java
@Override
public void setComparer(IElementComparer comparer) {
fViewer.setComparer(comparer);
}
项目:goclipse
文件:CheckboxTableViewerExt.java
public TypedStructuredSelection(List<?> elements, IElementComparer comparer) {
super(elements, comparer);
}
项目:translationstudio8
文件:CellSelection.java
/**
* Creates a structured selection from the given <code>List</code> and
* element comparer. If an element comparer is provided, it will be used to
* determine equality between structured selection objects provided that
* they both are based on the same (identical) comparer. See bug
*
* @param elements
* list of selected elements
* @param comparer
* the comparer, or null
* @since 3.4
*/
public CellSelection(List elements, List indicesList, Object focusElement, IElementComparer comparer) {
super(elements,focusElement,comparer);
this.elements = new ArrayList(elements);
this.indicesList = indicesList;
}
项目:translationstudio8
文件:SelectionWithFocusRow.java
/**
* FIXME
* @param elements
* @param focusElement
* @param comparer
*/
public SelectionWithFocusRow(List elements, Object focusElement, IElementComparer comparer) {
super(elements,comparer);
this.focusElement = focusElement;
}
项目:tmxeditor8
文件:CellSelection.java
/**
* Creates a structured selection from the given <code>List</code> and
* element comparer. If an element comparer is provided, it will be used to
* determine equality between structured selection objects provided that
* they both are based on the same (identical) comparer. See bug
*
* @param elements
* list of selected elements
* @param comparer
* the comparer, or null
* @since 3.4
*/
public CellSelection(List elements, List indicesList, Object focusElement, IElementComparer comparer) {
super(elements,focusElement,comparer);
this.elements = new ArrayList(elements);
this.indicesList = indicesList;
}
项目:tmxeditor8
文件:SelectionWithFocusRow.java
/**
* FIXME
* @param elements
* @param focusElement
* @param comparer
*/
public SelectionWithFocusRow(List elements, Object focusElement, IElementComparer comparer) {
super(elements,comparer);
this.focusElement = focusElement;
}