Search in sources :

Example 76 with CheckStateChangedEvent

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

the class ImportProjectWizardPage2 method initTreeListener.

/**
	 * 初始化两颗树的事件
	 */
private void initTreeListener() {
    selectElementTree.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(final CheckStateChangedEvent event) {
            BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {

                public void run() {
                    selectElementTreeCheckFunction(event);
                    setNotCoverForNotcheckOfSelectTree();
                    setPageCompleteState(OTHER_TYPE);
                }
            });
        }
    });
    repeatElementTree.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(final CheckStateChangedEvent event) {
            BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {

                public void run() {
                    Object element = event.getElement();
                    if (element instanceof ProjectResource) {
                        ProjectResource proResourceElement = (ProjectResource) element;
                        if (repeatElementTree.getChecked(proResourceElement)) {
                            proResourceElement.setNeedCover(true);
                        } else {
                            proResourceElement.setNeedCover(false);
                        }
                        // 处理所有的子文件或文件夹,以保存证他们都处于要覆盖状态
                        checkRepeatTreeChildCover(proResourceElement);
                        // 处理当前节点的所有父节点
                        ProjectResource parentProRes = proResourceElement.getParent();
                        while (parentProRes != null) {
                            parentProRes.setNeedCover(repeatElementTree.getChecked(parentProRes));
                            parentProRes = parentProRes.getParent();
                        }
                        repeatElementTree.refresh(true);
                    }
                    setPageCompleteState(OTHER_TYPE);
                }
            });
        }
    });
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ProjectResource(net.heartsome.cat.ts.importproject.widgiet.ProjectResource) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 77 with CheckStateChangedEvent

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

the class ExportConnectionUtil method createDialogArea.

/**
	 * Create dialog area content
	 *
	 * @param parent the parent composite
	 * @return the control
	 */
@SuppressWarnings("deprecation")
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    tableViewer = new CheckboxTreeViewer(composite, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    tableViewer.getTree().setLinesVisible(true);
    tableViewer.getTree().setHeaderVisible(true);
    tableViewer.getTree().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    /* Name */
    final TreeColumn nameColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    nameColumn.setText(Messages.nameColumn);
    nameColumn.setWidth(120);
    nameColumn.setImage(CommonUIPlugin.getImage("icons/checked_green.png"));
    nameColumn.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            selectAll = !selectAll;
            tableViewer.setAllChecked(selectAll);
            Image image = selectAll ? CommonUIPlugin.getImage("icons/checked_green.png") : CommonUIPlugin.getImage("icons/unchecked.gif");
            nameColumn.setImage(image);
            tableViewer.refresh();
            updateWidgetStatus();
        }
    });
    /* IP */
    TreeColumn ipColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    ipColumn.setText(Messages.iPColumn);
    ipColumn.setWidth(100);
    /* Port */
    TreeColumn portColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    portColumn.setText(Messages.portColumn);
    portColumn.setWidth(80);
    /* DB user */
    TreeColumn userColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    userColumn.setText(Messages.userColumn);
    userColumn.setWidth(100);
    /* Comment */
    TreeColumn commentColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    commentColumn.setText(Messages.commentColumn);
    commentColumn.setWidth(120);
    /* Java Url */
    TreeColumn javaUrlColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    javaUrlColumn.setText(Messages.javaUrlColumn);
    javaUrlColumn.setWidth(300);
    TreeColumn phpUrlColumn = new TreeColumn(tableViewer.getTree(), SWT.LEFT);
    phpUrlColumn.setText(Messages.phpUrlColumn);
    phpUrlColumn.setWidth(300);
    tableViewer.setContentProvider(new TreeViewerContentProvider());
    tableViewer.setLabelProvider(new TreeViewerLabelProvider());
    tableViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
                CheckboxTreeViewer viewer = (CheckboxTreeViewer) event.getSource();
                /* Select the sub node */
                if (event.getElement() instanceof CubridServer) {
                    viewer.setSubtreeChecked(event.getElement(), true);
                } else if (event.getElement() instanceof CubridDatabase) {
                    CubridDatabase database = (CubridDatabase) event.getElement();
                    viewer.setChecked(database.getServer(), true);
                }
            } else {
                CheckboxTreeViewer viewer = (CheckboxTreeViewer) event.getSource();
                ICubridNode element = (ICubridNode) event.getElement();
                viewer.setSubtreeChecked(element, false);
                if (element instanceof CubridDatabase) {
                    CubridDatabase database = (CubridDatabase) element;
                    /* Check the parent state */
                    ICubridNode parent = database.getParent();
                    if (parent != null) {
                        List<ICubridNode> children = parent.getChildren();
                        boolean isSelected = false;
                        for (ICubridNode child : children) {
                            DefaultSchemaNode childNode = (DefaultSchemaNode) child;
                            if (viewer.getChecked(childNode.getDatabase())) {
                                isSelected = true;
                                break;
                            }
                        }
                        viewer.setChecked(database.getServer(), isSelected);
                    }
                }
            }
            updateWidgetStatus();
        }
    });
    tableViewer.setInput(selections);
    tableViewer.expandAll();
    tableViewer.setAllChecked(true);
    setTitle(Messages.titleExportConnection);
    setMessage(Messages.msgExportConnection);
    return parentComp;
}
Also used : ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Image(org.eclipse.swt.graphics.Image) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Event(org.eclipse.swt.widgets.Event) List(java.util.List) ArrayList(java.util.ArrayList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 78 with CheckStateChangedEvent

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

the class ExportSettingPage method createControl.

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FormLayout());
    setControl(container);
    Composite leftComposite = new Composite(container, SWT.NONE);
    leftComposite.setLayout(new GridLayout());
    FormData leftData = new FormData();
    leftData.top = new FormAttachment(0, 5);
    leftData.bottom = new FormAttachment(100, 0);
    leftData.left = new FormAttachment(0, 5);
    leftData.right = new FormAttachment(45, 0);
    leftComposite.setLayoutData(leftData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(45, 0);
    rightData.right = new FormAttachment(100, -5);
    rightComposite.setLayoutData(rightData);
    GridLayout rightCompositeLayout = new GridLayout();
    rightCompositeLayout.verticalSpacing = 10;
    rightComposite.setLayout(rightCompositeLayout);
    Label tableInfoLabel = new Label(leftComposite, SWT.None);
    tableInfoLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    tableInfoLabel.setText(Messages.exportWizardSourceTableLable);
    treeViewer = new CheckboxTreeViewer(leftComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    treeViewer.getTree().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    treeViewer.setContentProvider(new FilterTreeContentProvider());
    treeViewer.getTree().setLinesVisible(true);
    treeViewer.getTree().setHeaderVisible(true);
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            updateDialogStatus(null);
        }
    });
    final TreeViewerColumn dbObjectCol = new TreeViewerColumn(treeViewer, SWT.NONE);
    dbObjectCol.setLabelProvider(new ExportObjectLabelProvider());
    final TreeViewerColumn whereCnd = new TreeViewerColumn(treeViewer, SWT.NONE);
    whereCnd.setLabelProvider(new ExportObjectLabelProvider());
    whereCnd.setEditingSupport(new EditingSupport(treeViewer) {

        TextCellEditor textCellEditor;

        protected boolean canEdit(Object element) {
            if (element instanceof ICubridNode) {
                ICubridNode node = (ICubridNode) element;
                if (node.getType() == NodeType.TABLE_COLUMN_FOLDER) {
                    return true;
                }
            }
            return false;
        }

        protected CellEditor getCellEditor(Object element) {
            if (textCellEditor == null) {
                textCellEditor = new TextCellEditor(treeViewer.getTree());
                textCellEditor.addListener(new ICellEditorListener() {

                    public void applyEditorValue() {
                    }

                    public void cancelEditor() {
                    }

                    public void editorValueChanged(boolean oldValidState, boolean newValidState) {
                    }
                });
            }
            return textCellEditor;
        }

        protected Object getValue(Object element) {
            final ICubridNode node = (ICubridNode) element;
            String condition = (String) node.getData(ExportObjectLabelProvider.CONDITION);
            if (condition == null) {
                return "";
            } else {
                return condition;
            }
        }

        protected void setValue(Object element, Object value) {
            final ICubridNode node = (ICubridNode) element;
            node.setData(ExportObjectLabelProvider.CONDITION, value);
            treeViewer.refresh();
            updateDialogStatus(null);
        }
    });
    dbObjectCol.getColumn().setWidth(160);
    dbObjectCol.getColumn().setText(Messages.tableLabel);
    whereCnd.getColumn().setWidth(120);
    whereCnd.getColumn().setText(Messages.conditionLabel);
    final Button selectAllBtn = new Button(leftComposite, SWT.CHECK);
    {
        selectAllBtn.setText(Messages.btnSelectAll);
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalIndent = 0;
        gridData.horizontalSpan = 3;
        selectAllBtn.setLayoutData(gridData);
    }
    selectAllBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            boolean selection = selectAllBtn.getSelection();
            for (ICubridNode node : tablesOrViewLst) {
                treeViewer.setGrayed(node, false);
                treeViewer.setChecked(node, selection);
            }
            updateDialogStatus(null);
        }
    });
    /* Export content option */
    Group exportOptionGroup = new Group(rightComposite, SWT.None);
    exportOptionGroup.setText(Messages.exportWizardWhatExport);
    exportOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    RowLayout layout = new RowLayout();
    layout.spacing = 8;
    layout.marginWidth = 5;
    exportOptionGroup.setLayout(layout);
    schemaButton = new Button(exportOptionGroup, SWT.CHECK);
    schemaButton.setText(Messages.lblExportTargetSchema);
    schemaButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            boolean selection = schemaButton.getSelection();
            indexButton.setEnabled(selection);
            serialButton.setEnabled(selection);
            viewButton.setEnabled(selection);
            startValueButton.setEnabled(selection);
            updateDialogStatus(null);
        }
    });
    dataButton = new Button(exportOptionGroup, SWT.CHECK);
    dataButton.setText(Messages.lblExportTargetData);
    dataButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    indexButton = new Button(exportOptionGroup, SWT.CHECK);
    indexButton.setText(Messages.lblExportTargetIndex);
    serialButton = new Button(exportOptionGroup, SWT.CHECK);
    serialButton.setText(Messages.lblExportTargetSerial);
    viewButton = new Button(exportOptionGroup, SWT.CHECK);
    viewButton.setText(Messages.lblExportTargetView);
    exportLobButton = new Button(exportOptionGroup, SWT.CHECK);
    exportLobButton.setText(Messages.lblExportLobData);
    exportLobButton.setToolTipText(Messages.lblExportLobData);
    exportLobButton.setEnabled(false);
    startValueButton = new Button(exportOptionGroup, SWT.CHECK);
    startValueButton.setText(Messages.lblExportTargetStartValue);
    startValueButton.setToolTipText(Messages.tipExportTargetStartValue);
    /* Type group */
    Group typeOptionGroup = new Group(rightComposite, SWT.None);
    typeOptionGroup.setText(Messages.exportWizardWhereExport);
    typeOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    typeOptionGroup.setLayout(new GridLayout(2, false));
    Label typeLabel = new Label(typeOptionGroup, SWT.None);
    typeLabel.setText(Messages.exportWizardFileType);
    typeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    Composite typeComposite = new Composite(typeOptionGroup, SWT.None);
    typeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    typeComposite.setLayout(new GridLayout(6, false));
    sqlButton = new Button(typeComposite, SWT.RADIO);
    sqlButton.setText("SQL");
    sqlButton.setToolTipText("SQL");
    sqlButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    sqlButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(false);
            setNullWidgetStatus(false);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    csvButton = new Button(typeComposite, SWT.RADIO);
    csvButton.setText("CSV");
    csvButton.setToolTipText("CSV");
    csvButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    csvButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    xlsButton = new Button(typeComposite, SWT.RADIO);
    xlsButton.setText("XLS");
    xlsButton.setToolTipText("XLS");
    xlsButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    xlsButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    xlsxButton = new Button(typeComposite, SWT.RADIO);
    xlsxButton.setText("XLSX");
    xlsxButton.setToolTipText("XLSX");
    xlsxButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    xlsxButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    txtButton = new Button(typeComposite, SWT.RADIO);
    txtButton.setText("TXT");
    txtButton.setToolTipText("TXT");
    txtButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    txtButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(true);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    obsButton = new Button(typeComposite, SWT.RADIO);
    obsButton.setText("OBS");
    obsButton.setToolTipText("OBS");
    obsButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    obsButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            useFirstAsColumnBtn.setEnabled(false);
            setNullWidgetStatus(false);
            setDelimiterWidgetStatus(false);
            updateDialogStatus(null);
            updateExportLobButtonStatus();
        }
    });
    Label pathLabel = new Label(typeOptionGroup, SWT.None);
    pathLabel.setText(Messages.exportWizardFilepath);
    pathLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    Composite fileComposite = new Composite(typeOptionGroup, SWT.None);
    fileComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    fileComposite.setLayout(new GridLayout(2, false));
    pathText = new Text(fileComposite, SWT.BORDER);
    pathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    pathText.setEditable(false);
    Button browseButton = new Button(fileComposite, SWT.None);
    browseButton.setText(Messages.btnBrowse);
    browseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    browseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            File savedDirFile = TableUtil.getSavedDir(getShell(), Messages.titleSelectFolderToBeExported, Messages.msgSelectFolderToBeExported, pathText.getText());
            if (savedDirFile != null) {
                String savePathString = null;
                String[] files = savedDirFile.list();
                String databaseName = getDatabase().getDatabaseInfo().getDbName();
                if (files != null && files.length > 0) {
                    String confirmMessage = Messages.bind(Messages.errorExportExistsFilesInFolder, databaseName);
                    boolean useCreate = CommonUITool.openConfirmBox(confirmMessage);
                    if (useCreate) {
                        File newFolder = new File(savedDirFile.getAbsolutePath() + File.separator + databaseName);
                        boolean existsDbNameFolder = newFolder.exists();
                        files = newFolder.list();
                        if (existsDbNameFolder && files != null && files.length > 0) {
                            String newFolderName = databaseName + "_" + DateUtil.getDatetimeStringOnNow("HHmmss");
                            savePathString = savedDirFile.getAbsolutePath() + File.separator + newFolderName;
                            String warnMessage = Messages.bind(Messages.errorExportExistsFilesInFolderWithRename, newFolderName);
                            CommonUITool.openWarningBox(warnMessage);
                        } else {
                            savePathString = savedDirFile.getAbsolutePath() + File.separator + databaseName;
                        }
                        new File(savePathString).mkdirs();
                    } else {
                        return;
                    }
                } else {
                    savePathString = savedDirFile.getAbsolutePath();
                }
                pathText.setText(savePathString);
            }
            updateDialogStatus(null);
        }
    });
    Group parsingGroup = new Group(rightComposite, SWT.None);
    parsingGroup.setText(Messages.exportWizardParsingOption);
    parsingGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    GridLayout parsingGroupLayout = new GridLayout(4, false);
    parsingGroupLayout.horizontalSpacing = 10;
    parsingGroup.setLayout(parsingGroupLayout);
    Label threadCountLabel = new Label(parsingGroup, SWT.None);
    threadCountLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    threadCountLabel.setText(Messages.lblThreadCount);
    threadCountSpinner = new Spinner(parsingGroup, SWT.BORDER | SWT.LEFT);
    threadCountSpinner.setValues(DEFAULT_EXPORT_THREAD_COUNT, MIN_EXPORT_THREAD_COUNT, MAX_EXPORT_THREAD_COUNT, 0, 1, 2);
    threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1, 1, -1, -1));
    Label emptyLabel = new Label(parsingGroup, SWT.None);
    emptyLabel.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
    emptyLabel.setText("");
    Label dbCharsetLabel = new Label(parsingGroup, SWT.None);
    dbCharsetLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dbCharsetLabel.setText(Messages.lblJDBCCharset);
    dbCharsetCombo = new Combo(parsingGroup, SWT.BORDER);
    dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dbCharsetCombo.setItems(QueryOptions.getAllCharset(null));
    dbCharsetCombo.setEnabled(false);
    Label fileCharsetLabel = new Label(parsingGroup, SWT.None);
    fileCharsetLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    fileCharsetLabel.setText(Messages.lblFileCharset);
    fileCharsetCombo = new Combo(parsingGroup, SWT.BORDER);
    fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, 21));
    fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
    Group dataOptionGroup = new Group(rightComposite, SWT.None);
    dataOptionGroup.setText(Messages.exportWizardDataOption);
    dataOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    dataOptionGroup.setLayout(new GridLayout(2, false));
    useFirstAsColumnBtn = new Button(dataOptionGroup, SWT.CHECK);
    {
        useFirstAsColumnBtn.setText(Messages.exportFirstLineFLAG);
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalIndent = 0;
        gridData.horizontalSpan = 2;
        useFirstAsColumnBtn.setLayoutData(gridData);
        useFirstAsColumnBtn.setSelection(false);
    }
    Group delimiterOptionGroup = new Group(dataOptionGroup, SWT.None);
    delimiterOptionGroup.setText(Messages.exportWizardDelimiterOptions);
    delimiterOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    delimiterOptionGroup.setLayout(new GridLayout(2, false));
    Label columnLabel = new Label(delimiterOptionGroup, SWT.None);
    columnLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    columnLabel.setText(Messages.exportWizardColumnSeperator);
    columnDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
    columnDelimiterCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    columnDelimiterCombo.setTextLimit(32);
    columnDelimiterCombo.setItems(columnDelimeterName);
    columnDelimiterCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus(null);
        }
    });
    Label rowLabel = new Label(delimiterOptionGroup, SWT.None);
    rowLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    rowLabel.setText(Messages.exportWizardRowSeperator);
    rowDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
    rowDelimiterCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    rowDelimiterCombo.setTextLimit(32);
    rowDelimiterCombo.setItems(rowDelimeterName);
    rowDelimiterCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus(null);
        }
    });
    Group nullValueGroup = new Group(dataOptionGroup, SWT.None);
    nullValueGroup.setText(Messages.exportWizardNullOptions);
    nullValueGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    nullValueGroup.setLayout(new GridLayout(3, false));
    nullOneButton = new Button(nullValueGroup, SWT.RADIO);
    nullOneButton.setText("'NULL'");
    nullOneButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nullTwoButton = new Button(nullValueGroup, SWT.RADIO);
    nullTwoButton.setText("'\\N'");
    nullTwoButton.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
    nullThreeButton = new Button(nullValueGroup, SWT.RADIO);
    nullThreeButton.setText("'(NULL)'");
    nullThreeButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    otherButton = new Button(nullValueGroup, SWT.RADIO);
    otherButton.setText(Messages.btnOther);
    otherButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    otherButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            updateDialogStatus(null);
        }
    });
    otherText = new Text(nullValueGroup, SWT.BORDER);
    otherText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    otherText.setTextLimit(64);
    otherText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus(null);
        }
    });
    useFirstAsColumnBtn.setEnabled(false);
    setNullWidgetStatus(false);
    setDelimiterWidgetStatus(false);
}
Also used : Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Spinner(org.eclipse.swt.widgets.Spinner) Label(org.eclipse.swt.widgets.Label) EditingSupport(org.eclipse.jface.viewers.EditingSupport) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) FilterTreeContentProvider(com.cubrid.common.ui.common.dialog.FilterTreeContentProvider) ExportObjectLabelProvider(com.cubrid.common.ui.common.navigator.ExportObjectLabelProvider) GridData(org.eclipse.swt.layout.GridData) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) File(java.io.File) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 79 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);
    tblHostList = hostListView.getTable();
    final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdColumnsTable.horizontalSpan = 3;
    gdColumnsTable.heightHint = 189;
    tblHostList.setLayoutData(gdColumnsTable);
    tblHostList.setLinesVisible(true);
    tblHostList.setHeaderVisible(true);
    final TableColumn hostName = new TableColumn(tblHostList, SWT.NONE);
    hostName.setAlignment(SWT.LEFT);
    hostName.setWidth(WIDTH_NAME);
    hostName.setText(Messages.columnHeaderServerInfo);
    if (export) {
        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);
            handleSelectAll(selectAll);
        }
    });
    final TableColumn hostAddress = new TableColumn(tblHostList, SWT.NONE);
    hostAddress.setAlignment(SWT.CENTER);
    hostAddress.setWidth(WIDTH_ADDRESS);
    hostAddress.setText(Messages.columnHeaderServerAddress);
    final TableColumn hostPort = new TableColumn(tblHostList, SWT.NONE);
    hostPort.setAlignment(SWT.CENTER);
    hostPort.setWidth(WIDTH_PORT);
    hostPort.setText(Messages.columnHeaderServerPort);
    final TableColumn jdbcVer = new TableColumn(tblHostList, SWT.NONE);
    jdbcVer.setAlignment(SWT.CENTER);
    jdbcVer.setWidth(WIDTH_JDBC);
    jdbcVer.setText(Messages.columnHeaderServerJdbcVersion);
    final TableColumn hostUser = new TableColumn(tblHostList, SWT.NONE);
    hostUser.setAlignment(SWT.CENTER);
    hostUser.setWidth(WIDTH_USER);
    hostUser.setText(Messages.columnHeaderServerUserName);
    final TableColumn savedPass = new TableColumn(tblHostList, SWT.NONE);
    savedPass.setAlignment(SWT.CENTER);
    savedPass.setWidth(WIDTH_SAVEPASS);
    savedPass.setText(Messages.columnHeaderServerAutoSave);
    DatabaseInfoTableViewerContentProvider contentProvider = new DatabaseInfoTableViewerContentProvider();
    DatabaseInfoTableViewerLabelProvider labelProvider = new DatabaseInfoTableViewerLabelProvider();
    hostListView.setContentProvider(contentProvider);
    hostListView.setLabelProvider(labelProvider);
    hostListView.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            boolean isSelect = event.getChecked();
            Object obj = event.getElement();
            if (obj instanceof DatabaseUIWrapper) {
                ((DatabaseUIWrapper) obj).setSeleted(isSelect);
            }
            updateWidgetStatus();
        }
    });
    hostListView.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent arg0) {
            ImportExportConnectionDialog.this.getButton(IDialogConstants.OK_ID).setEnabled(hostListView.getCheckedElements().length > 0);
        }
    });
    if (export) {
        initTableData();
        setSelectAll(true);
    }
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) DatabaseInfoTableViewerContentProvider(com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Image(org.eclipse.swt.graphics.Image) DatabaseUIWrapper(com.cubrid.cubridquery.ui.spi.model.DatabaseUIWrapper) TableColumn(org.eclipse.swt.widgets.TableColumn) DatabaseInfoTableViewerLabelProvider(com.cubrid.cubridquery.ui.connection.editor.DatabaseInfoTableViewerLabelProvider) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 80 with CheckStateChangedEvent

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

the class SelectTableComp method createTableGroup.

/**
	 * 
	 * Create the group of select tables
	 * 
	 * @param parent Composite
	 */
public void createTableGroup(Composite parent) {
    Group replTableInfoGroup = new Group(parent, SWT.NONE);
    replTableInfoGroup.setText(Messages.chsldb2grpSelectTablesPage);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    replTableInfoGroup.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    replTableInfoGroup.setLayout(layout);
    allTableBtn = new Button(replTableInfoGroup, SWT.CHECK);
    allTableBtn.setText(Messages.btnSelectAllTables);
    allTableBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    allTableBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (allTableBtn.getSelection()) {
                for (int i = 0; i < selectClassesTable.getItemCount(); i++) {
                    selectClassesTable.getItem(i).setChecked(true);
                }
            } else {
                for (int i = 0; i < selectClassesTable.getItemCount(); i++) {
                    selectClassesTable.getItem(i).setChecked(false);
                }
            }
        }
    });
    String[] columnNameArr = new String[] { Messages.tblColTableName };
    tableViewer = (CheckboxTableViewer) CommonUITool.createCheckBoxTableViewer(replTableInfoGroup, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 150));
    selectClassesTable = tableViewer.getTable();
    tableViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            allTableBtn.setSelection(false);
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) 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)

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