Java Code Examples for javax.swing.event.TreeSelectionListener

The following examples show how to use javax.swing.event.TreeSelectionListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Cafebabe   Source File: ClassTree.java    License: GNU General Public License v3.0 6 votes vote down vote up
public ClassTree(ClassMemberList ml) {
	ClassEditorPanel editor = new ClassEditorPanel(this);
	this.setRootVisible(false);
	this.setShowsRootHandles(true);
	this.setFocusable(false);
	this.setCellRenderer(new ClassTreeCellRenderer());
	this.setSelectionStyle(TreeSelectionStyle.group);

	this.addTreeSelectionListener(new TreeSelectionListener() {
		@Override
		public void valueChanged(TreeSelectionEvent e) {
			SortedTreeClassNode node = (SortedTreeClassNode) getLastSelectedPathComponent();
			if (node != null && node.getClazz() != null) {
				ml.setMethods(node.getClazz());
				Cafebabe.gui.smallEditorPanel.setViewportView(editor);
				editor.editClass(node.getClazz());
			}
		}
	});
	this.model = new DefaultTreeModel(root = new SortedTreeClassNode(""));
	this.setModel(model);
	this.setTransferHandler(new JarDropHandler(this, 0));
	this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
}
 
Example 2
Source Project: Cafebabe   Source File: ClassMemberList.java    License: GNU General Public License v3.0 6 votes vote down vote up
public ClassMemberList() {
	MethodEditorPanel editor = new MethodEditorPanel(this);
	this.setRootVisible(false);
	this.setShowsRootHandles(false);
	this.setFocusable(false);
	this.setCellRenderer(new MethodListCellRenderer());
	this.addTreeSelectionListener(new TreeSelectionListener() {
		@Override
		public void valueChanged(TreeSelectionEvent e) {
			MethodListNode node = (MethodListNode) getLastSelectedPathComponent();
			if (node != null && node.getMethod() != null) {
				Cafebabe.gui.smallEditorPanel.setViewportView(editor);
				editor.editMethod(node.getMethod());
			}
		}
	});
	this.model = new DefaultTreeModel(root = new MethodListNode(null, null));
	this.setModel(model);
	this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
}
 
Example 3
Source Project: netbeans   Source File: HintsPanel.java    License: Apache License 2.0 6 votes vote down vote up
public HintsPanel(HintMetadata preselected, @NullAllowed final CustomizerContext<?, ?> cc, ClassPathBasedHintWrapper cpBased) {
    this.cpBased = cpBased;
    this.queryStatus = cc == null ? QueryStatus.NEVER : QueryStatus.SHOW_QUERIES;
    this.showHeavyInspections = true;
    init(null, true, false, false, false, cc == null, false, cc != null);
    select(preselected);
    configurationsPanel.setVisible(false);
    
    if (cc != null) {
        errorTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
            @Override public void valueChanged(TreeSelectionEvent e) {
                HintMetadata hm = getSelectedHint();

                if (hm != null) {
                    cc.setSelectedId(AnalyzerImpl.ID_JAVA_HINTS_PREFIX + hm.id);
                }
            }
        });
    }
}
 
Example 4
Source Project: ramus   Source File: AbstractTableView.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected void createInnerComponent() {
    panel.removeAll();
    Attribute[] attributes = getAttributes();
    RootCreater rootCreater = getRootCreater();

    component = new RowTreeTableComponent(engine, qualifier, accessRules,
            rootCreater, attributes, framework);

    rowSet = component.getRowSet();
    table = component.getTable();

    table.getTreeSelectionModel().addTreeSelectionListener(
            new TreeSelectionListener() {
                @Override
                public void valueChanged(TreeSelectionEvent e) {
                    refreshActions();
                }
            });
    refreshActions();
    panel.add(component, BorderLayout.CENTER);
    panel.revalidate();
    panel.repaint();
}
 
Example 5
Source Project: JByteMod-Beta   Source File: ClassTree.java    License: GNU General Public License v2.0 6 votes vote down vote up
public ClassTree(JByteMod jam) {
  this.jbm = jam;
  this.setRootVisible(false);
  this.setShowsRootHandles(true);
  this.setCellRenderer(new TreeCellRenderer());
  this.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent e) {
      SortedTreeNode node = (SortedTreeNode) ClassTree.this.getLastSelectedPathComponent();
      if (node == null)
        return;
      if (node.getCn() != null && node.getMn() != null) {
        jam.selectMethod(node.getCn(), node.getMn());
      } else if (node.getCn() != null) {
        jam.selectClass(node.getCn());
      } else {

      }
    }
  });
  this.model = new DefaultTreeModel(new SortedTreeNode(""));
  this.setModel(model);
  this.setTransferHandler(new JarDropHandler(this, 0));
  this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
}
 
Example 6
Source Project: freeinternals   Source File: JPanelForTree.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a panel tool bar to contain a {@code JTree} object.
 *
 * @param jTree The tree to be contained
 * @param frame The parent window
 */
public JPanelForTree(final JTree jTree, final JFrame frame) {
    if (jTree == null) {
        throw new IllegalArgumentException("[tree] cannot be null.");
    }

    this.tree = jTree;
    this.topLevelFrame = frame;
    this.tree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(final javax.swing.event.TreeSelectionEvent evt) {
            treeSelectionChanged(evt);
        }
    });

    this.toolbar = new JToolBar();
    this.toolbarbtnDetails = new JButton("Details");
    this.initToolbar();

    this.layoutComponents();
}
 
Example 7
Source Project: DiskBrowser   Source File: AppleDiskTab.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void setSelectionListener (JTree tree)
// ---------------------------------------------------------------------------------//
{
  tree.addTreeSelectionListener (new TreeSelectionListener ()
  {
    @Override
    public void valueChanged (TreeSelectionEvent e)
    {
      // A null happens when there is a click in the DiskLayoutPanel, in order
      // to turn off the currently selected file
      AppleFileSource afs = (AppleFileSource) getSelectedObject ();
      if (afs != null)
        eventHandler.fireFileSelectionEvent (afs);
    }
  });
}
 
Example 8
Source Project: weblaf   Source File: TreePainter.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Installs custom {@link TreeSelectionListener} for complex selections update.
 */
protected void installTreeSelectionListeners ()
{
    treeSelectionListener = new TreeSelectionListener ()
    {
        @Override
        public void valueChanged ( @NotNull final TreeSelectionEvent e )
        {
            // Ensure component is still available
            // This might happen if painter is replaced from another TreeSelectionListener
            if ( component != null )
            {
                // Optimized selection repaint
                repaintSelection ();
            }
        }
    };
    component.addTreeSelectionListener ( treeSelectionListener );
}
 
Example 9
Source Project: consulo   Source File: SMTestRunnerResultsForm.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void addEventsListener(final EventsListener listener) {
  myEventListeners.add(listener);
  addTestsTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(final TreeSelectionEvent e) {
      //We should fire event only if it was generated by this component,
      //e.g. it is focused. Otherwise it is side effect of selecting proxy in
      //try by other component
      //if (myTreeView.isFocusOwner()) {
      @Nullable final SMTestProxy selectedProxy = (SMTestProxy)getTreeView().getSelectedTest();
      listener.onSelected(selectedProxy, SMTestRunnerResultsForm.this, SMTestRunnerResultsForm.this);
      //}
    }
  });
}
 
Example 10
Source Project: Spark   Source File: HistoryWindow.java    License: Apache License 2.0 6 votes vote down vote up
private TreeSelectionListener onTreeSelected() {
	return e -> {

           TreePath tp = e.getNewLeadSelectionPath();
           if (tp == null)
               return;

           Object node = tp.getLastPathComponent();
           if (!(node instanceof HistoryTreeNode))
               return;

           HistoryTreeNode entry = (HistoryTreeNode) node;
           HistoryEntry historyEntry = entry.getHistoryEntry();

           String historyText = (historyEntry == null || historyEntry
                   .isEmpty()) ? EMPTY : historyEntry.getHistory();

           historyContentText.setText(historyText);
       };
}
 
Example 11
Source Project: consulo   Source File: HintUpdateSupply.java    License: Apache License 2.0 6 votes vote down vote up
protected void installTreeListener(@Nonnull final JTree tree) {
  tree.addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(final TreeSelectionEvent e) {
      if (!isHintVisible(HintUpdateSupply.this.myHint) || isSelectedByMouse(tree)) return;

      TreePath path = tree.getSelectionPath();
      if (path != null) {
        final PsiElement psiElement = getPsiElementForHint(path.getLastPathComponent());
        if (psiElement != null && psiElement.isValid()) {
          updateHint(psiElement);
        }
      }
    }
  });
}
 
Example 12
Source Project: consulo   Source File: TreeToolbarDecorator.java    License: Apache License 2.0 6 votes vote down vote up
TreeToolbarDecorator(JTree tree, @Nullable final ElementProducer<?> producer) {
  myTree = tree;
  myProducer = producer;
  myAddActionEnabled = myRemoveActionEnabled = myUpActionEnabled = myDownActionEnabled = myTree.getModel() instanceof EditableTreeModel;
  if (myTree.getModel() instanceof EditableTreeModel) {
    createDefaultTreeActions();
  }
  myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      updateButtons();
    }
  });
  myTree.addPropertyChangeListener("enabled", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      updateButtons();
    }
  });
}
 
Example 13
Source Project: pdfxtk   Source File: Overview.java    License: Apache License 2.0 6 votes vote down vote up
ThreadPane(String name_, int tabIdx_) {
     name   = name_;
     tabIdx = tabIdx_;
     setLayout(new BorderLayout());
     setName(name + " (" + msgCount + ")");
     jtree.setRootVisible(false);
     jtree.setShowsRootHandles(true);
     jtree.setCellRenderer(new TreeRenderer());
     jtree.setScrollsOnExpand(true); 
     jtree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
     jtree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
  public void valueChanged(TreeSelectionEvent e) {
    if(e.getNewLeadSelectionPath() == null) return;
    if(e.getNewLeadSelectionPath().getLastPathComponent() instanceof LogMessageNode) {
      LogMessage m = ((LogMessageNode)e.getNewLeadSelectionPath().getLastPathComponent()).m;
      info.setText(Const.LOG_STRINGS[m.priority] + " from " + m.thread + " @ " + new Date(m.time).toString() + "\n" +
		   m.message + "\n" + 
		   m.getException());
    }
  }
});
     add(new JScrollPane(jtree), BorderLayout.CENTER);
   }
 
Example 14
Source Project: consulo   Source File: ToolSelectDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected ToolSelectDialog(@Nullable Project project, @Nullable String actionIdToSelect, BaseToolsPanel toolsPanel) {
  super(project);
  myToolsPanel = toolsPanel;
  myToolsPanel.reset();
  setOKActionEnabled(myToolsPanel.getSingleSelectedTool() != null);
  myToolsPanel.addSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      setOKActionEnabled(myToolsPanel.getSingleSelectedTool() != null);
    }
  });
  init();
  pack();
  if (actionIdToSelect != null) {
    myToolsPanel.selectTool(actionIdToSelect);
  }
  setTitle(ToolsBundle.message("tools.dialog.title"));
}
 
Example 15
Source Project: consulo   Source File: ScopeChooserConfigurable.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void initTree() {
  myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      final TreePath path = e.getOldLeadSelectionPath();
      if (path != null) {
        final MyNode node = (MyNode)path.getLastPathComponent();
        final NamedConfigurable namedConfigurable = node.getConfigurable();
        if (namedConfigurable instanceof ScopeConfigurable) {
          ((ScopeConfigurable)namedConfigurable).cancelCurrentProgress();
        }
      }
    }
  });
  super.initTree();
  myTree.setShowsRootHandles(false);
  new TreeSpeedSearch(myTree, new Convertor<TreePath, String>() {
    @Override
    public String convert(final TreePath treePath) {
      return ((MyNode)treePath.getLastPathComponent()).getDisplayName();
    }
  }, true);

  myTree.getEmptyText().setText(IdeBundle.message("scopes.no.scoped"));
}
 
Example 16
private Component createTreePanel() {
    treeComponent = new TaskTreeComponent(gradlePluginLord, new TaskTreeComponent.Interaction() {
        public void rightClick(JTree tree, int x, int y) {
            enableThingsAppropriately();
            popupMenu.show(tree, x, y);
        }

        public void taskInvoked(TaskView task, boolean isCtrlKeyDown) {
            if (isCtrlKeyDown) {
                gradlePluginLord.addExecutionRequestToQueue(task, false, "-a");
            } else {
                gradlePluginLord.addExecutionRequestToQueue(task, false);
            }
        }

        public void projectInvoked(ProjectView project) {
            executeDefaultTasksInProject(project);
        }
    });

    treeComponent.getTree().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            enableThingsAppropriately();
        }
    });

    defaultTreeBackground = treeComponent.getTree().getBackground();

    treeScrollPane = new JScrollPane();

    treeComponent.getTree().setBackground(workingBackgroundColor);  //change the color to better indicate that
    showTextInViewport("Has not built projects/tasks yet.");

    return treeScrollPane;
}
 
Example 17
private Component createTreePanel() {
    treeComponent = new TaskTreeComponent(gradlePluginLord, new TaskTreeComponent.Interaction() {
        public void rightClick(JTree tree, int x, int y) {
            enableThingsAppropriately();
            popupMenu.show(tree, x, y);
        }

        public void taskInvoked(TaskView task, boolean isCtrlKeyDown) {
            if (isCtrlKeyDown) {
                gradlePluginLord.addExecutionRequestToQueue(task, false, "-a");
            } else {
                gradlePluginLord.addExecutionRequestToQueue(task, false);
            }
        }

        public void projectInvoked(ProjectView project) {
            executeDefaultTasksInProject(project);
        }
    });

    treeComponent.getTree().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            enableThingsAppropriately();
        }
    });

    defaultTreeBackground = treeComponent.getTree().getBackground();

    treeScrollPane = new JScrollPane();

    treeComponent.getTree().setBackground(workingBackgroundColor);  //change the color to better indicate that
    showTextInViewport("Has not built projects/tasks yet.");

    return treeScrollPane;
}
 
Example 18
Source Project: dctb-utfpr-2018-1   Source File: Container.java    License: Apache License 2.0 5 votes vote down vote up
private void createJTree() {
    DefaultMutableTreeNode root
            = new DefaultMutableTreeNode("Ordem");
    DefaultMutableTreeNode types = new DefaultMutableTreeNode("tipos");
    root.add(types);

    DefaultMutableTreeNode fpTypes
            = new DefaultMutableTreeNode("Alb");
    types.add(fpTypes);
    fpTypes.add(new DefaultMutableTreeNode("A"));
    fpTypes.add(new DefaultMutableTreeNode("B"));

    DefaultMutableTreeNode intTypes
            = new DefaultMutableTreeNode("Num");
    types.add(intTypes);
    intTypes.add(new DefaultMutableTreeNode("1"));
    intTypes.add(new DefaultMutableTreeNode("2"));
    intTypes.add(new DefaultMutableTreeNode("3"));
    intTypes.add(new DefaultMutableTreeNode("4"));

    types.add(new DefaultMutableTreeNode("Rom"));
    types.add(new DefaultMutableTreeNode("Sem"));

    JTree tree = new JTree(root);

    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent tse) {
            titulo.setText("a seleção é: "
                    + tse.getPath().getLastPathComponent());
        }
    });

    bottom.add(tree);
}
 
Example 19
Source Project: org.alloytools.alloy   Source File: OurTree.java    License: Apache License 2.0 5 votes vote down vote up
/** Construct a Tree object with the given font size. */
public OurTree(int fontSize) {
    Font font = OurUtil.getVizFont().deriveFont((float) fontSize);
    OurTreeRenderer renderer = new OurTreeRenderer(fontSize);
    renderer.setFont(font);
    renderer.invalidate();
    renderer.validate();
    setRowHeight(0); // To allow variable row height on Mac OS X
    setCellRenderer(renderer);
    setFont(font);
    setBorder(new EmptyBorder(8, 8, 2, 2));
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    putClientProperty("JTree.lineStyle", "Angled");
    setRootVisible(true);
    setForeground(Color.BLACK);
    setBackground(Color.WHITE);
    setOpaque(true);
    addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = OurTree.this.getSelectionPath();
            if (path != null)
                OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent());
        }
    });
}
 
Example 20
Source Project: openjdk-jdk9   Source File: JTreeOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code JTree.addTreeSelectionListener(TreeSelectionListener)}
 * through queue
 */
public void addTreeSelectionListener(final TreeSelectionListener treeSelectionListener) {
    runMapping(new MapVoidAction("addTreeSelectionListener") {
        @Override
        public void map() {
            ((JTree) getSource()).addTreeSelectionListener(treeSelectionListener);
        }
    });
}
 
Example 21
Source Project: openjdk-jdk9   Source File: JTreeOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps
 * {@code JTree.removeTreeSelectionListener(TreeSelectionListener)}
 * through queue
 */
public void removeTreeSelectionListener(final TreeSelectionListener treeSelectionListener) {
    runMapping(new MapVoidAction("removeTreeSelectionListener") {
        @Override
        public void map() {
            ((JTree) getSource()).removeTreeSelectionListener(treeSelectionListener);
        }
    });
}
 
Example 22
Source Project: sldeditor   Source File: FSTree.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the tree selection callback.
 *
 * @param fileSelection the new tree selection
 */
public void setTreeSelection(FileSelectionInterface fileSelection) {

    addTreeSelectionListener(
            new TreeSelectionListener() {
                @Override
                public void valueChanged(TreeSelectionEvent e) {
                    if (!shouldIgnoreSelection()) {
                        if (fileSelection != null) {
                            fileSelection.treeSelection(e);
                        }
                    }
                }
            });
}
 
Example 23
Source Project: tda   Source File: TDA.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * add a tree listener for enabling/disabling menu and toolbar icons.
 * @param tree
 */
private void addTreeListener(JTree tree) {
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        ViewScrollPane emptyView = null;

        public void valueChanged(TreeSelectionEvent e) {
            getMainMenu().getCloseMenuItem().setEnabled(e.getPath() != null);
            if(getMainMenu().getCloseToolBarButton() != null) {
                getMainMenu().getCloseToolBarButton().setEnabled(e.getPath() != null);
            }
            // reset right pane of the top view:
            
            if(emptyView == null) {
                JEditorPane emptyPane = new JEditorPane("text/html", "<html><body bgcolor=\"ffffff\">   </body></html>");
                emptyPane.setEditable(false);

                emptyView = new ViewScrollPane(emptyPane, runningAsVisualVMPlugin);                    
            }

            if(e.getPath() == null || 
                    !(((DefaultMutableTreeNode) e.getPath().getLastPathComponent()).
                    getUserObject() instanceof Category)) {
                resetPane();
            }
        }
        
        private void resetPane() {
            int dividerLocation = topSplitPane.getDividerLocation();
            topSplitPane.setRightComponent(emptyView);
            topSplitPane.setDividerLocation(dividerLocation);
        }
        
    });
}
 
Example 24
public static void main(final String args[]) {
	final DefaultMutableTreeNode root = new DefaultMutableTreeNode(new CheckBoxNodeData("Root", true));

	final DefaultMutableTreeNode accessibility = add(root, "Accessibility", true);
	add(accessibility, "Move system caret with focus/selection changes", false);
	add(accessibility, "Always expand alt text for images", true);
	root.add(accessibility);

	final DefaultMutableTreeNode browsing = new DefaultMutableTreeNode(new CheckBoxNodeData("Browsing", null));
	add(browsing, "Notify when downloads complete", true);
	add(browsing, "Disable script debugging", true);
	add(browsing, "Use AutoComplete", true);
	add(browsing, "Browse in a new process", false);
	root.add(browsing);

	final CheckBoxTree tree = new CheckBoxTree(root);
	((DefaultMutableTreeNode) tree.getModel().getRoot())
			.add(new DefaultMutableTreeNode(new CheckBoxNodeData("gggg", null)));
	((DefaultTreeModel) tree.getModel()).reload();
	// listen for changes in the selection
	tree.addTreeSelectionListener(new TreeSelectionListener() {
		@Override
		public void valueChanged(final TreeSelectionEvent e) {
			// System.out.println("selection changed");
		}
	});
	// show the tree on screen
	final JFrame frame = new JFrame("CheckBox Tree");
	final JScrollPane scrollPane = new JScrollPane(tree);
	frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setSize(300, 150);
	frame.setVisible(true);
}
 
Example 25
Source Project: azure-devops-intellij   Source File: TfsTreeForm.java    License: MIT License 5 votes vote down vote up
public TfsTreeForm() {
    DataManager.registerDataProvider(tree, this);
    new TreeSpeedSearch(tree);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            selectedItem = doGetSelectedItem();
            pathField.setText(selectedItem != null ? selectedItem.path : null);
            eventDispatcher.getMulticaster().selectionChanged();
        }
    });
    PopupHandler.installPopupHandler(tree, POPUP_ACTION_GROUP, ActionPlaces.REMOTE_HOST_DIALOG_POPUP);
    setMessage(null, false);
}
 
Example 26
Source Project: zap-extensions   Source File: ExtensionScriptsUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void addSelectionListener(TreeSelectionListener tsl) {
    if (getView() == null) {
        return;
    }
    this.getScriptsPanel().getTree().addTreeSelectionListener(tsl);
}
 
Example 27
Source Project: zap-extensions   Source File: ExtensionScriptsUI.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void removeSelectionListener(TreeSelectionListener tsl) {
    if (getView() == null) {
        return;
    }
    this.getScriptsPanel().getTree().removeTreeSelectionListener(tsl);
}
 
Example 28
private Component createTreePanel() {
    treeComponent = new TaskTreeComponent(gradlePluginLord, new TaskTreeComponent.Interaction() {
        public void rightClick(JTree tree, int x, int y) {
            enableThingsAppropriately();
            popupMenu.show(tree, x, y);
        }

        public void taskInvoked(TaskView task, boolean isCtrlKeyDown) {
            if (isCtrlKeyDown) {
                gradlePluginLord.addExecutionRequestToQueue(task, false, "-a");
            } else {
                gradlePluginLord.addExecutionRequestToQueue(task, false);
            }
        }

        public void projectInvoked(ProjectView project) {
            executeDefaultTasksInProject(project);
        }
    });

    treeComponent.getTree().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            enableThingsAppropriately();
        }
    });

    defaultTreeBackground = treeComponent.getTree().getBackground();

    treeScrollPane = new JScrollPane();

    treeComponent.getTree().setBackground(workingBackgroundColor);  //change the color to better indicate that
    showTextInViewport("Has not built projects/tasks yet.");

    return treeScrollPane;
}
 
Example 29
private Component createTreePanel() {
    treeComponent = new TaskTreeComponent(gradlePluginLord, new TaskTreeComponent.Interaction() {
        public void rightClick(JTree tree, int x, int y) {
            enableThingsAppropriately();
            popupMenu.show(tree, x, y);
        }

        public void taskInvoked(TaskView task, boolean isCtrlKeyDown) {
            if (isCtrlKeyDown) {
                gradlePluginLord.addExecutionRequestToQueue(task, false, "-a");
            } else {
                gradlePluginLord.addExecutionRequestToQueue(task, false);
            }
        }

        public void projectInvoked(ProjectView project) {
            executeDefaultTasksInProject(project);
        }
    });

    treeComponent.getTree().addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            enableThingsAppropriately();
        }
    });

    defaultTreeBackground = treeComponent.getTree().getBackground();

    treeScrollPane = new JScrollPane();

    treeComponent.getTree().setBackground(workingBackgroundColor);  //change the color to better indicate that
    showTextInViewport("Has not built projects/tasks yet.");

    return treeScrollPane;
}
 
Example 30
Source Project: KodeBeagle   Source File: ProjectTree.java    License: Apache License 2.0 5 votes vote down vote up
public final TreeSelectionListener getTreeSelectionListener(final TreeNode root) {
    return new TreeSelectionListener() {
        @Override
        public void valueChanged(final TreeSelectionEvent treeSelectionEvent) {
            JTree jtree = (JTree) treeSelectionEvent.getSource();
            DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)
                    jtree.getLastSelectedPathComponent();
            if (selectedNode != null && selectedNode.isLeaf() && root.getChildCount() > 0) {
                final CodeInfo codeInfo = (CodeInfo) selectedNode.getUserObject();
                ProgressManager.getInstance().run(new FetchFileContentTask(
                        windowObjects.getProject(), codeInfo));
            }
        }
    };
}