Search in sources :

Example 6 with Node

use of com.microsoft.tooling.msservices.serviceexplorer.Node in project azure-tools-for-java by Microsoft.

the class ServiceExplorerView method hookMouseActions.

private void hookMouseActions() {
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            doubleClickAction.run();
        }
    });
    Tree tree = (Tree) viewer.getControl();
    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseUp(MouseEvent e) {
            if (e.button == 1) {
                // left button
                TreeItem[] selection = ((Tree) e.widget).getSelection();
                if (selection.length > 0) {
                    TreeItem item = ((Tree) e.widget).getSelection()[0];
                    Node node = ((TreeNode) item.getData()).node;
                    // we do not propagate the click event to it
                    if (!node.isLoading()) {
                        node.getClickAction().fireNodeActionEvent();
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeItem(org.eclipse.swt.widgets.TreeItem) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) Node(com.microsoft.tooling.msservices.serviceexplorer.Node) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Tree(org.eclipse.swt.widgets.Tree) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent)

Example 7 with Node

use of com.microsoft.tooling.msservices.serviceexplorer.Node in project azure-tools-for-java by Microsoft.

the class ServiceExplorerView method propertyChange.

@Override
public void propertyChange(final PropertyChangeEvent evt) {
    // this event is fired whenever a property on a node in the
    // model changes; we respond by triggering a node change
    // event in the tree's model
    final Node node = (Node) evt.getSource();
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            viewer.refresh((TreeNode) node.getViewData());
        }
    });
}
Also used : Node(com.microsoft.tooling.msservices.serviceexplorer.Node)

Aggregations

Node (com.microsoft.tooling.msservices.serviceexplorer.Node)7 RefreshableNode (com.microsoft.tooling.msservices.serviceexplorer.RefreshableNode)3 NodeAction (com.microsoft.tooling.msservices.serviceexplorer.NodeAction)1 Action (org.eclipse.jface.action.Action)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Menu (org.eclipse.swt.widgets.Menu)1 Tree (org.eclipse.swt.widgets.Tree)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1