use of org.eclipse.swt.widgets.Spinner in project netxms by netxms.
the class HistoricalDataSelectionDialog 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.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
layout.numColumns = 3;
dialogArea.setLayout(layout);
radioLastRecords = new Button(dialogArea, SWT.RADIO);
radioLastRecords.setText(Messages.get().HistoricalDataSelectionDialog_LastRecords);
GridData gd = new GridData();
gd.horizontalSpan = 3;
radioLastRecords.setLayoutData(gd);
radioLastRecords.setSelection(maxRecords != 0);
spinnerRecords = new Spinner(dialogArea, SWT.BORDER);
spinnerRecords.setMinimum(1);
spinnerRecords.setMaximum(65535);
spinnerRecords.setSelection(maxRecords);
gd = new GridData();
gd.horizontalSpan = 3;
spinnerRecords.setLayoutData(gd);
spinnerRecords.setEnabled(radioLastRecords.getSelection());
radioTimeFrame = new Button(dialogArea, SWT.RADIO);
radioTimeFrame.setText(Messages.get().HistoricalDataSelectionDialog_TimeFrame);
gd = new GridData();
gd.horizontalSpan = 3;
gd.verticalIndent = 5;
radioTimeFrame.setLayoutData(gd);
radioTimeFrame.setSelection(maxRecords == 0);
dtsFrom = new DateTimeSelector(dialogArea, SWT.NONE);
dtsFrom.setValue(timeFrom);
dtsFrom.setEnabled(radioTimeFrame.getSelection());
// $NON-NLS-1$
new Label(dialogArea, SWT.NONE).setText(" - ");
dtsTo = new DateTimeSelector(dialogArea, SWT.NONE);
dtsTo.setValue(timeTo);
dtsTo.setEnabled(radioTimeFrame.getSelection());
final SelectionListener listener = new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
spinnerRecords.setEnabled(radioLastRecords.getSelection());
dtsFrom.setEnabled(radioTimeFrame.getSelection());
dtsTo.setEnabled(radioTimeFrame.getSelection());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
};
radioLastRecords.addSelectionListener(listener);
radioTimeFrame.addSelectionListener(listener);
return dialogArea;
}
use of org.eclipse.swt.widgets.Spinner in project netxms by netxms.
the class LogParserRuleEditor method createActionArea.
/**
* Create action area
*/
private Composite createActionArea(Composite parent) {
Composite area = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
area.setLayout(layout);
long eventCode = 0;
if (rule.getEvent() != null) {
try {
eventCode = Long.parseLong(rule.getEvent().getEvent());
} catch (NumberFormatException e) {
EventObject o = ((NXCSession) ConsoleSharedData.getSession()).findEventObjectByName(rule.getEvent().getEvent());
if (o != null)
eventCode = o.getCode();
}
}
event = new EventSelector(area, SWT.NONE, true);
toolkit.adapt(event);
event.setLabel(Messages.get().LogParserRuleEditor_GenerateEvent);
event.setEventCode(eventCode);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
event.setLayoutData(gd);
event.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
eventParamCount.setEnabled(event.getEventCode() != 0);
editor.fireModifyListeners();
}
});
final WidgetFactory factory = new WidgetFactory() {
@Override
public Control createControl(Composite parent, int style) {
return new Spinner(parent, style);
}
};
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
eventParamCount = (Spinner) WidgetHelper.createLabeledControl(area, SWT.BORDER, factory, Messages.get().LogParserRuleEditor_Parameters, gd);
toolkit.adapt(eventParamCount);
eventParamCount.setMinimum(0);
eventParamCount.setMaximum(32);
if (rule.getEvent() != null) {
eventParamCount.setSelection(rule.getEvent().getParameterCount());
} else {
eventParamCount.setSelection(0);
eventParamCount.setEnabled(false);
}
eventParamCount.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
editor.fireModifyListeners();
}
});
final LogParserContext contextDefinition = rule.getContextDefinition();
context = new LabeledText(area, SWT.NONE);
toolkit.adapt(context);
context.setLabel(Messages.get().LogParserRuleEditor_ChangeContext);
// $NON-NLS-1$
context.setText((contextDefinition != null) ? contextDefinition.getData() : "");
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
context.setLayoutData(gd);
context.getTextControl().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
boolean contextSet = !context.getText().trim().isEmpty();
contextAction.setEnabled(contextSet);
contextResetMode.setEnabled(contextSet && (contextAction.getSelectionIndex() == 0));
editor.fireModifyListeners();
}
});
final Composite contextOptions = new Composite(area, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
layout.makeColumnsEqualWidth = true;
contextOptions.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
contextOptions.setLayoutData(gd);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
contextAction = WidgetHelper.createLabeledCombo(contextOptions, SWT.READ_ONLY, Messages.get().LogParserRuleEditor_ContextAction, gd);
toolkit.adapt(contextAction);
contextAction.add(Messages.get().LogParserRuleEditor_CtxActionActivate);
contextAction.add(Messages.get().LogParserRuleEditor_CtxActionClear);
if (contextDefinition != null) {
contextAction.select(contextDefinition.getAction());
} else {
contextAction.select(0);
contextAction.setEnabled(false);
}
contextAction.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
contextResetMode.setEnabled(contextAction.getSelectionIndex() == 0);
editor.fireModifyListeners();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
contextResetMode = WidgetHelper.createLabeledCombo(contextOptions, SWT.READ_ONLY, Messages.get().LogParserRuleEditor_ContextResetMode, gd);
toolkit.adapt(contextResetMode);
contextResetMode.add(Messages.get().LogParserRuleEditor_CtxModeAuto);
contextResetMode.add(Messages.get().LogParserRuleEditor_CtxModeManual);
if (contextDefinition != null) {
contextResetMode.select(contextDefinition.getReset());
contextResetMode.setEnabled(contextDefinition.getAction() == 0);
} else {
contextResetMode.select(0);
contextResetMode.setEnabled(false);
}
contextResetMode.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
editor.fireModifyListeners();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
checkboxBreak = toolkit.createButton(area, "Process all", SWT.CHECK);
checkboxBreak.setText("Break");
checkboxBreak.setSelection(rule.isBreakProcessing());
return area;
}
use of org.eclipse.swt.widgets.Spinner in project netxms by netxms.
the class LogParserRuleEditor method createMatchingArea.
/**
* Create matching area
*/
private Composite createMatchingArea(Composite parent) {
Composite area = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
area.setLayout(layout);
final ModifyListener listener = new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
editor.fireModifyListeners();
}
};
Composite matcher = new Composite(area, SWT.NONE);
toolkit.adapt(matcher);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
matcher.setLayoutData(gd);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
matcher.setLayout(layout);
regexp = new LabeledText(matcher, SWT.NONE);
regexp.setLabel(Messages.get().LogParserRuleEditor_MatchingRegExp);
regexp.setText(rule.getMatch().getMatch());
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
regexp.setLayoutData(gd);
regexp.getTextControl().addModifyListener(listener);
checkboxInvert = toolkit.createButton(matcher, "Invert", SWT.CHECK);
checkboxInvert.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editor.fireModifyListeners();
}
});
checkboxInvert.setSelection(rule.getMatch().getInvert());
Composite matcherRepeatConf = new Composite(matcher, SWT.NONE);
toolkit.adapt(matcherRepeatConf);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 2;
matcherRepeatConf.setLayoutData(gd);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
matcherRepeatConf.setLayout(layout);
final WidgetFactory factory = new WidgetFactory() {
@Override
public Control createControl(Composite parent, int style) {
return new Spinner(parent, style);
}
};
repeatCount = (Spinner) WidgetHelper.createLabeledControl(matcherRepeatConf, SWT.BORDER, factory, "Repeat count", WidgetHelper.DEFAULT_LAYOUT_DATA);
toolkit.adapt(repeatCount);
repeatCount.setMinimum(0);
repeatCount.setSelection(rule.getMatch().getRepeatCount());
repeatCount.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
editor.fireModifyListeners();
}
});
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
repeatCount.setLayoutData(gd);
Composite timeBackGroup = new Composite(matcherRepeatConf, SWT.NONE);
toolkit.adapt(timeBackGroup);
layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
layout.numColumns = 2;
timeBackGroup.setLayout(layout);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
timeBackGroup.setLayoutData(gd);
timeRange = WidgetHelper.createLabeledSpinner(timeBackGroup, SWT.BORDER, "Repeat interval", 1, 10000, WidgetHelper.DEFAULT_LAYOUT_DATA);
timeRange.setSelection(rule.getMatch().getTimeRagne());
toolkit.adapt(timeRange);
timeUnits = WidgetHelper.createLabeledCombo(timeBackGroup, SWT.READ_ONLY, "", WidgetHelper.DEFAULT_LAYOUT_DATA);
timeUnits.add("Seconds");
timeUnits.add("Minutes");
timeUnits.add("Hours");
timeUnits.select(rule.getMatch().getTimeUnit());
toolkit.adapt(timeUnits);
// time range
checkboxReset = toolkit.createButton(matcherRepeatConf, "Reset repeat count", SWT.CHECK);
checkboxReset.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editor.fireModifyListeners();
}
});
checkboxReset.setSelection(rule.getMatch().getReset());
severity = new LabeledText(area, SWT.NONE);
toolkit.adapt(severity);
severity.setLabel(editor.isSyslogParser() ? Messages.get().LogParserRuleEditor_Severity : "Level");
// $NON-NLS-1$
severity.setText(rule.getSeverityOrLevel(editor.isSyslogParser()));
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
severity.setLayoutData(gd);
severity.getTextControl().addModifyListener(listener);
facility = new LabeledText(area, SWT.NONE);
toolkit.adapt(facility);
facility.setLabel(editor.isSyslogParser() ? Messages.get().LogParserRuleEditor_Facility : "Id");
// $NON-NLS-1$
facility.setText(rule.getFacilityOrId(editor.isSyslogParser()));
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
facility.setLayoutData(gd);
facility.getTextControl().addModifyListener(listener);
tag = new LabeledText(area, SWT.NONE);
toolkit.adapt(tag);
tag.setLabel(editor.isSyslogParser() ? Messages.get().LogParserRuleEditor_SyslogTag : "Source");
// $NON-NLS-1$
tag.setText(rule.getTagOrSource(editor.isSyslogParser()));
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
tag.setLayoutData(gd);
tag.getTextControl().addModifyListener(listener);
activeContext = new LabeledText(area, SWT.NONE);
toolkit.adapt(activeContext);
activeContext.setLabel(Messages.get().LogParserRuleEditor_ActiveContext);
// $NON-NLS-1$
activeContext.setText((rule.getContext() != null) ? rule.getContext() : "");
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
activeContext.setLayoutData(gd);
activeContext.getTextControl().addModifyListener(listener);
description = new LabeledText(area, SWT.NONE);
toolkit.adapt(description);
description.setLabel("Description");
// $NON-NLS-1$
description.setText((rule.getDescription() != null) ? rule.getDescription() : "");
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
description.setLayoutData(gd);
description.getTextControl().addModifyListener(listener);
updateWindowsEventLogFields();
return area;
}
use of org.eclipse.swt.widgets.Spinner in project webtools.sourceediting by eclipse.
the class JSONSourcePreferencePage method createContentsForFormattingGroup.
@SuppressWarnings("restriction")
private void createContentsForFormattingGroup(Composite parent) {
Group formattingGroup = createGroup(parent, 2);
formattingGroup.setText(JSONUIMessages.Formatting_UI_);
fLineWidthLabel = createLabel(formattingGroup, JSONUIMessages.Line_width__UI_);
fLineWidthText = new Text(formattingGroup, SWT.SINGLE | SWT.BORDER);
GridData gData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.BEGINNING);
gData.widthHint = 25;
fLineWidthText.setLayoutData(gData);
fLineWidthText.addModifyListener(this);
// [269224] - Place the indent controls in their own composite for proper tab ordering
Composite indentComposite = createComposite(formattingGroup, 1);
((GridData) indentComposite.getLayoutData()).horizontalSpan = 2;
((GridLayout) indentComposite.getLayout()).marginWidth = 0;
((GridLayout) indentComposite.getLayout()).marginHeight = 0;
fIndentUsingTabs = createRadioButton(indentComposite, JSONUIMessages.Indent_using_tabs_);
((GridData) fIndentUsingTabs.getLayoutData()).horizontalSpan = 1;
fIndentUsingSpaces = createRadioButton(indentComposite, JSONUIMessages.Indent_using_spaces);
((GridData) fIndentUsingSpaces.getLayoutData()).horizontalSpan = 1;
createLabel(formattingGroup, JSONUIMessages.Indentation_size);
fIndentationSize = new Spinner(formattingGroup, SWT.BORDER);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
fIndentationSize.setLayoutData(gd);
fIndentationSize.setToolTipText(JSONUIMessages.Indentation_size_tip);
fIndentationSize.setMinimum(MIN_INDENTATION_SIZE);
fIndentationSize.setMaximum(MAX_INDENTATION_SIZE);
fIndentationSize.setIncrement(1);
fIndentationSize.setPageIncrement(4);
fIndentationSize.addModifyListener(this);
}
use of org.eclipse.swt.widgets.Spinner in project webtools.sourceediting by eclipse.
the class CSSSourcePreferencePage method createContentsForFormattingGroup.
private void createContentsForFormattingGroup(Composite parent) {
Group formattingGroup = createGroup(parent, 2);
formattingGroup.setText(CSSUIMessages.Formatting_UI_);
fLineWidthLabel = createLabel(formattingGroup, CSSUIMessages.Line_width__UI_);
fLineWidthText = new Text(formattingGroup, SWT.SINGLE | SWT.BORDER);
GridData gData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.BEGINNING);
gData.widthHint = 25;
fLineWidthText.setLayoutData(gData);
fLineWidthText.addModifyListener(this);
fPropertyPerLine = createCheckBox(formattingGroup, CSSUIMessages.PrefsLabel_WrappingInsertLineBreak);
((GridData) fPropertyPerLine.getLayoutData()).horizontalSpan = 2;
spaceBetweenSelectors = createCheckBox(formattingGroup, CSSUIMessages.PrefsLabel_SelectorWhitespace);
((GridData) spaceBetweenSelectors.getLayoutData()).horizontalSpan = 2;
fNowrapAttr = createCheckBox(formattingGroup, CSSUIMessages.PrefsLabel_WrappingWithoutAttr);
((GridData) fNowrapAttr.getLayoutData()).horizontalSpan = 2;
// [269224] - Place the indent controls in their own composite for proper tab ordering
Composite indentComposite = createComposite(formattingGroup, 1);
((GridData) indentComposite.getLayoutData()).horizontalSpan = 2;
((GridLayout) indentComposite.getLayout()).marginWidth = 0;
((GridLayout) indentComposite.getLayout()).marginHeight = 0;
fIndentUsingTabs = createRadioButton(indentComposite, CSSUIMessages.Indent_using_tabs_);
((GridData) fIndentUsingTabs.getLayoutData()).horizontalSpan = 1;
fIndentUsingSpaces = createRadioButton(indentComposite, CSSUIMessages.Indent_using_spaces);
((GridData) fIndentUsingSpaces.getLayoutData()).horizontalSpan = 1;
createLabel(formattingGroup, CSSUIMessages.Indentation_size);
fIndentationSize = new Spinner(formattingGroup, SWT.BORDER);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
fIndentationSize.setLayoutData(gd);
fIndentationSize.setToolTipText(CSSUIMessages.Indentation_size_tip);
fIndentationSize.setMinimum(MIN_INDENTATION_SIZE);
fIndentationSize.setMaximum(MAX_INDENTATION_SIZE);
fIndentationSize.setIncrement(1);
fIndentationSize.setPageIncrement(4);
fIndentationSize.addModifyListener(this);
}
Aggregations