org.eclipse.jface.viewers.IElementComparer Java Examples

The following examples show how to use org.eclipse.jface.viewers.IElementComparer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnhancedCheckBoxTableViewer.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructs a new hash table with the given capacity and the given element comparer.
 *
 * @param capacity
 *          the maximum number of elements that can be added without rehashing
 * @param comparer
 *          the element comparer to use to compare keys and obtain hash codes for keys, or
 *          <code>null</code> to use the normal <code>equals</code> and <code>hashCode</code>
 *          methods
 */
public CustomHashtable(int capacity, IElementComparer comparer) {
  if (capacity >= 0) {
    elementCount = 0;
    elementData = new HashMapEntry[capacity == 0 ? 1 : capacity];
    firstSlot = elementData.length;
    loadFactor = 0.75f;
    computeMaxSize();
  } else {
    throw new IllegalArgumentException();
  }
  this.comparer = comparer;
}
 
Example #2
Source File: PackageExplorerPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private IElementComparer createElementComparer() {
	if (getRootMode() == PROJECTS_AS_ROOTS)
		return null;
	else
		return WorkingSetModel.COMPARER;
}
 
Example #3
Source File: PackageViewerWrapper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IElementComparer getComparer() {
	return fViewer.getComparer();
}
 
Example #4
Source File: PackageViewerWrapper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void setComparer(IElementComparer comparer) {
	fViewer.setComparer(comparer);
}
 
Example #5
Source File: CheckboxTableViewerExt.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
public TypedStructuredSelection(List<?> elements, IElementComparer comparer) {
	super(elements, comparer);
}
 
Example #6
Source File: XPathExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createXPathChooser(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final GridLayout gl = new GridLayout(1, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    composite.setLayout(gl);
    final Label label = new Label(composite, SWT.WRAP);
    label.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 30).create());
    label.setText(Messages.selectElementLabel);

    xsdViewer = new TreeViewer(composite);
    provider = new XSDContentProvider(true);
    xsdViewer.setComparer(new IElementComparer() {

        @Override
        public int hashCode(final Object element) {
            return element.hashCode();
        }

        @Override
        public boolean equals(final Object a, final Object b) {
            if (a instanceof XSDFeature && b instanceof XSDFeature) {
                final String aName = ((XSDFeature) a).getName();
                final String bName = ((XSDFeature) b).getName();
                if (aName.equals(bName)) {
                    return EcoreUtil.equals(((XSDFeature) a).getType(), ((XSDFeature) b).getType());
                }
            }
            return a.equals(b);
        }
    });
    xsdViewer.setContentProvider(provider);
    final XSDLabelProvider labelProvider = new XSDLabelProvider();
    xsdViewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
    final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.minimumHeight = 100;
    xsdViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 150).create());
    xsdViewer.setInput(new Object());

    text = new Text(composite, SWT.WRAP | SWT.BORDER);
    text.setLayoutData(GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 40).create());

    xsdViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final ITreeSelection selection = (ITreeSelection) xsdViewer.getSelection();
            //                final String xpath = computeXPath(selection, false);
            //                if (dataName != null) {
            //                    if (xpath == null || xpath.isEmpty()) {
            //                        text.setText(dataName);
            //                    } else {
            //                        text.setText(xpath);
            //                    }
            //                }
            text.redraw();
            //                typeCombo.setSelection(new StructuredSelection(XPathReturnType.getType(selection.getFirstElement())));
            XPathExpressionEditor.this.fireSelectionChanged();
        }
    });

}
 
Example #7
Source File: DecisionTableWizard.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public void setActionsComparer(IElementComparer comparer) {
	this.actionComparer = comparer;
}
 
Example #8
Source File: DecisionTableWizard.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @return
 */
public IElementComparer getActionsComparer() {
	return this.actionComparer;
}
 
Example #9
Source File: EnhancedCheckBoxTableViewer.java    From eclipse-cs with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Constructs a new hash table with enough capacity to hold all keys in the given hash table,
 * then adds all key/value pairs in the given hash table to the new one, using the given element
 * comparer.
 *
 * @param capacity
 *          the maximum number of elements that can be added without rehashing
 * @param comparer
 *          the element comparer to use to compare keys and obtain hash codes for keys, or
 *          <code>null</code> to use the normal <code>equals</code> and <code>hashCode</code>
 *          methods
 */
public CustomHashtable(CustomHashtable table, IElementComparer comparer) {
  this(table.size() * 2, comparer);
  for (int i = table.elementData.length; --i >= 0;) {
    HashMapEntry entry = table.elementData[i];
    while (entry != null) {
      put(entry.key, entry.value);
      entry = entry.next;
    }
  }
}
 
Example #10
Source File: CellSelection.java    From nebula with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source File: SelectionWithFocusRow.java    From nebula with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * FIXME
 * @param elements
 * @param focusElement
 * @param comparer
 */
public SelectionWithFocusRow(List elements, Object focusElement, IElementComparer comparer) {
       super(elements,comparer);
       this.focusElement = focusElement;
}
 
Example #12
Source File: EnhancedCheckBoxTableViewer.java    From eclipse-cs with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Constructs a new hash table with the default capacity and the given element comparer.
 *
 * @param comparer
 *          the element comparer to use to compare keys and obtain hash codes for keys, or
 *          <code>null</code> to use the normal <code>equals</code> and <code>hashCode</code>
 *          methods
 */
public CustomHashtable(IElementComparer comparer) {
  this(DEFAULT_CAPACITY, comparer);
}
 
Example #13
Source File: CellSelection.java    From translationstudio8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #14
Source File: SelectionWithFocusRow.java    From translationstudio8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * FIXME
 * @param elements
 * @param focusElement
 * @param comparer
 */
public SelectionWithFocusRow(List elements, Object focusElement, IElementComparer comparer) {
       super(elements,comparer);
       this.focusElement = focusElement;
}
 
Example #15
Source File: CellSelection.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * 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;
}
 
Example #16
Source File: SelectionWithFocusRow.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * FIXME
 * @param elements
 * @param focusElement
 * @param comparer
 */
public SelectionWithFocusRow(List elements, Object focusElement, IElementComparer comparer) {
       super(elements,comparer);
       this.focusElement = focusElement;
}