Search in sources :

Example 51 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class VariableEditDialog 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.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    dialogArea.setLayout(layout);
    textName = new LabeledText(dialogArea, SWT.NONE);
    textName.setLabel(Messages.get().VariableEditDialog_Name);
    textName.getTextControl().setTextLimit(63);
    if (variable.getName() != null) {
        textName.setText(variable.getName());
        textName.getTextControl().setEditable(false);
    }
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 300;
    textName.setLayoutData(gd);
    if (!variable.getUnit().isEmpty()) {
        layout.numColumns = 2;
        gd.horizontalSpan = 2;
    }
    switch(variable.getDataType()) {
        case BOOLEAN:
            buttonEnable = new Button(dialogArea, SWT.CHECK);
            buttonEnable.setText("Enable");
            buttonEnable.setSelection(variable.getValueAsBoolean());
            if (variable.getName() != null)
                buttonEnable.setFocus();
            break;
        case CHOICE:
            valueMap = new HashMap<Integer, String>();
            gd = new GridData();
            gd.horizontalAlignment = SWT.FILL;
            gd.grabExcessHorizontalSpace = true;
            comboValue = WidgetHelper.createLabeledCombo(dialogArea, SWT.BORDER | SWT.READ_ONLY, Messages.get().VariableEditDialog_Value, gd);
            for (Entry<String, String> e : variable.getPossibleValues().entrySet()) {
                comboValue.add(e.getValue());
                int index = comboValue.getItemCount() - 1;
                valueMap.put(index, e.getKey());
                if (e.getKey().equals(variable.getValue()))
                    comboValue.select(index);
            }
            if (variable.getName() != null)
                comboValue.setFocus();
            break;
        case COLOR:
            colorSelector = WidgetHelper.createLabeledColorSelector(dialogArea, Messages.get().VariableEditDialog_Value, WidgetHelper.DEFAULT_LAYOUT_DATA);
            if (!variable.getValue().isEmpty())
                colorSelector.setColorValue(ColorConverter.parseColorDefinition(variable.getValue()));
            break;
        case INTEGER:
            spinnerValue = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().VariableEditDialog_Value, 0, (variable.getPossibleValues().isEmpty()) ? 0xffffff : Integer.parseInt((String) variable.getPossibleValues().keySet().toArray()[0]), WidgetHelper.DEFAULT_LAYOUT_DATA);
            spinnerValue.setSelection(variable.getValueAsInt());
            gd = new GridData();
            gd.horizontalAlignment = SWT.FILL;
            gd.grabExcessHorizontalSpace = true;
            spinnerValue.setLayoutData(gd);
            if (!variable.getUnit().isEmpty()) {
                Label unit = new Label(dialogArea, SWT.NONE);
                unit.setText(variable.getUnit());
                gd = new GridData();
                gd.grabExcessHorizontalSpace = true;
                gd.verticalIndent = 15;
                gd.horizontalAlignment = SWT.FILL;
                unit.setLayoutData(gd);
            }
            if (variable.getName() != null)
                spinnerValue.setFocus();
            break;
        case STRING:
            textValue = WidgetHelper.createLabeledText(dialogArea, SWT.BORDER, 300, Messages.get().VariableEditDialog_Value, variable.getValue(), WidgetHelper.DEFAULT_LAYOUT_DATA);
            textValue.setTextLimit(2000);
            gd = new GridData();
            gd.horizontalAlignment = SWT.FILL;
            gd.grabExcessHorizontalSpace = true;
            textValue.setLayoutData(gd);
            if (variable.getName() != null)
                textValue.setFocus();
            break;
    }
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label)

Example 52 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText 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;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) DashboardComposite(org.netxms.ui.eclipse.widgets.DashboardComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Spinner(org.eclipse.swt.widgets.Spinner) EventSelector(org.netxms.ui.eclipse.eventmanager.widgets.EventSelector) EventObject(org.netxms.client.events.EventObject) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 53 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText 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;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) DashboardComposite(org.netxms.ui.eclipse.widgets.DashboardComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 54 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class EnterMacAddressDlg 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.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
    dialogArea.setLayout(layout);
    textMac = new LabeledText(dialogArea, SWT.NONE);
    textMac.setLabel(Messages.get().EnterMacAddressDlg_MacAddress);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 300;
    textMac.setLayoutData(gd);
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) GridData(org.eclipse.swt.layout.GridData)

Example 55 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText in project netxms by netxms.

the class EnterIpAddressDlg 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;
    dialogArea.setLayout(layout);
    ipAddressText = new LabeledText(dialogArea, SWT.NONE);
    ipAddressText.setLabel(Messages.get().EnterIpAddressDlg_IpAddress);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 300;
    ipAddressText.setLayoutData(gd);
    if (zoningEnabled) {
        zoneSelector = new ZoneSelector(dialogArea, SWT.NONE, false);
        zoneSelector.setLabel(Messages.get().EnterIpAddressDlg_Zone);
        gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        gd.widthHint = 300;
        zoneSelector.setLayoutData(gd);
    }
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) ZoneSelector(org.netxms.ui.eclipse.objectbrowser.widgets.ZoneSelector) GridData(org.eclipse.swt.layout.GridData)

Aggregations

Composite (org.eclipse.swt.widgets.Composite)104 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)104 GridLayout (org.eclipse.swt.layout.GridLayout)103 GridData (org.eclipse.swt.layout.GridData)102 Button (org.eclipse.swt.widgets.Button)50 SelectionEvent (org.eclipse.swt.events.SelectionEvent)37 SelectionListener (org.eclipse.swt.events.SelectionListener)31 Group (org.eclipse.swt.widgets.Group)24 ObjectSelector (org.netxms.ui.eclipse.objectbrowser.widgets.ObjectSelector)22 Label (org.eclipse.swt.widgets.Label)18 RowLayout (org.eclipse.swt.layout.RowLayout)11 Spinner (org.eclipse.swt.widgets.Spinner)11 ModifyEvent (org.eclipse.swt.events.ModifyEvent)9 ModifyListener (org.eclipse.swt.events.ModifyListener)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 LabeledSpinner (org.netxms.ui.eclipse.widgets.LabeledSpinner)8 ColorSelector (org.eclipse.jface.preference.ColorSelector)6 DisposeEvent (org.eclipse.swt.events.DisposeEvent)6 DisposeListener (org.eclipse.swt.events.DisposeListener)6 WidgetFactory (org.netxms.ui.eclipse.tools.WidgetFactory)6