Example usage for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_SPACING

List of usage examples for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_SPACING

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_SPACING.

Prototype

int HORIZONTAL_SPACING

To view the source code for org.eclipse.jface.dialogs IDialogConstants HORIZONTAL_SPACING.

Click Source Link

Document

Horizontal spacing in dialog units (value 4).

Usage

From source file:org.apache.sling.ide.eclipse.ui.views.MVPEditor.java

License:Apache License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    // now add the node type dropbox-combo
    Composite header = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;//from ww w.j a v a2s.  co m
    layout.marginWidth = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.numColumns = 3;
    header.setLayout(layout);

    Label label = new Label(header, SWT.WRAP);
    label.setText("Modify property " + property.getName() + ":");
    GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
            | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
    data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setLayoutData(data);
    label.setFont(parent.getFont());

    ToolBar buttonBar = new ToolBar(header, SWT.NONE);
    ToolItem invisible = new ToolItem(buttonBar, SWT.NONE);

    ToolItem plus = new ToolItem(buttonBar, SWT.NONE);
    plus.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_ADD)
            .createImage());
    plus.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            plus();
        }
    });

    final ToolItem minus = new ToolItem(buttonBar, SWT.NONE);
    minus.setImage(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)
            .createImage());
    minus.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            minus();
        }
    });
    minus.setEnabled(false);

    Composite tableParent = new Composite(composite, SWT.NONE);
    final GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.heightHint = 150;
    tableParent.setLayoutData(layoutData);
    TableColumnLayout tableLayout = new TableColumnLayout();
    tableParent.setLayout(tableLayout);
    viewer = new TableViewer(tableParent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    viewer.getTable().setLinesVisible(true);
    viewer.getTable().setHeaderVisible(true);

    // accessing property here directly, instead of going via (JcrProperty)inputElement;
    String[] rawLines = property.getValuesAsString();
    // convert raw lines to Line objects for easier editing management
    for (int i = 0; i < rawLines.length; i++) {
        lines.add(new Line(rawLines[i]));
    }

    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return lines.toArray();
        }
    });

    TableViewerColumn column0 = new TableViewerColumn(viewer, SWT.NONE);
    column0.getColumn().setText("Type");
    column0.getColumn().setResizable(true);
    column0.getColumn().setWidth(100);
    tableLayout.setColumnData(column0.getColumn(), new ColumnWeightData(20, 100));
    column0.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            try {
                cell.setText(property.getTypeAsString());
                cell.setForeground(greyColor);
            } catch (Exception e) {
                cell.setText("n/a");
                cell.setForeground(greyColor);
            }
        }
    });

    TableViewerColumn column1 = new TableViewerColumn(viewer, SWT.NONE);
    column1.getColumn().setText("Value");
    column1.getColumn().setResizable(true);
    column1.getColumn().setWidth(200);
    tableLayout.setColumnData(column1.getColumn(), new ColumnWeightData(80, 200));

    column1.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            Line line = (Line) cell.getElement();
            cell.setText(line.getValue());
        }
    });
    column1.setEditingSupport(new EditingSupport(viewer) {

        @Override
        protected void setValue(Object element, Object value) {
            Line line = (Line) element;
            line.setValue(String.valueOf(value));
            // trigger a refresh:
            viewer.setInput(property);
        }

        @Override
        protected Object getValue(Object element) {
            final Line line = (Line) element;
            final String value = line.getValue();
            System.out.println("Value=" + value);
            return value;
        }

        @Override
        protected CellEditor getCellEditor(Object element) {
            return new TextCellEditor(viewer.getTable());
        }

        @Override
        protected boolean canEdit(Object element) {
            // all values are editable
            return true;
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection iss = (IStructuredSelection) selection;
                if (iss.isEmpty()) {
                    minus.setEnabled(false);
                } else {
                    minus.setEnabled(true);
                }
            } else {
                minus.setEnabled(false);
            }
        }
    });

    viewer.setInput(property);

    return composite;
}

From source file:org.bonitasoft.studio.connectors.ui.preferences.DBConnectorsPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    setPreferenceStore(BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore());
    final Composite titleComposite = new Composite(parent, SWT.NONE);
    titleComposite.setLayout(new GridLayout(2, false));
    titleComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    final Label imageLabel = new Label(titleComposite, SWT.NONE);
    imageLabel.setImage(Pics.getImage(PicsConstants.preferenceAdvanced));

    final Label title = new Label(titleComposite, SWT.NONE);
    title.setText(Messages.BonitaPreferenceDialog_DBConnectors);
    title.setFont(BonitaStudioFontRegistry.getPreferenceTitleFont());

    final Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = layout.marginWidth = 0;
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);// w w  w.  ja  v a 2  s  . c om
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    final Composite booleanEditorComposite = new Composite(composite, SWT.NONE);
    booleanEditorComposite.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create());
    booleanEditorComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).create());
    BooleanFieldEditor editor = new CheckBoxFieldEditor(BonitaPreferenceConstants.ALWAYS_USE_SCRIPTING_MODE,
            Messages.alwaysUseScriptingModeOutputPref, booleanEditorComposite);
    addField(editor);

    final Label label = new Label(composite, SWT.WRAP);
    label.setText(Messages.BonitaPreferencePage_DBConnectors_Description);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = 150;
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    label.setLayoutData(data);

    createDBConnectorsList(composite);
    createDriverManager(composite);

    initialize();
    checkState();

    return composite;
}

From source file:org.codehaus.groovy.eclipse.dsl.inferencing.suggestions.ui.AbstractDialogue.java

License:Apache License

protected Control createDialogArea(Composite parent) {
    invalidValues = new HashMap<IDialogueControlDescriptor, SetValue>();
    DialogueDescriptor descriptor = getDialogueDescriptor();
    setTitle(descriptor.getTitle());//from  ww w.  j  a  v a2  s . c o m
    setMessage(descriptor.getMessage());
    String iconLocation = descriptor.getIconLocation();
    if (iconLocation != null && iconLocation.length() > 0) {
        setTitleImage(GroovyDSLCoreActivator.getImageDescriptor(iconLocation).createImage());
    }
    Composite composite = new Composite(parent, SWT.NONE);

    GridLayoutFactory.fillDefaults().margins(getDefaultCompositeHMargin(), getDefaultCompositeVMargin())
            .spacing(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING),
                    convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING))
            .applyTo(composite);

    Dialog.applyDialogFont(composite);

    GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);

    createCommandArea(composite);

    return composite;
}

From source file:org.csstudio.auth.ui.dialogs.LoginDialog.java

License:Open Source License

/**
 * Creates the contents of this dialog.// w  w  w.j ava  2s.  c  o  m
 */
@Override
protected Control createDialogArea(final Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    setTitle(_title);
    setMessage(_message);

    // Create the layout
    Composite contents = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    contents.setLayout(layout);
    contents.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
    contents.setFont(parent.getFont());

    // user name
    Label label = new Label(contents, SWT.NONE);
    label.setText(Messages.LoginDialog_UserName);
    _username = new Text(contents, SWT.BORDER | SWT.FLAT);

    _username.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    _username.setText(_lastUser != null ? _lastUser : "");

    // password
    label = new Label(contents, SWT.NONE);
    label.setText(Messages.LoginDialog_Password);
    _password = new Text(contents, SWT.BORDER | SWT.FLAT | SWT.PASSWORD);
    _password.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));

    // Anonymous login checkbox
    _loginAnonymous = new Button(contents, SWT.CHECK);
    _loginAnonymous.setText(Messages.LoginDialog_LoginAnonymous);
    _loginAnonymous.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    _loginAnonymous.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            if (_loginAnonymous.getSelection()) {
                // Disable name/password when anonymous
                _username.setEnabled(false);
                _password.setEnabled(false);
            } else {
                // (Re-)enable name/password entry
                _username.setEnabled(true);
                _password.setEnabled(true);
                // ... and jump to name field
                _username.setFocus();
            }
        }
    });

    // remember password checkbox (invisible by default)
    _rememberLogin = new Button(contents, SWT.CHECK);
    _rememberLogin.setText("Remember my user name and password");
    _rememberLogin.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    _rememberLogin.setVisible(false);

    if (_lastUser != null && _lastUser.trim().length() > 0) {
        _password.setFocus();
    } else {
        _username.setFocus();
    }
    return parentComposite;
}

From source file:org.csstudio.auth.ui.internal.preferences.AddSubnetDialog.java

License:Open Source License

/**
 * {@inheritDoc}/*from w  ww  .  j  a  va2 s  . c  om*/
 */
@Override
protected Control createDialogArea(Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    setTitle("Add Subnet");
    setMessage("Please enter the subnet address and netmask.");

    Composite contents = new Composite(parentComposite, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.numColumns = 2;
    contents.setLayout(layout);
    contents.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
    contents.setFont(parentComposite.getFont());

    Label addressLabel = new Label(contents, SWT.NULL);
    addressLabel.setText("Subnet address:");
    _networkAddress = new Text(contents, SWT.SINGLE | SWT.BORDER);
    _networkAddress.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    _networkAddress.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (e.widget == _networkAddress) {
                autocompleteNetmask();
                checkValid();
            }
        }
    });

    Label netmaskLabel = new Label(contents, SWT.NULL);
    netmaskLabel.setText("Subnet address:");
    _netmask = new Text(contents, SWT.SINGLE | SWT.BORDER);
    _netmask.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    _netmask.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (e.widget == _netmask) {
                checkValid();
            }
        }
    });

    return contents;
}

From source file:org.csstudio.auth.ui.internal.preferences.SystemPropertyDialog.java

License:Open Source License

/**
 * {@inheritDoc}//from  www . j  a v a2  s  . com
 */
@Override
protected Control createDialogArea(final Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    Composite contents = new Composite(parentComposite, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.numColumns = 2;
    contents.setLayout(layout);
    contents.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
    contents.setFont(parentComposite.getFont());

    Label keyLabel = new Label(contents, SWT.NULL);
    keyLabel.setText(Messages.SystemPropertyDialog_KEY_LABEL);
    final Text keyText = new Text(contents, SWT.SINGLE | SWT.BORDER);
    GridData layoutData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
    layoutData.widthHint = 250;
    keyText.setLayoutData(layoutData);
    keyText.setText(_key);
    keyText.addModifyListener(new ModifyListener() {
        public void modifyText(final ModifyEvent e) {
            if (e.widget == keyText) {
                _key = keyText.getText();
                // enable the OK button if the "key" field contains not
                // just whitespace
                getButton(IDialogConstants.OK_ID).setEnabled(!_key.trim().equals("")); //$NON-NLS-1$
            }
        }
    });

    Label valueLabel = new Label(contents, SWT.NULL);
    valueLabel.setText(Messages.SystemPropertyDialog_VALUE_LABEL);
    final Text valueText = new Text(contents, SWT.SINGLE | SWT.BORDER);
    valueText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    valueText.setText(_value);
    valueText.addModifyListener(new ModifyListener() {
        public void modifyText(final ModifyEvent e) {
            if (e.widget == valueText) {
                _value = valueText.getText();
            }
        }
    });

    return contents;
}

From source file:org.csstudio.nsls2.startuphelper.StartupDialog.java

License:Open Source License

/**
 * Creates the contents of this dialog.//from  ww w.  j a  va  2s  .  co  m
 */
@Override
protected Control createDialogArea(final Composite parent) {
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    setTitle(_title);
    setMessage(_message);

    // Create the layout
    Composite contents = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    contents.setLayout(layout);
    contents.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, true));
    contents.setFont(parent.getFont());

    if (showLogin) {
        Group loginGroup = new Group(contents, SWT.SHADOW_ETCHED_IN);
        loginGroup.setText(Messages.LoginDialog_Login);
        createLoginSection(loginGroup);
    }

    if (showWorkspace) {
        Group workspaceGroup = new Group(contents, SWT.SHADOW_ETCHED_IN);
        workspaceGroup.setText(Messages.StartupDialog_SelectWorkspace);
        createWorkspaceSection(workspaceGroup);
    }

    return parentComposite;
}

From source file:org.csstudio.sds.util.SaveAsDialog.java

License:Open Source License

/**
 * {@inheritDoc}/*from  w ww. ja va2 s  . c om*/
 */
protected Control createDialogArea(final Composite parent) {
    // top level composite
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    // create a composite with standard margins and spacing
    Composite composite = new Composite(parentComposite, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    //        composite.setFont(parentComposite.getFont());

    Listener listener = new Listener() {
        public void handleEvent(final Event event) {
            setDialogComplete(validatePage());
        }
    };

    _resourceGroup = new ResourceAndContainerGroup(composite, listener, Messages.SaveAsDialog_FILE_LABEL,
            Messages.SaveAsDialog_FILE);
    _resourceGroup.setAllowExistingResources(true);

    return parentComposite;
}

From source file:org.dawb.workbench.ui.data.PlotDataChooseDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    // create a composite with standard margins and spacing
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);/*from  w ww . java  2  s .  c  o m*/
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    applyDialogFont(composite);

    // Add a choice list to choose the existing data. 
    Label label = new Label(composite, SWT.WRAP);
    label.setText(
            "Please choose the plotted data to which the error '" + error.getName() + "' should be assigned.");
    label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));

    label = new Label(composite, SWT.WRAP);
    label.setText("Plotted data ");
    label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));

    final Combo combo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    combo.setItems(getSelectionNames());
    combo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            final String name = combo.getItem(combo.getSelectionIndex());
            selection = getSelectionByName(name);
        }
    });
    combo.select(0);

    return composite;
}

From source file:org.drools.eclipse.flow.common.editor.action.ExportImageDialog.java

License:Apache License

protected Control createDialogArea(Composite parent) {
    // top level composite
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    // create a composite with standard margins and spacing
    Composite composite = new Composite(parentComposite, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);/*  ww w  . j av  a2  s.c  o  m*/
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setFont(parentComposite.getFont());

    Listener listener = new Listener() {
        public void handleEvent(Event event) {
            setDialogComplete(validatePage());
        }
    };

    resourceGroup = new ResourceAndContainerGroup(composite, listener,
            IDEWorkbenchMessages.SaveAsDialog_fileLabel, IDEWorkbenchMessages.SaveAsDialog_file);
    resourceGroup.setAllowExistingResources(true);

    return parentComposite;
}