Example usage for org.eclipse.jface.viewers ComboViewer ComboViewer

List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ComboViewer ComboViewer.

Prototype

public ComboViewer(CCombo list) 

Source Link

Document

Creates a combo viewer on the given CCombo control.

Usage

From source file:name.schedenig.eclipse.grepconsole.view.items.links.LinkDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
 *///  w  w  w .jav  a2  s .c  om
@Override
protected Control createDialogArea(Composite parent) {
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, Activator.PLUGIN_ID + ".edit_link"); //$NON-NLS-1$

    Composite composite = new Composite(parent, SWT.NONE);
    new GridLayoutBuilder(composite, 2, false).apply();
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    labelType = new Label(composite, SWT.NONE);
    labelType.setText(Messages.LinkDialog_type);
    labelType.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    comboType = new Combo(composite, SWT.READ_ONLY);
    comboType.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    viewerType = new ComboViewer(comboType);
    viewerType.setContentProvider(new ArrayContentProvider());
    viewerType.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            String name = TYPE_NAMES.get(element);

            return name == null ? String.valueOf(element) : name;
        }
    });

    viewerType.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            @SuppressWarnings("unchecked")
            Class<? extends IGrepLink> type = (Class<? extends IGrepLink>) ((IStructuredSelection) event
                    .getSelection()).getFirstElement();
            typeChanged(type);
        }
    });

    viewerType.setInput(new Class[] { NoLink.class, FileLink.class, JavaLink.class, UrlLink.class,
            CommandLink.class, ScriptLink.class });

    panelLinkSpecific = new Composite(composite, SWT.NONE);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
    gridData.verticalIndent = 10;
    panelLinkSpecific.setLayoutData(gridData);
    StackLayout linkSpecificLayout = new StackLayout();
    linkSpecificLayout.marginWidth = linkSpecificLayout.marginHeight = 0;
    panelLinkSpecific.setLayout(linkSpecificLayout);

    panelFile = new FileLinkPanel(panelLinkSpecific, withCaptureGroup);
    panels.put(FileLink.class, panelFile);

    panelJava = new JavaLinkPanel(panelLinkSpecific, withCaptureGroup);
    panels.put(JavaLink.class, panelJava);

    panelUrl = new UrlLinkPanel(panelLinkSpecific, withCaptureGroup);
    panels.put(UrlLink.class, panelUrl);

    panelCommand = new CommandLinkPanel(panelLinkSpecific, withCaptureGroup);
    panels.put(CommandLink.class, panelCommand);

    panelScript = new ScriptLinkPanel(panelLinkSpecific, withCaptureGroup);
    panels.put(ScriptLink.class, panelScript);

    refreshContent(true);

    return composite;
}

From source file:net.atos.jdt.ast.refactor.engine.internal.extpt.ui.RulesExtensionPointPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {

    // Builds graphical Structure
    Composite background = new Composite(parent, SWT.NONE);
    background.setLayout(new FormLayout());
    // background.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_BLUE));

    Label message = new Label(background, SWT.WRAP);
    message.setText(RulesPreferencePagesMessages.PREFERENCE_LABEL.value());
    new FormDataBuilder().horizontal().top().height(30).apply(message);

    Label comboLabel = new Label(background, SWT.NONE);
    comboLabel.setText(RulesPreferencePagesMessages.REPOSITORY_LABEL.value());
    new FormDataBuilder().left().top(message).width(100).apply(comboLabel);

    Combo combo = new Combo(background, SWT.READ_ONLY);
    new FormDataBuilder().left(comboLabel).top(message).right().apply(combo);

    ComboViewer comboViewer = new ComboViewer(combo);
    comboViewer.setContentProvider(new RulesRepositoriesContentProvider());
    comboViewer.setLabelProvider(new RulesRepositoriesLabelProvider());

    Group group = new Group(background, SWT.NONE);
    group.setLayout(new FormLayout());
    new FormDataBuilder().horizontal().top(combo).bottom().apply(group);
    group.setText(RulesPreferencePagesMessages.GROUP_LABEL.value());

    Tree tree = new Tree(group, SWT.CHECK | SWT.BORDER);
    new FormDataBuilder().fill().apply(tree);
    CheckboxTreeViewer treeViewer = new CheckboxTreeViewer(tree);
    treeViewer.setLabelProvider(new RulesLabelProvider());
    treeViewer.setContentProvider(new RulesContentProvider());
    treeViewer.setCheckStateProvider(new RulesCheckProvider(states));
    treeViewer.addCheckStateListener(new RulesCheckListener(states));

    // Add inputs
    comboViewer.addSelectionChangedListener(new RulesListRefreshmentListener(treeViewer));
    comboViewer.setInput(ASTRulesExtensionPoint.getInstance());

    return background;
}

From source file:net.atos.jdt.ast.validation.engine.internal.extpt.ui.RulesExtensionPointPreferencePage.java

License:Open Source License

@Override
protected Control createContents(final Composite parent) {

    // Builds graphical Structure
    final Composite background = new Composite(parent, SWT.NONE);
    background.setLayout(new FormLayout());

    final Label message = new Label(background, SWT.WRAP);
    message.setText(RulesPreferencePagesMessages.PREFERENCE_LABEL.value());
    new FormDataBuilder().horizontal().top().height(30).apply(message);

    final Button participantButton = new Button(background, SWT.CHECK);
    participantButton.setText(RulesPreferencePagesMessages.ENABLE_CUP.value());
    participantButton.setToolTipText(RulesPreferencePagesMessages.ENABLE_CUP_TOOLTIP.value());
    participantButton.setSelection(ASTRulesPreferences.isValidationParticipantEnabled());
    participantButton.addSelectionListener(new SelectionAdapter() {
        @Override//from  w ww. ja  v a  2s.co  m
        public void widgetSelected(final SelectionEvent e) {
            RulesExtensionPointPreferencePage.this.participantButtonEnabled = ((Button) e.widget)
                    .getSelection();
        }
    });
    new FormDataBuilder().left().right().top(message, 15).apply(participantButton);
    //
    final Button rulesSingletonButton = new Button(background, SWT.CHECK);
    rulesSingletonButton.setText(RulesPreferencePagesMessages.ENABLE_SINGLETONS.value());
    rulesSingletonButton.setToolTipText(RulesPreferencePagesMessages.ENABLE_SINGLETONS_TOOLTIP.value());
    rulesSingletonButton.setSelection(ASTRulesPreferences.areRulesSingletons());
    rulesSingletonButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            RulesExtensionPointPreferencePage.this.rulesAreSingletons = ((Button) e.widget).getSelection();
        }
    });
    //
    new FormDataBuilder().left().right().top(participantButton).apply(rulesSingletonButton);

    final Label comboLabel = new Label(background, SWT.NONE);
    comboLabel.setText(RulesPreferencePagesMessages.REPOSITORY_LABEL.value());
    new FormDataBuilder().left().top(rulesSingletonButton, 17).width(100).apply(comboLabel);

    final Combo combo = new Combo(background, SWT.READ_ONLY);
    new FormDataBuilder().left(comboLabel).top(rulesSingletonButton, 15).right().apply(combo);

    final ComboViewer comboViewer = new ComboViewer(combo);
    comboViewer.setContentProvider(new RulesRepositoriesContentProvider());
    comboViewer.setLabelProvider(new RulesRepositoriesLabelProvider());

    final Link link = new Link(background, SWT.NONE);
    link.setText(RulesPreferencePagesMessages.LINK_TO_QUICKSTART.value());
    link.addSelectionListener(new OpenLinkActionSelectionAdapter());
    new FormDataBuilder().bottom().left().right().apply(link);

    final Group group = new Group(background, SWT.NONE);
    group.setLayout(new FormLayout());
    new FormDataBuilder().horizontal().top(combo).bottom(link).apply(group);
    group.setText(RulesPreferencePagesMessages.GROUP_LABEL.value());

    final Tree tree = new Tree(group, SWT.CHECK | SWT.BORDER);
    new FormDataBuilder().fill().apply(tree);
    final CheckboxTreeViewer treeViewer = new CheckboxTreeViewer(tree);
    treeViewer.setLabelProvider(new RulesLabelProvider());
    treeViewer.setContentProvider(new RulesContentProvider());
    treeViewer.setCheckStateProvider(new RulesCheckProvider(this.states));
    treeViewer.addCheckStateListener(new RulesCheckListener(this.states));

    // Add inputs
    comboViewer.addSelectionChangedListener(new RulesListRefreshmentListener(treeViewer));
    comboViewer.setInput(ASTRulesExtensionPoint.getInstance());

    return background;
}

From source file:net.enilink.komma.edit.ui.wizards.RefactorMoveWizard.java

License:Open Source License

protected void createPages() {
    selectModelPage = new WizardPage("Select Target Model") {
        @Override//from w  w  w .  j  av  a 2s.  c  om
        public void createControl(Composite parent) {

            Composite composite = new Composite(parent, SWT.NONE);
            composite.setLayout(new GridLayout());

            Label label = new Label(composite, SWT.NONE);
            label.setText("Select target model:");

            final Combo combo = new Combo(composite, SWT.DROP_DOWN);
            final ComboViewer cViewer = new ComboViewer(combo);
            cViewer.addSelectionChangedListener(new ISelectionChangedListener() {
                @Override
                public void selectionChanged(SelectionChangedEvent event) {
                    targetModel = (IModel) cViewer.getElementAt(combo.getSelectionIndex());
                    setPageComplete(true);
                }
            });

            // get potential target models from list of active editors
            IEditorReference[] openEditors = workbench.getActiveWorkbenchWindow().getActivePage()
                    .getEditorReferences();
            for (IEditorReference ref : openEditors) {
                IEditorPart editor = ref.getEditor(true);
                if (editor != null
                        && editor != workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor()) {
                    IModel model = (IModel) editor.getAdapter(IModel.class);
                    if (model != null) {
                        cViewer.add(model);
                    }
                }
            }

            final Button keepNamespaceButton = new Button(composite, SWT.CHECK);
            keepNamespaceButton.setSelection(keepNamespace);
            keepNamespaceButton.setText("Keep namespaces");
            keepNamespaceButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    keepNamespace = keepNamespaceButton.getSelection();
                }
            });

            setDescription("Select the target model from the list of open editors.");
            setControl(composite);
            setPageComplete(false);
        }
    };

    showPreviewPage = new RefactorPreviewPage("Preview") {
        @Override
        public Collection<Change> collectChanges() {
            changes = new RefactoringProcessor(domain).createMoveChanges(currentSelection.toList(), targetModel,
                    keepNamespace);
            return changes;
        }
    };
}

From source file:net.enilink.komma.owl.editor.rcp.wizards.WizardConfigureOntologyPage.java

License:Open Source License

/**
 * The "advanced" section is not used for the link options but rather for
 * additional settings for the ontology creation (URI and format).
 *//*  w  ww  . j a va2  s . c om*/
@Override
public void createAdvancedControls(Composite parent) {
    Composite formatGroup = new Composite(parent, SWT.NONE);
    GridLayout formatlayout = new GridLayout(2, false);
    formatlayout.marginWidth = 0;
    formatGroup.setLayout(formatlayout);
    formatGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    formatGroup.setFont(parent.getFont());

    Label formatLabel = new Label(formatGroup, SWT.NONE);
    formatLabel.setText("File format:");

    formatField = new Combo(formatGroup, SWT.BORDER);
    formatViewer = new ComboViewer(formatField);
    formatViewer.setContentProvider(new IStructuredContentProvider() {
        @Override
        public void dispose() {
        }

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

        @SuppressWarnings("unchecked")
        @Override
        public Object[] getElements(Object input) {
            return ((List<IContentType>) input).toArray(new IContentType[0]);
        }
    });
    formatViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((IContentType) element).getName();
        }
    });

    // set the default extension here, as this is called from super()
    setFileExtension("rdf");

    // get the list of writeable content-types from the plugin registry
    QualifiedName mimeType = new QualifiedName(ModelPlugin.PLUGIN_ID, "mimeType");
    QualifiedName hasWriter = new QualifiedName(ModelPlugin.PLUGIN_ID, "hasWriter");
    List<IContentType> supportedTypes = new ArrayList<IContentType>();
    IContentType defaultSelection = null;
    for (IContentType contentType : Platform.getContentTypeManager().getAllContentTypes()) {
        IContentDescription desc = contentType.getDefaultDescription();
        // use those registered from the model plugin w/ mimeType property
        if (desc.getProperty(mimeType) != null
                && "true".equalsIgnoreCase(String.valueOf(desc.getProperty(hasWriter)))) {
            supportedTypes.add(contentType);
            if (contentType.isAssociatedWith("dummy." + getFileExtension())) {
                // preselect entry for the default extension (see above)
                defaultSelection = contentType;
            }
        }
    }
    formatViewer.setInput(supportedTypes);
    if (defaultSelection != null) {
        formatViewer.setSelection(new StructuredSelection(defaultSelection));
    }

    // handle changes to the format (also changes the extension)
    formatViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IContentType contentType = (IContentType) formatViewer
                    .getElementAt(formatField.getSelectionIndex());
            setFileExtension(contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)[0]);
        }
    });

    Composite uriGroup = new Composite(parent, SWT.NONE);
    GridLayout uriLayout = new GridLayout();
    uriLayout.marginWidth = 0;
    uriGroup.setLayout(uriLayout);
    uriGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    uriGroup.setFont(parent.getFont());

    Label uriLabel = new Label(uriGroup, SWT.NONE);
    uriLabel.setText("Enter the URI you wish to use:");

    uriField = new Text(uriGroup, SWT.BORDER);
    uriField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    // checkbox to use default URI (platform:/resource/$path)
    uriUseDefault = new Button(uriGroup, SWT.CHECK);
    uriUseDefault.setSelection(true);
    uriUseDefault.setText("Use a default URI");
    uriUseDefault.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            // enable/disable(+reset) URI text input
            if (uriUseDefault.getSelection()) {
                uriField.setEnabled(false);
                updateURI();
            } else {
                uriField.setEnabled(true);
            }

        }
    });
    uriUseDefault.notifyListeners(SWT.Selection, new Event());
}

From source file:net.refractions.udig.tutorials.featureeditor.CountryPanelFormCellEditor.java

License:Open Source License

public void createControl(Composite parent, FormToolkit toolkit) {

    this.toolkit = toolkit;

    form = toolkit.createScrolledForm(parent);
    form.getForm().addMessageHyperlinkListener(new HyperlinkAdapter() {
        @Override//from w ww  .  j ava2 s.c o  m
        public void linkActivated(HyperlinkEvent e) {
            final IMessage[] errors = (IMessage[]) e.data;
            if (errors.length > 0) {
                final IMessage topError = errors[0];
                topError.getControl().setFocus();
            }
        }
    });
    form.getMessageManager().setMessagePrefixProvider(new IMessagePrefixProvider() {
        @Override
        public String getPrefix(Control control) {
            return control.getData().toString() + " - ";
        }
    });
    form.setText("Country Form");
    final ColumnLayout layout = new ColumnLayout();
    layout.maxNumColumns = MAX_COLS;
    layout.minNumColumns = MIN_COLS;
    form.getBody().setLayout(layout);
    toolkit.decorateFormHeading(form.getForm());

    final Section section = toolkit.createSection(form.getBody(), SECTION_STYLE);
    section.setText("Country Details");
    section.setDescription("Update country details below.");
    section.addExpansionListener(new ExpansionAdapter() {
        public void expansionStateChanged(ExpansionEvent e) {
            // Nothing
        }
    });
    final Composite client = toolkit.createComposite(section, SWT.NONE);
    GridLayout sectionLayout = new GridLayout();
    sectionLayout.numColumns = 4;
    client.setLayout(sectionLayout);
    section.setClient(client);

    // SWT Widgets
    Label label = toolkit.createLabel(client, NAME_FORMA_LBL, LABEL_STYLE);
    FormTextCellEditor nameFormalEditor = new FormTextCellEditor(client, form.getMessageManager());
    nameFormal = (Text) nameFormalEditor.getControl();
    nameFormal.setData(NAME_FORMA_LBL);
    nameFormal.addKeyListener(this);
    GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 3;
    nameFormal.setLayoutData(layoutData);

    label = toolkit.createLabel(client, NAME_SORT_LBL, LABEL_STYLE);
    FormTextCellEditor nameSortEditor = new FormTextCellEditor(client, form.getMessageManager());
    nameSort = (Text) nameSortEditor.getControl();
    nameSort.setData(NAME_SORT_LBL);
    nameSort.addKeyListener(this);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 3;
    nameSort.setLayoutData(layoutData);

    label = toolkit.createLabel(client, POP_EST_LBL, LABEL_STYLE);
    FormTextCellEditor populationEditor = new FormTextCellEditor(client, form.getMessageManager());
    population = (Text) populationEditor.getControl();
    population.setData(POP_EST_LBL);
    population.addKeyListener(this);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 3;
    population.setLayoutData(layoutData);

    label = toolkit.createLabel(client, TYPE_LBL, LABEL_STYLE);
    FormComboBoxCellEditor typeEditor = new FormComboBoxCellEditor(client, TYPE_OPTS, form.getMessageManager());
    type = (CCombo) typeEditor.getControl();
    type.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            setEnabled(true);
        }
    });
    layoutData = new GridData();
    layoutData.horizontalSpan = 3;
    type.setLayoutData(layoutData);

    // JFace Viewer
    label = toolkit.createLabel(client, COLOR_MAP_LBL, LABEL_STYLE);
    FormComboBoxCellEditor colorEditor = new FormComboBoxCellEditor(client, new String[] {},
            form.getMessageManager());
    CCombo colorCombo = (CCombo) colorEditor.getControl();
    colorMap = new ComboViewer(colorCombo);
    colorMap.addSelectionChangedListener(this);
    layoutData = new GridData();
    layoutData.horizontalSpan = 3;
    colorMap.getControl().setLayoutData(layoutData);

    // hook up to data
    colorMap.setContentProvider(new IStructuredContentProvider() {
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Object[]) {
                return (Object[]) inputElement;
            }
            return null;
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // For dynamic content we would register listeners here
        }

        public void dispose() {
            // Nothing
        }
    });
    colorMap.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            return " " + element + " color";
        }
    });
    colorMap.setInput(COLOR_MAP_OPTS);

    // Other sample section - to try out ColumnLayout
    final Section sectionOther = toolkit.createSection(form.getBody(), SECTION_STYLE);
    sectionOther.setText("Others");
    sectionOther.setDescription(
            "Sample section to demo ColumnLayout, make the view width smaller to force it to relayout.");
    sectionOther.addExpansionListener(new ExpansionAdapter() {
        public void expansionStateChanged(ExpansionEvent e) {
            // Nothing
        }
    });
    final Composite clientOther = toolkit.createComposite(sectionOther, SWT.NONE);
    sectionLayout = new GridLayout();
    sectionLayout.numColumns = 4;
    clientOther.setLayout(sectionLayout);
    sectionOther.setClient(clientOther);

    Label remarksLbl = toolkit.createLabel(clientOther, REMARKS_LBL, LABEL_STYLE);
    FormTextCellEditor remarksEditor = new FormTextCellEditor(clientOther, form.getMessageManager());
    Text remarks = (Text) remarksEditor.getControl();
    remarks.setData(REMARKS_LBL);
    remarks.addKeyListener(this);
    layoutData = new GridData(GridData.FILL_HORIZONTAL);
    layoutData.horizontalSpan = 3;
    remarks.setLayoutData(layoutData);

    // Buttons
    apply = new Action("Apply") {
        @Override
        public void run() {
            applyChanges();
        }
    };
    apply.setEnabled(false);
    form.getToolBarManager().add(apply);

    reset = new Action("Reset") {
        @Override
        public void run() {
            resetChanges();
        }
    };
    reset.setEnabled(false);
    form.getToolBarManager().add(reset);

    form.getToolBarManager().update(true);

}

From source file:net.sf.eclipsecs.ui.config.CheckConfigurationPropertiesDialog.java

License:Open Source License

/**
 * Creates the dialogs main contents.//from w  w  w .ja va 2  s  .  co  m
 * 
 * @param parent the parent composite
 */
protected Control createDialogArea(Composite parent) {

    // set the logo
    this.setTitleImage(CheckstyleUIPluginImages.getImage(CheckstyleUIPluginImages.PLUGIN_LOGO));

    Composite composite = (Composite) super.createDialogArea(parent);

    Composite contents = new Composite(composite, SWT.NULL);
    contents.setLayout(new GridLayout(2, false));
    GridData fd = new GridData(GridData.FILL_BOTH);
    contents.setLayoutData(fd);

    Label lblConfigType = new Label(contents, SWT.NULL);
    lblConfigType.setText(Messages.CheckConfigurationPropertiesDialog_lblConfigType);
    fd = new GridData();

    // this is a weird hack to find the longest label
    // this is done to have a nice ordered appearance of the this label
    // and the labels below
    // this is very difficult to do, because they belong to different
    // layouts
    GC gc = new GC(lblConfigType);
    int nameSize = gc.textExtent(Messages.CheckConfigurationPropertiesDialog_lblName).x;
    int locationsSize = gc.textExtent(Messages.CheckConfigurationPropertiesDialog_lblLocation).x;
    int max = Math.max(nameSize, locationsSize);
    gc.dispose();

    fd.widthHint = max;
    lblConfigType.setLayoutData(fd);

    mConfigType = new ComboViewer(contents);
    fd = new GridData();
    mConfigType.getCombo().setLayoutData(fd);
    mConfigType.setContentProvider(new ArrayContentProvider());
    mConfigType.setLabelProvider(new LabelProvider() {
        /**
         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
         */
        public String getText(Object element) {
            return ((IConfigurationType) element).getName();
        }

        /**
         * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
         */
        public Image getImage(Object element) {
            return ConfigurationTypesUI.getConfigurationTypeImage((IConfigurationType) element);
        }
    });
    mConfigType.addSelectionChangedListener(new ISelectionChangedListener() {
        /**
         * @see ISelectionChangedListener#selectionChanged(
         *      org.eclipse.jface.viewers.SelectionChangedEvent)
         */
        public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSelection() instanceof IStructuredSelection) {
                IConfigurationType type = (IConfigurationType) ((IStructuredSelection) event.getSelection())
                        .getFirstElement();

                if (mConfigType.getCombo().isEnabled()) {

                    String oldName = mCheckConfig.getName();
                    String oldDescr = mCheckConfig.getDescription();

                    mCheckConfig = mWorkingSet.newWorkingCopy(type);
                    try {
                        mCheckConfig.setName(oldName);
                    } catch (CheckstylePluginException e) {
                        // NOOP
                    }
                    mCheckConfig.setDescription(oldDescr);
                }

                createConfigurationEditor(mCheckConfig);
            }
        }
    });

    mEditorPlaceHolder = new Composite(contents, SWT.NULL);
    GridLayout layout = new GridLayout(1, true);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    mEditorPlaceHolder.setLayout(layout);
    fd = new GridData(GridData.FILL_HORIZONTAL);
    fd.horizontalSpan = 2;
    mEditorPlaceHolder.setLayoutData(fd);

    return composite;
}

From source file:net.sf.eclipsecs.ui.config.RuleConfigurationEditDialog.java

License:Open Source License

private Composite createGeneralSection() {
    Composite generalSettings = new Composite(mMainTab, SWT.NULL);
    generalSettings.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout(2, false);
    generalSettings.setLayout(layout);/*from   w  ww  . j  av  a2  s  .  c  o  m*/

    // Build severity
    Label lblSeverity = new Label(generalSettings, SWT.NULL);
    lblSeverity.setText(Messages.RuleConfigurationEditDialog_lblSeverity);
    lblSeverity.setLayoutData(new GridData());

    mSeverityCombo = new ComboViewer(generalSettings);
    mSeverityCombo.setContentProvider(new ArrayContentProvider());
    mSeverityCombo.setLabelProvider(new LabelProvider() {
        /**
         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
         */
        public String getText(Object element) {
            return ((Severity) element).name();
        }
    });
    mSeverityCombo.getControl().setLayoutData(new GridData());

    Group properties = new Group(generalSettings, SWT.NULL);
    properties.setLayout(new GridLayout(3, false));
    properties.setText(Messages.RuleConfigurationEditDialog_lblProperties);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    properties.setLayoutData(gd);

    createConfigPropertyEntries(properties);

    if (mConfigPropertyWidgets == null || mConfigPropertyWidgets.length == 0) {

        properties.dispose();
    }
    return generalSettings;
}

From source file:net.sf.eclipsecs.ui.properties.FileSetEditDialog.java

License:Open Source License

private Control createCommonArea(Composite parent) {

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;/*from w w w  .  java 2  s  .  com*/
    layout.marginWidth = 0;
    composite.setLayout(layout);

    Label nameLabel = new Label(composite, SWT.NULL);
    nameLabel.setText(Messages.FileSetEditDialog_lblName);

    mFileSetNameText = new Text(composite, SWT.SINGLE | SWT.BORDER);
    mFileSetNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label lblConfiguration = new Label(composite, SWT.NULL);
    lblConfiguration.setText(Messages.FileSetEditDialog_lblCheckConfig);

    Composite comboComposite = new Composite(composite, SWT.NONE);
    layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    comboComposite.setLayout(layout);
    comboComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    mComboViewer = new ComboViewer(comboComposite);
    mComboViewer.getCombo().setVisibleItemCount(10);
    mComboViewer.setContentProvider(new CheckConfigurationContentProvider());
    mComboViewer.setLabelProvider(new CheckConfigurationLabelProvider());
    mComboViewer.setSorter(new CheckConfigurationViewerSorter());
    mComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mComboViewer.addSelectionChangedListener(mController);

    mConfigureButton = new Button(comboComposite, SWT.PUSH);
    mConfigureButton.setText(Messages.FileSetEditDialog_btnConfigure);
    mConfigureButton.addSelectionListener(mController);
    mConfigureButton.setLayoutData(new GridData());

    return composite;
}

From source file:net.sf.eclipsecs.ui.properties.SimpleFileSetsEditor.java

License:Open Source License

/**
 * {@inheritDoc}/*from   ww  w .  j a v  a2  s .  c o m*/
 */
public Control createContents(Composite parent) throws CheckstylePluginException {

    mController = new Controller();

    // group composite containing the config settings
    Group configArea = new Group(parent, SWT.NULL);
    configArea.setText(Messages.SimpleFileSetsEditor_titleSimpleConfig);
    configArea.setLayout(new FormLayout());

    this.mBtnManageConfigs = new Button(configArea, SWT.PUSH);
    this.mBtnManageConfigs.setText(Messages.SimpleFileSetsEditor_btnManageConfigs);
    this.mBtnManageConfigs.addSelectionListener(mController);
    FormData fd = new FormData();
    fd.top = new FormAttachment(0, 3);
    fd.right = new FormAttachment(100, -3);
    this.mBtnManageConfigs.setLayoutData(fd);

    mComboViewer = new ComboViewer(configArea);
    mComboViewer.getCombo().setVisibleItemCount(10);
    mComboViewer.setContentProvider(new CheckConfigurationContentProvider());
    mComboViewer.setLabelProvider(new CheckConfigurationLabelProvider());
    mComboViewer.setSorter(new CheckConfigurationViewerSorter());
    mComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    mComboViewer.addSelectionChangedListener(mController);
    fd = new FormData();
    fd.left = new FormAttachment(0, 3);
    fd.top = new FormAttachment(0, 3);
    fd.right = new FormAttachment(mBtnManageConfigs, -3, SWT.LEFT);
    // fd.right = new FormAttachment(100, -3);
    mComboViewer.getCombo().setLayoutData(fd);

    // Description
    Label lblConfigDesc = new Label(configArea, SWT.LEFT);
    lblConfigDesc.setText(Messages.SimpleFileSetsEditor_lblDescription);
    fd = new FormData();
    fd.left = new FormAttachment(0, 3);
    fd.top = new FormAttachment(mComboViewer.getCombo(), 3, SWT.BOTTOM);
    fd.right = new FormAttachment(100, -3);
    lblConfigDesc.setLayoutData(fd);

    this.mTxtConfigDescription = new Text(configArea,
            SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.VERTICAL);
    fd = new FormData();
    fd.left = new FormAttachment(0, 3);
    fd.top = new FormAttachment(lblConfigDesc, 0, SWT.BOTTOM);
    fd.right = new FormAttachment(100, -3);
    fd.bottom = new FormAttachment(100, -3);
    this.mTxtConfigDescription.setLayoutData(fd);

    // init the check configuration combo
    mComboViewer.setInput(mPropertyPage.getProjectConfigurationWorkingCopy());
    if (mDefaultFileSet.getCheckConfig() != null) {
        mComboViewer.setSelection(new StructuredSelection(mDefaultFileSet.getCheckConfig()));
    }

    return configArea;
}