Search in sources :

Example 1 with GlobalCheckConfigurationWorkingSet

use of net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet in project eclipse-cs by checkstyle.

the class CheckConfigurationWorkingSetEditor method createConfigTable.

/**
 * Creates the table viewer to show the existing check configurations.
 *
 * @param parent
 *          the parent composite
 * @return the table control
 */
private Control createConfigTable(Composite parent) {
    Table table = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    TableColumn column1 = new TableColumn(table, SWT.NULL);
    column1.setText(Messages.CheckstylePreferencePage_colCheckConfig);
    tableLayout.addColumnData(new ColumnWeightData(40));
    TableColumn column2 = new TableColumn(table, SWT.NULL);
    column2.setText(Messages.CheckstylePreferencePage_colLocation);
    tableLayout.addColumnData(new ColumnWeightData(30));
    TableColumn column3 = new TableColumn(table, SWT.NULL);
    column3.setText(Messages.CheckstylePreferencePage_colType);
    tableLayout.addColumnData(new ColumnWeightData(30));
    if (mWorkingSet instanceof GlobalCheckConfigurationWorkingSet) {
        TableColumn column4 = new TableColumn(table, SWT.NULL);
        column4.setText(Messages.CheckstylePreferencePage_colDefault);
        tableLayout.addColumnData(new ColumnWeightData(12));
    }
    mViewer = new EnhancedTableViewer(table);
    ConfigurationLabelProvider multiProvider = new ConfigurationLabelProvider();
    mViewer.setLabelProvider(multiProvider);
    mViewer.setTableComparableProvider(multiProvider);
    mViewer.setTableSettingsProvider(multiProvider);
    mViewer.installEnhancements();
    mViewer.setContentProvider(new ArrayContentProvider());
    mViewer.setInput(mWorkingSet.getWorkingCopies());
    mViewer.addDoubleClickListener(mController);
    mViewer.addSelectionChangedListener(mController);
    return table;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) GlobalCheckConfigurationWorkingSet(net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet) Table(org.eclipse.swt.widgets.Table) EnhancedTableViewer(net.sf.eclipsecs.ui.util.table.EnhancedTableViewer) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) TableLayout(org.eclipse.jface.viewers.TableLayout) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 2 with GlobalCheckConfigurationWorkingSet

use of net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet in project eclipse-cs by checkstyle.

the class CheckConfigurationWorkingSetEditor method createButtonBar.

/**
 * Creates the button bar.
 *
 * @param parent
 *          the parent composite
 * @return the button bar composite
 */
private Control createButtonBar(Composite parent) {
    Composite rightButtons = new Composite(parent, SWT.NULL);
    rightButtons.setLayout(new FormLayout());
    mAddButton = new Button(rightButtons, SWT.PUSH);
    mAddButton.setText(Messages.CheckstylePreferencePage_btnNew);
    mAddButton.addSelectionListener(mController);
    FormData fd = new FormData();
    fd.left = new FormAttachment(0);
    fd.top = new FormAttachment(0);
    fd.right = new FormAttachment(100);
    mAddButton.setLayoutData(fd);
    mEditButton = new Button(rightButtons, SWT.PUSH);
    mEditButton.setText(Messages.CheckstylePreferencePage_btnProperties);
    mEditButton.addSelectionListener(mController);
    fd = new FormData();
    fd.left = new FormAttachment(0);
    fd.top = new FormAttachment(mAddButton, 3, SWT.BOTTOM);
    fd.right = new FormAttachment(100);
    mEditButton.setLayoutData(fd);
    mConfigureButton = new Button(rightButtons, SWT.PUSH);
    mConfigureButton.setText(Messages.CheckstylePreferencePage_btnConfigure);
    mConfigureButton.addSelectionListener(mController);
    fd = new FormData();
    fd.left = new FormAttachment(0);
    fd.top = new FormAttachment(mEditButton, 3, SWT.BOTTOM);
    fd.right = new FormAttachment(100);
    mConfigureButton.setLayoutData(fd);
    mCopyButton = new Button(rightButtons, SWT.PUSH);
    mCopyButton.setText(Messages.CheckstylePreferencePage_btnCopy);
    mCopyButton.addSelectionListener(mController);
    fd = new FormData();
    fd.left = new FormAttachment(0);
    fd.top = new FormAttachment(mConfigureButton, 3, SWT.BOTTOM);
    fd.right = new FormAttachment(100);
    mCopyButton.setLayoutData(fd);
    mRemoveButton = new Button(rightButtons, SWT.PUSH);
    mRemoveButton.setText(Messages.CheckstylePreferencePage_btnRemove);
    mRemoveButton.addSelectionListener(mController);
    fd = new FormData();
    fd.left = new FormAttachment(0);
    fd.top = new FormAttachment(mCopyButton, 3, SWT.BOTTOM);
    fd.right = new FormAttachment(100);
    mRemoveButton.setLayoutData(fd);
    mDefaultButton = new Button(rightButtons, SWT.PUSH);
    mDefaultButton.setText(Messages.CheckstylePreferencePage_btnDefault);
    mDefaultButton.addSelectionListener(mController);
    mDefaultButton.setToolTipText(Messages.CheckstylePreferencePage_txtDefault);
    if (mWorkingSet instanceof GlobalCheckConfigurationWorkingSet) {
        fd = new FormData();
        fd.left = new FormAttachment(0);
        fd.top = new FormAttachment(mRemoveButton, 3, SWT.BOTTOM);
        fd.right = new FormAttachment(100);
        mDefaultButton.setLayoutData(fd);
    }
    mExportButton = new Button(rightButtons, SWT.PUSH);
    mExportButton.setText(Messages.CheckstylePreferencePage_btnExport);
    mExportButton.addSelectionListener(mController);
    fd = new FormData();
    fd.left = new FormAttachment(0);
    fd.right = new FormAttachment(100);
    fd.bottom = new FormAttachment(100);
    mExportButton.setLayoutData(fd);
    return rightButtons;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) GlobalCheckConfigurationWorkingSet(net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 3 with GlobalCheckConfigurationWorkingSet

use of net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet in project eclipse-cs by checkstyle.

the class CheckConfigurationWorkingSetEditor method setDefaultCheckConfig.

private void setDefaultCheckConfig() {
    IStructuredSelection selection = (IStructuredSelection) mViewer.getSelection();
    CheckConfigurationWorkingCopy checkConfig = (CheckConfigurationWorkingCopy) selection.getFirstElement();
    if (checkConfig == null) {
        // 
        return;
    }
    if (mWorkingSet instanceof GlobalCheckConfigurationWorkingSet) {
        ((GlobalCheckConfigurationWorkingSet) mWorkingSet).setDefaultCheckConfig(checkConfig);
    }
    mViewer.refresh();
}
Also used : GlobalCheckConfigurationWorkingSet(net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet) CheckConfigurationWorkingCopy(net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 4 with GlobalCheckConfigurationWorkingSet

use of net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet in project eclipse-cs by checkstyle.

the class ProjectConfigurationEditor method getEditedWorkingCopy.

/**
 * {@inheritDoc}
 */
@Override
public CheckConfigurationWorkingCopy getEditedWorkingCopy() throws CheckstylePluginException {
    mWorkingCopy.setName(mConfigName.getText());
    mWorkingCopy.setDescription(mDescription.getText());
    mWorkingCopy.getAdditionalData().put(ExternalFileConfigurationType.KEY_PROTECT_CONFIG, // $NON-NLS-1$
    "" + mChkProtectConfig.getSelection());
    try {
        mWorkingCopy.setLocation(mLocation.getText());
    } catch (CheckstylePluginException e) {
        String location = mLocation.getText();
        if (Strings.emptyToNull(location) == null) {
            throw e;
        }
        ICheckConfigurationWorkingSet ws = mCheckConfigDialog.getCheckConfigurationWorkingSet();
        IPath tmp = new Path(location);
        boolean isFirstPartProject = ResourcesPlugin.getWorkspace().getRoot().getProject(tmp.segment(0)).exists();
        if (ws instanceof LocalCheckConfigurationWorkingSet && !isFirstPartProject) {
            location = ((LocalCheckConfigurationWorkingSet) ws).getProject().getFullPath().append(location).toString();
            mLocation.setText(location);
        } else if (ws instanceof GlobalCheckConfigurationWorkingSet && !isFirstPartProject) {
            throw new CheckstylePluginException(NLS.bind(Messages.ProjectConfigurationEditor_msgNoProjectInWorkspace, tmp.segment(0)));
        }
        if (ensureFileExists(location)) {
            mWorkingCopy.setLocation(mLocation.getText());
        } else {
            throw e;
        }
    }
    return mWorkingCopy;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) GlobalCheckConfigurationWorkingSet(net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet) IPath(org.eclipse.core.runtime.IPath) ICheckConfigurationWorkingSet(net.sf.eclipsecs.core.config.ICheckConfigurationWorkingSet) CheckstylePluginException(net.sf.eclipsecs.core.util.CheckstylePluginException) LocalCheckConfigurationWorkingSet(net.sf.eclipsecs.core.projectconfig.LocalCheckConfigurationWorkingSet)

Aggregations

GlobalCheckConfigurationWorkingSet (net.sf.eclipsecs.core.config.GlobalCheckConfigurationWorkingSet)4 CheckConfigurationWorkingCopy (net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy)1 ICheckConfigurationWorkingSet (net.sf.eclipsecs.core.config.ICheckConfigurationWorkingSet)1 LocalCheckConfigurationWorkingSet (net.sf.eclipsecs.core.projectconfig.LocalCheckConfigurationWorkingSet)1 CheckstylePluginException (net.sf.eclipsecs.core.util.CheckstylePluginException)1 EnhancedTableViewer (net.sf.eclipsecs.ui.util.table.EnhancedTableViewer)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TableLayout (org.eclipse.jface.viewers.TableLayout)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1