Search in sources :

Example 16 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project tdi-studio-se by Talend.

the class HotSpotsTabPage method createHotSpotsViewer.

/**
     * Creates the hot spots viewer.
     * 
     * @param composite The parent composite
     * @param propertySheet The property sheet
     */
private void createHotSpotsViewer(Composite composite, PropertySheet propertySheet) {
    filteredTree = new HotSpotsFilteredTree(composite, propertySheet.getViewSite().getActionBars()) {

        @Override
        protected void addMenus(IMenuManager manager) {
            manager.add(new Separator());
            manager.add(new ConfigureCpuProfilerAction(cpuSection));
        }
    };
    TreeViewer hotSpotsViewer = filteredTree.getViewer();
    hotSpotsViewer.setContentProvider(new AbstractContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ICpuModel) {
                return ((ICpuModel) inputElement).getHotSpotRoots();
            }
            return new Object[0];
        }
    });
    hotSpotsViewer.setLabelProvider(new HotSpotsLabelProvider(filteredTree));
    hotSpotsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            filteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });
    filteredTree.sortColumn(hotSpotsViewer.getTree().getColumn(1));
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICpuModel(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModel) ConfigureCpuProfilerAction(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.ConfigureCpuProfilerAction) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 17 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project tdi-studio-se by Talend.

the class CallerCalleeTabPage method createCalleeViewer.

/**
     * Creates the callee viewer.
     * 
     * @param parent The parent composite
     * @param propertySheet The property sheet
     */
private void createCalleeViewer(Composite parent, PropertySheet propertySheet) {
    calleeFilteredTree = new HotSpotsFilteredTree(parent, propertySheet.getViewSite().getActionBars()) {

        @Override
        protected void addMenus(IMenuManager manager) {
            manager.add(new Separator());
            manager.add(new ConfigureCpuProfilerAction(cpuSection));
        }

        @Override
        public ViewerType getViewerType() {
            return ViewerType.Callee;
        }

        @Override
        protected String getMethodColumnName() {
            return Messages.calleeColumnLabel;
        }

        @Override
        protected String getMethodColumnToolTip() {
            return Messages.calleeColumnToolTip;
        }
    };
    TreeViewer calleeViewer = calleeFilteredTree.getViewer();
    calleeViewer.setContentProvider(new AbstractContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ICpuModel) {
                return ((ICpuModel) inputElement).getCallees();
            }
            return new Object[0];
        }
    });
    calleeViewer.setLabelProvider(new HotSpotsLabelProvider(calleeFilteredTree));
    calleeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            calleeFilteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });
    calleeFilteredTree.sortColumn(calleeViewer.getTree().getColumn(1));
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICpuModel(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModel) ConfigureCpuProfilerAction(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.ConfigureCpuProfilerAction) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 18 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project tdi-studio-se by Talend.

the class JSONFileStep1Form method initialize.

/**
     * 
     * Initialize value, forceFocus first field.
     */
@Override
protected void initialize() {
    getConnection().setInputModel(true);
    availableJSONTreeViewer = new TreeViewer(availableJSONTree);
    this.xmlTreePopulator = new TreePopulator(availableJSONTreeViewer);
    // this.xmlTreePopulator.configureDefaultTreeViewer();
    this.jsonTreePopulator = new JsonTreePopulator(availableJSONTreeViewer);
    // this.jsonTreePopulator.configureDefaultTreeViewer();
    this.availableJSONTreeViewer.setUseHashlookup(true);
    // add init of CheckBoxIsGuess and Determine the Initialize checkFileXsdorJSON
    // if (getConnection().getXsdFilePath() != null) {
    // fileFieldXsd.setText(getConnection().getXsdFilePath().replace("\\\\", "\\"));
    // // init the fileViewer
    // this.treePopulator.populateTree(fileFieldXsd.getText(), treeNode);
    // checkFieldsValue();
    // }
    EJsonReadbyMode eJsonReadbyMode = null;
    if (getConnection().getReadbyMode() != null) {
        eJsonReadbyMode = EJsonReadbyMode.getEJsonReadbyModeByValue(getConnection().getReadbyMode());
    }
    if (eJsonReadbyMode == null) {
        eJsonReadbyMode = getDefaultJsonReadbyMode();
    }
    // JSONFileStep1Form.this.wizard.setReadbyMode(readbyCombo.getText());
    readbyCombo.setText(eJsonReadbyMode.getDisplayName());
    getConnection().setReadbyMode(eJsonReadbyMode.getValue());
    JSONFileStep1Form.this.wizard.setReadbyMode(eJsonReadbyMode.getValue());
    if (getConnection().getJSONFilePath() != null) {
        //$NON-NLS-1$ //$NON-NLS-2$
        fileFieldJSON.setText(getConnection().getJSONFilePath().replace("\\\\", "\\"));
        // init the fileViewer
        checkFieldsValue();
        String jsonFilePath = fileFieldJSON.getText();
        if (isContextMode()) {
            ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection());
            jsonFilePath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, fileFieldJSON.getText()));
        }
        File file = new File(jsonFilePath);
        if (!file.exists() && getConnection().getFileContent() != null && getConnection().getFileContent().length > 0) {
            initFileContent();
            jsonFilePath = tempJSONXsdPath;
        }
        String tempxml = null;
        tempxml = getFilePath4Populate(jsonFilePath);
        switchPopulator(JSONFileStep1Form.this.wizard.getReadbyMode(), tempxml);
    }
    // Fields to the Group Delimited File Settings
    if (getConnection().getEncoding() != null && !getConnection().getEncoding().equals("")) {
        //$NON-NLS-1$
        encodingCombo.setText(getConnection().getEncoding());
    } else {
        encodingCombo.select(0);
    }
    encodingCombo.clearSelection();
    // if (getConnection().getMaskXPattern() != null) {
    // fieldMaskXPattern.setText(getConnection().getMaskXPattern().replace("\\\\", "\\"));
    // }
    adaptFormToEditable();
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) JsonTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.JsonTreePopulator) AbstractTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.AbstractTreePopulator) TreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.xml.TreePopulator) TreeViewer(org.eclipse.jface.viewers.TreeViewer) EJsonReadbyMode(org.talend.repository.ui.wizards.metadata.connection.files.json.EJsonReadbyMode) JsonTreePopulator(org.talend.repository.ui.wizards.metadata.connection.files.json.JsonTreePopulator) File(java.io.File)

Example 19 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project tdi-studio-se by Talend.

the class MultiSchemasUI method createHeaderSashForm.

private void createHeaderSashForm(Composite headerComposite) {
    GridLayout layout;
    headerSashForm = new SashForm(headerComposite, SWT.NONE);
    headerSashForm.setLayout(new FillLayout());
    headerSashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
    headerSashForm.setSashWidth(ExternalMultiSchemasUIProperties.SASHFORM_WIDTH);
    //
    multiSchemasFilePreview = new MultiSchemasShadowProcessPreview(this, headerSashForm);
    multiSchemasFilePreview.newTablePreview();
    Composite struComp = new Composite(headerSashForm, SWT.NONE);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    struComp.setLayout(layout);
    headerSashForm.setWeights(ExternalMultiSchemasUIProperties.getHeaderSashformWeights());
    //
    fetchBtn = new Button(struComp, SWT.PUSH);
    fetchBtn.setText(ExternalMultiSchemasUIProperties.FETCH_LABEL);
    fetchBtn.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    //
    schemaTreeViewer = new TreeViewer(struComp, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    Tree tree = schemaTreeViewer.getTree();
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    schemaTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    // SchemasTreeDnD dnd = new SchemasTreeDnD(schemaTreeViewer);
    // dnd.addDragAndDrop();
    schemaTreeViewer.setContentProvider(new SchemasTreeContentProvider());
    schemaTreeViewer.setLabelProvider(new SchemasTreeLabelProvider());
    // schemaTreeViewer.setSorter(new ViewerSorter() {
    //
    // @SuppressWarnings("unchecked")
    // @Override
    // public int compare(Viewer viewer, Object e1, Object e2) {
    // if (e1 instanceof SchemasKeyData && e2 instanceof SchemasKeyData) {
    // return getComparator().compare(((SchemasKeyData) e1).getKeyName(), ((SchemasKeyData) e2).getKeyName());
    // }
    // return super.compare(viewer, e1, e2);
    // }
    //
    // });
    TreeColumn column = new TreeColumn(tree, SWT.LEFT);
    column.setWidth(55);
    //$NON-NLS-1$
    column.setText("Schema");
    column.setResizable(true);
    column = new TreeColumn(tree, SWT.LEFT);
    column.setWidth(100);
    //$NON-NLS-1$
    column.setText("Record");
    column.setResizable(true);
    column = new TreeColumn(tree, SWT.LEFT);
    column.setWidth(20);
    //$NON-NLS-1$
    column.setText("Separator");
    column.setResizable(true);
    schemaTreeViewer.setColumnProperties(new String[] { ExternalMultiSchemasUIProperties.COLUMN_KEY, ExternalMultiSchemasUIProperties.COLUMN_RECORD, ExternalMultiSchemasUIProperties.COLUMN_SEPARATOR });
    // hywang for 10263
    int columnCount = schemaTreeViewer.getTree().getColumnCount();
    CellEditor[] editors = new CellEditor[columnCount];
    for (int i = 0; i < columnCount; i++) {
        editors[i] = new TextCellEditor(schemaTreeViewer.getTree());
    }
    schemaTreeViewer.setCellEditors(editors);
    schemaTreeViewer.setCellModifier(new ICellModifier() {

        public void modify(Object element, String property, Object value) {
            if (element != null) {
                if (element instanceof TreeItem) {
                    TreeItem item = (TreeItem) element;
                    if (item.getData() != null) {
                        if (item.getData() instanceof SchemasKeyData) {
                            SchemasKeyData key = (SchemasKeyData) item.getData();
                            if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_KEY)) {
                                final boolean flag = checkKeyValue(key.getUniqueRecord(), value.toString());
                                if (flag) {
                                    key.setUniqueRecord(value.toString());
                                }
                            }
                            if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_RECORD)) {
                                key.setRecordType(value.toString());
                            }
                            if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_SEPARATOR)) {
                                key.setSeparator(value.toString());
                            }
                        // Object input = schemaTreeViewer.getInput();
                        // SchemasKeyData in = (SchemasKeyData) input;
                        // if (in.getChildren().contains(key)) {
                        // in.getChildren().remove(in.getChildren().indexOf(key));
                        // List<MultiMetadataColumn> colums = multiSchemaManager.createPropertiesColumns(key);
                        // key.setMetadataColumns(colums);
                        // in.getChildren().add(key);
                        // }
                        }
                        schemaTreeViewer.refresh();
                    }
                }
            }
        }

        public Object getValue(Object element, String property) {
            String record = "";
            if (element != null) {
                if (element instanceof SchemasKeyData) {
                    SchemasKeyData key = (SchemasKeyData) element;
                    if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_KEY)) {
                        record = key.getUniqueRecord();
                    }
                    if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_RECORD)) {
                        record = key.getRecordType();
                    }
                    if (property.equals(ExternalMultiSchemasUIProperties.COLUMN_SEPARATOR)) {
                        record = key.getSeparator();
                    }
                }
            }
            return record;
        }

        public boolean canModify(Object element, String property) {
            return true;
        }
    });
    Composite operateTreeComposite = new Composite(struComp, SWT.NONE);
    operateTreeComposite.setLayout(new GridLayout(3, false));
    operateTreeComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
    addRow = new Button(operateTreeComposite, SWT.NONE);
    addRow.setText("Add");
    removeRow = new Button(operateTreeComposite, SWT.NONE);
    removeRow.setText("Remove");
    removeRow.setEnabled(false);
    editSchema = new Button(operateTreeComposite, SWT.NONE);
    editSchema.setText("Edit Columns");
    editSchema.setEnabled(false);
    Composite operation = new Composite(struComp, SWT.NONE);
    operation.setLayout(new GridLayout(2, false));
    operation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    leftBtn = new Button(operation, SWT.PUSH);
    leftBtn.setToolTipText("Left");
    leftBtn.setImage(ImageProvider.getImage(EImage.LEFT_ICON));
    leftBtn.setEnabled(false);
    rightBtn = new Button(operation, SWT.PUSH);
    rightBtn.setToolTipText("Right");
    rightBtn.setImage(ImageProvider.getImage(EImage.RIGHT_ICON));
    rightBtn.setEnabled(false);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) CommandStackForComposite(org.talend.commons.ui.command.CommandStackForComposite) TreeItem(org.eclipse.swt.widgets.TreeItem) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) FillLayout(org.eclipse.swt.layout.FillLayout) SchemasTreeLabelProvider(org.talend.designer.filemultischemas.ui.provider.SchemasTreeLabelProvider) Point(org.eclipse.swt.graphics.Point) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SchemasTreeContentProvider(org.talend.designer.filemultischemas.ui.provider.SchemasTreeContentProvider) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) Tree(org.eclipse.swt.widgets.Tree) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) MultiSchemasShadowProcessPreview(org.talend.designer.filemultischemas.ui.preview.MultiSchemasShadowProcessPreview) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData)

Example 20 with TreeViewer

use of org.eclipse.jface.viewers.TreeViewer in project tdi-studio-se by Talend.

the class MultiSchemasUI method creatButtom.

private void creatButtom(SashForm allContentForm) {
    //
    Composite composite = new Composite(allContentForm, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 2;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    schemaDetailsViewer = new TreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    final Tree tree = schemaDetailsViewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    createCardComposite(composite);
    getUIManager().changeSchemasDetailView(schemaDetailsViewer, getSchemaDetailModel());
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) CommandStackForComposite(org.talend.commons.ui.command.CommandStackForComposite) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)199 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)45 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)38 GridData (org.eclipse.swt.layout.GridData)37 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)36 Tree (org.eclipse.swt.widgets.Tree)34 Composite (org.eclipse.swt.widgets.Composite)33 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)31 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)29 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)28 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)28 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)27 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)27 ArrayList (java.util.ArrayList)24 GridLayout (org.eclipse.swt.layout.GridLayout)23 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)22