use of org.netxms.ui.eclipse.widgets.SetEditor 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;
}
Aggregations