use of org.netxms.ui.eclipse.widgets.LabeledSpinner in project netxms by netxms.
the class General 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);
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
textName = new LabeledText(dialogArea, SWT.NONE);
textName.setLabel(Messages.get().General_Name);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textName.setLayoutData(gd);
textName.setText(objectTool.getName());
createIcon();
createIconSelector(dialogArea);
textDescription = new LabeledText(dialogArea, SWT.NONE);
textDescription.setLabel(Messages.get().General_Description);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
textDescription.setLayoutData(gd);
textDescription.setText(objectTool.getDescription());
textData = new LabeledText(dialogArea, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
textData.setLayoutData(gd);
textData.setText(objectTool.getData());
switch(objectTool.getToolType()) {
case ObjectTool.TYPE_INTERNAL:
textData.setLabel(Messages.get().General_Operation);
break;
case ObjectTool.TYPE_LOCAL_COMMAND:
case ObjectTool.TYPE_SERVER_COMMAND:
textData.setLabel(Messages.get().General_Command);
createOutputGroup(dialogArea);
break;
case ObjectTool.TYPE_SERVER_SCRIPT:
textData.setLabel(Messages.get().General_Script);
createOutputGroup(dialogArea);
break;
case ObjectTool.TYPE_ACTION:
textData.setLabel(Messages.get().General_AgentCommand);
createOutputGroup(dialogArea);
break;
case ObjectTool.TYPE_URL:
textData.setLabel(Messages.get().General_URL);
break;
case ObjectTool.TYPE_FILE_DOWNLOAD:
// $NON-NLS-1$
String[] parameters = objectTool.getData().split("\u007F");
textData.setLabel(Messages.get().General_RemoteFileName);
// $NON-NLS-1$
textData.setText((parameters.length > 0) ? parameters[0] : "");
Group fileOptionsGoup = new Group(dialogArea, SWT.NONE);
fileOptionsGoup.setText(Messages.get().General_FileOptions);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
fileOptionsGoup.setLayoutData(gd);
GridLayout fileGroupLayout = new GridLayout();
fileGroupLayout.verticalSpacing = WidgetHelper.OUTER_SPACING;
fileGroupLayout.numColumns = 1;
fileOptionsGoup.setLayout(fileGroupLayout);
maxFileSize = new LabeledSpinner(fileOptionsGoup, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
maxFileSize.setLayoutData(gd);
maxFileSize.setLabel(Messages.get().General_LimitDownloadFileSizeLable);
maxFileSize.setRange(0, 0x7FFFFFFF);
try {
maxFileSize.setSelection((parameters.length > 1) ? Integer.parseInt(parameters[1]) : 0);
} catch (NumberFormatException e) {
maxFileSize.setSelection(0);
}
checkFollow = new Button(fileOptionsGoup, SWT.CHECK);
checkFollow.setText(Messages.get().General_FollowFileChanges);
if (// $NON-NLS-1$
parameters.length > 2) {
// $NON-NLS-1$
checkFollow.setSelection(parameters[2].equals("true") ? true : false);
}
break;
case ObjectTool.TYPE_TABLE_SNMP:
textData.setLabel(Messages.get().General_Title);
Group snmpOptGroup = new Group(dialogArea, SWT.NONE);
snmpOptGroup.setText(Messages.get().General_SNMPListOptions);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
snmpOptGroup.setLayoutData(gd);
layout = new GridLayout();
snmpOptGroup.setLayout(layout);
new Label(snmpOptGroup, SWT.NONE).setText(Messages.get().General_UseAsIndex);
radioIndexOID = new Button(snmpOptGroup, SWT.RADIO);
radioIndexOID.setText(Messages.get().General_OIDSuffix);
radioIndexOID.setSelection((objectTool.getFlags() & ObjectTool.SNMP_INDEXED_BY_VALUE) == 0);
radioIndexValue = new Button(snmpOptGroup, SWT.RADIO);
radioIndexValue.setText(Messages.get().General_FirstColumnValue);
radioIndexValue.setSelection(!radioIndexOID.getSelection());
break;
case ObjectTool.TYPE_TABLE_AGENT:
textData.setLabel(Messages.get().General_Title);
// $NON-NLS-1$
String[] parts = objectTool.getData().split("\u007F");
// $NON-NLS-1$
textData.setText((parts.length > 0) ? parts[0] : "");
textParameter = new LabeledText(dialogArea, SWT.NONE);
textParameter.setLabel(Messages.get().General_Parameter);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
textParameter.setLayoutData(gd);
// $NON-NLS-1$
textParameter.setText((parts.length > 1) ? parts[1] : "");
textRegexp = new LabeledText(dialogArea, SWT.NONE);
textRegexp.setLabel(Messages.get().General_RegExp);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
textRegexp.setLayoutData(gd);
// $NON-NLS-1$
textRegexp.setText((parts.length > 2) ? parts[2] : "");
break;
}
Group confirmationGroup = new Group(dialogArea, SWT.NONE);
confirmationGroup.setText(Messages.get().General_Confirmation);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
confirmationGroup.setLayoutData(gd);
layout = new GridLayout();
confirmationGroup.setLayout(layout);
checkConfirmation = new Button(confirmationGroup, SWT.CHECK);
checkConfirmation.setText(Messages.get().General_RequiresConfirmation);
checkConfirmation.setSelection((objectTool.getFlags() & ObjectTool.ASK_CONFIRMATION) != 0);
checkConfirmation.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
textConfirmation.setEnabled(checkConfirmation.getSelection());
if (checkConfirmation.getSelection())
textConfirmation.setFocus();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
textConfirmation = new LabeledText(confirmationGroup, SWT.NONE);
textConfirmation.setLabel(Messages.get().General_ConfirmationMessage);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textConfirmation.setLayoutData(gd);
textConfirmation.setText(objectTool.getConfirmationText());
textConfirmation.setEnabled(checkConfirmation.getSelection());
Group commandGroup = new Group(dialogArea, SWT.NONE);
commandGroup.setText(Messages.get().General_ShowInCommands);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
commandGroup.setLayoutData(gd);
layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = true;
commandGroup.setLayout(layout);
checkCommand = new Button(commandGroup, SWT.CHECK);
checkCommand.setText(Messages.get().General_ShowInCommandsTooltip);
checkCommand.setSelection((objectTool.getFlags() & ObjectTool.SHOW_IN_COMMANDS) != 0);
checkCommand.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
textCommandName.setEnabled(checkCommand.getSelection());
textCommandShortName.setEnabled(checkCommand.getSelection());
if (checkCommand.getSelection())
textCommandName.setFocus();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
checkCommand.setLayoutData(gd);
textCommandName = new LabeledText(commandGroup, SWT.NONE);
textCommandName.setLabel(Messages.get().General_CommandName);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textCommandName.setLayoutData(gd);
textCommandName.setText(objectTool.getCommandName());
textCommandName.setEnabled(checkCommand.getSelection());
textCommandShortName = new LabeledText(commandGroup, SWT.NONE);
textCommandShortName.setLabel(Messages.get().General_CommandShortName);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
textCommandShortName.setLayoutData(gd);
textCommandShortName.setText(objectTool.getCommandShortName());
textCommandShortName.setEnabled(checkCommand.getSelection());
// Disable option
checkDisable = new Button(dialogArea, SWT.CHECK);
checkDisable.setText(Messages.get().General_DisableObjectToll);
checkDisable.setSelection((objectTool.getFlags() & ObjectTool.DISABLED) > 0);
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.LabeledSpinner in project netxms by netxms.
the class General method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
config = (ChartConfig) getElement().getAdapter(ChartConfig.class);
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);
title = new LabeledText(dialogArea, SWT.NONE, SWT.BORDER);
title.setLabel(Messages.get().General_Title);
title.setText(config.getTitle());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
title.setLayoutData(gd);
Group optionsGroup = new Group(dialogArea, SWT.NONE);
optionsGroup.setText(Messages.get().General_Options);
layout = new GridLayout();
layout.marginWidth = WidgetHelper.OUTER_SPACING;
layout.marginHeight = WidgetHelper.OUTER_SPACING;
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.makeColumnsEqualWidth = true;
layout.numColumns = 3;
optionsGroup.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
optionsGroup.setLayoutData(gd);
checkShowGrid = new Button(optionsGroup, SWT.CHECK);
checkShowGrid.setText(Messages.get().General_ShowGridLines);
checkShowGrid.setSelection(config.isShowGrid());
checkLogScale = new Button(optionsGroup, SWT.CHECK);
checkLogScale.setText(Messages.get().General_LogScale);
checkLogScale.setSelection(config.isLogScale());
lineWidth = new LabeledSpinner(optionsGroup, SWT.NONE);
lineWidth.setLabel(Messages.get().General_LineWidth);
lineWidth.setRange(1, 99);
lineWidth.setSelection(config.getLineWidth());
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.verticalSpan = 2;
lineWidth.setLayoutData(gd);
checkStacked = new Button(optionsGroup, SWT.CHECK);
checkStacked.setText(Messages.get().General_Stacked);
checkStacked.setSelection(config.isStacked());
checkTranslucent = new Button(optionsGroup, SWT.CHECK);
checkTranslucent.setText(Messages.get().General_Translucent);
checkTranslucent.setSelection(config.isTranslucent());
checkShowLegend = new Button(optionsGroup, SWT.CHECK);
checkShowLegend.setText(Messages.get().General_ShowLegend);
checkShowLegend.setSelection(config.isShowLegend());
checkShowLegend.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
checkExtendedLegend.setEnabled(checkShowLegend.getSelection());
legendLocation.setEnabled(checkShowLegend.getSelection());
checkShowHostNames.setEnabled(checkShowLegend.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
checkShowHostNames = new Button(optionsGroup, SWT.CHECK);
checkShowHostNames.setText(Messages.get().General_ShowHostNames);
checkShowHostNames.setSelection(config.isShowHostNames());
checkShowHostNames.setEnabled(config.isShowLegend());
gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalSpan = 2;
gd.verticalAlignment = SWT.TOP;
legendLocation = WidgetHelper.createLabeledCombo(optionsGroup, SWT.READ_ONLY, Messages.get().General_LegendPosition, gd);
legendLocation.add(Messages.get().General_Left);
legendLocation.add(Messages.get().General_Right);
legendLocation.add(Messages.get().General_Top);
legendLocation.add(Messages.get().General_Bottom);
legendLocation.select(31 - Integer.numberOfLeadingZeros(config.getLegendPosition()));
legendLocation.setEnabled(config.isShowLegend());
checkExtendedLegend = new Button(optionsGroup, SWT.CHECK);
checkExtendedLegend.setText(Messages.get().General_8);
checkExtendedLegend.setSelection(config.isExtendedLegend());
checkExtendedLegend.setEnabled(config.isShowLegend());
checkAreaChart = new Button(optionsGroup, SWT.CHECK);
checkAreaChart.setText("Area chart");
checkAreaChart.setSelection(config.isArea());
checkUseMultipliers = new Button(optionsGroup, SWT.CHECK);
checkUseMultipliers.setText("Use multipliers");
checkUseMultipliers.setSelection(config.isUseMultipliers());
Composite refreshGroup = new Composite(optionsGroup, SWT.NONE);
layout = new GridLayout();
layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginTop = WidgetHelper.OUTER_SPACING;
refreshGroup.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 3;
refreshGroup.setLayoutData(gd);
checkAutoRefresh = new Button(refreshGroup, SWT.CHECK);
checkAutoRefresh.setText(Messages.get().General_Autorefresh);
checkAutoRefresh.setSelection(config.isAutoRefresh());
checkAutoRefresh.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
refreshIntervalSpinner.setEnabled(checkAutoRefresh.getSelection());
refreshIntervalScale.setEnabled(checkAutoRefresh.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
Composite refreshIntervalGroup = new Composite(refreshGroup, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginTop = WidgetHelper.OUTER_SPACING;
refreshIntervalGroup.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
refreshIntervalGroup.setLayoutData(gd);
Label label = new Label(refreshIntervalGroup, SWT.NONE);
label.setText(Messages.get().General_RefreshInterval);
gd = new GridData();
gd.horizontalAlignment = SWT.LEFT;
gd.horizontalSpan = 2;
label.setLayoutData(gd);
refreshIntervalScale = new Scale(refreshIntervalGroup, SWT.HORIZONTAL);
refreshIntervalScale.setMinimum(1);
refreshIntervalScale.setMaximum(600);
refreshIntervalScale.setSelection(config.getRefreshRate());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
refreshIntervalScale.setLayoutData(gd);
refreshIntervalScale.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
refreshIntervalSpinner.setSelection(refreshIntervalScale.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
refreshIntervalScale.setEnabled(config.isAutoRefresh());
refreshIntervalSpinner = new Spinner(refreshIntervalGroup, SWT.BORDER);
refreshIntervalSpinner.setMinimum(1);
refreshIntervalSpinner.setMaximum(600);
refreshIntervalSpinner.setSelection(config.getRefreshRate());
refreshIntervalSpinner.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
refreshIntervalScale.setSelection(refreshIntervalSpinner.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
refreshIntervalSpinner.setEnabled(config.isAutoRefresh());
timeSelector = new TimePeriodSelector(dialogArea, SWT.NONE, config.timePeriod());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
timeSelector.setLayoutData(gd);
yAxisRange = new YAxisRangeEditor(dialogArea, SWT.NONE);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
yAxisRange.setLayoutData(gd);
yAxisRange.setSelection(config.isAutoScale(), config.modifyYBase(), config.getMinYScaleValue(), config.getMaxYScaleValue());
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.LabeledSpinner in project netxms by netxms.
the class DashboardElements 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 = (Dashboard) getElement().getAdapter(Dashboard.class);
if (// Paranoid check
object == null)
return dialogArea;
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.numColumns = 2;
dialogArea.setLayout(layout);
columnCount = new LabeledSpinner(dialogArea, SWT.NONE);
columnCount.setLabel(Messages.get().DashboardElements_NumColumns);
columnCount.setRange(1, 128);
columnCount.setSelection(object.getNumColumns());
GridData gridData = new GridData();
gridData.horizontalAlignment = SWT.LEFT;
gridData.horizontalSpan = 2;
columnCount.setLayoutData(gridData);
final String[] columnNames = { Messages.get().DashboardElements_Type, Messages.get().DashboardElements_Span, "Height" };
final int[] columnWidths = { 150, 60, 90 };
viewer = new SortableTableViewer(dialogArea, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new DashboardElementsLabelProvider());
elements = copyElements(object.getElements());
viewer.setInput(elements.toArray());
gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
gridData.heightHint = 0;
gridData.horizontalSpan = 2;
viewer.getControl().setLayoutData(gridData);
Composite leftButtons = new Composite(dialogArea, SWT.NONE);
RowLayout buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginLeft = 0;
leftButtons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.LEFT;
leftButtons.setLayoutData(gridData);
upButton = new Button(leftButtons, SWT.PUSH);
upButton.setText(Messages.get().DashboardElements_Up);
upButton.setEnabled(false);
upButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveUp();
}
});
downButton = new Button(leftButtons, SWT.PUSH);
downButton.setText(Messages.get().DashboardElements_Down);
downButton.setEnabled(false);
downButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
moveDown();
}
});
Composite rightButtons = new Composite(dialogArea, SWT.NONE);
buttonLayout = new RowLayout();
buttonLayout.type = SWT.HORIZONTAL;
buttonLayout.pack = false;
buttonLayout.marginWidth = 0;
buttonLayout.marginRight = 0;
rightButtons.setLayout(buttonLayout);
gridData = new GridData();
gridData.horizontalAlignment = SWT.RIGHT;
rightButtons.setLayoutData(gridData);
addButton = new Button(rightButtons, SWT.PUSH);
addButton.setText(Messages.get().DashboardElements_Add);
addButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
addNewElement();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
editButton = new Button(rightButtons, SWT.PUSH);
editButton.setText(Messages.get().DashboardElements_Edit);
editButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
editElement();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
editXmlButton = new Button(rightButtons, SWT.PUSH);
editXmlButton.setText(Messages.get().DashboardElements_EditXML);
editXmlButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
editElementXml();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
deleteButton = new Button(rightButtons, SWT.PUSH);
deleteButton.setText(Messages.get().DashboardElements_Delete);
deleteButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
deleteElements();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
int index = elements.indexOf(selection.getFirstElement());
upButton.setEnabled((selection.size() == 1) && (index > 0));
downButton.setEnabled((selection.size() == 1) && (index >= 0) && (index < elements.size() - 1));
editButton.setEnabled(selection.size() == 1);
deleteButton.setEnabled(selection.size() > 0);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
editButton.notifyListeners(SWT.Selection, new Event());
}
});
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.LabeledSpinner in project netxms by netxms.
the class EditTableThresholdDialog method createDialogArea.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
dialogArea.setLayout(layout);
activationEvent = new EventSelector(dialogArea, SWT.NONE);
activationEvent.setLabel(Messages.get().EditTableThresholdDialog_ActivationEvent);
activationEvent.setEventCode(threshold.getActivationEvent());
activationEvent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
deactivationEvent = new EventSelector(dialogArea, SWT.NONE);
deactivationEvent.setLabel(Messages.get().EditTableThresholdDialog_DeactivationEvent);
deactivationEvent.setEventCode(threshold.getDeactivationEvent());
deactivationEvent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
sampleCount = new LabeledSpinner(dialogArea, SWT.NONE);
sampleCount.setLabel("Sample count");
sampleCount.setRange(1, 100000);
sampleCount.setSelection(threshold.getSampleCount());
new Label(dialogArea, SWT.NONE).setText(Messages.get().EditTableThresholdDialog_Conditions);
conditionsEditor = new TableConditionsEditor(dialogArea, SWT.BORDER, columnCallback);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 700;
gd.heightHint = 400;
conditionsEditor.setLayoutData(gd);
conditionsEditor.setConditions(threshold.getConditions());
return dialogArea;
}
use of org.netxms.ui.eclipse.widgets.LabeledSpinner in project netxms by netxms.
the class AbstractChart method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
config = (AbstractChartConfig) getElement().getAdapter(AbstractChartConfig.class);
Composite dialogArea = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.makeColumnsEqualWidth = false;
dialogArea.setLayout(layout);
title = new LabeledText(dialogArea, SWT.NONE);
title.setLabel(Messages.get().AbstractChart_Title);
title.setText(config.getTitle());
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
title.setLayoutData(gd);
legendPosition = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, Messages.get().AbstractChart_LegendPosition, WidgetHelper.DEFAULT_LAYOUT_DATA);
legendPosition.add(Messages.get().AbstractChart_Left);
legendPosition.add(Messages.get().AbstractChart_Right);
legendPosition.add(Messages.get().AbstractChart_Top);
legendPosition.add(Messages.get().AbstractChart_Bottom);
legendPosition.select(positionIndexFromValue(config.getLegendPosition()));
Group optionsGroup = new Group(dialogArea, SWT.NONE);
optionsGroup.setText(Messages.get().AbstractChart_Options);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.verticalSpan = (config instanceof LineChartConfig) ? 3 : 2;
optionsGroup.setLayoutData(gd);
GridLayout optionsLayout = new GridLayout();
optionsGroup.setLayout(optionsLayout);
checkShowTitle = new Button(optionsGroup, SWT.CHECK);
checkShowTitle.setText(Messages.get().AbstractChart_ShowTitle);
checkShowTitle.setSelection(config.isShowTitle());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
checkShowTitle.setLayoutData(gd);
checkShowLegend = new Button(optionsGroup, SWT.CHECK);
checkShowLegend.setText(Messages.get().AbstractChart_ShowLegend);
checkShowLegend.setSelection(config.isShowLegend());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
checkShowLegend.setLayoutData(gd);
if (config instanceof LineChartConfig) {
checkExtendedLegend = new Button(optionsGroup, SWT.CHECK);
checkExtendedLegend.setText(Messages.get().AbstractChart_ExtendedLegend);
checkExtendedLegend.setSelection(((LineChartConfig) config).isExtendedLegend());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
checkExtendedLegend.setLayoutData(gd);
checkLogScale = new Button(optionsGroup, SWT.CHECK);
checkLogScale.setText(Messages.get().AbstractChart_LogartithmicScale);
checkLogScale.setSelection(((LineChartConfig) config).isLogScaleEnabled());
gd = new GridData();
gd.horizontalSpan = layout.numColumns;
checkLogScale.setLayoutData(gd);
checkStacked = new Button(optionsGroup, SWT.CHECK);
checkStacked.setText(Messages.get().AbstractChart_Stacked);
checkStacked.setSelection(((LineChartConfig) config).isStacked());
gd = new GridData();
gd.horizontalSpan = layout.numColumns;
checkStacked.setLayoutData(gd);
checkAreaChart = new Button(optionsGroup, SWT.CHECK);
checkAreaChart.setText("&Area chart");
checkAreaChart.setSelection(((LineChartConfig) config).isArea());
gd = new GridData();
gd.horizontalSpan = layout.numColumns;
checkAreaChart.setLayoutData(gd);
}
checkTranslucent = new Button(optionsGroup, SWT.CHECK);
checkTranslucent.setText(Messages.get().AbstractChart_Translucent);
checkTranslucent.setSelection(config.isTranslucent());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
checkTranslucent.setLayoutData(gd);
if (config instanceof ComparisonChartConfig) {
checkShowIn3D = new Button(optionsGroup, SWT.CHECK);
checkShowIn3D.setText(Messages.get().AbstractChart_3DView);
checkShowIn3D.setSelection(((ComparisonChartConfig) config).isShowIn3D());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
checkShowIn3D.setLayoutData(gd);
if ((config instanceof BarChartConfig) || (config instanceof TubeChartConfig)) {
checkTransposed = new Button(optionsGroup, SWT.CHECK);
checkTransposed.setText(Messages.get().AbstractChart_Transposed);
checkTransposed.setSelection((config instanceof BarChartConfig) ? ((BarChartConfig) config).isTransposed() : ((TubeChartConfig) config).isTransposed());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
checkTransposed.setLayoutData(gd);
}
}
if (config instanceof LineChartConfig) {
checkShowGrid = new Button(optionsGroup, SWT.CHECK);
checkShowGrid.setText(Messages.get().AbstractChart_ShowGrid);
checkShowGrid.setSelection(((LineChartConfig) config).isShowGrid());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
checkShowGrid.setLayoutData(gd);
checkInteractive = new Button(optionsGroup, SWT.CHECK);
checkInteractive.setText("&Interactive");
checkInteractive.setSelection(((LineChartConfig) config).isInteractive());
gd = new GridData();
gd.horizontalSpan = layout.numColumns;
checkInteractive.setLayoutData(gd);
Composite timeRangeArea = new Composite(dialogArea, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
timeRangeArea.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
timeRangeArea.setLayoutData(gd);
timeRange = WidgetHelper.createLabeledSpinner(timeRangeArea, SWT.BORDER, Messages.get().AbstractChart_TimeInterval, 1, 10000, WidgetHelper.DEFAULT_LAYOUT_DATA);
timeRange.setSelection(((LineChartConfig) config).getTimeRange());
timeUnits = WidgetHelper.createLabeledCombo(timeRangeArea, SWT.READ_ONLY, Messages.get().AbstractChart_TimeUnits, WidgetHelper.DEFAULT_LAYOUT_DATA);
timeUnits.add(Messages.get().AbstractChart_Minutes);
timeUnits.add(Messages.get().AbstractChart_Hours);
timeUnits.add(Messages.get().AbstractChart_Days);
timeUnits.select(((LineChartConfig) config).getTimeUnits());
}
Composite rateAndWidthArea = new Composite(dialogArea, SWT.NONE);
layout = new GridLayout();
layout.numColumns = (config instanceof LineChartConfig) ? 2 : 1;
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
layout.makeColumnsEqualWidth = true;
rateAndWidthArea.setLayout(layout);
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
rateAndWidthArea.setLayoutData(gd);
refreshRate = new LabeledSpinner(rateAndWidthArea, SWT.NONE);
refreshRate.setLabel(Messages.get().AbstractChart_RefreshInterval);
refreshRate.setRange(1, 10000);
refreshRate.setSelection(config.getRefreshRate());
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
refreshRate.setLayoutData(gd);
if (config instanceof LineChartConfig) {
lineWidth = new LabeledSpinner(rateAndWidthArea, SWT.NONE);
lineWidth.setLabel(Messages.get().AbstractChart_LineWidth);
lineWidth.setRange(1, 32);
lineWidth.setSelection(((LineChartConfig) config).getLineWidth());
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
lineWidth.setLayoutData(gd);
}
if (!(config instanceof PieChartConfig)) {
yAxisRange = new YAxisRangeEditor(dialogArea, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = layout.numColumns;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
yAxisRange.setLayoutData(gd);
yAxisRange.setSelection(config.isAutoScale(), config.modifyYBase(), config.getMinYScaleValue(), config.getMaxYScaleValue());
}
return dialogArea;
}
Aggregations