Search in sources :

Example 21 with TreeSelection

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

the class ERDNDController method fillInSelectedNode.

/**
	 * Fill in the selected node
	 *
	 * @param schemaNodeList
	 *            all table nodes
	 * @return boolean
	 */
private boolean fillInSelectedNode(List<ISchemaNode> schemaNodeList) {
    TreeViewer treeViewer = perspectiveTreeviewerMap.get(PerspectiveManager.getInstance().getCurrentPerspectiveId());
    if (treeViewer == null) {
        return false;
    }
    ISelection selection = treeViewer.getSelection();
    if (!(selection instanceof TreeSelection)) {
        return false;
    }
    TreeSelection ts = (TreeSelection) selection;
    Object[] objs = ts.toArray();
    boolean hasSystemTable = false;
    for (Object obj : objs) {
        if (obj instanceof ISchemaNode) {
            ISchemaNode node = (ISchemaNode) obj;
            String type = node.getType();
            if (NodeType.USER_TABLE.equals(type) || NodeType.USER_PARTITIONED_TABLE.equals(type) || NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
                schemaNodeList.add(node);
            } else if (NodeType.SYSTEM_TABLE.equals(type)) {
                hasSystemTable = true;
            }
        }
    }
    if (hasSystemTable) {
        CommonUITool.openInformationBox(com.cubrid.common.ui.er.Messages.cannotDragSystemTable);
    }
    return true;
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ISelection(org.eclipse.jface.viewers.ISelection)

Example 22 with TreeSelection

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

the class AbstractTreeNodeButton method selectionChanged.

public void selectionChanged(SelectionChangedEvent event) {
    if (treeViewer != null && !treeViewer.getTree().isDisposed()) {
        if (treeViewer.getSelection() instanceof TreeSelection) {
            TreeSelection selection = (TreeSelection) treeViewer.getSelection();
            updateStatus(selection);
        }
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreeSelection(org.eclipse.jface.viewers.TreeSelection)

Example 23 with TreeSelection

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

the class AbstractTreeNodeButton method selectionChanged.

public void selectionChanged(SelectionChangedEvent event) {
    if (treeViewer != null && !treeViewer.getTree().isDisposed()) {
        if (treeViewer.getSelection() instanceof TreeSelection) {
            TreeSelection selection = (TreeSelection) treeViewer.getSelection();
            updateStatus(selection);
        }
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreeSelection(org.eclipse.jface.viewers.TreeSelection)

Example 24 with TreeSelection

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

the class AbstractTreeNodeButton method init.

private void init(Composite parent, String tooltip, Image image) {
    button = new Button(parent, SWT.PUSH);
    button.setToolTipText(tooltip);
    button.setImage(image);
    button.setEnabled(false);
    button.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (treeViewer != null && !treeViewer.getTree().isDisposed() && treeViewer.getSelection() instanceof ITreeSelection) {
                handleSelectionEvent((TreeSelection) treeViewer.getSelection());
            }
        }
    });
    treeViewer = manager.getUiManager().getFoxUI().getTreeViewer();
    addTreeListeners();
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) Button(org.eclipse.swt.widgets.Button) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreeSelection(org.eclipse.jface.viewers.TreeSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Event(org.eclipse.swt.widgets.Event)

Example 25 with TreeSelection

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

the class FocusOnAction method aboutToShow.

/**
     * Notifies when menu is about to be shown.
     */
public void aboutToShow() {
    ICpuModel cpuModel = (ICpuModel) filteredTree.getViewer().getInput();
    boolean focused = cpuModel.getFocusTarget() != null;
    setChecked(focused);
    Object element = ((TreeSelection) filteredTree.getViewer().getSelection()).getFirstElement();
    // frame is selected on call tree
    if (element instanceof ICallTreeNode) {
        selectedNode = (ICallTreeNode) element;
        setEnabled(true);
        if (!focused) {
            updateMenu();
        }
        return;
    }
    if (filteredTree.getViewerType() == ViewerType.CallTree) {
        // thread node is selected on call tree
        selectedNode = null;
    } else {
        selectedNode = cpuModel.getFocusTarget();
    }
    setEnabled(focused);
    updateMenu();
}
Also used : ICallTreeNode(org.talend.designer.runtime.visualization.internal.core.cpu.ICallTreeNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ICpuModel(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModel)

Aggregations

TreeSelection (org.eclipse.jface.viewers.TreeSelection)31 TreePath (org.eclipse.jface.viewers.TreePath)12 ISelection (org.eclipse.jface.viewers.ISelection)7 TreeViewer (org.eclipse.jface.viewers.TreeViewer)6 Test (org.junit.Test)6 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)4 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)4 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)4 IValgrindMessage (org.eclipse.linuxtools.valgrind.core.IValgrindMessage)4 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)3 ValgrindViewPart (org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart)3 UiModelSession (org.eclipse.linuxtools.oprofile.ui.model.UiModelSession)3 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)2 CachegrindOutput (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput)2