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

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

Introduction

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

Prototype

int VERTICAL_MARGIN

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

Click Source Link

Document

Vertical margin in dialog units (value 7).

Usage

From source file:org.eclipse.jst.servlet.ui.internal.wizard.MultiSelectFilteredFilterFileSelectionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    GridData gd = new GridData();

    fChild = new Composite(parent, SWT.NONE);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fChild, "com.ibm.etools.webapplicationedit.webx2010"); //$NON-NLS-1$
    GridLayout gl = new GridLayout();
    gl.numColumns = 2;/*from  w ww .jav a  2  s . c  om*/
    gl.marginHeight = 5;
    fChild.setLayout(gl);

    gd.verticalAlignment = GridData.FILL;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessVerticalSpace = true;
    fChild.setLayoutData(gd);

    fPageBook = new PageBook(fChild, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.verticalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalSpan = 2;
    fPageBook.setLayoutData(gd);
    super.createDialogArea(fPageBook);

    Composite composite = new Composite(fPageBook, 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(parent.getFont());

    Label messageLabel = new Label(composite, SWT.NONE);
    gd = new GridData();
    messageLabel.setLayoutData(gd);
    messageLabel.setText(WebAppEditResourceHandler.getString("Choose_a_filter__1")); //$NON-NLS-1$

    fText = createText(composite);

    messageLabel = new Label(composite, SWT.NONE);
    gd = new GridData();
    messageLabel.setLayoutData(gd);
    messageLabel.setText(WebAppEditResourceHandler.getString("Matching_filters__2")); //$NON-NLS-1$

    fUpperList = createUpperList(composite);

    messageLabel = new Label(composite, SWT.NONE);
    gd = new GridData();
    messageLabel.setLayoutData(gd);
    messageLabel.setText(WebAppEditResourceHandler.getString("Qualifier__3")); //$NON-NLS-1$

    fLowerList = createLowerList(composite);

    fServletControl = composite;

    fPageBook.showPage(fServletControl);
    return parent;
}

From source file:org.eclipse.jst.servlet.ui.internal.wizard.MultiSelectFilteredListenerFileSelectionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    GridData gd = new GridData();

    fChild = new Composite(parent, SWT.NONE);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fChild, "com.ibm.etools.webapplicationedit.webx2010"); //$NON-NLS-1$
    GridLayout gl = new GridLayout();
    gl.numColumns = 2;/*  www .  ja va 2  s .  c o  m*/
    gl.marginHeight = 5;
    fChild.setLayout(gl);

    gd.verticalAlignment = GridData.FILL;
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessVerticalSpace = true;
    fChild.setLayoutData(gd);

    fPageBook = new PageBook(fChild, SWT.NONE);
    gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.verticalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    gd.horizontalSpan = 2;
    fPageBook.setLayoutData(gd);
    super.createDialogArea(fPageBook);

    Composite composite = new Composite(fPageBook, 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(parent.getFont());

    Label messageLabel = new Label(composite, SWT.NONE);
    gd = new GridData();
    messageLabel.setLayoutData(gd);
    messageLabel.setText(WebAppEditResourceHandler.getString("Choose_a_listener__1")); //$NON-NLS-1$ 

    fText = createText(composite);

    messageLabel = new Label(composite, SWT.NONE);
    gd = new GridData();
    messageLabel.setLayoutData(gd);
    messageLabel.setText(WebAppEditResourceHandler.getString("Matching_listener__2")); //$NON-NLS-1$ 

    fUpperList = createUpperList(composite);

    messageLabel = new Label(composite, SWT.NONE);
    gd = new GridData();
    messageLabel.setLayoutData(gd);
    messageLabel.setText(WebAppEditResourceHandler.getString("Qualifier__3")); //$NON-NLS-1$

    fLowerList = createLowerList(composite);

    fServletControl = composite;

    fPageBook.showPage(fServletControl);
    return parent;
}

From source file:org.eclipse.koneki.ldt.debug.ui.internal.interpreters.AddLuaInterpreterDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {

    Composite container = new Composite(parent, SWT.NONE);
    Point margin = new Point(0, 0);
    margin.x = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    margin.y = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    Point spacing = new Point(0, 0);
    spacing.x = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    spacing.y = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    GridLayoutFactory.swtDefaults().spacing(spacing).margins(margin).numColumns(3).applyTo(container);
    GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(container);

    createLabel(container, InterpretersMessages.addInterpreterDialog_InterpreterEnvironmentType);
    typesCombo = new ComboViewer(container);
    GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).span(2, 1)
            .applyTo(typesCombo.getControl());

    createLabel(container, InterpretersMessages.addInterpreterDialog_InterpreterExecutableName);
    pathText = new Text(container, SWT.SINGLE | SWT.BORDER);
    GridDataFactory.swtDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).hint(300, SWT.DEFAULT)
            .applyTo(pathText);/* w  w  w  .j  a v  a 2 s.  c  o m*/
    browseButton = new Button(container, SWT.PUSH);
    browseButton.setText(InterpretersMessages.addInterpreterDialog_browse1);
    GridDataFactory.swtDefaults().hint(SWTUtil.getButtonWidthHint(browseButton), -1).applyTo(browseButton);

    createLabel(container, InterpretersMessages.addInterpreterDialog_InterpreterEnvironmentName);
    nameText = new Text(container, SWT.SINGLE | SWT.BORDER);
    GridDataFactory.swtDefaults().grab(true, false).span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(nameText);

    createLabel(container, InterpretersMessages.AddInterpreterDialog_iArgs);
    argsText = new Text(container, SWT.SINGLE | SWT.BORDER);
    GridDataFactory.swtDefaults().grab(true, false).span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(argsText);

    environementVariableBlock = new LuaInterpreterEnvironmentVariablesBlock(new AddInterpreterDialogAdapter(
            requestor, getShell(), interpreterInstallTypes, currentInterperter));
    final Composite environmentComposite = (Composite) environementVariableBlock.createControl(container);
    GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(2).applyTo(environmentComposite);
    GridDataFactory.swtDefaults().grab(true, true).span(3, 1).align(SWT.FILL, SWT.FILL)
            .applyTo(environmentComposite);

    // Interpreter Capabilities
    capabilitiesGroup = new Group(container, SWT.None);
    capabilitiesGroup.setText(Messages.AddLuaInterpreterDialog_CapabilitesGroupLabel);
    GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(1).applyTo(capabilitiesGroup);
    GridDataFactory.swtDefaults().grab(true, false).span(3, 1).align(SWT.FILL, SWT.FILL)
            .applyTo(capabilitiesGroup);

    capabilitiesDesctiptionLabel = new Label(capabilitiesGroup, SWT.NONE);
    toItalic(capabilitiesDesctiptionLabel);
    GridDataFactory.swtDefaults().span(3, 1).grab(true, false).align(SWT.FILL, SWT.FILL)
            .applyTo(capabilitiesDesctiptionLabel);

    handlesExecutionOption = new Button(capabilitiesGroup, SWT.CHECK);
    handlesExecutionOption.setText(Messages.AddLuaInterpreterDialog_ExecutionOption);

    handlesFilesAsArguments = new Button(capabilitiesGroup, SWT.CHECK);
    handlesFilesAsArguments.setText(Messages.AddLuaInterpreterDialog_FilesAsArguments);

    applyDialogFont(container);
    hookListeners();
    init();

    return container;
}

From source file:org.eclipse.launchbar.ui.internal.dialogs.LaunchConfigurationEditDialog.java

License:Open Source License

@Override
protected Control createButtonBar(Composite parent) {
    // Clone super's implementation, removes the monitor since we don't run from here
    // And adds in the left button bar.
    Font font = parent.getFont();
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/*w  w w . ja va2 s.com*/
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    composite.setFont(font);

    // create help control if needed
    if (isHelpAvailable()) {
        createHelpControl(composite);
    }

    Composite leftButtonComp = new Composite(composite, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.numColumns = 0;
    leftButtonComp.setLayout(layout);
    leftButtonComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    leftButtonComp.setFont(parent.getFont());

    createButton(leftButtonComp, DELETE_ID, Messages.LaunchConfigurationEditDialog_0, false);
    createButton(leftButtonComp, DUPLICATE_ID, Messages.LaunchConfigurationEditDialog_1, false);
    // launch button text same as in eclipse LaunchConfigurationDialog - mode name
    createButton(leftButtonComp, LAUNCH_ID, getLaunchButtonText(), false);

    Composite mainButtonComp = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.numColumns = 0;
    mainButtonComp.setLayout(layout);
    mainButtonComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    mainButtonComp.setFont(parent.getFont());

    createButton(mainButtonComp, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(mainButtonComp, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

    return composite;
}

From source file:org.eclipse.libra.framework.ui.internal.TerminationDialog.java

License:Open Source License

/**
 * Creates and returns the contents of the upper part 
 * of this dialog (above the button bar).
 *
 * @param parent the parent composite to contain the dialog area
 * @return the dialog area control//  w  ww.  j  ava  2s .  com
 */
protected Control createDialogArea(Composite parent) {
    // create a composite with standard margins and spacing
    Composite composite = new Composite(parent, 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(parent.getFont());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent,
            ContextIds.FRAMEWORK_INSTANCE_CLEAN_WORK_DIR_TERMINATE);

    Label label = new Label(composite, SWT.WRAP);
    label.setText(message);
    GridData data = new GridData();
    data.widthHint = 400;
    label.setLayoutData(data);

    Dialog.applyDialogFont(composite);

    return composite;
}

From source file:org.eclipse.linuxtools.internal.tools.launch.ui.properties.LinuxtoolsPathPropertyPage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);/*from  w w  w  . j av  a  2  s  . com*/

    result = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = 0;
    layout.numColumns = 1;
    result.setLayout(layout);
    String paths[][] = fillPaths();

    //defaults
    getPreferenceStore().setDefault(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME,
            LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
    getPreferenceStore().setDefault(LINUXTOOLS_PATH_COMBO_NAME,
            LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathDefault());

    // Add radio buttons
    Composite radios = new Composite(result, SWT.NONE);
    GridLayout layoutRadios = new GridLayout();
    layoutRadios.marginWidth = 0;
    layoutRadios.numColumns = 1;
    GridData gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessHorizontalSpace = true;
    radios.setLayout(layoutRadios);
    radios.setLayoutData(gridData);

    boolean systemPathSelected = getPreferenceStore()
            .getBoolean(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME);
    systemEnvButton = new Button(radios, SWT.RADIO);
    systemEnvButton.setText(Messages.LINUXTOOLS_PATH_SYSTEM_ENV);
    systemEnvButton.setSelection(systemPathSelected);
    systemEnvButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            updateOptionsEnable();
        }
    });

    customButton = new Button(radios, SWT.RADIO);
    customButton.setText(Messages.LINUXTOOLS_PATH_CUSTOM);
    customButton.setToolTipText(Messages.LINUXTOOLS_PATH_CUSTOM_TOOLTIP);
    customButton.setSelection(!systemPathSelected);

    //Add combo box
    linuxtoolsPathCombo = new CustomComboFieldEditor(LINUXTOOLS_PATH_COMBO_NAME, Messages.LINUXTOOLS_PATH_COMBO,
            paths, result);
    linuxtoolsPathCombo.setPage(this);
    linuxtoolsPathCombo.setPreferenceStore(getPreferenceStore());
    linuxtoolsPathCombo.load();
    linuxtoolsPathCombo.setPropertyChangeListener(event -> {
        customSelected = event.getNewValue().toString().equals(""); //$NON-NLS-1$
        if (!customSelected) {
            linuxtoolsPath.setStringValue(event.getNewValue().toString());
        }
        updateOptionsEnable();
    });

    //Add textbox
    linuxtoolsPath = new StringFieldEditor(LaunchCoreConstants.LINUXTOOLS_PATH_NAME, Messages.LINUXTOOLS_PATH,
            result);

    linuxtoolsPath.setPage(this);
    linuxtoolsPath.setPreferenceStore(getPreferenceStore());
    linuxtoolsPath.getTextControl(result).setToolTipText(Messages.LINUXTOOLS_PATH_TOOLTIP);

    String selected = getPreferenceStore().getString(LINUXTOOLS_PATH_COMBO_NAME);
    customSelected = selected.equals(""); //$NON-NLS-1$
    getPreferenceStore().setDefault(LaunchCoreConstants.LINUXTOOLS_PATH_NAME,
            LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathDefault());
    linuxtoolsPath.load();
    linuxtoolsPathCombo.setSelectedValue(linuxtoolsPath.getStringValue());
    Dialog.applyDialogFont(result);
    updateOptionsEnable();
    return result;
}

From source file:org.eclipse.linuxtools.tools.launch.ui.properties.LinuxtoolsPathPropertyPage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);/*from   w  w w .ja  v a  2  s.  co  m*/

    result = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = 0;
    layout.numColumns = 1;
    result.setLayout(layout);
    String paths[][] = fillPaths();

    //defaults
    getPreferenceStore().setDefault(LinuxtoolsPathProperty.LINUXTOOLS_PATH_SYSTEM_NAME,
            LINUXTOOLS_PATH_SYSTEM_DEFAULT);
    getPreferenceStore().setDefault(LINUXTOOLS_PATH_COMBO_NAME, paths[0][1]);

    // Add radio buttons
    Composite radios = new Composite(result, SWT.NONE);
    GridLayout layoutRadios = new GridLayout();
    layoutRadios.marginWidth = 0;
    layoutRadios.numColumns = 1;
    radios.setLayout(layoutRadios);
    Composite space = new Composite(result, SWT.NONE);

    boolean systemPathSelected = getPreferenceStore()
            .getBoolean(LinuxtoolsPathProperty.LINUXTOOLS_PATH_SYSTEM_NAME);
    systemEnvButton = new Button(radios, SWT.RADIO);
    systemEnvButton.setText(Messages.LINUXTOOLS_PATH_SYSTEM_ENV);
    systemEnvButton.setSelection(systemPathSelected);
    systemEnvButton.addSelectionListener(new SelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            updateOptionsEnable();
        }

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

    customButton = new Button(radios, SWT.RADIO);
    customButton.setText(Messages.LINUXTOOLS_PATH_CUSTOM);
    customButton.setToolTipText(Messages.LINUXTOOLS_PATH_CUSTOM_TOOLTIP);
    customButton.setSelection(!systemPathSelected);

    //Add combo box
    linuxtoolsPathCombo = new ComboFieldEditor(LINUXTOOLS_PATH_COMBO_NAME, Messages.LINUXTOOLS_PATH_COMBO,
            paths, result);
    linuxtoolsPathCombo.setPage(this);
    linuxtoolsPathCombo.setPreferenceStore(getPreferenceStore());
    linuxtoolsPathCombo.load();
    linuxtoolsPathCombo.setPropertyChangeListener(new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            customSelected = event.getNewValue().toString().equals("");
            if (!customSelected)
                linuxtoolsPath.setStringValue(event.getNewValue().toString());
            updateOptionsEnable();
        }
    });

    //Add textbox
    linuxtoolsPath = new StringFieldEditor(LinuxtoolsPathProperty.LINUXTOOLS_PATH_NAME,
            Messages.LINUXTOOLS_PATH, result);

    linuxtoolsPath.setPage(this);
    linuxtoolsPath.setPreferenceStore(getPreferenceStore());
    linuxtoolsPath.getTextControl(result).setToolTipText(Messages.LINUXTOOLS_PATH_TOOLTIP);

    String selected = getPreferenceStore().getString(LINUXTOOLS_PATH_COMBO_NAME);
    customSelected = selected.equals("");
    getPreferenceStore().setDefault(LinuxtoolsPathProperty.LINUXTOOLS_PATH_NAME,
            LinuxtoolsPathProperty.LINUXTOOLS_PATH_DEFAULT);
    linuxtoolsPath.load();

    Dialog.applyDialogFont(result);
    updateOptionsEnable();
    return result;
}

From source file:org.eclipse.ltk.internal.ui.refactoring.PreviewWizardPage.java

License:Open Source License

private Control createNullPage(Composite parent) {
    Composite result = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    result.setLayout(layout);// w w w.  j  a v a2s .c om
    Label label = new Label(result, SWT.CENTER);
    label.setText(RefactoringUIMessages.PreviewWizardPage_no_source_code_change);
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    Dialog.applyDialogFont(result);
    return result;
}

From source file:org.eclipse.m2e.core.ui.internal.dialogs.MavenGoalSelectionDialog.java

License:Open Source License

protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, 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);/*from  ww w.java  2 s.c  o m*/
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    Label selectGoalLabel = new Label(composite, SWT.NONE);
    selectGoalLabel.setText(org.eclipse.m2e.core.ui.internal.Messages.MavenGoalSelectionDialog_lblSelect);

    final GoalsFilter filter = new GoalsFilter();

    final Text filterText = new Text(composite, SWT.BORDER);
    GridData gd_filterText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd_filterText.widthHint = 200;
    filterText.setLayoutData(gd_filterText);
    filterText.setFocus();

    final TreeViewer treeViewer = createTreeViewer(composite);
    treeViewer.addFilter(filter);

    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 500;
    data.heightHint = 400;
    // data.widthHint = convertWidthInCharsToPixels(fWidth);
    // data.heightHint = convertHeightInCharsToPixels(fHeight);

    final Tree tree = treeViewer.getTree();
    tree.setLayoutData(data);
    tree.setFont(parent.getFont());

    filterText.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            String text = filterText.getText();
            filter.setFilter(text);
            treeViewer.refresh();
            if (text.trim().length() == 0) {
                treeViewer.collapseAll();
            } else {
                treeViewer.expandAll();
            }
        }
    });

    filterText.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.ARROW_DOWN) {
                tree.setFocus();
                tree.setSelection(tree.getTopItem().getItem(0));

                Object[] elements = ((ITreeContentProvider) treeViewer.getContentProvider()).getElements(null);
                treeViewer.setSelection(new StructuredSelection(elements[0]));
            }

        }
    });

    isQualifiedNameButton = new Button(composite, SWT.CHECK);
    isQualifiedNameButton
            .setText(org.eclipse.m2e.core.ui.internal.Messages.MavenGoalSelectionDialog_btnQualified);
    isQualifiedNameButton.setSelection(true);
    isQualifiedNameButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            isQualifiedName = isQualifiedNameButton.getSelection();
        }
    });

    //    if (fIsEmpty) {
    //        messageLabel.setEnabled(false);
    //        treeWidget.setEnabled(false);
    //    }

    return composite;
}

From source file:org.eclipse.m2e.core.ui.internal.preferences.RemoteArchetypeCatalogDialog.java

License:Open Source License

protected Control createButtonBar(Composite parent) {
    Composite composite = new Composite(parent, 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);/* w w w  . j ava 2 s. c  o m*/
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    composite.setFont(parent.getFont());

    // create help control if needed
    if (isHelpAvailable()) {
        createHelpControl(composite);
    }

    verifyButton = createButton(composite, VERIFY_ID, Messages.RemoteArchetypeCatalogDialog_btnVerify, false);
    verifyButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            verifyButton.setEnabled(false);
            String url = catalogUrlCombo.getText();
            final RemoteCatalogFactory factory = new RemoteCatalogFactory(url, null, true);

            new Job(Messages.RemoteArchetypeCatalogDialog_job_download) {
                protected IStatus run(IProgressMonitor monitor) {
                    IStatus status = Status.OK_STATUS;
                    ArchetypeCatalog catalog = null;
                    try {
                        catalog = factory.getArchetypeCatalog();
                    } finally {
                        final IStatus s = status;
                        @SuppressWarnings("unchecked")
                        final List<Archetype> archetypes = catalog == null ? Collections.emptyList()
                                : catalog.getArchetypes();
                        getShell().getDisplay().asyncExec(new Runnable() {
                            public void run() {
                                verifyButton.setEnabled(true);
                                if (!s.isOK()) {
                                    setErrorMessage(NLS.bind(Messages.RemoteArchetypeCatalogDialog_error_read,
                                            s.getMessage()));
                                    getButton(IDialogConstants.OK_ID).setEnabled(false);
                                } else if (archetypes.size() == 0) {
                                    setMessage(Messages.RemoteArchetypeCatalogDialog_error_empty,
                                            IStatus.WARNING);
                                } else {
                                    setMessage(NLS.bind(Messages.RemoteArchetypeCatalogDialog_message_found,
                                            archetypes.size()), IStatus.INFO);
                                }
                            }
                        });
                    }
                    return Status.OK_STATUS;
                }
            }.schedule();
        }
    });

    Label filler = new Label(composite, SWT.NONE);
    filler.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    layout.numColumns++;

    super.createButtonsForButtonBar(composite); // cancel button

    return composite;
}