Search in sources :

Example 11 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project eclipse.platform.text by eclipse.

the class SelectResourcesDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    Label label = new Label(composite, SWT.LEFT);
    label.setText(fInstruction);
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fResourceGroup = new SelectResourcesBlock(composite, ResourcesPlugin.getWorkspace().getRoot(), getResourceProvider(IResource.FOLDER | IResource.PROJECT), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), getResourceProvider(IResource.FILE), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), SWT.NONE, useHeightHint(parent));
    fResourceGroup.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateSelectionCount();
        }
    });
    fCountIndication = new Label(composite, SWT.LEFT);
    fCountIndication.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    createSelectionButtonGroup(composite);
    setInitialSelection();
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 12 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project erlide_eclipse by erlang.

the class ErlangWizardResourceImportPage method createFileSelectionGroup.

/**
 * Create the import source selection widget
 */
protected void createFileSelectionGroup(final Composite parent) {
    // Just create with a dummy root.
    selectionGroup = new ResourceTreeAndListGroup(parent, // $NON-NLS-1$
    new FileSystemElement("Dummy", null, true), getFolderProvider(), new WorkbenchLabelProvider(), getFileProvider(), new WorkbenchLabelProvider(), SWT.NONE, DialogUtil.inRegularFontMode(parent));
    final ICheckStateListener listener = new ICheckStateListener() {

        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            updateWidgetEnablements();
        }
    };
    final WorkbenchViewerComparator comparator = new WorkbenchViewerComparator();
    selectionGroup.setTreeComparator(comparator);
    selectionGroup.setListComparator(comparator);
    selectionGroup.addCheckStateListener(listener);
}
Also used : WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) FileSystemElement(org.eclipse.ui.dialogs.FileSystemElement) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) WorkbenchViewerComparator(org.eclipse.ui.model.WorkbenchViewerComparator) ResourceTreeAndListGroup(org.erlide.ui.util.ResourceTreeAndListGroup)

Example 13 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project erlide_eclipse by erlang.

the class ErlangMainTab method createProjectsGroup.

/**
 * @param comp
 */
private void createProjectsGroup(final Composite comp) {
    final Group projectsGroup = SWTUtil.createGroup(comp, "Projects", 2, GridData.FILL_HORIZONTAL);
    projectsTable = CheckboxTableViewer.newCheckList(projectsGroup, SWT.HIDE_SELECTION | SWT.BORDER);
    projectsTable.setLabelProvider(new ProjectsLabelProvider());
    projectsTable.setContentProvider(new ProjectsContentProvider());
    final Table table_1 = projectsTable.getTable();
    final GridData gd_table_1 = new GridData(SWT.LEFT, SWT.FILL, true, true);
    gd_table_1.widthHint = 287;
    gd_table_1.heightHint = 126;
    gd_table_1.minimumHeight = 108;
    gd_table_1.minimumWidth = 256;
    table_1.setLayoutData(gd_table_1);
    projectsTable.addCheckStateListener(new ICheckStateListener() {

        @Override
        @SuppressWarnings("synthetic-access")
        public void checkStateChanged(final CheckStateChangedEvent event) {
            updateLaunchConfigurationDialog();
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) Table(org.eclipse.swt.widgets.Table) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 14 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project erlide_eclipse by erlang.

the class RuntimePreferencePage method createMyControl.

private Control createMyControl(final Composite ancestor) {
    final Composite parent = new Composite(ancestor, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    parent.setLayout(layout);
    final Font font = ancestor.getFont();
    parent.setFont(font);
    GridData data;
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    composite.setLayout(gridLayout);
    final Label erlideLabel = new Label(composite, SWT.NONE);
    erlideLabel.setToolTipText("The erlide runtime is used for IDE purposes, not for running project code. " + "It is the most recent stable version that is installed.");
    final String erlideName = erlideRuntime == null ? "none" : erlideRuntime.getName();
    erlideLabel.setText(RuntimePreferenceMessages.RuntimePreferencePage_erlideLabel_text + " " + erlideName);
    new Label(composite, SWT.NONE);
    new Label(parent, SWT.NONE);
    final Label tableLabel = new Label(parent, SWT.NONE);
    tableLabel.setText("Installed runtimes:");
    data = new GridData();
    data.horizontalSpan = 2;
    tableLabel.setLayoutData(data);
    tableLabel.setFont(font);
    final Table table = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (e.detail == SWT.CHECK) {
                final RuntimeInfo ri = (RuntimeInfo) e.item.getData();
                defaultRuntime = ri;
            }
        }
    });
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.widthHint = 403;
    table.setLayoutData(data);
    table.setFont(font);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    final TableColumn column1 = new TableColumn(table, SWT.NULL);
    column1.setWidth(80);
    column1.setText(RuntimePreferenceMessages.name);
    column1.setResizable(true);
    column1.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            sortByName();
        }
    });
    final TableColumn column2 = new TableColumn(table, SWT.NULL);
    column2.setWidth(150);
    column2.setText("Directory");
    column2.setResizable(true);
    column2.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            sortByDirectory();
        }
    });
    final TableColumn column3 = new TableColumn(table, SWT.NULL);
    column3.setWidth(80);
    column3.setText("Version");
    column3.setResizable(false);
    fRuntimeList = new CheckboxTableViewer(table);
    fRuntimeList.setLabelProvider(new RuntimeLabelProvider());
    fRuntimeList.setContentProvider(new RuntimeContentProvider());
    fRuntimeList.setInput(runtimes);
    if (defaultRuntime == null || defaultRuntime == RuntimeInfo.NO_RUNTIME_INFO) {
        defaultRuntime = RuntimeCore.getRuntimeInfoCatalog().getDefaultRuntime();
    }
    if (defaultRuntime != null) {
        fRuntimeList.setCheckedElements(new Object[] { defaultRuntime });
    }
    // by default, sort by name
    sortByName();
    fRuntimeList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent evt) {
            enableButtons();
        }
    });
    fRuntimeList.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(final CheckStateChangedEvent event) {
            if (event.getChecked()) {
                setCheckedRuntime((RuntimeInfo) event.getElement());
            } else {
                setCheckedRuntime(null);
            }
        }
    });
    fRuntimeList.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(final DoubleClickEvent e) {
            if (!fRuntimeList.getSelection().isEmpty()) {
                editRuntime();
            }
        }
    });
    table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent event) {
            if (event.character == SWT.DEL && event.stateMask == 0) {
                removeSelectedRuntimes();
            }
        }
    });
    final Composite buttons = new Composite(parent, SWT.NULL);
    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);
    buttons.setFont(font);
    fAddButton = createPushButton(buttons, RuntimePreferenceMessages.add);
    fAddButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            addRuntime();
        }
    });
    fEditButton = createPushButton(buttons, RuntimePreferenceMessages.edit);
    fEditButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            editRuntime();
        }
    });
    fDuplicateButton = createPushButton(buttons, RuntimePreferenceMessages.duplicate);
    fDuplicateButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            duplicateRuntime();
        }
    });
    fRemoveButton = createPushButton(buttons, RuntimePreferenceMessages.remove);
    fRemoveButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            removeSelectedRuntimes();
        }
    });
    fDetectButton = createPushButton(buttons, RuntimePreferenceMessages.detect);
    fDetectButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event evt) {
            detectRuntimes();
        }
    });
    configureTableResizing(parent, buttons, table, column1, column2, column3);
    enableButtons();
    return parent;
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Font(org.eclipse.swt.graphics.Font) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLayout(org.eclipse.jface.viewers.TableLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) GridData(org.eclipse.swt.layout.GridData) KeyEvent(org.eclipse.swt.events.KeyEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 15 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener in project tmdm-studio-se by Talend.

the class RepositoryViewObjectCheckedWidget method initWidget.

private void initWidget() {
    // 
    setLayout(new GridLayout());
    treeViewer = new ContainerCheckedTreeViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
    Tree tree = getTree();
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    installColumns();
    treeViewer.setContentProvider(new ContentProvider());
    treeViewer.getTree().addListener(SWT.PaintItem, new Listener() {

        public void handleEvent(Event event) {
            TreeItem item = (TreeItem) event.item;
            Object data = item.getData();
            if (data != null && lockedViewObjs.contains(data)) {
                String text = item.getText(event.index);
                Point point = event.gc.textExtent(text);
                int y = event.y + point.y / 2 + 2;
                int x = event.x + 20;
                event.gc.drawLine(x, y, x + point.x, y);
                event.gc.drawText(Messages.RepositoryViewObjectCheckedWidget_lock, x + point.x + 2, event.y + 2);
            }
        }
    });
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        private void checkSubElement(IRepositoryViewObject viewObj) {
            if (viewObj instanceof FolderRepositoryObject) {
                Item item = viewObj.getProperty().getItem();
                List<IRepositoryViewObject> children = RepositoryResourceUtil.findViewObjects(viewObj.getRepositoryObjectType(), item, true, true);
                if (children != null) {
                    for (IRepositoryViewObject child : children) {
                        checkSubElement(child);
                    }
                }
            } else {
                if (lockedViewObjs.contains(viewObj)) {
                    treeViewer.setChecked(viewObj, false);
                }
            }
        }

        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (element instanceof IRepositoryViewObject) {
                checkSubElement((IRepositoryViewObject) element);
            }
        }
    });
    if (adapter != null) {
        treeViewer.addCheckStateListener(new ICheckStateListener() {

            public void checkStateChanged(CheckStateChangedEvent event) {
                updateSeverityCount();
            }
        });
    }
    treeViewer.addFilter(new ViewerFilter() {

        private boolean containVisibleElement(FolderRepositoryObject parent) {
            Item item = parent.getProperty().getItem();
            List<IRepositoryViewObject> children = RepositoryResourceUtil.findViewObjects(parent.getRepositoryObjectType(), item, true, true);
            boolean result = false;
            for (IRepositoryViewObject viewObj : children) {
                if (viewObj instanceof FolderRepositoryObject) {
                    boolean r = containVisibleElement((FolderRepositoryObject) viewObj);
                    if (r) {
                        result = true;
                    }
                } else if (viewObj instanceof IRepositoryViewObject) {
                    if (isVisibleViewObj(viewObj)) {
                        updateServerDef(viewObj);
                        // updateLockedObject(viewObj);
                        result = true;
                    }
                }
            }
            return result;
        }

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (reconciliation) {
                return true;
            } else {
                if (element instanceof FolderRepositoryObject) {
                    return containVisibleElement((FolderRepositoryObject) element);
                } else {
                    IRepositoryViewObject viewObj = (IRepositoryViewObject) element;
                    return isVisibleViewObj(viewObj);
                }
            }
        }
    });
    // show time
    final Button showTimestampBun = new Button(this, SWT.CHECK);
    showTimestampBun.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showTimeStampColumns(showTimestampBun.getSelection());
        }
    });
    showTimestampBun.setText(Messages.ConsistencyConflict_showTimeStampColumn);
    // 
    treeViewer.setInput(input);
    selectAll(true);
    treeViewer.expandAll();
    if (adapter != null) {
        adapter.initSeverityControl(this);
    }
    updateSeverityCount();
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Point(org.eclipse.swt.graphics.Point) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) TreeItem(org.eclipse.swt.widgets.TreeItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Aggregations

ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)101 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)97 GridData (org.eclipse.swt.layout.GridData)62 Composite (org.eclipse.swt.widgets.Composite)48 GridLayout (org.eclipse.swt.layout.GridLayout)44 SelectionEvent (org.eclipse.swt.events.SelectionEvent)40 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)34 Label (org.eclipse.swt.widgets.Label)32 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)31 Button (org.eclipse.swt.widgets.Button)30 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)22 Viewer (org.eclipse.jface.viewers.Viewer)21 Table (org.eclipse.swt.widgets.Table)21 ArrayList (java.util.ArrayList)19 TableColumn (org.eclipse.swt.widgets.TableColumn)17 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)16 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)16 Event (org.eclipse.swt.widgets.Event)16 Listener (org.eclipse.swt.widgets.Listener)15 List (java.util.List)13