use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class MapSeedNodes method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
if (object == null || !(object instanceof NetworkMap))
return dialogArea;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
viewer = new TableViewer(dialogArea, SWT.BORDER);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new LabelProvider() {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
public String getText(Object element) {
return ((AbstractObject) element).getObjectName();
}
});
NXCSession session = (NXCSession) ConsoleSharedData.getSession();
seedNodes = new HashSet<AbstractObject>(session.findMultipleObjects(((NetworkMap) object).getSeedObjectIds(), false));
viewer.setInput(seedNodes);
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText("Add...");
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
addButton.addSelectionListener(new SelectionListener() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
dlg.enableMultiSelection(true);
if (dlg.open() == Window.OK) {
List<AbstractObject> selected = dlg.getSelectedObjects();
if (selected.size() > 0) {
seedNodes.addAll(selected);
viewer.setInput(seedNodes);
isModified = true;
}
}
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText("Delete");
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.addSelectionListener(new SelectionListener() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() > 0) {
seedNodes.removeAll(selection.toList());
viewer.setInput(seedNodes);
isModified = true;
}
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
return dialogArea;
}
use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class TrustedNodes method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().TrustedNodes_Node };
final int[] columnWidths = { 300 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
AbstractObject[] nodes = object.getTrustedNodes();
for (int i = 0; i < nodes.length; i++) {
if (nodes[i] != null)
trustedNodes.put(nodes[i].getObjectId(), nodes[i]);
}
viewer.setInput(trustedNodes.values().toArray());
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().TrustedNodes_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(true));
if (dlg.open() == Window.OK) {
AbstractObject[] nodes = dlg.getSelectedObjects(AbstractNode.class);
for (int i = 0; i < nodes.length; i++) trustedNodes.put(nodes[i].getObjectId(), nodes[i]);
viewer.setInput(trustedNodes.values().toArray());
isModified = true;
}
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().TrustedNodes_Delete);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator<AbstractObject> it = selection.iterator();
if (it.hasNext()) {
while (it.hasNext()) {
AbstractObject object = it.next();
trustedNodes.remove(object.getObjectId());
}
viewer.setInput(trustedNodes.values().toArray());
isModified = true;
}
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
return dialogArea;
}
use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class Dashboards method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
Composite dialogArea = new Composite(parent, SWT.NONE);
object = (AbstractObject) getElement().getAdapter(AbstractObject.class);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
final String[] columnNames = { Messages.get().Dashboards_Dashboard };
final int[] columnWidths = { 300 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
for (AbstractObject d : object.getDashboards(false)) dashboards.put(d.getObjectId(), d);
viewer.setInput(dashboards.values().toArray());
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
viewer.getControl().setLayoutData(gridData);
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
buttons.setLayoutData(gridData);
addButton = new Button(buttons, SWT.PUSH);
addButton.setText(Messages.get().TrustedNodes_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getShell(), null, ObjectSelectionDialog.createDashboardSelectionFilter());
dlg.showFilterToolTip(false);
if (dlg.open() == Window.OK) {
AbstractObject[] d = dlg.getSelectedObjects(Dashboard.class);
for (int i = 0; i < d.length; i++) dashboards.put(d[i].getObjectId(), d[i]);
viewer.setInput(dashboards.values().toArray());
isModified = true;
}
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().TrustedNodes_Delete);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Iterator<AbstractObject> it = selection.iterator();
if (it.hasNext()) {
while (it.hasNext()) {
AbstractObject object = it.next();
dashboards.remove(object.getObjectId());
}
viewer.setInput(dashboards.values().toArray());
isModified = true;
}
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
return dialogArea;
}
use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class ExportFileBuilder method addTemplates.
/**
* Add templates to list
*/
private void addTemplates() {
final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createTemplateSelectionFilter());
dlg.enableMultiSelection(true);
dlg.showFilterToolTip(false);
if (dlg.open() == Window.OK) {
final Set<Long> idList = new HashSet<Long>();
for (AbstractObject o : dlg.getSelectedObjects()) {
if (o instanceof TemplateGroup) {
Set<AbstractObject> children = ((TemplateGroup) o).getAllChilds(AbstractObject.OBJECT_TEMPLATE);
for (AbstractObject child : children) {
templates.put(((Template) child).getObjectId(), (Template) child);
idList.add(child.getObjectId());
}
} else if (o instanceof Template) {
templates.put(((Template) o).getObjectId(), (Template) o);
idList.add(o.getObjectId());
}
}
templateViewer.setInput(templates.values().toArray());
setModified();
new ConsoleJob(Messages.get().ExportFileBuilder_ResolveJobName, this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
final Set<Long> eventCodes = new HashSet<Long>();
final Map<Long, Script> scriptList = new HashMap<Long, Script>();
for (Long id : idList) {
long[] e = session.getDataCollectionEvents(id);
for (long c : e) {
if (c >= 100000)
eventCodes.add(c);
}
for (Script s : session.getDataCollectionScripts(id)) scriptList.put(s.getId(), s);
}
runInUIThread(new Runnable() {
@Override
public void run() {
for (EventObject e : session.findMultipleEventObjects(eventCodes.toArray(new Long[eventCodes.size()]))) {
events.put(e.getCode(), e);
}
eventViewer.setInput(events.values().toArray());
scripts.putAll(scriptList);
scriptViewer.setInput(scripts.values().toArray());
}
});
}
@Override
protected String getErrorMessage() {
return null;
}
}.start();
}
}
use of org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog in project netxms by netxms.
the class ApplyTemplate method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
if ((parentId == null) || (parentId.isEmpty()))
return;
final ObjectSelectionDialog dlg = new ObjectSelectionDialog(shell, null, ObjectSelectionDialog.createNodeSelectionFilter(true));
if (dlg.open() == Window.OK) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().ApplyTemplate_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().ApplyTemplate_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
List<AbstractObject> objects = dlg.getSelectedObjects();
for (AbstractObject o : objects) if (parentId == null) {
session.applyTemplate(0, o.getObjectId());
} else {
for (Long l : parentId) {
if (o instanceof Container) {
for (AbstractObject obj : ((Container) o).getAllChilds(AbstractObject.OBJECT_NODE)) {
session.applyTemplate(l, obj.getObjectId());
}
} else
session.applyTemplate(l, o.getObjectId());
}
}
}
}.start();
}
}
Aggregations