Search in sources :

Example 41 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText 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;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Label(org.eclipse.swt.widgets.Label) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 42 with LabeledText

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

the class PerfTab 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);
    dci = editor.getObjectAsItem();
    try {
        settings = PerfTabGraphSettings.createFromXml(dci.getPerfTabSettings());
    } catch (Exception e) {
        // Create default empty settings
        settings = new PerfTabGraphSettings();
    }
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 4;
    dialogArea.setLayout(layout);
    checkShow = new Button(dialogArea, SWT.CHECK);
    checkShow.setText(Messages.get().PerfTab_ShowOnPerfTab);
    checkShow.setSelection(settings.isEnabled());
    GridData gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkShow.setLayoutData(gd);
    title = new LabeledText(dialogArea, SWT.NONE);
    title.setLabel(Messages.get().PerfTab_Title);
    title.setText(settings.getTitle());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    title.setLayoutData(gd);
    Composite colors = new Composite(dialogArea, SWT.NONE);
    colors.setLayout(new RowLayout(SWT.VERTICAL));
    new Label(colors, SWT.NONE).setText(Messages.get().PerfTab_Color);
    color = new ColorSelector(colors);
    color.setColorValue(ColorConverter.rgbFromInt(settings.getColorAsInt()));
    type = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, Messages.get().PerfTab_Type, new GridData(SWT.LEFT, SWT.CENTER, false, false));
    type.add(Messages.get().PerfTab_Line);
    type.add(Messages.get().PerfTab_Area);
    type.select(settings.getType());
    orderNumber = WidgetHelper.createLabeledSpinner(dialogArea, SWT.BORDER, Messages.get().PerfTab_Order, 0, 65535, new GridData(SWT.LEFT, SWT.CENTER, false, false));
    orderNumber.setSelection(settings.getOrder());
    groupName = new LabeledText(dialogArea, SWT.NONE);
    groupName.setLabel("Group");
    groupName.setText(settings.getGroupName());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    groupName.setLayoutData(gd);
    name = new LabeledText(dialogArea, SWT.NONE);
    name.setLabel(Messages.get().PerfTab_NameInLegend);
    name.setText(settings.getName());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.horizontalSpan = layout.numColumns;
    name.setLayoutData(gd);
    Group timeGroup = new Group(dialogArea, SWT.NONE);
    timeGroup.setText(Messages.get().PerfTab_TeimePeriod);
    GridLayout timeGroupLayout = new GridLayout();
    timeGroupLayout.marginWidth = WidgetHelper.OUTER_SPACING;
    timeGroupLayout.marginHeight = WidgetHelper.OUTER_SPACING;
    timeGroupLayout.horizontalSpacing = 16;
    timeGroupLayout.makeColumnsEqualWidth = true;
    timeGroupLayout.numColumns = 1;
    timeGroup.setLayout(timeGroupLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = timeGroupLayout.numColumns;
    timeGroup.setLayoutData(gd);
    Composite timeRangeArea = new Composite(timeGroup, SWT.NONE);
    timeGroupLayout = new GridLayout();
    timeGroupLayout.numColumns = 2;
    timeGroupLayout.marginWidth = 0;
    timeGroupLayout.marginHeight = 0;
    timeGroupLayout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
    timeRangeArea.setLayout(timeGroupLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    timeRangeArea.setLayoutData(gd);
    timeRange = WidgetHelper.createLabeledSpinner(timeRangeArea, SWT.BORDER, Messages.get().PerfTab_TimeInterval, 1, 10000, WidgetHelper.DEFAULT_LAYOUT_DATA);
    timeRange.setSelection(settings.getTimeRange());
    timeUnits = WidgetHelper.createLabeledCombo(timeRangeArea, SWT.READ_ONLY, Messages.get().PerfTab_TimeUnits, WidgetHelper.DEFAULT_LAYOUT_DATA);
    timeUnits.add(Messages.get().PerfTab_Minutes);
    timeUnits.add(Messages.get().PerfTab_Hours);
    timeUnits.add(Messages.get().PerfTab_Days);
    timeUnits.select(settings.getTimeUnits());
    Group optionsGroup = new Group(dialogArea, SWT.NONE);
    optionsGroup.setText(Messages.get().PerfTab_Options);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 3;
    gd.verticalSpan = 2;
    optionsGroup.setLayoutData(gd);
    GridLayout optionsLayout = new GridLayout();
    optionsGroup.setLayout(optionsLayout);
    checkShowThresholds = new Button(optionsGroup, SWT.CHECK);
    checkShowThresholds.setText(Messages.get().PerfTab_ShowThresholds);
    checkShowThresholds.setSelection(settings.isShowThresholds());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkShowThresholds.setLayoutData(gd);
    checkLogScale = new Button(optionsGroup, SWT.CHECK);
    checkLogScale.setText(Messages.get().PerfTab_LogarithmicScale);
    checkLogScale.setSelection(settings.isLogScaleEnabled());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkLogScale.setLayoutData(gd);
    checkStacked = new Button(optionsGroup, SWT.CHECK);
    checkStacked.setText("&Stacked");
    checkStacked.setSelection(settings.isStacked());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkStacked.setLayoutData(gd);
    checkShowLegendAlways = new Button(optionsGroup, SWT.CHECK);
    checkShowLegendAlways.setText("Always show &legend");
    checkShowLegendAlways.setSelection(settings.isShowLegendAlways());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkShowLegendAlways.setLayoutData(gd);
    checkExtendedLegend = new Button(optionsGroup, SWT.CHECK);
    checkExtendedLegend.setText("&Extended legend");
    checkExtendedLegend.setSelection(settings.isExtendedLegend());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkExtendedLegend.setLayoutData(gd);
    checkInvertValues = new Button(optionsGroup, SWT.CHECK);
    checkInvertValues.setText("&Inverted values");
    checkInvertValues.setSelection(settings.isInvertedValues());
    gd = new GridData();
    gd.horizontalSpan = layout.numColumns;
    checkInvertValues.setLayoutData(gd);
    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(settings.isAutoScale(), settings.modifyYBase(), settings.getMinYScaleValue(), settings.getMaxYScaleValue());
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) RowLayout(org.eclipse.swt.layout.RowLayout) PerfTabGraphSettings(org.netxms.ui.eclipse.perfview.PerfTabGraphSettings) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) YAxisRangeEditor(org.netxms.ui.eclipse.perfview.widgets.YAxisRangeEditor) ColorSelector(org.eclipse.jface.preference.ColorSelector)

Example 43 with LabeledText

use of org.netxms.ui.eclipse.widgets.LabeledText 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;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Spinner(org.eclipse.swt.widgets.Spinner) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner) Label(org.eclipse.swt.widgets.Label) Scale(org.eclipse.swt.widgets.Scale) LabeledSpinner(org.netxms.ui.eclipse.widgets.LabeledSpinner) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) YAxisRangeEditor(org.netxms.ui.eclipse.perfview.widgets.YAxisRangeEditor) TimePeriodSelector(org.netxms.ui.eclipse.widgets.TimePeriodSelector) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 44 with LabeledText

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

the class PredefinedGraph method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    settings = (GraphSettings) getElement().getAdapter(GraphSettings.class);
    acl = new HashMap<Long, AccessListElement>(settings.getAccessList().size());
    for (AccessListElement e : settings.getAccessList()) acl.put(e.getUserId(), new AccessListElement(e));
    // Initiate loading of user manager plugin if it was not loaded before
    // $NON-NLS-1$
    Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    name = new LabeledText(dialogArea, SWT.NONE, SWT.BORDER);
    name.setLabel(Messages.get().PredefinedGraph_Name);
    name.setText(settings.getName());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    name.setLayoutData(gd);
    Group users = new Group(dialogArea, SWT.NONE);
    users.setText(Messages.get().PredefinedGraph_UsersAndGroups);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    users.setLayoutData(gd);
    layout = new GridLayout();
    users.setLayout(layout);
    final String[] columnNames = { Messages.get().PredefinedGraph_LoginName, Messages.get().PredefinedGraph_Rights };
    final int[] columnWidths = { 150, 100 };
    userList = new SortableTableViewer(users, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    userList.setContentProvider(new ArrayContentProvider());
    userList.setLabelProvider(new AccessListLabelProvider());
    userList.setComparator(new AccessListComparator());
    userList.setInput(acl.values().toArray());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    userList.getControl().setLayoutData(gd);
    Composite buttons = new Composite(users, SWT.NONE);
    FillLayout buttonsLayout = new FillLayout();
    buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
    buttons.setLayout(buttonsLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    gd.widthHint = 184;
    buttons.setLayoutData(gd);
    final Button addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().PredefinedGraph_Add);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            SelectUserDialog dlg = new SelectUserDialog(PredefinedGraph.this.getShell(), AbstractUserObject.class);
            if (dlg.open() == Window.OK) {
                AbstractUserObject[] selection = dlg.getSelection();
                for (AbstractUserObject user : selection) acl.put(user.getId(), new AccessListElement(user.getId(), 0));
                userList.setInput(acl.values().toArray());
            }
        }
    });
    final Button deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().PredefinedGraph_Delete);
    deleteButton.setEnabled(false);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @SuppressWarnings("unchecked")
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection sel = (IStructuredSelection) userList.getSelection();
            Iterator<AccessListElement> it = sel.iterator();
            while (it.hasNext()) {
                AccessListElement element = it.next();
                acl.remove(element.getUserId());
            }
            userList.setInput(acl.values().toArray());
        }
    });
    Group rights = new Group(dialogArea, SWT.NONE);
    rights.setText(Messages.get().PredefinedGraph_AccessRights);
    rights.setLayout(new RowLayout(SWT.VERTICAL));
    gd = new GridData();
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    rights.setLayoutData(gd);
    createAccessCheck(rights, Messages.get().PredefinedGraph_Read, GraphSettings.ACCESS_READ);
    createAccessCheck(rights, Messages.get().PredefinedGraph_Modify, GraphSettings.ACCESS_WRITE);
    userList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            if (sel.size() == 1) {
                enableAllChecks(true);
                AccessListElement element = (AccessListElement) sel.getFirstElement();
                int rights = element.getAccessRights();
                for (int i = 0, mask = 1; i < 16; i++, mask <<= 1) {
                    Button check = accessChecks.get(mask);
                    if (check != null) {
                        check.setSelection((rights & mask) == mask);
                    }
                }
            } else {
                enableAllChecks(false);
            }
            deleteButton.setEnabled(sel.size() > 0);
        }
    });
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) SelectUserDialog(org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog) AccessListComparator(org.netxms.ui.eclipse.perfview.propertypages.helpers.AccessListComparator) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) AbstractUserObject(org.netxms.client.users.AbstractUserObject) FillLayout(org.eclipse.swt.layout.FillLayout) AccessListElement(org.netxms.client.AccessListElement) AccessListLabelProvider(org.netxms.ui.eclipse.perfview.propertypages.helpers.AccessListLabelProvider) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 45 with LabeledText

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

the class TemplateGraph method createContents.

/* (non-Javadoc)
    * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createContents(Composite parent) {
    settings = (GraphSettings) getElement().getAdapter(GraphSettings.class);
    acl = new HashMap<Long, AccessListElement>(settings.getAccessList().size());
    for (AccessListElement e : settings.getAccessList()) acl.put(e.getUserId(), new AccessListElement(e));
    // Initiate loading of user manager plugin if it was not loaded before
    // $NON-NLS-1$
    Platform.getAdapterManager().loadAdapter(new AccessListElement(0, 0), "org.eclipse.ui.model.IWorkbenchAdapter");
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    name = new LabeledText(dialogArea, SWT.NONE, SWT.BORDER);
    name.setLabel(Messages.get().PredefinedGraph_Name);
    name.setText(settings.getName());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    name.setLayoutData(gd);
    Group users = new Group(dialogArea, SWT.NONE);
    users.setText(Messages.get().PredefinedGraph_UsersAndGroups);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    users.setLayoutData(gd);
    layout = new GridLayout();
    users.setLayout(layout);
    final String[] columnNames = { Messages.get().PredefinedGraph_LoginName, Messages.get().PredefinedGraph_Rights };
    final int[] columnWidths = { 150, 100 };
    userList = new SortableTableViewer(users, columnNames, columnWidths, 0, SWT.UP, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    userList.setContentProvider(new ArrayContentProvider());
    userList.setLabelProvider(new AccessListLabelProvider());
    userList.setComparator(new AccessListComparator());
    userList.setInput(acl.values().toArray());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    userList.getControl().setLayoutData(gd);
    Composite buttons = new Composite(users, SWT.NONE);
    FillLayout buttonsLayout = new FillLayout();
    buttonsLayout.spacing = WidgetHelper.INNER_SPACING;
    buttons.setLayout(buttonsLayout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.RIGHT;
    gd.widthHint = 184;
    buttons.setLayoutData(gd);
    final Button addButton = new Button(buttons, SWT.PUSH);
    addButton.setText(Messages.get().PredefinedGraph_Add);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            SelectUserDialog dlg = new SelectUserDialog(TemplateGraph.this.getShell(), AbstractUserObject.class);
            if (dlg.open() == Window.OK) {
                AbstractUserObject[] selection = dlg.getSelection();
                for (AbstractUserObject user : selection) acl.put(user.getId(), new AccessListElement(user.getId(), 0));
                userList.setInput(acl.values().toArray());
            }
        }
    });
    final Button deleteButton = new Button(buttons, SWT.PUSH);
    deleteButton.setText(Messages.get().PredefinedGraph_Delete);
    deleteButton.setEnabled(false);
    deleteButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        @SuppressWarnings("unchecked")
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection sel = (IStructuredSelection) userList.getSelection();
            Iterator<AccessListElement> it = sel.iterator();
            while (it.hasNext()) {
                AccessListElement element = it.next();
                acl.remove(element.getUserId());
            }
            userList.setInput(acl.values().toArray());
        }
    });
    Group rights = new Group(dialogArea, SWT.NONE);
    rights.setText(Messages.get().PredefinedGraph_AccessRights);
    rights.setLayout(new RowLayout(SWT.VERTICAL));
    gd = new GridData();
    gd.grabExcessVerticalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    rights.setLayoutData(gd);
    createAccessCheck(rights, Messages.get().PredefinedGraph_Read, GraphSettings.ACCESS_READ);
    createAccessCheck(rights, Messages.get().PredefinedGraph_Modify, GraphSettings.ACCESS_WRITE);
    userList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection sel = (IStructuredSelection) event.getSelection();
            if (sel.size() == 1) {
                enableAllChecks(true);
                AccessListElement element = (AccessListElement) sel.getFirstElement();
                int rights = element.getAccessRights();
                for (int i = 0, mask = 1; i < 16; i++, mask <<= 1) {
                    Button check = accessChecks.get(mask);
                    if (check != null) {
                        check.setSelection((rights & mask) == mask);
                    }
                }
            } else {
                enableAllChecks(false);
            }
            deleteButton.setEnabled(sel.size() > 0);
        }
    });
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) SelectUserDialog(org.netxms.ui.eclipse.usermanager.dialogs.SelectUserDialog) AccessListComparator(org.netxms.ui.eclipse.perfview.propertypages.helpers.AccessListComparator) SortableTableViewer(org.netxms.ui.eclipse.widgets.SortableTableViewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) AbstractUserObject(org.netxms.client.users.AbstractUserObject) FillLayout(org.eclipse.swt.layout.FillLayout) AccessListElement(org.netxms.client.AccessListElement) AccessListLabelProvider(org.netxms.ui.eclipse.perfview.propertypages.helpers.AccessListLabelProvider) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionListener(org.eclipse.swt.events.SelectionListener)

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