Search in sources :

Example 11 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)

Example 12 with TreeViewer

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

the class DynamicComposite method getConnectionItems.

/**
     * DOC qzhang Comment method "getConnectionItems".
     * 
     * @return
     * @throws PersistenceException
     */
private List<ConnectionItem> getConnectionItems() throws PersistenceException {
    List<ConnectionItem> list = new ArrayList<ConnectionItem>();
    IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
    if (repositoryView != null) {
        TreeViewer viewer = (TreeViewer) repositoryView.getViewer();
        IContentProvider contentProvider = viewer.getContentProvider();
        if (contentProvider instanceof RepositoryContentProvider) {
            RepositoryContentProvider provider = (RepositoryContentProvider) contentProvider;
            RepositoryNode metadataConNode = provider.getRootRepositoryNode(ERepositoryObjectType.METADATA);
            for (IRepositoryNode connectionItem : metadataConNode.getChildren()) {
                if (viewer.isExpandable(connectionItem)) {
                    provider.getChildren(connectionItem);
                }
                for (IRepositoryNode node : connectionItem.getChildren()) {
                    addConnectionItem(viewer, provider, list, (RepositoryNode) node);
                }
            }
        }
    }
    return list;
}
Also used : IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryContentProvider(org.talend.repository.viewer.ui.provider.RepositoryContentProvider) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 13 with TreeViewer

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

the class AbstractFilteredTree method addListeners.

/**
     * Adds the listeners.
     */
private void addListeners() {
    TreeViewer viewer = getViewer();
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            openAction.selectionChanged(event);
            copyAction.selectionChanged(event);
        }
    });
    viewer.addSelectionChangedListener(showCallersCalleesAction);
    viewer.addOpenListener(new IOpenListener() {

        @Override
        public void open(OpenEvent event) {
            openAction.run();
        }
    });
    Activator.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}
Also used : IOpenListener(org.eclipse.jface.viewers.IOpenListener) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Example 14 with TreeViewer

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

the class NotificationComparator method compare.

/*
     * @see ViewerComparator#compare(Viewer, Object, Object)
     */
@Override
public int compare(Viewer treeViewer, Object e1, Object e2) {
    int result = 0;
    if (!(e1 instanceof Notification) || !(e2 instanceof Notification) || !(treeViewer instanceof TreeViewer)) {
        return result;
    }
    Notification element1 = (Notification) e1;
    Notification element2 = (Notification) e2;
    Tree tree = ((TreeViewer) treeViewer).getTree();
    if (columnIndex == getColumnIndex(tree, NotificationColumn.MESSAGE)) {
        result = super.compare(treeViewer, element1.getMessage(), element2.getMessage());
    } else if (columnIndex == getColumnIndex(tree, NotificationColumn.DATE)) {
        result = element1.getTimeStamp() > element2.getTimeStamp() ? 1 : -1;
    } else if (columnIndex == getColumnIndex(tree, NotificationColumn.TYPE)) {
        result = super.compare(treeViewer, element1.getType(), element2.getType());
    } else if (columnIndex == getColumnIndex(tree, NotificationColumn.SEQUENCE_NUMBER)) {
        result = element1.getSequenceNumber() > element2.getSequenceNumber() ? 1 : -1;
    }
    if (sortDirection == SWT.DOWN) {
        result *= -1;
    }
    return result;
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) Tree(org.eclipse.swt.widgets.Tree) Notification(javax.management.Notification)

Example 15 with TreeViewer

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

the class ShowRoutineItemsDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    routineViewer = new TreeViewer(composite);
    labelProvider = new ShowRoutineItemsLabelProvider(allRoutineItems, existedRoutinesRecord);
    routineViewer.setContentProvider(labelProvider);
    routineViewer.setLabelProvider(labelProvider);
    routineViewer.setInput(allRoutineItems);
    routineViewer.setFilters(new ViewerFilter[] { new ShowRoutineItemsViewerFilter(allRoutineItems, system) });
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    layoutData.heightHint = 150;
    layoutData.widthHint = 200;
    routineViewer.getTree().setLayoutData(layoutData);
    routineViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
        }
    });
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

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