Search in sources :

Example 6 with WidgetFactory

use of org.netxms.ui.eclipse.tools.WidgetFactory in project netxms by netxms.

the class Layout method createContents.

/* (non-Javadoc)
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createContents(Composite parent) {
    elementConfig = (DashboardElementConfig) getElement().getAdapter(DashboardElementConfig.class);
    elementLayout = elementConfig.getLayout();
    Composite dialogArea = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    final WidgetFactory factory = new WidgetFactory() {

        @Override
        public Control createControl(Composite parent, int style) {
            Spinner spinner = new Spinner(parent, style);
            spinner.setMinimum(1);
            spinner.setMaximum(8);
            return spinner;
        }
    };
    spinnerHorizontalSpan = (Spinner) WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, factory, Messages.get().Layout_HSpan, WidgetHelper.DEFAULT_LAYOUT_DATA);
    spinnerHorizontalSpan.setSelection(elementLayout.horizontalSpan);
    spinnerHeightHint = (Spinner) WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, factory, Messages.get().Layout_HHint, WidgetHelper.DEFAULT_LAYOUT_DATA);
    spinnerHeightHint.setMinimum(-1);
    spinnerHeightHint.setMaximum(8192);
    spinnerHeightHint.setSelection(elementLayout.heightHint);
    spinnerVerticalSpan = (Spinner) WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, factory, Messages.get().Layout_VSpan, WidgetHelper.DEFAULT_LAYOUT_DATA);
    spinnerVerticalSpan.setSelection(elementLayout.verticalSpan);
    checkGrabVerticalSpace = new Button(dialogArea, SWT.CHECK);
    checkGrabVerticalSpace.setText(Messages.get().Layout_GrapExtraV);
    checkGrabVerticalSpace.setSelection(elementLayout.grabVerticalSpace);
    checkGrabVerticalSpace.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) Button(org.eclipse.swt.widgets.Button) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData)

Example 7 with WidgetFactory

use of org.netxms.ui.eclipse.tools.WidgetFactory in project netxms by netxms.

the class EditGroupBoxDialog 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.OUTER_SPACING;
    dialogArea.setLayout(layout);
    /* title */
    textTitle = new LabeledText(dialogArea, SWT.NONE);
    textTitle.setLabel(Messages.get().AddGroupBoxDialog_Title);
    textTitle.setText(groupBox.getTitle());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 300;
    textTitle.setLayoutData(gd);
    /* width and height */
    Composite attrArea = new Composite(dialogArea, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    attrArea.setLayout(layout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    attrArea.setLayoutData(gd);
    WidgetFactory factory = new WidgetFactory() {

        @Override
        public Control createControl(Composite parent, int style) {
            Spinner spinner = new Spinner(parent, style | SWT.BORDER);
            spinner.setMinimum(20);
            spinner.setMaximum(4096);
            return spinner;
        }
    };
    spinnerWidth = (Spinner) WidgetHelper.createLabeledControl(attrArea, SWT.NONE, factory, Messages.get().AddGroupBoxDialog_Width, WidgetHelper.DEFAULT_LAYOUT_DATA);
    spinnerWidth.setSelection(groupBox.getWidth());
    spinnerHeight = (Spinner) WidgetHelper.createLabeledControl(attrArea, SWT.NONE, factory, Messages.get().AddGroupBoxDialog_Height, WidgetHelper.DEFAULT_LAYOUT_DATA);
    spinnerHeight.setSelection(groupBox.getHeight());
    colorSelector = WidgetHelper.createLabeledColorSelector(attrArea, Messages.get().AddGroupBoxDialog_Color, WidgetHelper.DEFAULT_LAYOUT_DATA);
    colorSelector.setColorValue(DEFAULT_COLOR);
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Spinner(org.eclipse.swt.widgets.Spinner) GridData(org.eclipse.swt.layout.GridData)

Example 8 with WidgetFactory

use of org.netxms.ui.eclipse.tools.WidgetFactory in project netxms by netxms.

the class ImagePropertiesDialog method createDialogArea.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected Control createDialogArea(Composite parent) {
    final Composite dialogArea = (Composite) super.createDialogArea(parent);
    final GridLayout layout = new GridLayout();
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    dialogArea.setLayout(layout);
    WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, new WidgetFactory() {

        @Override
        public Control createControl(Composite parent, int style) {
            final Composite composite = new Composite(parent, SWT.NONE);
            final GridLayout compositeLayout = new GridLayout();
            compositeLayout.numColumns = 2;
            // compositeLayout.verticalSpacing = WidgetHelper.INNER_SPACING;
            composite.setLayout(compositeLayout);
            fileNameInputField = new Text(composite, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
            GridData gd = new GridData();
            gd.widthHint = 300;
            // gd.heightHint = 300;
            gd.grabExcessHorizontalSpace = true;
            gd.grabExcessVerticalSpace = true;
            gd.horizontalAlignment = SWT.FILL;
            gd.verticalAlignment = SWT.FILL;
            fileNameInputField.setLayoutData(gd);
            final Button button = new Button(composite, SWT.NONE);
            button.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    FileDialog dialog = new FileDialog(shell, SWT.OPEN);
                    dialog.setText(Messages.get().ImagePropertiesDialog_Title);
                    final String selectedFile = dialog.open();
                    if (selectedFile != null) {
                        fileName = selectedFile;
                        fileNameInputField.setText(selectedFile);
                        if (nameInputField.getText().length() == 0) {
                            String imageName = new File(fileName).getName();
                            final int lastIndexOf = imageName.lastIndexOf('.');
                            if (lastIndexOf != -1) {
                                imageName = imageName.substring(0, lastIndexOf);
                            }
                            nameInputField.setText(imageName);
                        }
                    }
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                    widgetSelected(e);
                }
            });
            // $NON-NLS-1$
            button.setText("...");
            return composite;
        }
    }, Messages.get().ImagePropertiesDialog_ImageFile, WidgetHelper.DEFAULT_LAYOUT_DATA);
    nameInputField = WidgetHelper.createLabeledText(dialogArea, SWT.SINGLE | SWT.BORDER, SWT.DEFAULT, Messages.get().ImagePropertiesDialog_ImageName, name == null ? "" : name, // $NON-NLS-1$
    WidgetHelper.DEFAULT_LAYOUT_DATA);
    nameInputField.getShell().setMinimumSize(300, 0);
    categoryCombo = WidgetHelper.createLabeledCombo(dialogArea, SWT.DROP_DOWN | SWT.BORDER, Messages.get().ImagePropertiesDialog_Category, WidgetHelper.DEFAULT_LAYOUT_DATA);
    categoryCombo.getShell().setMinimumSize(300, 0);
    int counter = 0;
    for (String name : categories) {
        categoryCombo.add(name);
        if (name.equals(category)) {
            categoryCombo.select(counter);
        }
        counter++;
    }
    return dialogArea;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 9 with WidgetFactory

use of org.netxms.ui.eclipse.tools.WidgetFactory in project netxms by netxms.

the class RerunTimeDialog method createDialogArea.

/* (non-Javadoc)
    * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
    */
@Override
protected Control createDialogArea(Composite parent) {
    final Composite dialogArea = (Composite) super.createDialogArea(parent);
    GridLayout layout = new GridLayout();
    layout.marginHeight = WidgetHelper.DIALOG_HEIGHT_MARGIN;
    layout.marginWidth = WidgetHelper.DIALOG_WIDTH_MARGIN;
    layout.numColumns = 2;
    dialogArea.setLayout(layout);
    final WidgetFactory factory = new WidgetFactory() {

        @Override
        public Control createControl(Composite parent, int style) {
            return new DateTimeSelector(parent, style);
        }
    };
    dateSelector = (DateTimeSelector) WidgetHelper.createLabeledControl(dialogArea, SWT.NONE, factory, "New execution time", WidgetHelper.DEFAULT_LAYOUT_DATA);
    dateSelector.setValue(new Date());
    return dialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) DateTimeSelector(org.netxms.ui.eclipse.widgets.DateTimeSelector) Date(java.util.Date)

Example 10 with WidgetFactory

use of org.netxms.ui.eclipse.tools.WidgetFactory in project netxms by netxms.

the class InstanceDiscovery 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);
    editor = (DataCollectionObjectEditor) getElement().getAdapter(DataCollectionObjectEditor.class);
    dco = editor.getObject();
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = WidgetHelper.OUTER_SPACING;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    dialogArea.setLayout(layout);
    discoveryMethod = WidgetHelper.createLabeledCombo(dialogArea, SWT.BORDER | SWT.READ_ONLY, Messages.get().InstanceDiscovery_Method, WidgetHelper.DEFAULT_LAYOUT_DATA);
    discoveryMethod.add(Messages.get().InstanceDiscovery_None);
    discoveryMethod.add(Messages.get().InstanceDiscovery_AgentList);
    discoveryMethod.add(Messages.get().InstanceDiscovery_AgentTable);
    discoveryMethod.add(Messages.get().InstanceDiscovery_SnmpWalkValues);
    discoveryMethod.add(Messages.get().InstanceDiscovery_SnmpWalkOids);
    discoveryMethod.add(Messages.get().InstanceDiscovery_Script);
    discoveryMethod.select(dco.getInstanceDiscoveryMethod());
    discoveryMethod.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int method = discoveryMethod.getSelectionIndex();
            discoveryData.setLabel(getDataLabel(method));
            discoveryData.setEnabled(method != DataCollectionObject.IDM_NONE);
            filterScript.setEnabled(method != DataCollectionObject.IDM_NONE);
            instanceRetentionMode.setEnabled(method != DataCollectionObject.IDM_NONE);
            instanceRetentionTime.setEnabled(method != DataCollectionObject.IDM_NONE && instanceRetentionMode.getSelectionIndex() > 0);
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    discoveryData = new LabeledText(dialogArea, SWT.NONE);
    discoveryData.setLabel(getDataLabel(dco.getInstanceDiscoveryMethod()));
    discoveryData.setText(dco.getInstanceDiscoveryData());
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    discoveryData.setLayoutData(gd);
    discoveryData.setEnabled(dco.getInstanceDiscoveryMethod() != DataCollectionObject.IDM_NONE);
    groupRetention = new Group(dialogArea, SWT.NONE);
    groupRetention.setText("Instance retention");
    gd = new GridData();
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.horizontalSpan = 2;
    groupRetention.setLayoutData(gd);
    GridLayout retentionLayout = new GridLayout();
    retentionLayout.numColumns = 2;
    retentionLayout.horizontalSpacing = WidgetHelper.OUTER_SPACING;
    groupRetention.setLayout(retentionLayout);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    instanceRetentionMode = WidgetHelper.createLabeledCombo(groupRetention, SWT.READ_ONLY, "Instance retention mode", gd);
    instanceRetentionMode.add("Server default");
    instanceRetentionMode.add("Custom");
    instanceRetentionMode.select(dco.getInstanceRetentionTime() == -1 ? 0 : 1);
    instanceRetentionMode.setEnabled(dco.getInstanceDiscoveryMethod() != DataCollectionObject.IDM_NONE);
    instanceRetentionMode.addSelectionListener(new SelectionListener() {

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetSelected(SelectionEvent e) {
            instanceRetentionTime.setEnabled(instanceRetentionMode.getSelectionIndex() == 1);
        }

        /* (non-Javadoc)
          * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
          */
        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    instanceRetentionTime = WidgetHelper.createLabeledSpinner(groupRetention, SWT.BORDER, "Instance retention time (days)", 0, 100, new GridData());
    instanceRetentionTime.setSelection(dco.getInstanceRetentionTime());
    instanceRetentionTime.setEnabled(instanceRetentionMode.getSelectionIndex() > 0);
    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$1\tInstance to test\r\n\r\nReturn value:\r\n\ttrue/false to accept or reject instance without additional changes or\r\n\tarray of two or three elements to modify instance:\r\n\t\t1st element - true/false to indicate acceptance;\r\n\t\t2nd element - new instance name;\r\n\t\t3rd element - new instance display name.");
        }
    };
    filterScript = (ScriptEditor) WidgetHelper.createLabeledControl(dialogArea, SWT.BORDER, factory, Messages.get().InstanceDiscovery_FilterScript, gd);
    filterScript.addFunctions(Arrays.asList(DCI_FUNCTIONS));
    filterScript.addVariables(Arrays.asList(DCI_VARIABLES));
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.verticalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    filterScript.setLayoutData(gd);
    filterScript.setText(dco.getInstanceDiscoveryFilter());
    filterScript.setEnabled(dco.getInstanceDiscoveryMethod() != DataCollectionObject.IDM_NONE);
    return dialogArea;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) SelectionListener(org.eclipse.swt.events.SelectionListener) ScriptEditor(org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor)

Aggregations

GridLayout (org.eclipse.swt.layout.GridLayout)11 Composite (org.eclipse.swt.widgets.Composite)11 WidgetFactory (org.netxms.ui.eclipse.tools.WidgetFactory)11 GridData (org.eclipse.swt.layout.GridData)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 Spinner (org.eclipse.swt.widgets.Spinner)6 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)6 SelectionListener (org.eclipse.swt.events.SelectionListener)5 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 Button (org.eclipse.swt.widgets.Button)3 ScriptEditor (org.netxms.ui.eclipse.nxsl.widgets.ScriptEditor)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 DashboardComposite (org.netxms.ui.eclipse.widgets.DashboardComposite)2 File (java.io.File)1 Date (java.util.Date)1 Control (org.eclipse.swt.widgets.Control)1 FileDialog (org.eclipse.swt.widgets.FileDialog)1 Group (org.eclipse.swt.widgets.Group)1 Text (org.eclipse.swt.widgets.Text)1