use of org.netxms.client.objects.Cluster in project netxms by netxms.
the class ServiceTreeModel method addToModel.
/**
* Add given object and it's appropriate child objects to model
*
* @param object NetXMS object
*/
private void addToModel(ServiceTreeElement parent, AbstractObject object, int level) {
final ServiceTreeElement element = new ServiceTreeElement(parent, object);
elements.add(element);
for (AbstractObject o : object.getChildsAsArray()) {
if ((o instanceof Container) || (o instanceof Node) || (o instanceof Cluster) || (o instanceof Condition)) {
addToModel(element, o, level + 1);
}
}
}
use of org.netxms.client.objects.Cluster in project netxms by netxms.
the class SummaryTablesDynamicMenu method fill.
/* (non-Javadoc)
* @see org.eclipse.jface.action.ContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
*/
@Override
public void fill(Menu menu, int index) {
final Object selection = evalService.getCurrentState().getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
if ((selection == null) || !(selection instanceof IStructuredSelection))
return;
final AbstractObject baseObject = (AbstractObject) ((IStructuredSelection) selection).getFirstElement();
if (!(baseObject instanceof Container) && !(baseObject instanceof Cluster) && !(baseObject instanceof ServiceRoot) && !(baseObject instanceof Subnet) && !(baseObject instanceof Zone) && !(baseObject instanceof EntireNetwork))
return;
final Menu tablesMenu = new Menu(menu);
DciSummaryTableDescriptor[] tables = SummaryTablesCache.getInstance().getTables();
Arrays.sort(tables, new Comparator<DciSummaryTableDescriptor>() {
@Override
public int compare(DciSummaryTableDescriptor arg0, DciSummaryTableDescriptor arg1) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
return arg0.getMenuPath().replace("&", "").compareToIgnoreCase(arg1.getMenuPath().replace("&", ""));
}
});
Map<String, Menu> menus = new HashMap<String, Menu>();
int added = 0;
for (int i = 0; i < tables.length; i++) {
if (tables[i].getMenuPath().isEmpty())
continue;
// $NON-NLS-1$
String[] path = tables[i].getMenuPath().split("\\-\\>");
Menu rootMenu = tablesMenu;
for (int j = 0; j < path.length - 1; j++) {
// $NON-NLS-1$ //$NON-NLS-2$
String key = path[j].replace("&", "");
Menu currMenu = menus.get(key);
if (currMenu == null) {
currMenu = new Menu(rootMenu);
MenuItem item = new MenuItem(rootMenu, SWT.CASCADE);
item.setText(path[j]);
item.setMenu(currMenu);
menus.put(key, currMenu);
}
rootMenu = currMenu;
}
final MenuItem item = new MenuItem(rootMenu, SWT.PUSH);
item.setText(path[path.length - 1]);
item.setData(tables[i]);
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
queryTable(baseObject.getObjectId(), ((DciSummaryTableDescriptor) item.getData()).getId());
}
});
added++;
}
if (added > 0) {
MenuItem tablesMenuItem = new MenuItem(menu, SWT.CASCADE, index);
tablesMenuItem.setText(Messages.get().SummaryTablesDynamicMenu_MenuName);
tablesMenuItem.setMenu(tablesMenu);
} else {
tablesMenu.dispose();
}
}
use of org.netxms.client.objects.Cluster 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.client.objects.Cluster in project netxms by netxms.
the class DataCollectionObjectPropertyTester method test.
/* (non-Javadoc)
* @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
*/
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
if (!(receiver instanceof DataCollectionObject))
return false;
if (// $NON-NLS-1$
property.equals("isClusterObject")) {
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
AbstractObject owner = session.findObjectById(((DataCollectionObject) receiver).getNodeId());
if (owner instanceof Cluster)
return true;
if (owner instanceof AbstractNode) {
for (AbstractObject o : owner.getParentsAsArray()) {
if (o instanceof Cluster)
return true;
}
}
return false;
}
if (// $NON-NLS-1$
property.equals("isTemplateObject")) {
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
AbstractObject owner = session.findObjectById(((DataCollectionObject) receiver).getNodeId());
return (owner instanceof Template);
}
return false;
}
use of org.netxms.client.objects.Cluster in project netxms by netxms.
the class TableColumns method queryColumns.
/**
* Query columns from agent
*/
private void queryColumns() {
if (!MessageDialogHelper.openQuestion(getShell(), "Warning", "Current column definition will be replaced by definition provided by agent. Continue?"))
return;
AbstractObject object = ConsoleSharedData.getSession().findObjectById(dci.getNodeId());
if ((editor.getSourceNode() == 0) && ((object instanceof Template) || (object instanceof Cluster))) {
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
if (dlg.open() != Window.OK)
return;
object = dlg.getSelectedObjects().get(0);
}
updateColumnsFromAgent(dci.getName(), true, object);
}
Aggregations