use of org.netxms.ui.eclipse.perfview.views.helpers.GraphTreeLabelProvider in project netxms by netxms.
the class PredefinedGraphTree method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
session = (NXCSession) ConsoleSharedData.getSession();
parent.setLayout(new FormLayout());
// Create filter area
filterText = new FilterText(parent, SWT.NONE);
filterText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
onFilterModify();
}
});
filterText.setCloseAction(new Action() {
@Override
public void run() {
enableFilter(false);
}
});
viewer = new TreeViewer(parent, SWT.NONE);
viewer.setUseHashlookup(true);
viewer.setContentProvider(new GraphTreeContentProvider());
viewer.setLabelProvider(new GraphTreeLabelProvider());
viewer.setComparer(new IElementComparer() {
@Override
public int hashCode(Object element) {
if ((element instanceof GraphSettings)) {
return (int) ((GraphSettings) element).getId();
}
if ((element instanceof GraphFolder)) {
return ((GraphFolder) element).getName().hashCode();
}
return element.hashCode();
}
@Override
public boolean equals(Object a, Object b) {
if ((a instanceof GraphSettings) && (b instanceof GraphSettings))
return ((GraphSettings) a).getId() == ((GraphSettings) b).getId();
if ((a instanceof GraphFolder) && (b instanceof GraphFolder))
return ((GraphFolder) a).getName().equals(((GraphFolder) b).getName());
return a.equals(b);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
actionOpen.run();
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@SuppressWarnings("rawtypes")
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator it = selection.iterator();
boolean enabled = false;
while (it.hasNext()) {
if (it.next() instanceof GraphSettings) {
enabled = true;
break;
}
}
actionOpen.setEnabled(enabled);
actionDelete.setEnabled(enabled);
actionProperties.setEnabled(enabled);
}
});
filter = new GraphTreeFilter();
viewer.addFilter(filter);
// Setup layout
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(filterText);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
viewer.getTree().setLayoutData(fd);
fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
filterText.setLayoutData(fd);
activateContext();
createActions();
contributeToActionBars();
createPopupMenu();
reloadGraphList();
session.addListener(this);
// Set initial focus to filter input line
if (initShowFilter)
filterText.setFocus();
else
// Will hide filter area correctly
enableFilter(false);
}
Aggregations