Search in sources :

Example 11 with TreeViewerColumn

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

the class KeysPreferencePage method createTree.

private void createTree(Composite parent) {
    fPatternFilter = new CategoryPatternFilter(true, fDefaultCategory);
    fPatternFilter.filterCategories(true);
    GridData gridData;
    fFilteredTree = new CategoryFilterTree(parent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION, fPatternFilter);
    final GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    fFilteredTree.setLayout(layout);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.verticalAlignment = SWT.FILL;
    fFilteredTree.setLayoutData(gridData);
    viewer = fFilteredTree.getViewer();
    // Make sure the filtered tree has a height of ITEMS_TO_SHOW
    final Tree tree = viewer.getTree();
    tree.setHeaderVisible(true);
    final Object layoutData = tree.getLayoutData();
    if (layoutData instanceof GridData) {
        gridData = (GridData) layoutData;
        final int itemHeight = tree.getItemHeight();
        if (itemHeight > 1) {
            gridData.heightHint = ITEMS_TO_SHOW * itemHeight;
        }
    }
    BindingModelComparator comparator = new BindingModelComparator();
    comparator.setSortColumn(2);
    viewer.setComparator(comparator);
    final TreeColumn commandNameColumn = new TreeColumn(tree, SWT.LEFT, COMMAND_NAME_COLUMN);
    commandNameColumn.setText(Messages.getString("preferencepage.KeysPreferencePage.commandNameColumn"));
    tree.setSortColumn(commandNameColumn);
    tree.setSortDirection(comparator.isAscending() ? SWT.UP : SWT.DOWN);
    commandNameColumn.addSelectionListener(new ResortColumn(comparator, commandNameColumn, viewer, COMMAND_NAME_COLUMN));
    final TreeViewerColumn triggerSequenceColumn = new TreeViewerColumn(viewer, SWT.LEFT, KEY_SEQUENCE_COLUMN);
    triggerSequenceColumn.getColumn().setText(Messages.getString("preferencepage.KeysPreferencePage.triggerSequenceColumn"));
    triggerSequenceColumn.getColumn().addSelectionListener(new ResortColumn(comparator, triggerSequenceColumn.getColumn(), viewer, KEY_SEQUENCE_COLUMN));
    triggerSequenceColumn.setEditingSupport(new TableViewerEditingSupport(viewer, 1));
    final TreeColumn categoryColumn = new TreeColumn(tree, SWT.LEFT, CATEGORY_COLUMN);
    categoryColumn.setText(Messages.getString("preferencepage.KeysPreferencePage.categoryColumn"));
    categoryColumn.addSelectionListener(new ResortColumn(comparator, categoryColumn, viewer, CATEGORY_COLUMN));
    viewer.setContentProvider(new ModelContentProvider());
    viewer.setLabelProvider(new BindingElementLabelProvider());
    fFilteredTree.getPatternFilter().setIncludeLeadingWildcard(true);
    final TreeColumn[] columns = viewer.getTree().getColumns();
    columns[COMMAND_NAME_COLUMN].setWidth(240);
    columns[KEY_SEQUENCE_COLUMN].setWidth(130);
    columns[CATEGORY_COLUMN].setWidth(130);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        // When the viewer changes selection, update the model's current
        // selection
        public void selectionChanged(SelectionChangedEvent event) {
            changeBackground();
            ModelElement binding = (ModelElement) ((IStructuredSelection) event.getSelection()).getFirstElement();
            model.setSelectedElement(binding);
        }
    });
    IPropertyChangeListener treeUpdateListener = new IPropertyChangeListener() {

        // When the model changes a property, update the viewer
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getSource() == model && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
                Object newVal = event.getNewValue();
                StructuredSelection structuredSelection = newVal == null ? null : new StructuredSelection(newVal);
                viewer.setSelection(structuredSelection, true);
            } else if (event.getSource() instanceof BindingElement && ModelElement.PROP_MODEL_OBJECT.equals(event.getProperty())) {
                viewer.update(event.getSource(), null);
            } else if (BindingElement.PROP_CONFLICT.equals(event.getProperty())) {
                viewer.update(event.getSource(), null);
            } else if (BindingModel.PROP_BINDINGS.equals(event.getProperty())) {
            // viewer.refresh();
            } else if (BindingModel.PROP_BINDING_ADD.equals(event.getProperty())) {
                viewer.add(model, event.getNewValue());
            } else if (BindingModel.PROP_BINDING_REMOVE.equals(event.getProperty())) {
                viewer.remove(event.getNewValue());
            } else if (BindingModel.PROP_BINDING_FILTER.equals(event.getProperty())) {
            // viewer.refresh();
            }
            changeBackground();
        // isValid();
        }
    };
    keyController.addPropertyChangeListener(treeUpdateListener);
    // IPropertyChangeListener conflictsListener = new IPropertyChangeListener() {
    // public void propertyChange(PropertyChangeEvent event) {
    // // System.out.println(event.getNewValue().getClass());
    // if (keyController.getConflictModel().getConflicts() != null) {
    // if (ConflictModel.PROP_CONFLICTS.equals(event.getProperty())) {
    // // lstConflict.clear();
    // if (event.getNewValue() != null) {
    // lstConflict.addAll((Collection<? extends Object>) event.getNewValue());
    // }
    // // conflictViewer.setInput(event.getNewValue());
    // } else if (ConflictModel.PROP_CONFLICTS_ADD.equals(event.getProperty())) {
    // if (event.getNewValue() != null) {
    // lstConflict.add(event.getNewValue());
    // }
    // // conflictViewer.add(event.getNewValue());
    // } else if (ConflictModel.PROP_CONFLICTS_REMOVE.equals(event.getProperty())) {
    // // conflictViewer.remove(event.getNewValue());
    // if (event.getNewValue() != null) {
    // lstConflict.remove(event.getNewValue());
    // }
    // }
    // } else {
    // lstConflict.clear();
    // }
    // // if (event.getSource() == keyController.getConflictModel()
    // // && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
    // // if (keyController.getConflictModel().getConflicts() != null) {
    // // Object newVal = event.getNewValue();
    // // StructuredSelection structuredSelection = newVal == null ? null : new StructuredSelection(
    // // newVal);
    // // // conflictViewer.setSelection(structuredSelection, true);
    // // }
    // // } else if (ConflictModel.PROP_CONFLICTS.equals(event.getProperty())) {
    // // // lstConflict.clear();
    // // if (event.getNewValue() != null) {
    // // lstConflict.addAll((Collection<? extends Object>) event.getNewValue());
    // // }
    // // // conflictViewer.setInput(event.getNewValue());
    // // } else if (ConflictModel.PROP_CONFLICTS_ADD.equals(event.getProperty())) {
    // // if (event.getNewValue() != null) {
    // // lstConflict.clear();
    // // lstConflict.add(event.getNewValue());
    // // }
    // // // conflictViewer.add(event.getNewValue());
    // // } else if (ConflictModel.PROP_CONFLICTS_REMOVE.equals(event.getProperty())) {
    // // // conflictViewer.remove(event.getNewValue());
    // // if (event.getNewValue() != null) {
    // // lstConflict.clear();
    // // lstConflict.remove(event.getNewValue());
    // // }
    // // }
    // }
    // };
    // keyController.addPropertyChangeListener(conflictsListener);
    IPropertyChangeListener dataUpdateListener = new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            BindingElement bindingElement = null;
            boolean weCare = false;
            if (event.getSource() == model && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
                bindingElement = (BindingElement) event.getNewValue();
                weCare = true;
            } else if (event.getSource() == model.getSelectedElement() && ModelElement.PROP_MODEL_OBJECT.equals(event.getProperty())) {
                bindingElement = (BindingElement) event.getSource();
                weCare = true;
            }
            if (bindingElement == null && weCare) {
                //$NON-NLS-1$
                fBindingText.setText("");
            } else if (bindingElement != null) {
                KeySequence trigger = (KeySequence) bindingElement.getTrigger();
                fKeySequenceText.setKeySequence(trigger);
            }
        }
    };
    keyController.addPropertyChangeListener(dataUpdateListener);
}
Also used : BindingElement(org.eclipse.ui.internal.keys.model.BindingElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ModelElement(org.eclipse.ui.internal.keys.model.ModelElement) GridLayout(org.eclipse.swt.layout.GridLayout) TreeColumn(org.eclipse.swt.widgets.TreeColumn) Tree(org.eclipse.swt.widgets.Tree) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) GridData(org.eclipse.swt.layout.GridData) KeySequence(org.eclipse.jface.bindings.keys.KeySequence)

Example 12 with TreeViewerColumn

use of org.eclipse.jface.viewers.TreeViewerColumn 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 13 with TreeViewerColumn

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

the class ServiceDashboardEditor method createPartControl.

public void createPartControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    composite.setLayout(layout);
    Composite buttonComp = new Composite(composite, SWT.None);
    buttonComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 24));
    Composite dataComp = new Composite(composite, SWT.None);
    dataComp.setLayout(new FillLayout());
    dataComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    /*Create button*/
    createButtonComposite(buttonComp);
    serviceTreeViewer = new TreeViewer(dataComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    serviceTreeViewer.getTree().setHeaderVisible(true);
    serviceTreeViewer.getTree().setLinesVisible(true);
    ColumnViewerToolTipSupport.enableFor(serviceTreeViewer, ToolTip.NO_RECREATE);
    final TreeColumn hostColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    hostColumn.setText(Messages.columnGroupOrHost);
    hostColumn.setWidth(200);
    serviceTreeViewer.setSorter(ServiceDashboardEditorSorter.Name_ASC);
    setColumnSorter(hostColumn, ServiceDashboardEditorSorter.Name_ASC, ServiceDashboardEditorSorter.Name_DESC);
    /*TreeColumn statusColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
		statusColumn.setText(Messages.columnStatus);
		statusColumn.setWidth(100);*/
    final TreeColumn ipColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    ipColumn.setText(Messages.columnAddress);
    ipColumn.setWidth(100);
    setColumnSorter(ipColumn, ServiceDashboardEditorSorter.Address_ASC, ServiceDashboardEditorSorter.Address_DESC);
    TreeColumn portColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    portColumn.setText(Messages.columnPort);
    portColumn.pack();
    setColumnSorter(portColumn, ServiceDashboardEditorSorter.Port_ASC, ServiceDashboardEditorSorter.Port_DESC);
    TreeColumn userColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    userColumn.setText(Messages.columnUser);
    userColumn.pack();
    setColumnSorter(userColumn, ServiceDashboardEditorSorter.User_ASC, ServiceDashboardEditorSorter.User_DESC);
    TreeViewerColumn volumnColumnData = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
    volumnColumnData.getColumn().setText(Messages.columnData);
    volumnColumnData.getColumn().setToolTipText(Messages.columnDataTip);
    volumnColumnData.getColumn().pack();
    setColumnSorter(volumnColumnData.getColumn(), ServiceDashboardEditorSorter.Data_ASC, ServiceDashboardEditorSorter.Data_DESC);
    TreeViewerColumn volumnColumnIndex = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
    volumnColumnIndex.getColumn().setText(Messages.columnIndex);
    volumnColumnIndex.getColumn().setToolTipText(Messages.columnIndexTip);
    volumnColumnIndex.getColumn().pack();
    setColumnSorter(volumnColumnIndex.getColumn(), ServiceDashboardEditorSorter.Index_ASC, ServiceDashboardEditorSorter.Index_DESC);
    TreeViewerColumn volumnColumnTemp = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
    volumnColumnTemp.getColumn().setText(Messages.columnTemp);
    volumnColumnTemp.getColumn().setToolTipText(Messages.columnTempTip);
    volumnColumnTemp.getColumn().pack();
    setColumnSorter(volumnColumnTemp.getColumn(), ServiceDashboardEditorSorter.Temp_ASC, ServiceDashboardEditorSorter.Temp_DESC);
    TreeViewerColumn volumnColumnGeneric = new TreeViewerColumn(serviceTreeViewer, SWT.LEFT);
    volumnColumnGeneric.getColumn().setText(Messages.columnGeneric);
    volumnColumnGeneric.getColumn().setToolTipText(Messages.columnGenericTip);
    volumnColumnGeneric.getColumn().pack();
    setColumnSorter(volumnColumnGeneric.getColumn(), ServiceDashboardEditorSorter.Generic_ASC, ServiceDashboardEditorSorter.Generic_DESC);
    TreeColumn tpsColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    tpsColumn.setText(Messages.columnTps);
    tpsColumn.setWidth(50);
    setColumnSorter(tpsColumn, ServiceDashboardEditorSorter.Tps_ASC, ServiceDashboardEditorSorter.Tps_DESC);
    TreeColumn qpsColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    qpsColumn.setText(Messages.columnQps);
    qpsColumn.setWidth(50);
    setColumnSorter(qpsColumn, ServiceDashboardEditorSorter.Qps_ASC, ServiceDashboardEditorSorter.Qps_DESC);
    TreeColumn errorColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    errorColumn.setText(Messages.columnErrorQ);
    errorColumn.setWidth(50);
    setColumnSorter(errorColumn, ServiceDashboardEditorSorter.ErrorQ_ASC, ServiceDashboardEditorSorter.ErrorQ_DESC);
    TreeColumn memColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    memColumn.setText(Messages.columnMemory);
    memColumn.setWidth(100);
    setColumnSorter(memColumn, ServiceDashboardEditorSorter.Memory_ASC, ServiceDashboardEditorSorter.Memory_DESC);
    TreeColumn diskColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    diskColumn.setText(Messages.columnDisk);
    diskColumn.setWidth(60);
    setColumnSorter(diskColumn, ServiceDashboardEditorSorter.Disk_ASC, ServiceDashboardEditorSorter.Disk_DESC);
    TreeColumn cpuColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    cpuColumn.setText(Messages.columnCpu);
    cpuColumn.pack();
    setColumnSorter(cpuColumn, ServiceDashboardEditorSorter.Cpu_ASC, ServiceDashboardEditorSorter.Cpu_DESC);
    TreeColumn dbColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    dbColumn.setText(Messages.columnDbOnOff);
    dbColumn.setWidth(80);
    setColumnSorter(dbColumn, ServiceDashboardEditorSorter.DbStatus_ASC, ServiceDashboardEditorSorter.DbStatus_DESC);
    TreeColumn verColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    verColumn.setText(Messages.columnVersion);
    verColumn.setWidth(70);
    setColumnSorter(verColumn, ServiceDashboardEditorSorter.Version_ASC, ServiceDashboardEditorSorter.Version_DESC);
    TreeColumn brokerPortColumn = new TreeColumn(serviceTreeViewer.getTree(), SWT.LEFT);
    brokerPortColumn.setText(Messages.columnBrokerPort);
    brokerPortColumn.setWidth(120);
    setColumnSorter(brokerPortColumn, ServiceDashboardEditorSorter.BrokerPort_ASC, ServiceDashboardEditorSorter.BrokerPort_DESC);
    serviceTreeViewer.setContentProvider(new ServiceDashboardContentProvider());
    serviceTreeViewer.setLabelProvider(new ServiceDashboardLabelProvider());
    addCellTip(volumnColumnData, 1);
    addCellTip(volumnColumnIndex, 2);
    addCellTip(volumnColumnTemp, 3);
    addCellTip(volumnColumnGeneric, 4);
    serviceTreeViewer.getTree().addMouseListener(new MouseListener() {

        public void mouseUp(MouseEvent e) {
        }

        public void mouseDown(MouseEvent e) {
        }

        public void mouseDoubleClick(MouseEvent e) {
            CubridServer[] servers = getSelectedServer();
            if (servers.length == 1) {
                if (!servers[0].isConnected()) {
                    ActionManager manager = ActionManager.getInstance();
                    final ConnectHostAction connectHostAction = (ConnectHostAction) manager.getAction(ConnectHostAction.ID);
                    connectHostAction.doRun(getSelectedServer());
                    loadAllData();
                }
            }
        }
    });
    initMenu(serviceTreeViewer.getTree());
}
Also used : ActionManager(com.cubrid.common.ui.spi.action.ActionManager) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) ConnectHostAction(com.cubrid.cubridmanager.ui.host.action.ConnectHostAction) DisConnectHostAction(com.cubrid.cubridmanager.ui.host.action.DisConnectHostAction) FillLayout(org.eclipse.swt.layout.FillLayout) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn)

Example 14 with TreeViewerColumn

use of org.eclipse.jface.viewers.TreeViewerColumn in project bndtools by bndtools.

the class BundleTree method createInfoViewer.

private void createInfoViewer(Composite container) {
    infoViewerComposite = new Composite(container, SWT.NONE);
    infoViewerComposite.setLayoutData(createFillGridData());
    TreeColumnLayout layout = new TreeColumnLayout();
    infoViewerComposite.setLayout(layout);
    infoViewer = new TreeViewer(infoViewerComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    infoViewer.setUseHashlookup(true);
    infoViewer.getTree().setHeaderVisible(true);
    TreeViewerColumn treeViewerColumn = new TreeViewerColumn(infoViewer, SWT.NONE);
    TreeColumn treeColumn = treeViewerColumn.getColumn();
    layout.setColumnData(treeColumn, new ColumnWeightData(450, 180, true));
    treeColumn.setText(Messages.bundleAndPackageName);
    treeViewerColumn.setLabelProvider(new InfoLabelProvider());
    treeViewerColumn = new TreeViewerColumn(infoViewer, SWT.NONE);
    treeColumn = treeViewerColumn.getColumn();
    layout.setColumnData(treeColumn, new ColumnWeightData(80, 80, true));
    treeColumn.setText(Messages.version2);
    treeViewerColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof Baseline) {
                return ((Baseline) element).getOlderVersion().getWithoutQualifier().toString();
            }
            if (element instanceof Info) {
                return ((Info) element).olderVersion.toString();
            }
            //$NON-NLS-1$
            return "";
        }
    });
    treeViewerColumn = new TreeViewerColumn(infoViewer, SWT.NONE);
    treeColumn = treeViewerColumn.getColumn();
    layout.setColumnData(treeColumn, new ColumnWeightData(80, 80, true));
    treeColumn.setText(Messages.newVersion);
    treeViewerColumn.setLabelProvider(new ColumnLabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof Baseline) {
                return ((Baseline) element).getSuggestedVersion().toString();
            }
            if (element instanceof Info) {
                //$NON-NLS-1$
                return ((Info) element).suggestedVersion != null ? ((Info) element).suggestedVersion.toString() : "";
            }
            //$NON-NLS-1$
            return "";
        }
    });
    treeViewerColumn.setEditingSupport(new InlineComboEditingSupport(infoViewer));
    infoViewer.setContentProvider(infoTreeViewerProvider);
    infoViewer.setAutoExpandLevel(2);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Baseline(aQute.bnd.differ.Baseline) Info(aQute.bnd.differ.Baseline.Info) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) TreeColumn(org.eclipse.swt.widgets.TreeColumn)

Example 15 with TreeViewerColumn

use of org.eclipse.jface.viewers.TreeViewerColumn in project linuxtools by eclipse.

the class CachegrindViewPart method refreshView.

@Override
public void refreshView() {
    if (outputs != null && outputs.length > 0) {
        String[] events = outputs[0].getEvents();
        for (int i = 0; i < events.length; i++) {
            TreeViewerColumn column = new TreeViewerColumn(viewer, SWT.NONE);
            column.getColumn().setText(events[i]);
            column.getColumn().setWidth(COLUMN_SIZE);
            column.getColumn().setToolTipText(getFullEventName(events[i]));
            column.getColumn().setResizable(true);
            column.getColumn().addSelectionListener(getHeaderListener());
            column.setLabelProvider(labelProvider);
        }
        viewer.setInput(outputs);
        viewer.getTree().layout(true);
    }
}
Also used : TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn)

Aggregations

TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)17 Composite (org.eclipse.swt.widgets.Composite)10 TreeViewer (org.eclipse.jface.viewers.TreeViewer)9 GridLayout (org.eclipse.swt.layout.GridLayout)8 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)7 GridData (org.eclipse.swt.layout.GridData)7 TreeColumn (org.eclipse.swt.widgets.TreeColumn)7 Tree (org.eclipse.swt.widgets.Tree)6 TreeColumnLayout (org.eclipse.jface.layout.TreeColumnLayout)5 ArrayList (java.util.ArrayList)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 CellEditor (org.eclipse.jface.viewers.CellEditor)3 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)3 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)3 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)3 EditingSupport (org.eclipse.jface.viewers.EditingSupport)3 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3