use of org.eclipse.jface.viewers.ITreeViewerListener in project tdi-studio-se by Talend.
the class StatLogsAndImplicitcontextTreeViewPage method createStatTree.
private void createStatTree(Composite composite) {
//$NON-NLS-1$
Group g = widgetFactory.createGroup(composite, Messages.getString("StatsAndLogsComposite.StatsLogsSettings"));
GridData gd = new GridData(GridData.FILL_BOTH);
g.setLayoutData(gd);
g.setLayout(new FillLayout());
statViewer = new CheckboxRepositoryTreeViewer(g, SWT.MULTI | SWT.V_SCROLL);
statContentProvider = new AllJobContentProvider(repositoryView);
statViewer.setContentProvider(statContentProvider);
statViewer.setLabelProvider(new RepositoryLabelProvider(repositoryView));
statViewer.setSorter(repositoryView.getViewer().getSorter());
IViewSite viewSite = repositoryView.getViewSite();
statViewer.setInput(viewSite);
// This only tree listener aim is to change open/close icons on folders :
statViewer.addTreeListener(new ITreeViewerListener() {
@Override
public void treeCollapsed(TreeExpansionEvent event) {
RepositoryNode node = (RepositoryNode) event.getElement();
if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
TreeItem item = getObject(statViewer.getTree(), event.getElement());
if (item != null) {
item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_CLOSE_ICON));
}
}
}
@Override
public void treeExpanded(TreeExpansionEvent event) {
RepositoryNode node = (RepositoryNode) event.getElement();
if (node.getType().equals(ENodeType.SIMPLE_FOLDER)) {
TreeItem item = getObject(statViewer.getTree(), event.getElement());
if (item != null) {
item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_OPEN_ICON));
}
}
}
});
statViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
RepositoryNode node = (RepositoryNode) event.getElement();
List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
processItems(objects, node);
if (event.getChecked()) {
statAddedObjects.addAll(objects);
statRemovedObjects.removeAll(objects);
statCheckedObjects.addAll(objects);
} else {
statAddedObjects.removeAll(objects);
statRemovedObjects.addAll(objects);
statCheckedObjects.removeAll(objects);
}
// set checked
statViewer.setCheckedElements(statCheckedObjects.toArray());
// viewer.refresh();
}
});
RepositoryNode[] nodes = statContentProvider.getContents();
List<RepositoryNode> objects = new ArrayList<RepositoryNode>();
if (nodes != null) {
for (RepositoryNode n : nodes) {
processItems(objects, n);
for (RepositoryNode node : objects) {
if (isStatUseProjectSetting(node)) {
if (!statCheckedObjects.contains(node)) {
statCheckedObjects.add(node);
}
}
}
}
}
statViewer.setCheckedElements(statCheckedObjects.toArray());
if (nodes != null) {
statViewer.setExpandedElements(nodes);
}
}
use of org.eclipse.jface.viewers.ITreeViewerListener in project cubrid-manager by CUBRID.
the class CubridHostNavigatorView method createNavigator.
/**
* Create the navigator
*/
protected void createNavigator() {
tv.setSorter(new CMNavigatorViewSorter());
tv.setContentProvider(new DeferredContentProvider());
tv.setLabelProvider(new DecoratingLabelProvider(new NavigatorTreeLabelProvider()));
tv.addDoubleClickListener(LayoutManager.getInstance());
tv.addTreeListener(new ITreeViewerListener() {
public void treeCollapsed(TreeExpansionEvent event) {
CommonUITool.clearExpandedElements(tv);
}
public void treeExpanded(TreeExpansionEvent event) {
CommonUITool.clearExpandedElements(tv);
}
});
CubridActionBuilder.init();
hookRetragetActions();
addHostListener();
}
use of org.eclipse.jface.viewers.ITreeViewerListener in project eclipse.platform.text by eclipse.
the class FileSearchPage method configureTreeViewer.
@Override
protected void configureTreeViewer(TreeViewer viewer) {
viewer.setUseHashlookup(true);
FileLabelProvider innerLabelProvider = new FileLabelProvider(this, FileLabelProvider.SHOW_LABEL);
viewer.setLabelProvider(new DecoratingFileSearchLabelProvider(innerLabelProvider));
viewer.setContentProvider(new FileTreeContentProvider(this, viewer));
viewer.setComparator(new DecoratorIgnoringViewerSorter(innerLabelProvider));
fContentProvider = (IFileSearchContentProvider) viewer.getContentProvider();
addDragAdapters(viewer);
viewer.addTreeListener(new ITreeViewerListener() {
@Override
public void treeCollapsed(TreeExpansionEvent event) {
}
@Override
public void treeExpanded(TreeExpansionEvent event) {
autoExpand(viewer, event.getElement());
}
});
}
use of org.eclipse.jface.viewers.ITreeViewerListener in project dsl-devkit by dsldevkit.
the class ValidPreferenceCheckedTreeViewer method initViewer.
/**
* Initialize the tree viewer.
*/
private void initViewer() {
setUseHashlookup(true);
addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
doCheckStateChanged(event.getElement());
}
});
addTreeListener(new ITreeViewerListener() {
@Override
public void treeCollapsed(final TreeExpansionEvent event) {
// nothing to do here
}
@Override
public void treeExpanded(final TreeExpansionEvent event) {
final Widget item = findItem(event.getElement());
if (item instanceof TreeItem) {
initializeItem((TreeItem) item);
}
}
});
}
use of org.eclipse.jface.viewers.ITreeViewerListener in project usbdm-eclipse-plugins by podonoghue.
the class DeviceSelectorPanel method createControl.
/**
* Create control composite
*
* @param parent
*/
private void createControl(Composite parent) {
setLayout(new GridLayout(3, false));
Label label = new Label(this, SWT.NONE);
label.setText("Search Filter: ");
fDeviceText = new Text(this, SWT.BORDER);
fDeviceText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
fDeviceText.setToolTipText("Filter/name of device");
fDeviceText.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
}
@Override
public void focusGained(FocusEvent e) {
fDeviceText.selectAll();
}
});
fDeviceText.setText(NO_DEVICE_STRING);
fDeviceText.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) {
e.text = e.text.toUpperCase();
if (!e.text.matches("[A-Z|0-9|_\\-]*")) {
e.doit = false;
}
}
});
fDeviceText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
fMatchErrorMsg = null;
try {
filter = new NameFilter(fDeviceText.getText());
} catch (PatternSyntaxException e) {
fMatchErrorMsg = "Illegal filter";
filter = Filter.NullNameFilter;
}
filterNodes();
}
});
fButton = new Button(this, SWT.NONE);
fButton.setText("X");
fButton.setToolTipText("Clear filter");
GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
gd.widthHint = 40;
fButton.setLayoutData(gd);
fButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
fDeviceText.setText(NO_DEVICE_STRING);
fDeviceText.setFocus();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
}
});
fViewer = new TreeViewer(this, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
fViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
fViewer.getTree().setToolTipText("Available devices");
fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
// System.err.println("selectionChanged() "+event);
if (!((TreeViewer) event.getSource()).getControl().isFocusControl()) {
// Filter selection events due to re-population of tree i.e. when tree doesn't have focus
return;
}
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) {
Object domain = iterator.next();
if (domain instanceof DeviceModel) {
DeviceModel deviceModel = (DeviceModel) domain;
fDeviceName = deviceModel.getName();
fDeviceText.setText(fDeviceName);
}
}
}
});
fViewer.setContentProvider(new ViewContentProvider());
fViewer.setInput(fModel);
fViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parent, Object item) {
if (item instanceof BaseModel) {
boolean rv = ((BaseModel) item).isAvailable();
return rv;
}
return true;
}
});
fViewer.addTreeListener(new ITreeViewerListener() {
@Override
public void treeExpanded(TreeExpansionEvent event) {
if (fMatchingNodesCount <= EXPAND_THRESHOLD) {
return;
}
Object domain = event.getElement();
if (domain instanceof CategoryModel) {
CategoryModel deviceModel = (CategoryModel) domain;
BaseModel parent = deviceModel.getParent();
for (BaseModel sibling : parent.getChildren()) {
if (sibling == domain) {
continue;
}
fViewer.collapseToLevel(sibling, AbstractTreeViewer.ALL_LEVELS);
}
}
}
@Override
public void treeCollapsed(TreeExpansionEvent arg0) {
}
});
}
Aggregations