use of org.netxms.ui.eclipse.tools.WidgetFactory in project netxms by netxms.
the class SummaryTableFilter method createContents.
/* (non-Javadoc)
* @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createContents(Composite parent) {
table = (DciSummaryTable) getElement().getAdapter(DciSummaryTable.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);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.widthHint = 0;
gd.heightHint = 0;
final WidgetFactory factory = new WidgetFactory() {
@Override
public Control createControl(Composite parent, int style) {
return new ScriptEditor(parent, style, SWT.H_SCROLL | SWT.V_SCROLL, false, "Variables:\r\n\t$object\tcurrent object\r\n\t$node\tcurrent object if it's class is Node\r\n\r\nReturn value: true to include current object into this summary table");
}
};
filter = (ScriptEditor) WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, factory, Messages.get().SummaryTableFilter_FilterScript, gd);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
filter.setLayoutData(gd);
filter.setText(table.getNodeFilter());
return dialogArea;
}
use of org.netxms.ui.eclipse.tools.WidgetFactory in project netxms by netxms.
the class Transformation 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);
GridLayout layout = new GridLayout();
layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
layout.marginWidth = 0;
layout.marginHeight = 0;
dialogArea.setLayout(layout);
if (editor.getObject() instanceof DataCollectionItem) {
deltaCalculation = WidgetHelper.createLabeledCombo(dialogArea, SWT.BORDER | SWT.READ_ONLY, Messages.get().Transformation_Step1, WidgetHelper.DEFAULT_LAYOUT_DATA);
deltaCalculation.add(Messages.get().Transformation_DeltaNone);
deltaCalculation.add(Messages.get().Transformation_DeltaSimple);
deltaCalculation.add(Messages.get().Transformation_DeltaAvgPerSec);
deltaCalculation.add(Messages.get().Transformation_DeltaAvgPerMin);
deltaCalculation.select(editor.getObjectAsItem().getDeltaCalculation());
}
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
gd.widthHint = 0;
gd.heightHint = 0;
final WidgetFactory factory = new WidgetFactory() {
@Override
public Control createControl(Composite parent, int style) {
return new ScriptEditor(parent, style, SWT.H_SCROLL | SWT.V_SCROLL, true, "Variables:\r\n\t$1\t\t\tvalue to transform (after delta calculation);\r\n\t$dci\t\t\tthis DCI object;\r\n\t$isCluster\ttrue if DCI is on cluster;\r\n\t$node\t\tcurrent node object (null if DCI is not on the node);\r\n\t$object\t\tcurrent object.\r\n\r\nReturn value: transformed DCI value or null to keep original value.");
}
};
transformationScript = (ScriptEditor) WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, factory, (editor.getObject() instanceof DataCollectionItem) ? Messages.get().Transformation_Step2 : Messages.get().Transformation_Script, gd);
transformationScript.addFunctions(Arrays.asList(DCI_FUNCTIONS));
transformationScript.addVariables(Arrays.asList(DCI_VARIABLES));
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
transformationScript.setLayoutData(gd);
transformationScript.setText(editor.getObject().getTransformationScript());
if (editor.getObject() instanceof DataCollectionItem) {
testScriptButton = new Button(transformationScript.getParent(), SWT.PUSH);
testScriptButton.setText(Messages.get().Transformation_Test);
gd = new GridData();
gd.horizontalAlignment = SWT.RIGHT;
gd.widthHint = WidgetHelper.BUTTON_WIDTH_HINT;
testScriptButton.setLayoutData(gd);
testScriptButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
TestTransformationDlg dlg = new TestTransformationDlg(getShell(), editor.getObject().getNodeId(), transformationScript.getText());
dlg.open();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
}
return dialogArea;
}
use of org.netxms.ui.eclipse.tools.WidgetFactory in project netxms by netxms.
the class ConditionDciEditDialog 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.numColumns = 2;
dialogArea.setLayout(layout);
LabeledText node = new LabeledText(dialogArea, SWT.NONE, SWT.BORDER | SWT.READ_ONLY);
node.setLabel(Messages.get().ConditionDciEditDialog_Node);
node.setText(nodeName);
GridData gd = new GridData();
gd.horizontalSpan = 2;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.widthHint = 400;
node.setLayoutData(gd);
LabeledText parameter = new LabeledText(dialogArea, SWT.NONE, SWT.BORDER | SWT.READ_ONLY);
parameter.setLabel(Messages.get().ConditionDciEditDialog_Parameter);
parameter.setText(dciName);
gd = new GridData();
gd.horizontalSpan = 2;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
parameter.setLayoutData(gd);
if (dci.getType() != DataCollectionObject.DCO_TYPE_TABLE) {
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
function = WidgetHelper.createLabeledCombo(dialogArea, SWT.NONE, Messages.get().ConditionDciEditDialog_Function, gd);
function.add(Messages.get().ConditionDciEditDialog_FuncLast);
function.add(Messages.get().ConditionDciEditDialog_FuncAvg);
function.add(Messages.get().ConditionDciEditDialog_FuncDeviation);
function.add(Messages.get().ConditionDciEditDialog_FuncDiff);
function.add(Messages.get().ConditionDciEditDialog_FuncError);
function.add(Messages.get().ConditionDciEditDialog_FuncSum);
function.select(dci.getFunction());
function.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
polls.setEnabled(isFunctionWithArgs());
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
final WidgetFactory factory = new WidgetFactory() {
@Override
public Control createControl(Composite parent, int style) {
Spinner spinner = new Spinner(parent, style);
spinner.setMinimum(1);
spinner.setMaximum(255);
return spinner;
}
};
polls = (Spinner) WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, factory, Messages.get().ConditionDciEditDialog_Polls, gd);
polls.setSelection(dci.getPolls());
polls.setEnabled(isFunctionWithArgs());
}
return dialogArea;
}
use of org.netxms.ui.eclipse.tools.WidgetFactory 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.netxms.ui.eclipse.tools.WidgetFactory 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;
}
Aggregations