Search in sources :

Example 21 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 22 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 23 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 24 with TreeViewer

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

the class ErrorDetailDialog method createTreeTableViewer.

/**
     * DOC chuang Comment method "createTreeTableView".
     * 
     * @param parent
     */
private void createTreeTableViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer = new TreeViewer(composite, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    // init tree
    final Tree tree = viewer.getTree();
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);
    tree.setLayoutData(new GridData(GridData.FILL_BOTH));
    // create tree column
    TreeColumn column = new TreeColumn(tree, SWT.NONE);
    //$NON-NLS-1$
    column.setText("Resource");
    column.setWidth(150);
    column = new TreeColumn(tree, SWT.NONE);
    //$NON-NLS-1$
    column.setText("Description");
    column.setWidth(300);
    viewer.setContentProvider(new ErrorDetailContentProvider());
    viewer.setLabelProvider(new ErrorDetailLabelProvider());
    viewer.setInput(errors);
    viewer.expandAll();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree)

Example 25 with TreeViewer

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

the class JSONFileOutputStep2Form method addJSONFileViewer.

private void addJSONFileViewer(final Composite mainComposite, final int width, final int height) {
    final Group group = Form.createGroup(mainComposite, 1, "Linker Target", height);
    GridData data = new GridData(GridData.FILL_BOTH);
    Composite composite = new Composite(group, SWT.BORDER);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(data);
    JSONViewer = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    data = new GridData(GridData.FILL_BOTH);
    JSONViewer.getControl().setLayoutData(data);
    JSONViewer.setUseHashlookup(true);
    Tree tree = JSONViewer.getTree();
    if (isReadOnly()) {
        tree.setEnabled(false);
    }
    tree.setLinesVisible(true);
    tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("JSON Tree");
    column1.setWidth(120);
    TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
    column2.setText("Related Column");
    column2.setWidth(100);
    TreeColumn column3 = new TreeColumn(tree, SWT.CENTER);
    column3.setText("Node Status");
    column3.setWidth(100);
    TreeColumn column4 = new TreeColumn(tree, SWT.CENTER);
    column4.setText("Default Value");
    column4.setWidth(100);
    tree.setHeaderVisible(true);
    JSONFileTreeViewerProvider provider = new JSONFileTreeViewerProvider();
    JSONViewer.setLabelProvider(provider);
    JSONViewer.setCellModifier(new ICellModifier() {

        public void modify(Object element, String property, Object value) {
            TreeItem treeItem = (TreeItem) element;
            FOXTreeNode node = (FOXTreeNode) treeItem.getData();
            if (property.equals("C1")) {
                node.setLabel((String) value);
            }
            if (property.equals("C4")) {
                node.setDefaultValue((String) value);
            }
            JSONViewer.refresh(node);
        }

        public Object getValue(Object element, String property) {
            FOXTreeNode node = (FOXTreeNode) element;
            if (property.equals("C1")) {
                //$NON-NLS-1$
                return node.getLabel();
            }
            if (property.equals("C4")) {
                //$NON-NLS-1$
                return node.getDefaultValue();
            }
            return null;
        }

        public boolean canModify(Object element, String property) {
            FOXTreeNode node = (FOXTreeNode) element;
            if (property.equals("C1")) {
                if (node.getLabel() != null && node.getLabel().length() > 0) {
                    return true;
                }
            }
            if (property.equals("C4")) {
                if (node.getDefaultValue() != null && node.getDefaultValue().length() > 0) {
                    return true;
                }
            }
            return false;
        }
    });
    JSONViewer.setColumnProperties(new String[] { "C1", "C2", "C3", "C4" });
    CellEditor editor = new TextCellEditor(JSONViewer.getTree());
    editor.addListener(new DialogErrorJSONLabelCellEditor(editor, "C1"));
    CellEditor editorDefault = new TextCellEditor(JSONViewer.getTree());
    editorDefault.addListener(new DialogErrorJSONLabelCellEditor(editorDefault, "C4"));
    JSONViewer.setCellEditors(new CellEditor[] { editor, null, null, editorDefault });
    JSONViewer.setContentProvider(provider);
    // JSONViewer.setInput(treeData);
    JSONViewer.expandAll();
    createAction();
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(JSONViewer.getControl());
    JSONViewer.getControl().setMenu(menu);
    JSONViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
        }
    });
    initToolBar(composite);
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) GridLayout(org.eclipse.swt.layout.GridLayout) JSONFileTreeViewerProvider(org.talend.repository.json.ui.wizards.view.JSONFileTreeViewerProvider) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

TreeViewer (org.eclipse.jface.viewers.TreeViewer)248 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 GridData (org.eclipse.swt.layout.GridData)50 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)45 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)43 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)42 Composite (org.eclipse.swt.widgets.Composite)42 Tree (org.eclipse.swt.widgets.Tree)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 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)36 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)36 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)36 GridLayout (org.eclipse.swt.layout.GridLayout)34 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)31 ArrayList (java.util.ArrayList)29 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)27 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)27 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)25