Search in sources :

Example 6 with ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener 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 ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener 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 ICheckStateListener

use of org.eclipse.jface.viewers.ICheckStateListener 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 ICheckStateListener

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

the class MatchFilterSelectionDialog method createMatchFilterControls.

private void createMatchFilterControls(Composite parent) {
    // Create list viewer
    Label l = new Label(parent, SWT.NONE);
    l.setFont(parent.getFont());
    l.setText(SearchMessages.MatchFilterSelectionDialog_filter_description);
    Table table = new Table(parent, SWT.CHECK | SWT.BORDER);
    table.setFont(parent.getFont());
    fListViewer = new CheckboxTableViewer(table);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.minimumHeight = convertHeightInCharsToPixels(8);
    table.setLayoutData(data);
    class ListenerAndLabelProvider extends LabelProvider implements ISelectionChangedListener, ICheckStateListener {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            performFilterListSelectionChanged();
        }

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            performFilterListCheckStateChanged();
        }

        @Override
        public String getText(Object element) {
            return ((MatchFilter) element).getName();
        }
    }
    ListenerAndLabelProvider listenerAndLP = new ListenerAndLabelProvider();
    fListViewer.setLabelProvider(listenerAndLP);
    fListViewer.setContentProvider(new ArrayContentProvider());
    fListViewer.addSelectionChangedListener(listenerAndLP);
    fListViewer.addCheckStateListener(listenerAndLP);
    fListViewer.setInput(fAllFilters);
    fListViewer.setCheckedElements(fEnabledFilters);
    l = new Label(parent, SWT.NONE);
    l.setFont(parent.getFont());
    l.setText(SearchMessages.MatchFilterSelectionDialog_description_label);
    fDescription = new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);
    fDescription.setFont(parent.getFont());
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = convertHeightInCharsToPixels(3);
    fDescription.setLayoutData(data);
}
Also used : Table(org.eclipse.swt.widgets.Table) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Text(org.eclipse.swt.widgets.Text) MatchFilter(org.eclipse.search.ui.text.MatchFilter) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 10 with ICheckStateListener

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

the class TemplatePreferencePage method createContents.

@Override
protected Control createContents(Composite ancestor) {
    Composite parent = new Composite(ancestor, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    parent.setLayout(layout);
    Composite innerParent = new Composite(parent, SWT.NONE);
    GridLayout innerLayout = new GridLayout();
    innerLayout.numColumns = 2;
    innerLayout.marginHeight = 0;
    innerLayout.marginWidth = 0;
    innerParent.setLayout(innerLayout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 2;
    innerParent.setLayoutData(gd);
    Composite tableComposite = new Composite(innerParent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 360;
    data.heightHint = convertHeightInCharsToPixels(10);
    tableComposite.setLayoutData(data);
    ColumnLayout columnLayout = new ColumnLayout();
    tableComposite.setLayout(columnLayout);
    Table table = new Table(tableComposite, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    GC gc = new GC(getShell());
    gc.setFont(JFaceResources.getDialogFont());
    TemplateViewerComparator viewerComparator = new TemplateViewerComparator();
    TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setText(TemplatesMessages.TemplatePreferencePage_column_name);
    int minWidth = computeMinimumColumnWidth(gc, TemplatesMessages.TemplatePreferencePage_column_name);
    columnLayout.addColumnData(new ColumnWeightData(2, minWidth, true));
    column1.addSelectionListener(new TemplateColumnSelectionAdapter(column1, 0, viewerComparator));
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText(TemplatesMessages.TemplatePreferencePage_column_context);
    minWidth = computeMinimumContextColumnWidth(gc);
    columnLayout.addColumnData(new ColumnWeightData(1, minWidth, true));
    column2.addSelectionListener(new TemplateColumnSelectionAdapter(column2, 1, viewerComparator));
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText(TemplatesMessages.TemplatePreferencePage_column_description);
    minWidth = computeMinimumColumnWidth(gc, TemplatesMessages.TemplatePreferencePage_column_description);
    columnLayout.addColumnData(new ColumnWeightData(3, minWidth, true));
    column3.addSelectionListener(new TemplateColumnSelectionAdapter(column3, 2, viewerComparator));
    TableColumn column4 = new TableColumn(table, SWT.NONE);
    column4.setAlignment(SWT.CENTER);
    column4.setText(TemplatesMessages.TemplatePreferencePage_column_autoinsert);
    minWidth = computeMinimumColumnWidth(gc, TemplatesMessages.TemplatePreferencePage_column_autoinsert);
    minWidth = Math.max(minWidth, computeMinimumColumnWidth(gc, TemplatesMessages.TemplatePreferencePage_on));
    columnLayout.addColumnData(new ColumnPixelData(minWidth, false, false));
    column4.addSelectionListener(new TemplateColumnSelectionAdapter(column4, 3, viewerComparator));
    gc.dispose();
    fTableViewer = new CheckboxTableViewer(table);
    fTableViewer.setLabelProvider(new TemplateLabelProvider());
    fTableViewer.setContentProvider(new TemplateContentProvider());
    fTableViewer.setComparator(viewerComparator);
    // Specify default sorting
    table.setSortColumn(column1);
    table.setSortDirection(viewerComparator.getDirection());
    fTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent e) {
            edit();
        }
    });
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent e) {
            selectionChanged1();
        }
    });
    fTableViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            TemplatePersistenceData d = (TemplatePersistenceData) event.getElement();
            d.setEnabled(event.getChecked());
        }
    });
    BidiUtils.applyTextDirection(fTableViewer.getControl(), BidiUtils.BTD_DEFAULT);
    Composite buttons = new Composite(innerParent, SWT.NONE);
    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    buttons.setLayout(layout);
    fAddButton = new Button(buttons, SWT.PUSH);
    fAddButton.setText(TemplatesMessages.TemplatePreferencePage_new);
    fAddButton.setLayoutData(getButtonGridData(fAddButton));
    fAddButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            add();
        }
    });
    fEditButton = new Button(buttons, SWT.PUSH);
    fEditButton.setText(TemplatesMessages.TemplatePreferencePage_edit);
    fEditButton.setLayoutData(getButtonGridData(fEditButton));
    fEditButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            edit();
        }
    });
    fRemoveButton = new Button(buttons, SWT.PUSH);
    fRemoveButton.setText(TemplatesMessages.TemplatePreferencePage_remove);
    fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton));
    fRemoveButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            remove();
        }
    });
    createSeparator(buttons);
    fRestoreButton = new Button(buttons, SWT.PUSH);
    fRestoreButton.setText(TemplatesMessages.TemplatePreferencePage_restore);
    fRestoreButton.setLayoutData(getButtonGridData(fRestoreButton));
    fRestoreButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            restoreDeleted();
        }
    });
    fRevertButton = new Button(buttons, SWT.PUSH);
    fRevertButton.setText(TemplatesMessages.TemplatePreferencePage_revert);
    fRevertButton.setLayoutData(getButtonGridData(fRevertButton));
    fRevertButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            revert();
        }
    });
    createSeparator(buttons);
    fImportButton = new Button(buttons, SWT.PUSH);
    fImportButton.setText(TemplatesMessages.TemplatePreferencePage_import);
    fImportButton.setLayoutData(getButtonGridData(fImportButton));
    fImportButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            import_();
        }
    });
    fExportButton = new Button(buttons, SWT.PUSH);
    fExportButton.setText(TemplatesMessages.TemplatePreferencePage_export);
    fExportButton.setLayoutData(getButtonGridData(fExportButton));
    fExportButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(Event e) {
            export();
        }
    });
    fPatternViewer = doCreateViewer(parent);
    if (isShowFormatterSetting()) {
        fFormatButton = new Button(parent, SWT.CHECK);
        fFormatButton.setText(TemplatesMessages.TemplatePreferencePage_use_code_formatter);
        GridData gd1 = new GridData();
        gd1.horizontalSpan = 2;
        fFormatButton.setLayoutData(gd1);
        fFormatButton.setSelection(getPreferenceStore().getBoolean(getFormatterPreferenceKey()));
    }
    fTableViewer.setInput(fTemplateStore);
    fTableViewer.setAllChecked(false);
    fTableViewer.setCheckedElements(getEnabledTemplates());
    updateButtons();
    Dialog.applyDialogFont(parent);
    innerParent.layout();
    return parent;
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) SelectionListener(org.eclipse.swt.events.SelectionListener) ITextListener(org.eclipse.jface.text.ITextListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) DisposeListener(org.eclipse.swt.events.DisposeListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) FocusListener(org.eclipse.swt.events.FocusListener) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GC(org.eclipse.swt.graphics.GC) TemplatePersistenceData(org.eclipse.jface.text.templates.persistence.TemplatePersistenceData) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) GridData(org.eclipse.swt.layout.GridData) FocusEvent(org.eclipse.swt.events.FocusEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Event(org.eclipse.swt.widgets.Event) TextEvent(org.eclipse.jface.text.TextEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) 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