Search in sources :

Example 6 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project cubrid-manager by CUBRID.

the class ImportExportConnectionDialog method createTable.

private void createTable(Composite composite) {
    hostListView = CheckboxTableViewer.newCheckList(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    hostListView.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (isExport) {
                valid();
            }
        }
    });
    final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdColumnsTable.horizontalSpan = 3;
    gdColumnsTable.heightHint = 189;
    hostListView.getTable().setLayoutData(gdColumnsTable);
    hostListView.getTable().setLinesVisible(true);
    hostListView.getTable().setHeaderVisible(true);
    final TableColumn hostName = new TableColumn(hostListView.getTable(), SWT.NONE);
    hostName.setAlignment(SWT.LEFT);
    hostName.setWidth(WIDTH_NAME);
    hostName.setText(Messages.columnHeaderServerInfo);
    if (isExport) {
        hostName.setImage(CommonUIPlugin.getImage("icons/checked_green.png"));
    } else {
        hostName.setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
    }
    hostName.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            selectAll = !selectAll;
            hostListView.setAllChecked(selectAll);
            Image image = selectAll ? CommonUIPlugin.getImage("icons/checked_green.png") : CommonUIPlugin.getImage("icons/unchecked.gif");
            hostName.setImage(image);
            hostListView.refresh();
            if (isExport) {
                valid();
            }
        }
    });
    final TableColumn hostAddress = new TableColumn(hostListView.getTable(), SWT.NONE);
    hostAddress.setAlignment(SWT.CENTER);
    hostAddress.setWidth(WIDTH_ADDRESS);
    hostAddress.setText(Messages.columnHeaderServerAddress);
    final TableColumn hostPort = new TableColumn(hostListView.getTable(), SWT.NONE);
    hostPort.setAlignment(SWT.CENTER);
    hostPort.setWidth(WIDTH_PORT);
    hostPort.setText(Messages.columnHeaderServerPort);
    final TableColumn jdbcVer = new TableColumn(hostListView.getTable(), SWT.NONE);
    jdbcVer.setAlignment(SWT.CENTER);
    jdbcVer.setWidth(WIDTH_JDBC);
    jdbcVer.setText(Messages.columnHeaderServerJdbcVersion);
    final TableColumn hostUser = new TableColumn(hostListView.getTable(), SWT.NONE);
    hostUser.setAlignment(SWT.CENTER);
    hostUser.setWidth(WIDTH_USER);
    hostUser.setText(Messages.columnHeaderServerUserName);
    //		final TableColumn savedPass = new TableColumn(hostListView.getTable(), SWT.NONE);
    //		savedPass.setAlignment(SWT.CENTER);
    //		savedPass.setWidth(WIDTH_SAVEPASS);
    //		savedPass.setText(Messages.columnHeaderServerAutoSave);
    hostListView.setContentProvider(new ServerInfoTableViewerContentProvider());
    hostListView.setLabelProvider(new ServerInfoTableViewerLabelProvider());
    if (isExport) {
        initExportTableData();
    }
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) ServerInfoTableViewerLabelProvider(com.cubrid.cubridmanager.ui.host.editor.ServerInfoTableViewerLabelProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ServerInfoTableViewerContentProvider(com.cubrid.cubridmanager.ui.host.editor.ServerInfoTableViewerContentProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Image(org.eclipse.swt.graphics.Image) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 7 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project cubrid-manager by CUBRID.

the class LoadDatabaseDialog method createDbUnloadInfoTable.

/**
	 * 
	 * Create database unload information table
	 * 
	 * @param parent the parent composite
	 */
private void createDbUnloadInfoTable(Composite parent) {
    final String[] columnNameArr = new String[] { Messages.tblColumnLoadType, Messages.tblColumnPath, Messages.tblColumnDate };
    tableViewer = (CheckboxTableViewer) CommonUITool.createCheckBoxTableViewer(parent, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, 100));
    tableViewer.addCheckStateListener(new ICheckStateListener() {

        @SuppressWarnings("unchecked")
        public void checkStateChanged(CheckStateChangedEvent event) {
            Map<String, String> map = (Map<String, String>) event.getElement();
            String checkedType = map.get("0");
            String checkedPath = map.get("1");
            String checkedDate = map.get("2");
            if (event.getChecked()) {
                for (int i = 0, n = unloadInfoTable.getItemCount(); i < n; i++) {
                    if (unloadInfoTable.getItem(i).getChecked()) {
                        String type = unloadInfoTable.getItem(i).getText(0);
                        String path = unloadInfoTable.getItem(i).getText(1);
                        String date = unloadInfoTable.getItem(i).getText(2);
                        if (checkedType.equals(type) && checkedPath.equals(path) && checkedDate.equals(date)) {
                            continue;
                        }
                        if (checkedType.equals(type)) {
                            unloadInfoTable.getItem(i).setChecked(false);
                        }
                    }
                }
            }
            valid();
        }
    });
    unloadInfoTable = tableViewer.getTable();
}
Also used : TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project translationstudio8 by heartsome.

the class WizardExportResourcesPage2 method createResourcesGroup.

/**
	 * Creates the checkbox tree and list for selecting resources.
	 * @param parent
	 *            the parent control
	 */
protected final void createResourcesGroup(Composite parent) {
    // create the input element, which has the root resource
    // as its only child
    List input = new ArrayList();
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < projects.length; i++) {
        if (projects[i].isOpen()) {
            input.add(projects[i]);
        }
    }
    this.resourceGroup = new ResourceTreeAndListGroup(parent, input, getResourceProvider(IResource.FOLDER | IResource.PROJECT), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), getResourceProvider(IResource.FILE), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(), SWT.NONE, DialogUtil.inRegularFontMode(parent));
    ICheckStateListener listener = new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            updateWidgetEnablements();
        }
    };
    this.resourceGroup.addCheckStateListener(listener);
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) IProject(org.eclipse.core.resources.IProject) ResourceTreeAndListGroup(org.eclipse.ui.internal.ide.dialogs.ResourceTreeAndListGroup)

Example 9 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project hale by halestudio.

the class AbstractFeatureTypesPage method createContent.

@Override
protected void createContent(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new GridLayout(1, false));
    // create filtered tree
    PatternFilter patternFilter = new PatternFilter();
    patternFilter.setIncludeLeadingWildcard(true);
    FilteredTree tree = new FilteredTree(page, SWT.BORDER | SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL, patternFilter, true) {

        @Override
        protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
            return new CheckboxTreeViewer(parent, style);
        }
    };
    // configure viewer
    viewer = (CheckboxTreeViewer) tree.getViewer();
    contentProvider = new FeatureTypeTreeContentProvider();
    viewer.setContentProvider(contentProvider);
    // viewer.setComparator(new DefinitionComparator());
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            Object doubleClicked = selection.getFirstElement();
            if (doubleClicked instanceof String)
                viewer.setExpandedState(doubleClicked, !viewer.getExpandedState(doubleClicked));
            else {
                boolean newState = !checkStateProvider.isChecked(doubleClicked);
                viewer.setChecked(doubleClicked, newState);
                checkStateOfTypeChanged((QName) doubleClicked, newState);
            }
        }
    });
    viewer.setLabelProvider(new FeatureTypeTreeLabelProvider());
    // because elements filtered by FilteredTree lose their checked state:
    checkStateProvider = new ICheckStateProvider() {

        @Override
        public boolean isGrayed(Object element) {
            if (element instanceof String) {
                Object[] children = contentProvider.getChildren(element);
                boolean containsChecked = false;
                boolean containsUnchecked = false;
                for (Object child : children) {
                    if (isChecked(child))
                        containsChecked = true;
                    else
                        containsUnchecked = true;
                    if (containsChecked && containsUnchecked)
                        return true;
                }
            }
            return false;
        }

        @Override
        public boolean isChecked(Object element) {
            if (element instanceof String) {
                for (Object child : contentProvider.getChildren(element)) if (isChecked(child))
                    return true;
                return false;
            }
            return selected.contains(element);
        }
    };
    viewer.setCheckStateProvider(checkStateProvider);
    viewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getElement() instanceof String) {
                // update children
                viewer.setGrayed(event.getElement(), false);
                for (Object child : contentProvider.getChildren(event.getElement())) {
                    if (checkStateProvider.isChecked(child) != event.getChecked()) {
                        viewer.setChecked(child, event.getChecked());
                        checkStateOfTypeChanged((QName) child, event.getChecked());
                    }
                }
                viewer.setGrayed(event.getElement(), checkStateProvider.isGrayed(event.getElement()));
            // only two levels, no need to update any parents or
            // children's children
            } else {
                checkStateOfTypeChanged((QName) event.getElement(), event.getChecked());
            }
        }
    });
    setControl(page);
    // initial update
    updateState(selected);
}
Also used : PatternFilter(org.eclipse.ui.dialogs.PatternFilter) Composite(org.eclipse.swt.widgets.Composite) ICheckStateProvider(org.eclipse.jface.viewers.ICheckStateProvider) QName(javax.xml.namespace.QName) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 10 with CheckStateChangedEvent

use of org.eclipse.jface.viewers.CheckStateChangedEvent in project hale by halestudio.

the class SchemasRetrievalPage method createComponent.

private void createComponent() {
    if (multipleSelection) {
        selectAll = new Button(page, SWT.CHECK);
        selectAll.setText("Select all");
        selectAll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
        selectAll.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                schemaTable.setAllChecked(((Button) e.getSource()).getSelection());
            }
        });
        schemaTable = CheckboxTableViewer.newCheckList(page, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    } else
        schemaTable = CheckboxTableViewer.newCheckList(page, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
    schemaTable.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return element.toString();
        }
    });
    schemaTable.setContentProvider(ArrayContentProvider.getInstance());
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
    layoutData.widthHint = SWT.DEFAULT;
    layoutData.heightHint = 8 * schemaTable.getTable().getItemHeight();
    schemaTable.getControl().setLayoutData(layoutData);
    schemaTable.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked() && (!multipleSelection)) {
                schemaTable.setAllChecked(false);
                schemaTable.setCheckedElements(new Object[] { event.getElement() });
            }
            setPageComplete(validate());
        }
    });
    setPageComplete(false);
    page.layout(true, true);
}
Also used : Button(org.eclipse.swt.widgets.Button) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)99 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)96 GridData (org.eclipse.swt.layout.GridData)62 Composite (org.eclipse.swt.widgets.Composite)47 GridLayout (org.eclipse.swt.layout.GridLayout)43 SelectionEvent (org.eclipse.swt.events.SelectionEvent)39 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)33 Label (org.eclipse.swt.widgets.Label)33 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)32 Button (org.eclipse.swt.widgets.Button)29 CheckboxTableViewer (org.eclipse.jface.viewers.CheckboxTableViewer)22 Viewer (org.eclipse.jface.viewers.Viewer)22 Table (org.eclipse.swt.widgets.Table)21 ArrayList (java.util.ArrayList)18 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