Search in sources :

Example 1 with SelectionAdapter

use of ch.acanda.eclipse.pmd.ui.util.SelectionAdapter in project eclipse-pmd by acanda.

the class AddRuleSetConfigurationWizardPage method createControl.

@Override
public void createControl(final Composite parent) {
    final Composite container = new Composite(parent, SWT.NULL);
    setControl(container);
    container.setLayout(new GridLayout(3, false));
    final Label lblLocation = new Label(container, SWT.NONE);
    lblLocation.setText("Location:");
    location = new Text(container, SWT.BORDER);
    location.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    SWTBotID.set(location, SWTBotID.LOCATION);
    browse = new Button(container, SWT.NONE);
    browse.setText("Browse...");
    SWTBotID.set(browse, SWTBotID.BROWSE);
    browse.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            controller.browse(((Control) e.widget).getShell());
        }
    });
    final Label lblName = new Label(container, SWT.NONE);
    lblName.setText("Name:");
    name = new Text(container, SWT.BORDER);
    name.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    SWTBotID.set(name, SWTBotID.NAME);
    // This button is only here to make this row the same height as the previous row.
    // Without this button the distance between the text of this row and the text of
    // the previous row is much larger than the distance between the text of this row
    // and the table of the next row.
    final Button button = new Button(container, SWT.NONE);
    button.setEnabled(false);
    button.setVisible(false);
    final Label lblRules = new Label(container, SWT.NONE);
    final GridData lblRulesGridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
    lblRulesGridData.verticalIndent = 3;
    lblRules.setLayoutData(lblRulesGridData);
    lblRules.setText("Rules:");
    final Composite tableComposite = new Composite(container, SWT.NONE);
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final TableColumnLayout tableCompositeTableColumnLayout = new TableColumnLayout();
    tableComposite.setLayout(tableCompositeTableColumnLayout);
    tableViewer = new TableViewer(tableComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
    final Table table = tableViewer.getTable();
    table.setLinesVisible(true);
    SWTBotID.set(table, SWTBotID.RULES);
    final TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    final TableColumn tblclmnName = tableViewerColumn.getColumn();
    tableCompositeTableColumnLayout.setColumnData(tblclmnName, new ColumnWeightData(1, 200, false));
    tblclmnName.setText("Name");
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    initDataBindings();
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(ch.acanda.eclipse.pmd.ui.util.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 2 with SelectionAdapter

use of ch.acanda.eclipse.pmd.ui.util.SelectionAdapter in project eclipse-pmd by acanda.

the class PMDPropertyPage method createContents.

@Override
protected Control createContents(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NULL);
    final GridLayout layout = new GridLayout(3, false);
    layout.marginWidth = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    enablePMDCheckbox = new Button(composite, SWT.CHECK);
    enablePMDCheckbox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    enablePMDCheckbox.setText("Enable PMD for this project");
    SWTBotID.set(enablePMDCheckbox, SWTBotID.ENABLE_PMD);
    final Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    final Label lblSelectRulesSets = new Label(composite, SWT.NONE);
    lblSelectRulesSets.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    lblSelectRulesSets.setText("Select rules sets");
    final RuleSetConfigurationTable ruleSetConfigurationTable = new RuleSetConfigurationTable(composite, controller.getModel());
    ruleSetConfigurationTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 2));
    addRuleSet = new Button(composite, SWT.NONE);
    SWTBotID.set(addRuleSet, SWTBotID.ADD);
    setButtonLayoutData(addRuleSet);
    addRuleSet.setText("Add...");
    addRuleSet.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            controller.addRuleSetConfiguration(((Control) e.widget).getShell());
        }
    });
    initDataBindings();
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(ch.acanda.eclipse.pmd.ui.util.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

SelectionAdapter (ch.acanda.eclipse.pmd.ui.util.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Control (org.eclipse.swt.widgets.Control)2 Label (org.eclipse.swt.widgets.Label)2 TableColumnLayout (org.eclipse.jface.layout.TableColumnLayout)1 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 Text (org.eclipse.swt.widgets.Text)1