Search in sources :

Example 1 with Zone

use of org.netxms.client.objects.Zone in project netxms by netxms.

the class NXCSession method removeOrphanedObjects.

/**
 * Remove orphaned objects (with last parent left)
 *
 * @param parent
 */
private void removeOrphanedObjects(AbstractObject parent) {
    Iterator<Long> it = parent.getChildren();
    while (it.hasNext()) {
        AbstractObject object = objectList.get(it.next());
        if ((object != null) && (object.getParentCount() == 1)) {
            objectList.remove(object.getObjectId());
            objectListGUID.remove(object.getGuid());
            if (object instanceof Zone)
                zoneList.remove(((Zone) object).getUIN());
            removeOrphanedObjects(object);
        }
    }
}
Also used : Zone(org.netxms.client.objects.Zone) AbstractObject(org.netxms.client.objects.AbstractObject) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 2 with Zone

use of org.netxms.client.objects.Zone 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 Zone

use of org.netxms.client.objects.Zone in project netxms by netxms.

the class DashboardsDynamicMenu 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 object = (AbstractObject) ((IStructuredSelection) selection).getFirstElement();
    if (!(object instanceof Container) && !(object instanceof Cluster) && !(object instanceof Node) && !(object instanceof MobileDevice) && !(object instanceof ServiceRoot) && !(object instanceof Subnet) && !(object instanceof Zone) && !(object instanceof Condition) && !(object instanceof EntireNetwork) && !(object instanceof Sensor))
        return;
    List<AbstractObject> dashboards = object.getDashboards(true);
    if (dashboards.isEmpty())
        return;
    Collections.sort(dashboards, new Comparator<AbstractObject>() {

        @Override
        public int compare(AbstractObject o1, AbstractObject o2) {
            return o1.getObjectName().compareToIgnoreCase(o2.getObjectName());
        }
    });
    final Menu dashboardsMenu = new Menu(menu);
    for (AbstractObject d : dashboards) {
        final MenuItem item = new MenuItem(dashboardsMenu, SWT.PUSH);
        item.setText(d.getObjectName());
        item.setData(d.getObjectId());
        item.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                try {
                    window.getActivePage().showView(DashboardView.ID, item.getData().toString(), IWorkbenchPage.VIEW_ACTIVATE);
                } catch (PartInitException ex) {
                    MessageDialogHelper.openError(window.getShell(), Messages.get().OpenDashboard_Error, Messages.get().OpenDashboard_ErrorText + ex.getMessage());
                }
            }
        });
    }
    MenuItem dashboardsMenuItem = new MenuItem(menu, SWT.CASCADE, index);
    dashboardsMenuItem.setText(Messages.get().DashboardsDynamicMenu_Dashboards);
    dashboardsMenuItem.setMenu(dashboardsMenu);
}
Also used : Condition(org.netxms.client.objects.Condition) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Zone(org.netxms.client.objects.Zone) Node(org.netxms.client.objects.Node) 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) ServiceRoot(org.netxms.client.objects.ServiceRoot) Container(org.netxms.client.objects.Container) MobileDevice(org.netxms.client.objects.MobileDevice) AbstractObject(org.netxms.client.objects.AbstractObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AbstractObject(org.netxms.client.objects.AbstractObject) Menu(org.eclipse.swt.widgets.Menu) PartInitException(org.eclipse.ui.PartInitException) Subnet(org.netxms.client.objects.Subnet) Sensor(org.netxms.client.objects.Sensor)

Example 4 with Zone

use of org.netxms.client.objects.Zone in project netxms by netxms.

the class ZoneSelector method setZoneUIN.

/**
 * Set zone UIN
 *
 * @param zoneUIN new zone UIN
 */
public void setZoneUIN(long zoneUIN) {
    this.zoneUIN = zoneUIN;
    if (zoneUIN == -1) {
        // $NON-NLS-1$
        setText(emptySelectionName);
    } else {
        final Zone zone = ConsoleSharedData.getSession().findZone(zoneUIN);
        // $NON-NLS-1$ //$NON-NLS-2$
        setText((zone != null) ? zone.getObjectName() : ("<" + Long.toString(zoneUIN) + ">"));
    }
}
Also used : Zone(org.netxms.client.objects.Zone)

Example 5 with Zone

use of org.netxms.client.objects.Zone in project netxms by netxms.

the class ObjectFinder method startSearch.

/**
 * Start search
 */
private void startSearch() {
    InetAddress addrStart = null, addrEnd = null;
    if (!ipRangeStart.getText().trim().isEmpty() && !ipRangeEnd.getText().trim().isEmpty()) {
        try {
            addrStart = InetAddress.getByName(ipRangeStart.getText().trim());
        } catch (UnknownHostException e) {
            MessageDialogHelper.openWarning(getSite().getShell(), "Warning", "IP address range start is invalid");
        }
        try {
            addrEnd = InetAddress.getByName(ipRangeEnd.getText().trim());
        } catch (UnknownHostException e) {
            MessageDialogHelper.openWarning(getSite().getShell(), "Warning", "IP address range end is invalid");
        }
    }
    List<Integer> classFilter = new ArrayList<Integer>();
    for (Object o : classList.getCheckedElements()) classFilter.add(((ObjectClass) o).classId);
    List<Long> zoneFilter = new ArrayList<Long>();
    if (session.isZoningEnabled()) {
        for (Object o : zoneList.getCheckedElements()) zoneFilter.add(((Zone) o).getUIN());
    }
    if (radioRegularExpression.getSelection())
        doSearch(text.getText().trim(), SEARCH_MODE_REGEXP, classFilter, zoneFilter, addrStart, addrEnd);
    else
        doSearch(text.getText().trim().toLowerCase(), radioPattern.getSelection() ? SEARCH_MODE_PATTERN : SEARCH_MODE_NORMAL, classFilter, zoneFilter, addrStart, addrEnd);
}
Also used : UnknownHostException(java.net.UnknownHostException) Zone(org.netxms.client.objects.Zone) ArrayList(java.util.ArrayList) AbstractObject(org.netxms.client.objects.AbstractObject) GenericObject(org.netxms.client.objects.GenericObject) InetAddress(java.net.InetAddress)

Aggregations

Zone (org.netxms.client.objects.Zone)14 AbstractObject (org.netxms.client.objects.AbstractObject)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 AbstractNode (org.netxms.client.objects.AbstractNode)3 AccessPoint (org.netxms.client.objects.AccessPoint)3 Cluster (org.netxms.client.objects.Cluster)3 Container (org.netxms.client.objects.Container)3 Subnet (org.netxms.client.objects.Subnet)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 RowLayout (org.eclipse.swt.layout.RowLayout)2 Button (org.eclipse.swt.widgets.Button)2 Group (org.eclipse.swt.widgets.Group)2 Menu (org.eclipse.swt.widgets.Menu)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2