Java Code Examples for org.eclipse.jface.viewers.TableViewer#remove()

The following examples show how to use org.eclipse.jface.viewers.TableViewer#remove() . 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: TypeScriptSearchTableContentProvider.java    From typescript.java with MIT License 6 votes vote down vote up
public void elementsChanged(Object[] updatedElements) {
	TableViewer viewer = getViewer();
	int elementLimit = getElementLimit();
	boolean tableLimited = elementLimit != -1;
	for (int i = 0; i < updatedElements.length; i++) {
		if (fResult.getMatchCount(updatedElements[i]) > 0) {
			if (viewer.testFindItem(updatedElements[i]) != null)
				viewer.update(updatedElements[i], null);
			else {
				if (!tableLimited || viewer.getTable().getItemCount() < elementLimit)
					viewer.add(updatedElements[i]);
			}
		} else
			viewer.remove(updatedElements[i]);
	}
}
 
Example 2
Source File: FileTableContentProvider.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void elementsChanged(Object[] updatedElements) {
    TableViewer viewer = getViewer();
    int elementLimit = getElementLimit();
    boolean tableLimited = elementLimit != -1;
    for (int i = 0; i < updatedElements.length; i++) {
        if (fResult.getMatchCount(updatedElements[i]) > 0) {
            if (viewer.testFindItem(updatedElements[i]) != null)
                viewer.update(updatedElements[i], null);
            else {
                if (!tableLimited || viewer.getTable().getItemCount() < elementLimit)
                    viewer.add(updatedElements[i]);
            }
        } else
            viewer.remove(updatedElements[i]);
    }
}
 
Example 3
Source File: UnDefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void handleUnDefineDelButton(TableViewer tableViewer) {
  final IStructuredSelection selection = (IStructuredSelection) tableViewer
      .getSelection();
  final Shell shell = tableViewer.getControl().getShell();
  if (MessageDialog.openQuestion(shell,
      "CMake-Undefine deletion confirmation",
      "Are you sure to delete the selected CMake-undefines?")) {
    @SuppressWarnings("unchecked")
    ArrayList<String> undefines = (ArrayList<String>) tableViewer.getInput();
    undefines.removeAll(selection.toList());
    tableViewer.remove(selection.toArray());// updates the display
  }
}
 
Example 4
Source File: DefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void handleDefineDelButton(TableViewer tableViewer) {
  final IStructuredSelection selection = (IStructuredSelection) tableViewer
      .getSelection();
  final Shell shell = tableViewer.getControl().getShell();
  if (MessageDialog.openQuestion(shell, "CMake-Define deletion confirmation",
      "Are you sure to delete the selected CMake-defines?")) {
    @SuppressWarnings("unchecked")
    ArrayList<CmakeDefine> defines = (ArrayList<CmakeDefine>) tableViewer
        .getInput();
    defines.removeAll(selection.toList());
    tableViewer.remove(selection.toArray());// updates the display
  }
}
 
Example 5
Source File: JavaSearchTableContentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void elementsChanged(Object[] updatedElements) {
	if (getSearchResult() == null)
		return;

	int addLimit= getAddLimit();

	TableViewer viewer= (TableViewer) getPage().getViewer();
	Set<Object> updated= new HashSet<Object>();
	Set<Object> added= new HashSet<Object>();
	Set<Object> removed= new HashSet<Object>();
	for (int i= 0; i < updatedElements.length; i++) {
		if (getPage().getDisplayedMatchCount(updatedElements[i]) > 0) {
			if (viewer.testFindItem(updatedElements[i]) != null)
				updated.add(updatedElements[i]);
			else {
				if (addLimit > 0) {
					added.add(updatedElements[i]);
					addLimit--;
				}
			}
		} else {
			removed.add(updatedElements[i]);
		}
	}

	viewer.add(added.toArray());
	viewer.update(updated.toArray(), new String[] { SearchLabelProvider.PROPERTY_MATCH_COUNT });
	viewer.remove(removed.toArray());
}