Java Code Examples for org.eclipse.swt.widgets.Tree.isDisposed()

The following are Jave code examples for showing how to use isDisposed() of the org.eclipse.swt.widgets.Tree class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: SMVHunter   File: DeviceContentProvider.java   Source Code and License Vote up 6 votes
@Override
public void setChildren(final FileEntry entry, FileEntry[] children) {
    final Tree t = mViewer.getTree();
    if (t != null && t.isDisposed() == false) {
        Display display = t.getDisplay();
        if (display.isDisposed() == false) {
            display.asyncExec(new Runnable() {
                @Override
                public void run() {
                    if (t.isDisposed() == false) {
                        // refresh the entry.
                        mViewer.refresh(entry);

                        // force it open, since on linux and windows
                        // when getChildren() returns null, the node is
                        // not considered expanded.
                        mViewer.setExpandedState(entry, true);
                    }
                }
            });
        }
    }
}
 
Example 2
Project: SMVHunter   File: DeviceContentProvider.java   Source Code and License Vote up 6 votes
@Override
public void refreshEntry(final FileEntry entry) {
    final Tree t = mViewer.getTree();
    if (t != null && t.isDisposed() == false) {
        Display display = t.getDisplay();
        if (display.isDisposed() == false) {
            display.asyncExec(new Runnable() {
                @Override
                public void run() {
                    if (t.isDisposed() == false) {
                        // refresh the entry.
                        mViewer.refresh(entry);
                    }
                }
            });
        }
    }
}
 
Example 3
Project: eclipse-batch-editor   File: AbstractFilterableTreeQuickDialog.java   Source Code and License Vote up 5 votes
@Override
public void keyPressed(KeyEvent event) {
	if (event.keyCode == SWT.ARROW_DOWN) {
		Tree tree = treeViewer.getTree();
		if (tree.isDisposed()) {
			return;
		}
		if (tree.isFocusControl()) {
			return;
		}
		tree.setFocus();
		return;
	}
	if (event.character == '\r') {
		ISelection selection = treeViewer.getSelection();
		openSelectionAndCloseDialog(selection);
		return;
	}
	boolean allowedChar = false;
	allowedChar = allowedChar || event.character == '*';
	allowedChar = allowedChar || event.character == '(';
	allowedChar = allowedChar || event.character == ')';
	allowedChar = allowedChar || Character.isJavaIdentifierPart(event.character);
	allowedChar = allowedChar || Character.isWhitespace(event.character);
	if (!allowedChar) {
		event.doit = false;
		return;
	}
	if (treeViewer == null) {
		return;
	}

}
 
Example 4
Project: eclipse-bash-editor   File: AbstractFilterableTreeQuickDialog.java   Source Code and License Vote up 5 votes
@Override
public void keyPressed(KeyEvent event) {
	if (event.keyCode == SWT.ARROW_DOWN) {
		Tree tree = treeViewer.getTree();
		if (tree.isDisposed()) {
			return;
		}
		if (tree.isFocusControl()) {
			return;
		}
		tree.setFocus();
		return;
	}
	if (event.character == '\r') {
		ISelection selection = treeViewer.getSelection();
		openSelectionAndCloseDialog(selection);
		return;
	}
	boolean allowedChar = false;
	allowedChar = allowedChar || event.character == '*';
	allowedChar = allowedChar || event.character == '(';
	allowedChar = allowedChar || event.character == ')';
	allowedChar = allowedChar || Character.isJavaIdentifierPart(event.character);
	allowedChar = allowedChar || Character.isWhitespace(event.character);
	if (!allowedChar) {
		event.doit = false;
		return;
	}
	if (treeViewer == null) {
		return;
	}

}
 
Example 5
Project: egradle   File: AbstractFilterableTreeQuickDialog.java   Source Code and License Vote up 5 votes
@Override
public void keyPressed(KeyEvent event) {
	if (event.keyCode == SWT.ARROW_DOWN) {
		Tree tree = treeViewer.getTree();
		if (tree.isDisposed()) {
			return;
		}
		if (tree.isFocusControl()) {
			return;
		}
		tree.setFocus();
		return;
	}
	if (event.character == '\r') {
		ISelection selection = treeViewer.getSelection();
		openSelectionAndCloseDialog(selection);
		return;
	}
	boolean allowedChar = false;
	allowedChar = allowedChar || event.character == '*';
	allowedChar = allowedChar || event.character == '(';
	allowedChar = allowedChar || event.character == ')';
	allowedChar = allowedChar || Character.isJavaIdentifierPart(event.character);
	allowedChar = allowedChar || Character.isWhitespace(event.character);
	if (!allowedChar) {
		event.doit = false;
		return;
	}
	if (treeViewer == null) {
		return;
	}

}
 
Example 6
Project: PDFReporter-Studio   File: JDReportOutlineView.java   Source Code and License Vote up 5 votes
/**
 * Sets the contents.
 * 
 * @param contents
 *          the new contents
 */
public void setContents(Object contents) {
	if (getViewer().getEditPartFactory() != null){
		getViewer().setContents(contents);
	}
	if (outline instanceof Tree) {
		Tree tree = (Tree) outline;
		if (!tree.isDisposed() && tree.getItems() != null && tree.getItems().length > 0)
			tree.getItem(0).setExpanded(true);
	}
}
 
Example 7
Project: mytourbook   File: ColumnManager.java   Source Code and License Vote up 5 votes
/**
 * Read the column order from a table/tree.
 * 
 * @return Returns <code>null</code> when table/tree cannot be accessed.
 */
private String[] getColumns_FromViewer_Ids() {

	final ArrayList<String> orderedColumnIds = new ArrayList<String>();

	int[] columnOrder = null;

	if (_columnViewer instanceof TableViewer) {

		final Table table = ((TableViewer) _columnViewer).getTable();
		if (table.isDisposed()) {
			return null;
		}
		columnOrder = table.getColumnOrder();

	} else if (_columnViewer instanceof TreeViewer) {

		final Tree tree = ((TreeViewer) _columnViewer).getTree();
		if (tree.isDisposed()) {
			return null;
		}
		columnOrder = tree.getColumnOrder();
	}

	if (columnOrder == null) {
		return null;
	}

	// create columns in the correct sort order
	for (final int createIndex : columnOrder) {

		final ColumnDefinition colDef = getColDef_ByCreateIndex(createIndex);

		if (colDef != null) {
			orderedColumnIds.add(colDef.getColumnId());
		}
	}

	return orderedColumnIds.toArray(new String[orderedColumnIds.size()]);
}