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;
}
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;
}
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();
}
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;
}
Aggregations