Search in sources :

Example 61 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project osate2 by osate.

the class WSPage method createControl.

@Override
public void createControl(Composite parent) {
    comp = new Composite(parent, SWT.BORDER);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    comp.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    comp.setLayoutData(gd);
    setControl(comp);
    tv = CheckboxTableViewer.newCheckList(comp, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    IStructuredContentProvider contentProvider = createContentProvider();
    tv.setContentProvider(contentProvider);
    tv.setLabelProvider(new WorkingSetLabelProvider());
    tv.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tv.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            selectionChanged();
        }
    });
    setInput(contentProvider.getElements(null));
    Composite fileSelectCom = new Composite(comp, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    fileSelectCom.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    fileSelectCom.setLayoutData(gd);
    IPreferenceStore store = OsateUiPlugin.getDefault().getPreferenceStore();
    String lastUsedFile = store.getString(LAST_USED_WS_FILE);
    usedFiles.add(lastUsedFile);
    dest = new Combo(fileSelectCom, SWT.DROP_DOWN);
    dest.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    updateItems(lastUsedFile);
    dest.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            validateInput();
        }
    });
    Button chooserBtn = new Button(fileSelectCom, SWT.NONE);
    chooserBtn.setText("Browse...");
    chooserBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // ignored
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateItems(getFileFromUser());
            validateInput();
        }
    });
    validateInput();
}
Also used : WorkingSetLabelProvider(org.eclipse.ui.internal.dialogs.WorkingSetLabelProvider) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 62 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project spotbugs by spotbugs.

the class GroupSelectionDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    int columns = 2;
    composite.setLayout(new GridLayout(columns, false));
    GridData layoutData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    layoutData.minimumHeight = 200;
    layoutData.minimumWidth = 250;
    layoutData.heightHint = 200;
    layoutData.widthHint = 250;
    composite.setLayoutData(layoutData);
    checkList = CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER | SWT.RESIZE | SWT.V_SCROLL | SWT.H_SCROLL);
    Table table = checkList.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(false);
    table.setLayoutData(new GridData(GridData.FILL_BOTH));
    TableColumn nameColumn = new TableColumn(table, SWT.NONE);
    nameColumn.setText("Group Visibility / Sort Order");
    nameColumn.setResizable(true);
    nameColumn.setWidth(170);
    checkList.setContentProvider(new ArrayContentProvider());
    // ITableLabelProvider labelProvider= new SeparateTableLabelProvider();
    // checkList.setLabelProvider(labelProvider);
    checkList.setInput(allowedGroups);
    checkList.setCheckedElements(preSelectedGroups.toArray());
    checkList.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            boolean checked = event.getChecked();
            GroupType element = (GroupType) event.getElement();
            selectionMap.put(element, Boolean.valueOf(checked));
        }
    });
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            handleTableSelection();
        }
    });
    createButtonList(composite);
    return composite;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 63 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project jbosstools-jst by jbosstools.

the class EditPreprocessingList method createControl.

public Control createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    File root = projectTemplate.getLocation();
    ArrayList input = new ArrayList();
    input.add(root);
    selectionGroup = new CustomCheckboxTreeAndListGroup(composite, input, new ResourceContentProvider(ResourceContentProvider.FOLDER), new ResourceLabelProvider(), new ResourceContentProvider(ResourceContentProvider.FILE), new ResourceLabelProvider(), SWT.NONE, SIZING_SELECTION_WIDGET_WIDTH, SIZING_SELECTION_WIDGET_HEIGHT);
    composite.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            TableColumn[] columns = selectionGroup.getListTable().getColumns();
            for (int i = 0; i < columns.length; i++) {
                columns[i].pack();
            }
        }
    });
    selectionGroup.setTreeChecked(root, false);
    Iterator excluded = getIncludedResources().iterator();
    while (excluded.hasNext()) {
        File o = (File) excluded.next();
        if (o.isDirectory()) {
            selectionGroup.setTreeChecked(o, true);
        } else if (o.isFile()) {
            selectionGroup.initialCheckListItem((File) o);
        }
    }
    selectionGroup.setExpansions();
    selectionGroup.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            validate();
        }
    });
    return composite;
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) File(java.io.File)

Example 64 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project jbosstools-base by jbosstools.

the class RuntimePreferencePage method createDetectorViewer.

private TableViewer createDetectorViewer(Composite parent) {
    final CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE);
    Table table = tableViewer.getTable();
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 150;
    table.setLayoutData(gd);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    String[] columnNames = new String[] { Messages.RuntimePreferencePage_Type, Messages.RuntimePreferencePage_Link };
    for (int i = 0; i < columnNames.length; i++) {
        TableColumn tc = new TableColumn(table, SWT.LEFT);
        tc.setText(columnNames[i]);
    }
    ColumnLayoutData[] layouts = { new ColumnWeightData(300, 300), new ColumnWeightData(100, 50) };
    TableLayout layout = new TableLayout();
    for (int i = 0; i < layouts.length; i++) {
        layout.addColumnData(layouts[i]);
    }
    table.setLayout(layout);
    tableViewer.setLabelProvider(new RuntimeDetectorLabelProvider());
    tableViewer.setContentProvider(new RuntimeDetectorContentProvider(runtimeDetectors));
    tableViewer.setInput(runtimeDetectors);
    for (IRuntimeDetector detector : runtimeDetectors) {
        tableViewer.setChecked(detector, detector.isEnabled());
    }
    tableViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            IRuntimeDetector detector = (IRuntimeDetector) event.getElement();
            if (detector.isValid()) {
                detector.setEnabled(!detector.isEnabled());
            } else {
                MessageDialog.openWarning(getShell(), Messages.RuntimePreferencePage_Information, NLS.bind(Messages.RuntimePreferencePage_Detector_is_invalid, detector.getName()));
                tableViewer.setChecked(detector, false);
            }
        }
    });
    for (int i = 0; i < runtimeDetectors.size(); i++) {
        TableItem item = table.getItem(i);
        Object data = item.getData();
        if (data instanceof IRuntimeDetector) {
            IRuntimeDetector detector = (IRuntimeDetector) data;
            final String preferenceId = detector.getPreferenceId();
            final String prefName = detector.getName();
            if (preferenceId != null && preferenceId.trim().length() > 0) {
                Link link = new Link(table, SWT.NONE);
                link.setText(Messages.RuntimePreferencePage_A_Link_a);
                link.setEnabled(detector.isValid());
                TableEditor editor = new TableEditor(table);
                editor.grabHorizontal = editor.grabVertical = true;
                editor.setEditor(link, item, 1);
                link.addSelectionListener(new SelectionAdapter() {

                    public void widgetSelected(SelectionEvent e) {
                        boolean switchPage = true;
                        if (isDirty)
                            switchPage = MessageDialog.open(MessageDialog.QUESTION, getShell(), NLS.bind(Messages.RuntimePreferencePage_Open_preferences, prefName), NLS.bind(Messages.RuntimePreferencePage_You_have_unsaved_changes, prefName), SWT.NONE);
                        if (switchPage) {
                            if (isDirty) {
                                performOk();
                                RuntimeWorkbenchUtils.refreshPreferencePageUIThread(getShell(), preferenceId);
                            } else {
                                PreferencesUtil.createPreferenceDialogOn(getShell(), preferenceId, null, null);
                            }
                        }
                    }
                });
            }
        }
    }
    return tableViewer;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Table(org.eclipse.swt.widgets.Table) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) IRuntimeDetector(org.jboss.tools.runtime.core.model.IRuntimeDetector) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) TableEditor(org.eclipse.swt.custom.TableEditor) GridData(org.eclipse.swt.layout.GridData) ColumnLayoutData(org.eclipse.jface.viewers.ColumnLayoutData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) AutoResizeTableLayout(org.jboss.tools.runtime.ui.internal.dialogs.AutoResizeTableLayout) TableLayout(org.eclipse.jface.viewers.TableLayout) Link(org.eclipse.swt.widgets.Link)

Example 65 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project jbosstools-base by jbosstools.

the class EditRuntimePathDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    getShell().setText(Messages.EditRuntimePathDialog_Edit_runtime_detection_path);
    Composite area = (Composite) super.createDialogArea(parent);
    Composite contents = new Composite(area, SWT.NONE);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 400;
    gd.widthHint = 700;
    contents.setLayoutData(gd);
    contents.setLayout(new GridLayout(1, false));
    applyDialogFont(contents);
    initializeDialogUnits(area);
    Composite pathComposite = new Composite(contents, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    pathComposite.setLayoutData(gd);
    pathComposite.setLayout(new GridLayout(3, false));
    Label pathLabel = new Label(pathComposite, SWT.NONE);
    pathLabel.setText(Messages.EditRuntimePathDialog_Path);
    final Text pathText = new Text(pathComposite, SWT.BORDER);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    pathText.setLayoutData(gd);
    pathText.setText(runtimePath.getPath());
    Button browseButton = new Button(pathComposite, SWT.NONE);
    browseButton.setText(Messages.EditRuntimePathDialog_Browse);
    browseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IDialogSettings dialogSettings = RuntimeUIActivator.getDefault().getDialogSettings();
            DirectoryDialog dialog = new DirectoryDialog(getShell());
            dialog.setMessage(Messages.EditRuntimePathDialog_Edit_Path);
            dialog.setFilterPath(pathText.getText());
            final String path = dialog.open();
            if (path == null) {
                return;
            }
            runtimePath.setPath(path);
            dialogSettings.put(JBossRuntimePreferencesInitializer.LASTPATH, path);
            pathText.setText(path);
            refreshRuntimes(getShell(), new RuntimePath[] { runtimePath }, treeViewer, false);
        }
    });
    Label refreshLabel = new Label(pathComposite, SWT.NONE);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    gd.horizontalSpan = 2;
    refreshLabel.setLayoutData(gd);
    refreshLabel.setText(Messages.EditRuntimePathDialog_Runtimes_found_at_this_path);
    final Button refreshButton = new Button(pathComposite, SWT.NONE);
    refreshButton.setText(Messages.EditRuntimePathDialog_Refresh);
    refreshButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            refreshRuntimes(getShell(), new RuntimePath[] { runtimePath }, treeViewer, false);
        }
    });
    pathText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            runtimePath.setPath(pathText.getText());
            if (!pathText.getText().isEmpty()) {
                refreshButton.setEnabled((new File(pathText.getText()).isDirectory()));
            }
        }
    });
    refreshButton.setEnabled((new File(pathText.getText()).isDirectory()));
    treeViewer = createRuntimeViewer(new RuntimePath[] { runtimePath }, contents, 100);
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            RuntimeDefinition definition = (RuntimeDefinition) event.getElement();
            definition.setEnabled(!definition.isEnabled());
        }
    });
    return area;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RuntimePath(org.jboss.tools.runtime.core.model.RuntimePath) RuntimeDefinition(org.jboss.tools.runtime.core.model.RuntimeDefinition) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) File(java.io.File) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)136 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)133 GridData (org.eclipse.swt.layout.GridData)89 Composite (org.eclipse.swt.widgets.Composite)68 GridLayout (org.eclipse.swt.layout.GridLayout)61 SelectionEvent (org.eclipse.swt.events.SelectionEvent)56 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)47 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)45 Button (org.eclipse.swt.widgets.Button)43 Label (org.eclipse.swt.widgets.Label)42 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)31 Table (org.eclipse.swt.widgets.Table)30 Viewer (org.eclipse.jface.viewers.Viewer)29 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)26 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)26 TableColumn (org.eclipse.swt.widgets.TableColumn)23 ArrayList (java.util.ArrayList)21 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)20 Text (org.eclipse.swt.widgets.Text)18 List (java.util.List)16