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);
}
}
}
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();
}
}
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);
}
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) + ">"));
}
}
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);
}
Aggregations