use of net.sf.eclipsecs.core.config.meta.RuleGroupMetadata in project eclipse-cs by checkstyle.
the class CheckConfigurationConfigureDialog method createTreeViewer.
private Control createTreeViewer(Composite parent) {
Group knownModules = new Group(parent, SWT.NULL);
knownModules.setLayout(new GridLayout());
knownModules.setText(Messages.CheckConfigurationConfigureDialog_lblKnownModules);
mTxtTreeFilter = new Text(knownModules, SWT.SINGLE | SWT.BORDER);
mTxtTreeFilter.setText(mDefaultFilterText);
mTxtTreeFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mTxtTreeFilter.addModifyListener(mController);
mTxtTreeFilter.addKeyListener(mController);
// select all of the default text on focus gain
mTxtTreeFilter.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if (mDefaultFilterText.equals(mTxtTreeFilter.getText())) {
getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
mTxtTreeFilter.selectAll();
}
});
}
}
@Override
public void focusLost(FocusEvent e) {
}
});
mTreeViewer = new TreeViewer(knownModules, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
mTreeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
mTreeViewer.setContentProvider(new MetaDataContentProvider());
mTreeViewer.setLabelProvider(new MetaDataLabelProvider());
mTreeViewer.addSelectionChangedListener(mController);
mTreeViewer.addDoubleClickListener(mController);
mTreeViewer.getTree().addKeyListener(mController);
// filter hidden elements
mTreeViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
boolean passes = true;
if (element instanceof RuleGroupMetadata) {
passes = !((RuleGroupMetadata) element).isHidden();
} else if (element instanceof RuleMetadata) {
passes = !((RuleMetadata) element).isHidden();
}
return passes;
}
});
mAddButton = new Button(knownModules, SWT.PUSH);
mAddButton.setText((Messages.CheckConfigurationConfigureDialog_btnAdd));
GridData gd = new GridData();
gd.horizontalAlignment = GridData.END;
mAddButton.setLayoutData(gd);
mAddButton.addSelectionListener(mController);
return knownModules;
}
use of net.sf.eclipsecs.core.config.meta.RuleGroupMetadata in project eclipse-cs by checkstyle.
the class CheckConfigurationConfigureDialog method initialize.
/**
* Initialize the dialogs controls with the data.
*/
private void initialize() {
mConfigurable = mConfiguration.isConfigurable();
try {
mModules = mConfiguration.getModules();
} catch (CheckstylePluginException e) {
mModules = new ArrayList<>();
CheckstyleUIPlugin.errorDialog(getShell(), e, true);
}
mTableViewer.setInput(mModules);
this.setTitle(NLS.bind(Messages.CheckConfigurationConfigureDialog_titleMessageArea, mConfiguration.getType().getName(), mConfiguration.getName()));
if (mConfigurable) {
this.setMessage(Messages.CheckConfigurationConfigureDialog_msgEditConfig);
} else {
this.setMessage(Messages.CheckConfigurationConfigureDialog_msgReadonlyConfig);
}
// set the logo
this.setTitleImage(CheckstyleUIPluginImages.getImage(CheckstyleUIPluginImages.PLUGIN_LOGO));
mAddButton.setEnabled(mConfigurable);
mRemoveButton.setEnabled(mConfigurable);
mTreeViewer.setInput(MetadataFactory.getRuleGroupMetadata());
List<RuleGroupMetadata> checkGroups = MetadataFactory.getRuleGroupMetadata();
if (!checkGroups.isEmpty()) {
ISelection initialSelection = new StructuredSelection(checkGroups.get(0));
mTreeViewer.setSelection(initialSelection);
}
}
Aggregations