use of org.netxms.ui.eclipse.objectbrowser.widgets.ObjectTree in project netxms by netxms.
the class SelectDciDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
Composite dialogArea = (Composite) super.createDialogArea(parent);
dialogArea.setLayout(new FillLayout());
if (fixedNode == 0) {
splitter = new SashForm(dialogArea, SWT.HORIZONTAL);
objectTree = new ObjectTree(splitter, SWT.BORDER, ObjectTree.NONE, null, ObjectSelectionDialog.createNodeSelectionFilter(true), true, false);
// $NON-NLS-1$
String text = settings.get("SelectDciDialog.Filter");
if (text != null)
objectTree.setFilter(text);
}
dciList = new DciList(null, (fixedNode == 0) ? splitter : dialogArea, SWT.BORDER, null, "SelectDciDialog.dciList", dcObjectType, allowSingleSelection ? SWT.NONE : SWT.MULTI, // $NON-NLS-1$
allowNoValueObjects);
dciList.setDcObjectType(dcObjectType);
dciList.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
okPressed();
}
});
if (fixedNode == 0) {
try {
int[] weights = new int[2];
// $NON-NLS-1$
weights[0] = settings.getInt("SelectDciDialog.weight1");
// $NON-NLS-1$
weights[1] = settings.getInt("SelectDciDialog.weight2");
splitter.setWeights(weights);
} catch (NumberFormatException e) {
splitter.setWeights(new int[] { 30, 70 });
}
objectTree.getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
AbstractObject object = objectTree.getFirstSelectedObject2();
if ((object != null) && ((object instanceof AbstractNode) || (object instanceof MobileDevice) || (object instanceof Cluster) || (allowTemplateItems && (object instanceof Template) || (object instanceof Sensor)))) {
dciList.setNode(object);
} else {
dciList.setNode(null);
}
}
});
objectTree.setFocus();
} else {
dciList.setNode(((NXCSession) ConsoleSharedData.getSession()).findObjectById(fixedNode));
}
return dialogArea;
}
use of org.netxms.ui.eclipse.objectbrowser.widgets.ObjectTree in project netxms by netxms.
the class ObjectBrowser method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
FormLayout formLayout = new FormLayout();
parent.setLayout(formLayout);
// Read custom root objects
long[] rootObjects = null;
objectTree = new ObjectTree(parent, SWT.NONE, ObjectTree.MULTI, rootObjects, null, true, true);
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
objectTree.setLayoutData(fd);
objectTree.setHideSubInterfaces(initHideSubInterfaces);
objectTree.setHideTemplateChecks(initHideTemplateChecks);
objectTree.setHideUnmanaged(initHideUnmanaged);
objectTree.enableFilter(initShowFilter);
objectTree.enableStatusIndicator(initShowStatus);
objectTree.addOpenListener(new ObjectOpenListener() {
@Override
public boolean openObject(AbstractObject object) {
return callOpenObjectHandler(object);
}
});
createActions();
createMenu();
createToolBar();
createPopupMenu();
objectTree.enableDropSupport(this);
objectTree.enableDragSupport();
getSite().setSelectionProvider(objectTree.getTreeViewer());
objectTree.getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int size = ((IStructuredSelection) objectTree.getTreeViewer().getSelection()).size();
actionMoveObject.setEnabled(size == 1);
}
});
objectTree.setFilterCloseAction(new Action() {
@Override
public void run() {
actionShowFilter.setChecked(false);
objectTree.enableFilter(false);
}
});
final TreeViewer tree = objectTree.getTreeViewer();
TreeViewerEditor.create(tree, new ColumnViewerEditorActivationStrategy(tree) {
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
return event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
}
}, ColumnViewerEditor.DEFAULT);
TextCellEditor editor = new TextCellEditor(tree.getTree(), SWT.BORDER);
editor.addListener(new ICellEditorListener() {
@Override
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
}
@Override
public void cancelEditor() {
objectTree.enableRefresh();
}
@Override
public void applyEditorValue() {
}
});
// TODO: override editor method that creates control to disable refresh
tree.setCellEditors(new CellEditor[] { editor });
// $NON-NLS-1$
tree.setColumnProperties(new String[] { "name" });
tree.setCellModifier(new ICellModifier() {
@Override
public void modify(Object element, String property, Object value) {
final Object data = (element instanceof Item) ? ((Item) element).getData() : element;
if (// $NON-NLS-1$
property.equals("name")) {
if (data instanceof AbstractObject) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final String newName = value.toString();
new ConsoleJob(Messages.get().ObjectBrowser_RenameJobName, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.setObjectName(((AbstractObject) data).getObjectId(), newName);
}
@Override
protected String getErrorMessage() {
return String.format(Messages.get().ObjectBrowser_RenameJobError, ((AbstractObject) data).getObjectName());
}
}.start();
}
}
objectTree.enableRefresh();
}
@Override
public Object getValue(Object element, String property) {
if (// $NON-NLS-1$
property.equals("name")) {
if (element instanceof AbstractObject) {
return ((AbstractObject) element).getObjectName();
}
}
return null;
}
@Override
public boolean canModify(Object element, String property) {
if (// $NON-NLS-1$
property.equals("name")) {
objectTree.disableRefresh();
return true;
}
// $NON-NLS-1$
return false;
}
});
activateContext();
restoreSelection();
}
use of org.netxms.ui.eclipse.objectbrowser.widgets.ObjectTree in project netxms by netxms.
the class ObjectSelectionDialog method createDialogArea.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
* .Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
IDialogSettings settings = Activator.getDefault().getDialogSettings();
Composite dialogArea = (Composite) super.createDialogArea(parent);
dialogArea.setLayout(new FormLayout());
objectTree = new ObjectTree(dialogArea, SWT.NONE, multiSelection ? ObjectTree.MULTI : 0, rootObjects, classFilter, showFilterToolTip, showFilterCloseButton);
// $NON-NLS-1$
String text = settings.get("SelectObject.Filter");
if (text != null)
objectTree.setFilter(text);
FormData fd = new FormData();
fd.left = new FormAttachment(0, 0);
fd.top = new FormAttachment(0, 0);
fd.right = new FormAttachment(100, 0);
fd.bottom = new FormAttachment(100, 0);
objectTree.setLayoutData(fd);
return dialogArea;
}
use of org.netxms.ui.eclipse.objectbrowser.widgets.ObjectTree in project netxms by netxms.
the class DashboardNavigator 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();
final Set<Integer> classFilter = new HashSet<Integer>(2);
classFilter.add(AbstractObject.OBJECT_DASHBOARDGROUP);
classFilter.add(AbstractObject.OBJECT_DASHBOARD);
objectTree = new ObjectTree(parent, SWT.NONE, ObjectTree.NONE, getRootObjects(classFilter), classFilter, false, true);
objectTree.enableFilter(false);
objectTree.getTreeViewer().expandToLevel(2);
createActions();
contributeToActionBars();
createPopupMenu();
getSite().setSelectionProvider(objectTree.getTreeViewer());
sessionListener = new SessionListener() {
@Override
public void notificationHandler(SessionNotification n) {
if ((n.getCode() == SessionNotification.OBJECT_CHANGED) && (n.getObject() instanceof DashboardRoot)) {
objectTree.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
}
};
session.addListener(sessionListener);
}
use of org.netxms.ui.eclipse.objectbrowser.widgets.ObjectTree in project netxms by netxms.
the class SelectInstallTargetDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
dialogArea.setLayout(layout);
final SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
objectTree.setEnabled(radioInstallOnSelected.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
};
radioInstallOnCurrent = new Button(dialogArea, SWT.RADIO);
radioInstallOnCurrent.setText(Messages.get().SelectInstallTargetDialog_InstallOnAlreadyInstalled);
radioInstallOnCurrent.setSelection(installMode == INSTALL_ON_CURRENT);
radioInstallOnCurrent.addSelectionListener(listener);
radioInstallOnSelected = new Button(dialogArea, SWT.RADIO);
radioInstallOnSelected.setText(Messages.get().SelectInstallTargetDialog_InstallOnSelected);
radioInstallOnSelected.setSelection(installMode == INSTALL_ON_SELECTED);
radioInstallOnSelected.addSelectionListener(listener);
// Read custom root objects
long[] rootObjects = null;
// $NON-NLS-1$
Object value = ConsoleSharedData.getProperty("PolicyManager.rootObjects");
if ((value != null) && (value instanceof long[])) {
rootObjects = (long[]) value;
}
objectTree = new ObjectTree(dialogArea, SWT.BORDER, ObjectTree.CHECKBOXES, rootObjects, ObjectSelectionDialog.createNodeSelectionFilter(false), true, false);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 300;
objectTree.setLayoutData(gd);
objectTree.setEnabled(installMode == INSTALL_ON_SELECTED);
return dialogArea;
}
Aggregations