use of org.netxms.ui.eclipse.tools.ObjectLabelComparator in project netxms by netxms.
the class PersistentStorageView method createPartControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
// GridLayout layout = new GridLayout();
// layout.verticalSpacing = WidgetHelper.INNER_SPACING;
// layout.marginWidth = 0;
// layout.marginHeight = 0;
// parent.setLayout(layout);
final String[] setColumnNames = { "Key", "Value" };
final int[] setColumnWidths = { 150, 200 };
viewerSetValue = new SortableTableViewer(parent, setColumnNames, setColumnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewerSetValue.setContentProvider(new ArrayContentProvider());
viewerSetValue.setLabelProvider(new AttributeLabelProvider());
viewerSetValue.setComparator(new ObjectLabelComparator((ILabelProvider) viewerSetValue.getLabelProvider()));
viewerSetValue.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int size = ((IStructuredSelection) viewerSetValue.getSelection()).size();
actionEdit.setEnabled(size == 1);
actionDelete.setEnabled(size > 0);
}
});
createActions();
contributeToActionBars();
createPopupMenu();
refresh();
}
use of org.netxms.ui.eclipse.tools.ObjectLabelComparator in project netxms by netxms.
the class RulePStorage method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
editor = (RuleEditor) getElement().getAdapter(RuleEditor.class);
rule = editor.getRule();
pStorageDelete.addAll(rule.getPStorageDelete());
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);
final int vInd = WidgetHelper.OUTER_SPACING - WidgetHelper.INNER_SPACING;
Label label = new Label(dialogArea, SWT.NONE);
label.setText("Set persistent storage values");
GridData gd = new GridData();
gd.verticalIndent = vInd;
label.setLayoutData(gd);
sEditor = new SetEditor(dialogArea, SWT.NONE);
sEditor.putAll(rule.getPStorageSet());
gd = new GridData();
gd.verticalIndent = vInd;
gd.verticalAlignment = GridData.FILL;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
sEditor.setLayoutData(gd);
label = new Label(dialogArea, SWT.NONE);
label.setText("Delete persistent storage entries");
gd = new GridData();
gd.verticalIndent = vInd;
label.setLayoutData(gd);
final String[] deleteColumnNames = { "Key" };
final int[] deleteColumnWidths = { 150 };
viewerDeleteValue = new SortableTableViewer(dialogArea, deleteColumnNames, deleteColumnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewerDeleteValue.setContentProvider(new ArrayContentProvider());
viewerDeleteValue.setComparator(new ObjectLabelComparator((ILabelProvider) viewerDeleteValue.getLabelProvider()));
viewerDeleteValue.setInput(pStorageDelete.toArray());
viewerDeleteValue.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int size = ((IStructuredSelection) viewerDeleteValue.getSelection()).size();
editDeleteValueButton.setEnabled(size == 1);
removeDeleteValueButton.setEnabled(size > 0);
}
});
gd = new GridData();
gd.verticalAlignment = GridData.FILL;
gd.grabExcessVerticalSpace = true;
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
viewerDeleteValue.getControl().setLayoutData(gd);
Composite buttonsDeleteValue = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginLeft = 0;
buttonLayout.marginRight = 0;
buttonsDeleteValue.setLayout(buttonLayout);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
buttonsDeleteValue.setLayoutData(gd);
addDeleteValueButton = new Button(buttonsDeleteValue, SWT.PUSH);
addDeleteValueButton.setText("Add");
addDeleteValueButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addPStorageDeleteAction();
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addDeleteValueButton.setLayoutData(rd);
editDeleteValueButton = new Button(buttonsDeleteValue, SWT.PUSH);
editDeleteValueButton.setText("Edit");
editDeleteValueButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
editPStorageDeleteAction();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
editDeleteValueButton.setLayoutData(rd);
editDeleteValueButton.setEnabled(false);
removeDeleteValueButton = new Button(buttonsDeleteValue, SWT.PUSH);
removeDeleteValueButton.setText("Delete");
removeDeleteValueButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deletePStorageDeleteAction();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
removeDeleteValueButton.setLayoutData(rd);
removeDeleteValueButton.setEnabled(false);
return dialogArea;
}
use of org.netxms.ui.eclipse.tools.ObjectLabelComparator in project netxms by netxms.
the class RuleEvents method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
session = (NXCSession) ConsoleSharedData.getSession();
editor = (RuleEditor) getElement().getAdapter(RuleEditor.class);
rule = editor.getRule();
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
checkInverted = new Button(dialogArea, SWT.CHECK);
checkInverted.setText(Messages.get().RuleEvents_InvertedRule);
checkInverted.setSelection(rule.isEventsInverted());
final String[] columnNames = { Messages.get().RuleEvents_Event };
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 EventObjectLabelProvider());
viewer.setComparator(new ObjectLabelComparator((ILabelProvider) viewer.getLabelProvider()));
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
int size = ((IStructuredSelection) viewer.getSelection()).size();
deleteButton.setEnabled(size > 0);
}
});
for (EventObject o : session.findMultipleEventObjects(rule.getEvents().toArray(new Long[0]))) events.put(o.getCode(), o);
viewer.setInput(events.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.marginLeft = 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(Messages.get().RuleEvents_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
addEvent();
}
});
RowData rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
addButton.setLayoutData(rd);
deleteButton = new Button(buttons, SWT.PUSH);
deleteButton.setText(Messages.get().RuleEvents_Delete);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
deleteEvent();
}
});
rd = new RowData();
rd.width = WidgetHelper.BUTTON_WIDTH_HINT;
deleteButton.setLayoutData(rd);
deleteButton.setEnabled(false);
return dialogArea;
}
use of org.netxms.ui.eclipse.tools.ObjectLabelComparator in project netxms by netxms.
the class ExportFileBuilder method createTemplateSection.
/**
* Create "Templates" section
*/
private void createTemplateSection() {
Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
section.setText(Messages.get().ExportFileBuilder_SectionTemplates);
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);
templateViewer = new TableViewer(clientArea, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
toolkit.adapt(templateViewer.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;
templateViewer.getTable().setLayoutData(gd);
templateViewer.setContentProvider(new ArrayContentProvider());
templateViewer.setLabelProvider(new WorkbenchLabelProvider());
templateViewer.setComparator(new ObjectLabelComparator((ILabelProvider) templateViewer.getLabelProvider()));
templateViewer.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) {
addTemplates();
}
});
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(templateViewer, templates);
}
});
}
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) {
Composite dialogArea = (Composite) super.createContents(parent);
dco = editor.getObject();
// Initiate loading of user manager plugin if it was not loaded before
// $NON-NLS-1$ //$NON-NLS-2$
Platform.getAdapterManager().loadAdapter(new User(""), "org.eclipse.ui.model.IWorkbenchAdapter");
// Build internal copy of access list
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
for (Long uid : dco.getAccessList()) {
AbstractUserObject o = session.findUserDBObjectById(uid);
if (o != null)
acl.add(o);
}
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("Restrict access to the following users");
viewer = new TableViewer(dialogArea, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new AccessListLabelProvider());
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);
setViewerInput();
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("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("Remove");
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;
}
Aggregations