private void addCheckbox(final JPanel panel, final TreeAction action) { String text = action instanceof FileStructureFilter ? ((FileStructureFilter) action).getCheckBoxText() : action instanceof FileStructureNodeProvider ? ((FileStructureNodeProvider) action).getCheckBoxText() : null; if (text == null) return; Shortcut[] shortcuts = action instanceof FileStructureFilter ? ((FileStructureFilter) action).getShortcut() : ((FileStructureNodeProvider) action).getShortcut(); final JCheckBox chkFilter = new JCheckBox(); UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, chkFilter); final boolean selected = getDefaultValue(action); chkFilter.setSelected(selected); myTreeActionsOwner.setActionIncluded( action, action instanceof FileStructureFilter ? !selected : selected); chkFilter.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { final boolean state = chkFilter.isSelected(); if (!myAutoClicked.contains(chkFilter)) { saveState(action, state); } myTreeActionsOwner.setActionIncluded( action, action instanceof FileStructureFilter ? !state : state); // final String filter = mySpeedSearch.isPopupActive() ? // mySpeedSearch.getEnteredPrefix() : null; // mySpeedSearch.hidePopup(); Object selection = ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements()); if (selection instanceof FilteringTreeStructure.FilteringNode) { selection = ((FilteringTreeStructure.FilteringNode) selection).getDelegate(); } myTreeStructure.rebuildTree(); myFilteringStructure.rebuild(); final Object sel = selection; final Runnable runnable = new Runnable() { public void run() { ApplicationManager.getApplication() .runReadAction( new Runnable() { @Override public void run() { myAbstractTreeBuilder .refilter(sel, true, false) .doWhenProcessed( new Runnable() { @Override public void run() { if (mySpeedSearch.isPopupActive()) { mySpeedSearch.refreshSelection(); } } }); } }); } }; if (ApplicationManager.getApplication().isUnitTestMode()) { runnable.run(); } else { ApplicationManager.getApplication().invokeLater(runnable); } } }); chkFilter.setFocusable(false); if (shortcuts.length > 0) { text += " (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")"; new AnAction() { public void actionPerformed(final AnActionEvent e) { chkFilter.doClick(); } }.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree); } chkFilter.setText(text); panel.add(chkFilter); myCheckBoxes.put(action.getClass(), chkFilter); }
public int doAfterBody() throws JspException { BodyContent body = getBodyContent(); String content = body.getString().trim(); try { if ((this.method == null) || (this.method.equals(""))) { throw new RuntimeException("Tree既未指定Method"); } TreeAction tree = new TreeAction(); tree.setTagBody(content); tree.setMethod(this.method); HtmlP p = new HtmlP(); p.parseHtml(content); tree.setTemplate(p); tree.setID(this.id); tree.setLazy(this.lazy); tree.setExpand(this.expand); if (this.level <= 0) { this.level = 999; } tree.setLevel(this.level); tree.setStyle(this.style); HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); HttpServletResponse response = (HttpServletResponse) this.pageContext.getResponse(); Current.init(request, response, this.method); tree.setParams(Current.getRequest()); Current.invokeMethod(this.method, new Object[] {tree}); getPreviousOut().write(tree.getHtml()); } catch (Exception e1) { e1.printStackTrace(); } return 6; }