本文整理汇总了Java中org.eclipse.jface.viewers.IElementComparer类的典型用法代码示例。如果您正苦于以下问题:Java IElementComparer类的具体用法?Java IElementComparer怎么用?Java IElementComparer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IElementComparer类属于org.eclipse.jface.viewers包,在下文中一共展示了IElementComparer类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getQualifiedName
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
/**
* @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;
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:34,代码来源:MarkerFactory.java
示例2: DwprofileOutlinePageTreeViewer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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;
}
});
}
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:39,代码来源:DwprofileOutlinePageTreeViewer.java
示例3: HyexpressionOutlinePageTreeViewer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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;
}
});
}
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:39,代码来源:HyexpressionOutlinePageTreeViewer.java
示例4: HyvalidityformulaOutlinePageTreeViewer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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;
}
});
}
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:39,代码来源:HyvalidityformulaOutlinePageTreeViewer.java
示例5: HydatavalueOutlinePageTreeViewer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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;
}
});
}
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:39,代码来源:HydatavalueOutlinePageTreeViewer.java
示例6: HymappingOutlinePageTreeViewer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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;
}
});
}
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:39,代码来源:HymappingOutlinePageTreeViewer.java
示例7: HyconstraintsOutlinePageTreeViewer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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;
}
});
}
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:39,代码来源:HyconstraintsOutlinePageTreeViewer.java
示例8: HymanifestOutlinePageTreeViewer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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;
}
});
}
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:39,代码来源:HymanifestOutlinePageTreeViewer.java
示例9: CrossCollectionProjectTable
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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();
}
});
}
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:61,代码来源:CrossCollectionProjectTable.java
示例10: CrossCollectionRepositoryTable
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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();
}
});
}
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:61,代码来源:CrossCollectionRepositoryTable.java
示例11: addTreeView
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
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)
}
开发者ID:nresare,项目名称:javapasswordsafe,代码行数:56,代码来源:PasswordSafeJFace.java
示例12: createTableViewer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
/**
* 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;
}
开发者ID:eclipse,项目名称:eavp,代码行数:75,代码来源:TableComponentComposite.java
示例13: createElementComparer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
private IElementComparer createElementComparer() {
if (getRootMode() == PROJECTS_AS_ROOTS)
return null;
else
return WorkingSetModel.COMPARER;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:7,代码来源:PackageExplorerPart.java
示例14: getComparer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
@Override
public IElementComparer getComparer() {
return fViewer.getComparer();
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:PackageViewerWrapper.java
示例15: setComparer
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
@Override
public void setComparer(IElementComparer comparer) {
fViewer.setComparer(comparer);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:5,代码来源:PackageViewerWrapper.java
示例16: TypedStructuredSelection
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
public TypedStructuredSelection(List<?> elements, IElementComparer comparer) {
super(elements, comparer);
}
开发者ID:GoClipse,项目名称:goclipse,代码行数:4,代码来源:CheckboxTableViewerExt.java
示例17: CellSelection
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
/**
* 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;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:18,代码来源:CellSelection.java
示例18: SelectionWithFocusRow
import org.eclipse.jface.viewers.IElementComparer; //导入依赖的package包/类
/**
* FIXME
* @param elements
* @param focusElement
* @param comparer
*/
public SelectionWithFocusRow(List elements, Object focusElement, IElementComparer comparer) {
super(elements,comparer);
this.focusElement = focusElement;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:11,代码来源:SelectionWithFocusRow.java
注:本文中的org.eclipse.jface.viewers.IElementComparer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论