use of org.eclipse.swt.events.TreeEvent in project tdq-studio-se by Talend.
the class TwoPartCheckSelectionDialog method create.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.window.Window#create()
*/
@Override
public void create() {
BusyIndicator.showWhile(null, new Runnable() {
public void run() {
parentCreate();
fViewer.setCheckedElements(getInitialElementSelections().toArray());
fViewer.getTree().addTreeListener(new TreeAdapter() {
@Override
public void treeExpanded(TreeEvent e) {
TreeItem item = (TreeItem) e.item;
handleTreeExpanded(item);
super.treeExpanded(e);
}
});
updateOKStatus();
}
});
}
use of org.eclipse.swt.events.TreeEvent in project tdq-studio-se by Talend.
the class TwoPartCheckSelectionDialog method createFirstPart.
/**
* Creates the tree viewer.
*
* @param parent the parent composite
* @return the tree viewer
*/
protected CheckboxTreeViewer createFirstPart(Composite parent) {
if (fContainerMode) {
if (DIALOG_TYPE_TABLE == this.getDialogType()) {
fViewer = new TableSelectionViewer(parent, SWT.BORDER);
} else if (!this.addConnFilter) {
fViewer = new MatchColumnSelectionViewer(parent, SWT.BORDER);
} else {
fViewer = new ColumnSelectionViewer(parent, SWT.BORDER);
}
// {
//
// protected void handleTreeExpand(TreeEvent event) {
// super.handleTreeExpand(event);
// checkElementChecked();
// }
// };
} else {
fViewer = new CheckboxTreeViewer(parent, SWT.BORDER) {
@Override
protected void handleTreeExpand(TreeEvent event) {
super.handleTreeExpand(event);
// checkElementChecked();
}
};
}
fViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
applyDialogFont(fViewer.getTree());
fViewer.setContentProvider(fContentProvider);
// mod gdbu 2011-7-25 bug 23220
((ResourceViewContentProvider) fContentProvider).setTreeViewer(fViewer);
// ~23220
fViewer.setLabelProvider(fLabelProvider);
fViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateOKStatus();
}
});
fViewer.setComparator(fComparator);
if (fFilters != null) {
for (int i = 0; i != fFilters.size(); i++) {
fViewer.addFilter(fFilters.get(i));
}
}
fViewer.setInput(fInput);
// fViewer.
fViewer.addSelectionChangedListener(this);
return fViewer;
}
use of org.eclipse.swt.events.TreeEvent in project BiglyBT by BiglySoftware.
the class SideBarEntrySWT method setTreeItem.
public void setTreeItem(TreeItem treeItem) {
if (swtItem != null && treeItem != null) {
Debug.out("Warning: Sidebar " + id + " already has a treeitem");
return;
}
this.swtItem = treeItem;
if (treeItem != null) {
setDisposed(false);
ImageLoader imageLoader = ImageLoader.getInstance();
imgClose = imageLoader.getImage("image.sidebar.closeitem");
imgCloseSelected = imageLoader.getImage("image.sidebar.closeitem-selected");
treeItem.addDisposeListener(this);
treeItem.getParent().addTreeListener(new TreeListener() {
@Override
public void treeExpanded(TreeEvent e) {
if (e.item == swtItem) {
SideBarEntrySWT.super.setExpanded(true);
}
}
@Override
public void treeCollapsed(TreeEvent e) {
if (e.item == swtItem) {
SideBarEntrySWT.super.setExpanded(false);
}
}
});
// Some/All OSes will auto-set treeitem's expanded flag to false if there
// is no children. To workaround, we store expanded state internally and
// set parent to expanded when a child is added
TreeItem parentItem = treeItem.getParentItem();
if (parentItem != null) {
MdiEntry parentEntry = (MdiEntry) parentItem.getData("MdiEntry");
if (parentEntry.isExpanded()) {
parentItem.setExpanded(true);
}
}
setExpanded(isExpanded());
}
if (buildonSWTItemSet) {
build();
}
if (showonSWTItemSet) {
show();
}
}
use of org.eclipse.swt.events.TreeEvent in project netxms by netxms.
the class ObjectTree method enableStatusIndicator.
/**
* @param enabled
*/
public void enableStatusIndicator(boolean enabled) {
if (statusIndicatorEnabled == enabled)
return;
statusIndicatorEnabled = enabled;
if (enabled) {
statusIndicator = new ObjectStatusIndicator(this, SWT.NONE);
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = filterEnabled ? new FormAttachment(filterText) : new FormAttachment(0, 0);
fd.bottom = new FormAttachment(100, 0);
statusIndicator.setLayoutData(fd);
fd = (FormData) objectTree.getTree().getLayoutData();
fd.left = new FormAttachment(statusIndicator);
statusIndicatorSelectionListener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
updateStatusIndicator();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
updateStatusIndicator();
}
};
objectTree.getTree().getVerticalBar().addSelectionListener(statusIndicatorSelectionListener);
statusIndicatorTreeListener = new TreeListener() {
@Override
public void treeCollapsed(TreeEvent e) {
updateStatusIndicator();
}
@Override
public void treeExpanded(TreeEvent e) {
updateStatusIndicator();
}
};
objectTree.getTree().addTreeListener(statusIndicatorTreeListener);
updateStatusIndicator();
} else {
objectTree.getTree().getVerticalBar().removeSelectionListener(statusIndicatorSelectionListener);
objectTree.getTree().removeTreeListener(statusIndicatorTreeListener);
statusIndicator.dispose();
statusIndicator = null;
statusIndicatorSelectionListener = null;
statusIndicatorTreeListener = null;
FormData fd = (FormData) objectTree.getTree().getLayoutData();
fd.left = new FormAttachment(0, 0);
}
layout(true, true);
}
use of org.eclipse.swt.events.TreeEvent in project pentaho-kettle by pentaho.
the class TreeMemory method addTreeListener.
/**
* This method creates, adds and returns a tree listener that will keep track of the expanded/collapsed state of the
* TreeItems. This state will then be stored in the TreeMemory singleton.
*
* @param tree
* The tree to add the listener to
* @return The created/added TreeListener
*/
public static final TreeListener addTreeListener(final Tree tree, final String treeName) {
TreeListener treeListener = new TreeListener() {
public void treeExpanded(TreeEvent e) {
TreeItem treeItem = (TreeItem) e.item;
String[] path = ConstUI.getTreeStrings(treeItem);
TreeMemory treeMemory = TreeMemory.getInstance();
treeMemory.storeExpanded(treeName, path, true);
}
public void treeCollapsed(TreeEvent e) {
TreeItem treeItem = (TreeItem) e.item;
String[] path = ConstUI.getTreeStrings(treeItem);
TreeMemory treeMemory = TreeMemory.getInstance();
treeMemory.storeExpanded(treeName, path, false);
}
};
tree.addTreeListener(treeListener);
return treeListener;
}
Aggregations