use of org.netxms.client.datacollection.DciSummaryTableDescriptor 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.datacollection.DciSummaryTableDescriptor in project netxms by netxms.
the class SummaryTableManager method refresh.
/**
* Refresh viewer
*/
private void refresh() {
new // $NON-NLS-1$
ConsoleJob(// $NON-NLS-1$
"Get configured DCI summary tables", // $NON-NLS-1$
this, // $NON-NLS-1$
Activator.PLUGIN_ID, // $NON-NLS-1$
null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final List<DciSummaryTableDescriptor> list = session.listDciSummaryTables();
runInUIThread(new Runnable() {
@Override
public void run() {
descriptors.clear();
for (DciSummaryTableDescriptor d : list) descriptors.put(d.getId(), d);
viewer.setInput(descriptors.values().toArray());
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().SummaryTableManager_JobError;
}
}.start();
}
use of org.netxms.client.datacollection.DciSummaryTableDescriptor in project netxms by netxms.
the class SummaryTableManager method editSummaryTable.
/**
* Edit existing dataset
*/
private void editSummaryTable() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final DciSummaryTableDescriptor d = (DciSummaryTableDescriptor) selection.getFirstElement();
new ConsoleJob(Messages.get().SummaryTableManager_ReadJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final DciSummaryTable t = session.getDciSummaryTable(d.getId());
runInUIThread(new Runnable() {
@Override
public void run() {
PropertyDialog dlg = PropertyDialog.createDialogOn(getSite().getShell(), null, t);
dlg.getShell().setText(Messages.get().SummaryTableManager_TitleEdit);
dlg.open();
d.updateFromTable(t);
viewer.update(d, null);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().SummaryTableManager_ReadJobError;
}
}.start();
}
use of org.netxms.client.datacollection.DciSummaryTableDescriptor in project netxms by netxms.
the class SummaryTableSelectionDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
final Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
dialogArea.setLayout(layout);
viewer = new TableViewer(dialogArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((DciSummaryTableDescriptor) element).getTitle() + " (" + ((DciSummaryTableDescriptor) element).getMenuPath().replace("&", "") + ")";
}
});
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
String n1 = ((DciSummaryTableDescriptor) e1).getTitle() + " (" + ((DciSummaryTableDescriptor) e1).getMenuPath().replace("&", "") + ")";
String n2 = ((DciSummaryTableDescriptor) e2).getTitle() + " (" + ((DciSummaryTableDescriptor) e2).getMenuPath().replace("&", "") + ")";
return n1.compareToIgnoreCase(n2);
}
});
viewer.setInput(SummaryTablesCache.getInstance().getTables());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 400;
viewer.getControl().setLayoutData(gd);
return dialogArea;
}
use of org.netxms.client.datacollection.DciSummaryTableDescriptor in project netxms by netxms.
the class ExportFileBuilder method doExport.
/**
* Do export operation and call completion handler when done
*
* @param completionHandler
*/
private void doExport(final ExportCompletionHandler completionHandler) {
final long[] eventList = new long[events.size()];
int i = 0;
for (EventObject o : events.values()) eventList[i++] = o.getCode();
final long[] templateList = new long[templates.size()];
i = 0;
for (Template t : templates.values()) templateList[i++] = t.getObjectId();
final long[] trapList = new long[traps.size()];
i = 0;
for (SnmpTrap t : traps.values()) trapList[i++] = t.getId();
final UUID[] ruleList = new UUID[rules.size()];
i = 0;
for (EventProcessingPolicyRule r : rules.values()) ruleList[i++] = r.getGuid();
final long[] scriptList = new long[scripts.size()];
i = 0;
for (Script s : scripts.values()) scriptList[i++] = s.getId();
final long[] toolList = new long[tools.size()];
i = 0;
for (ObjectTool t : tools.values()) toolList[i++] = t.getId();
final long[] summaryTableList = new long[summaryTables.size()];
i = 0;
for (DciSummaryTableDescriptor t : summaryTables.values()) summaryTableList[i++] = t.getId();
final long[] actionList = new long[actions.size()];
i = 0;
for (ServerAction a : actions.values()) actionList[i++] = a.getId();
final String descriptionText = description.getText();
new ConsoleJob(Messages.get().ExportFileBuilder_ExportJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final String xml = session.exportConfiguration(descriptionText, eventList, trapList, templateList, ruleList, scriptList, toolList, summaryTableList, actionList);
runInUIThread(new Runnable() {
@Override
public void run() {
completionHandler.exportCompleted(xml);
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ExportFileBuilder_ExportJobError;
}
}.start();
}
Aggregations