use of org.netxms.ui.eclipse.tools.ObjectLabelComparator 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.tools.ObjectLabelComparator 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.tools.ObjectLabelComparator in project netxms by netxms.
the class AccessControl method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
objectTool = (ObjectToolDetails) getElement().getAdapter(ObjectToolDetails.class);
// Build internal copy of access list
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
for (Long uid : objectTool.getAccessList()) {
AbstractUserObject o = session.findUserDBObjectById(uid);
if (o != null)
acl.add(o);
}
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.INNER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
Label label = new Label(dialogArea, SWT.NONE);
label.setText(Messages.get().AccessControl_Label);
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
viewer.getTable().setSortDirection(SWT.UP);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 300;
viewer.getTable().setLayoutData(gd);
viewer.setInput(acl.toArray());
Composite buttons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttons.setLayout(buttonLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.verticalIndent = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
buttons.setLayoutData(gd);
buttonAdd = new Button(buttons, SWT.PUSH);
buttonAdd.setText(Messages.get().AccessControl_Add);
buttonAdd.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addUser();
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonAdd.setLayoutData(rd);
buttonRemove = new Button(buttons, SWT.PUSH);
buttonRemove.setText(Messages.get().AccessControl_Delete);
buttonRemove.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
removeUsers();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
buttonRemove.setLayoutData(rd);
return dialogArea;
}
use of org.netxms.ui.eclipse.tools.ObjectLabelComparator in project netxms by netxms.
the class ExportFileBuilder method createEventSection.
/**
* Create "Events" section
*/
private void createEventSection() {
Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText(Messages.get().ExportFileBuilder_SectionEvents);
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
Composite clientArea = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
clientArea.setLayout(layout);
section.setClient(clientArea);
eventViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
toolkit.adapt(eventViewer.getTable());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 200;
gd.verticalSpan = 2;
eventViewer.getTable().setLayoutData(gd);
eventViewer.setContentProvider(new ArrayContentProvider());
eventViewer.setLabelProvider(new WorkbenchLabelProvider());
eventViewer.setComparator(new ObjectLabelComparator((ILabelProvider) eventViewer.getLabelProvider()));
eventViewer.getTable().setSortDirection(SWT.UP);
final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkAdd.setText(Messages.get().ExportFileBuilder_Add);
linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkAdd.setLayoutData(gd);
linkAdd.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
addEvents();
}
});
final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkRemove.setText(Messages.get().ExportFileBuilder_Remove);
linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkRemove.setLayoutData(gd);
linkRemove.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
removeObjects(eventViewer, events);
}
});
}
use of org.netxms.ui.eclipse.tools.ObjectLabelComparator in project netxms by netxms.
the class ExportFileBuilder method createTrapSection.
/**
* Create "SNMP Traps" section
*/
private void createTrapSection() {
Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText(Messages.get().ExportFileBuilder_SectionTraps);
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
Composite clientArea = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
clientArea.setLayout(layout);
section.setClient(clientArea);
trapViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
toolkit.adapt(trapViewer.getTable());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.heightHint = 200;
gd.verticalSpan = 2;
trapViewer.getTable().setLayoutData(gd);
trapViewer.setContentProvider(new ArrayContentProvider());
trapViewer.setLabelProvider(new TrapListLabelProvider());
trapViewer.setComparator(new ObjectLabelComparator((ILabelProvider) eventViewer.getLabelProvider()));
trapViewer.getTable().setSortDirection(SWT.UP);
final ImageHyperlink linkAdd = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkAdd.setText(Messages.get().ExportFileBuilder_Add);
linkAdd.setImage(SharedIcons.IMG_ADD_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkAdd.setLayoutData(gd);
linkAdd.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
if (snmpTrapCache == null) {
new ConsoleJob(Messages.get().ExportFileBuilder_TrapsLoadJobName, ExportFileBuilder.this, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
snmpTrapCache = session.getSnmpTrapsConfigurationSummary();
runInUIThread(new Runnable() {
@Override
public void run() {
addTraps();
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().ExportFileBuilder_TrapsLoadJobError;
}
}.start();
} else {
addTraps();
}
}
});
final ImageHyperlink linkRemove = toolkit.createImageHyperlink(clientArea, SWT.NONE);
linkRemove.setText(Messages.get().ExportFileBuilder_Remove);
linkRemove.setImage(SharedIcons.IMG_DELETE_OBJECT);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
linkRemove.setLayoutData(gd);
linkRemove.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(HyperlinkEvent e) {
removeObjects(trapViewer, traps);
}
});
}
Aggregations