Search in sources :

Example 1 with Cluster

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);
        }
    }
}
Also used : Condition(org.netxms.client.objects.Condition) Container(org.netxms.client.objects.Container) AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) Cluster(org.netxms.client.objects.Cluster)

Example 2 with Cluster

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();
    }
}
Also used : HashMap(java.util.HashMap) Zone(org.netxms.client.objects.Zone) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Cluster(org.netxms.client.objects.Cluster) MenuItem(org.eclipse.swt.widgets.MenuItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EntireNetwork(org.netxms.client.objects.EntireNetwork) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor) ServiceRoot(org.netxms.client.objects.ServiceRoot) Container(org.netxms.client.objects.Container) AbstractObject(org.netxms.client.objects.AbstractObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AbstractObject(org.netxms.client.objects.AbstractObject) Menu(org.eclipse.swt.widgets.Menu) Subnet(org.netxms.client.objects.Subnet)

Example 3 with Cluster

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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) AbstractNode(org.netxms.client.objects.AbstractNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Cluster(org.netxms.client.objects.Cluster) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) DciList(org.netxms.ui.eclipse.datacollection.widgets.DciList) Template(org.netxms.client.objects.Template) SashForm(org.eclipse.swt.custom.SashForm) MobileDevice(org.netxms.client.objects.MobileDevice) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) ObjectTree(org.netxms.ui.eclipse.objectbrowser.widgets.ObjectTree) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) AbstractObject(org.netxms.client.objects.AbstractObject) Sensor(org.netxms.client.objects.Sensor)

Example 4 with Cluster

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;
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionObject(org.netxms.client.datacollection.DataCollectionObject) AbstractObject(org.netxms.client.objects.AbstractObject) Cluster(org.netxms.client.objects.Cluster) Template(org.netxms.client.objects.Template)

Example 5 with Cluster

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);
}
Also used : ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) AbstractObject(org.netxms.client.objects.AbstractObject) Cluster(org.netxms.client.objects.Cluster) Template(org.netxms.client.objects.Template)

Aggregations

Cluster (org.netxms.client.objects.Cluster)22 AbstractObject (org.netxms.client.objects.AbstractObject)21 Container (org.netxms.client.objects.Container)11 AbstractNode (org.netxms.client.objects.AbstractNode)10 ServiceRoot (org.netxms.client.objects.ServiceRoot)7 Condition (org.netxms.client.objects.Condition)6 MobileDevice (org.netxms.client.objects.MobileDevice)6 Node (org.netxms.client.objects.Node)6 Sensor (org.netxms.client.objects.Sensor)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 Composite (org.eclipse.swt.widgets.Composite)5 NXCSession (org.netxms.client.NXCSession)5 Subnet (org.netxms.client.objects.Subnet)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 Template (org.netxms.client.objects.Template)4 ArrayList (java.util.ArrayList)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 RowLayout (org.eclipse.swt.layout.RowLayout)3 PartInitException (org.eclipse.ui.PartInitException)3