use of javax.swing.event.TreeSelectionListener in project sirix by sirixdb.
the class TreeView method refreshUpdate.
@Override
public void refreshUpdate(final Optional<VisualItemAxis> pAxis) {
// Use our sirix model and renderer.
dispose();
final ReadDB db = mGUI.getReadDB();
mTree.setModel(new TreeModel(db));
mTree.setCellRenderer(new TreeCellRenderer(db));
if (mTree.getTreeSelectionListeners().length == 0) {
// Listen for when the selection changes.
mTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(final TreeSelectionEvent paramE) {
if (paramE.getNewLeadSelectionPath() != null && paramE.getNewLeadSelectionPath() != paramE.getOldLeadSelectionPath()) {
/*
* Returns the last path element of the selection. This method is
* useful only when the selection model allows a single selection.
*/
final Node node = (Node) paramE.getNewLeadSelectionPath().getLastPathComponent();
db.setKey(node.getNodeKey());
mNotifier.update(mView, Optional.<VisualItemAxis>absent());
}
}
});
}
}
use of javax.swing.event.TreeSelectionListener in project selenium_java by sergueik.
the class JSplitPaneClassFile method createAndShowGUI.
private void createAndShowGUI(JFrame top) {
// Construct class file viewer
final JTreeClassFile jTreeClassFile = new JTreeClassFile(this.classFile);
jTreeClassFile.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(final javax.swing.event.TreeSelectionEvent evt) {
jTreeClassFileSelectionChanged(evt);
}
});
final JPanelForTree panel = new JPanelForTree(jTreeClassFile, top);
final JTabbedPane tabbedPane = new JTabbedPane();
// Construct binary viewer
this.binaryViewer = new JBinaryViewer();
this.binaryViewer.setData(this.classFile.getClassByteArray());
this.binaryViewerView = new JScrollPane(this.binaryViewer);
this.binaryViewerView.getVerticalScrollBar().setValue(0);
tabbedPane.add("Class File", this.binaryViewerView);
// Construct opcode viewer
this.opcode = new JTextPane();
this.opcode.setAlignmentX(Component.LEFT_ALIGNMENT);
// this.opcode.setFont(new Font(Font.DIALOG_INPUT, Font.PLAIN, 14));
this.opcode.setEditable(false);
this.opcode.setBorder(null);
this.opcode.setContentType("text/html");
tabbedPane.add("Opcode", new JScrollPane(this.opcode));
// Class report
this.report = new JTextPane();
this.report.setAlignmentX(Component.LEFT_ALIGNMENT);
this.report.setEditable(false);
this.report.setBorder(null);
this.report.setContentType("text/html");
tabbedPane.add("Report", new JScrollPane(this.report));
this.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
this.setDividerSize(5);
this.setDividerLocation(280);
this.setLeftComponent(panel);
this.setRightComponent(tabbedPane);
this.binaryViewerView.getVerticalScrollBar().setValue(0);
}
use of javax.swing.event.TreeSelectionListener in project Eidolons by IDemiurge.
the class ModelManager method adjustTreeTabSelection.
public static void adjustTreeTabSelection(ObjType type, boolean select) {
int code = // type.getOBJ_TYPE_ENUM().getCode();
ListMaster.getIndexString(new ArrayList<>(ArcaneVault.getMainBuilder().getTabBuilder().getTabNames()), type.getOBJ_TYPE(), true);
ArcaneVault.getMainBuilder().getTabBuilder().getTabbedPane().setSelectedIndex(code);
// ArcaneVault.getMainBuilder().getEditViewPanel().selectType(type);
// Class<?> ENUM_CLASS =
// EnumMaster.findEnumClass(type.getOBJ_TYPE_ENUM().getGroupingKey().getName());
List<String> list = EnumMaster.findEnumConstantNames(type.getOBJ_TYPE_ENUM().getGroupingKey().getName());
int index = ListMaster.getIndexString(list, type.getGroupingKey(), true);
if (type.getOBJ_TYPE_ENUM() == DC_TYPE.SKILLS) {
if (index > 5) {
index--;
}
}
TabBuilder tb = ArcaneVault.getMainBuilder().getTabBuilder().getSubTabs(code);
tb.getTabbedPane().setSelectedIndex(index);
// getOrCreate path for node? I could keep some map from type to path...
if (!select) {
if (tb.getTree().getTreeSelectionListeners().length != 1) {
return;
}
TreeSelectionListener listener = tb.getTree().getTreeSelectionListeners()[0];
tb.getTree().removeTreeSelectionListener(listener);
try {
TreeMaster.collapseTree(tb.getTree());
DefaultMutableTreeNode node = TreeMaster.findNode(tb.getTree(), type.getName());
if (node == null) {
// tb.getTabbedPane().setSelectedIndex(prevIndex);
return;
}
tb.getTree().setSelectionPath(new TreePath(node.getPath()));
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
tb.getTree().addTreeSelectionListener(listener);
}
return;
}
TreeMaster.collapseTree(tb.getTree());
DefaultMutableTreeNode node = TreeMaster.findNode(tb.getTree(), type.getName());
tb.getTree().setSelectionPath(new TreePath(node.getPath()));
}
use of javax.swing.event.TreeSelectionListener in project opennars by opennars.
the class NarseseTemplatePanel method newPanel.
private static JPanel newPanel(List<NarseseTemplate> templates) {
JPanel p = new JPanel(new BorderLayout());
JPanel menu = new JPanel(new BorderLayout());
DefaultMutableTreeNode tree = new DefaultMutableTreeNode();
for (NarseseTemplate n : templates) {
DefaultMutableTreeNode nt = new DefaultMutableTreeNode(n);
tree.add(nt);
}
JTree t = new JTree(tree);
menu.add(t, BorderLayout.CENTER);
final JComboBox formSelect = new JComboBox();
formSelect.addItem("en");
formSelect.addItem("narsese");
menu.add(formSelect, BorderLayout.NORTH);
p.add(menu, BorderLayout.WEST);
ActionListener change = new ActionListener() {
JPanel r = null;
@Override
public void actionPerformed(ActionEvent e) {
if (t.getSelectionModel().isSelectionEmpty())
return;
Object o = ((DefaultMutableTreeNode) t.getSelectionModel().getSelectionPath().getLastPathComponent()).getUserObject();
if (!(o instanceof NarseseTemplate))
return;
if (r != null) {
p.remove(r);
}
r = newPanel((NarseseTemplate) o, formSelect.getSelectedItem().toString());
p.add(r, BorderLayout.CENTER);
p.validate();
}
};
formSelect.addActionListener(change);
t.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
change.actionPerformed(null);
}
});
change.actionPerformed(null);
return p;
}
use of javax.swing.event.TreeSelectionListener in project flutter-intellij by flutter.
the class TextOnlyActionWrapper method initToolWindow.
public void initToolWindow(@NotNull ToolWindow toolWindow) {
final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
final ContentManager contentManager = toolWindow.getContentManager();
final DefaultActionGroup toolbarGroup = new DefaultActionGroup();
toolbarGroup.add(actionCenter);
toolbarGroup.add(actionPadding);
toolbarGroup.add(actionColumn);
toolbarGroup.add(actionRow);
toolbarGroup.addSeparator();
toolbarGroup.add(actionExtractMethod);
toolbarGroup.addSeparator();
toolbarGroup.add(actionMoveUp);
toolbarGroup.add(actionMoveDown);
toolbarGroup.addSeparator();
toolbarGroup.add(actionRemove);
toolbarGroup.add(new ShowOnlyWidgetsAction(AllIcons.General.Filter, "Show only widgets"));
final Content content = contentFactory.createContent(null, null, false);
content.setCloseable(false);
windowPanel = new OutlineComponent(this);
content.setComponent(windowPanel);
windowToolbar = ActionManager.getInstance().createActionToolbar("PreviewViewToolbar", toolbarGroup, true);
windowPanel.setToolbar(windowToolbar.getComponent());
final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
tree = new OutlineTree(rootNode);
tree.setCellRenderer(new OutlineTreeCellRenderer());
tree.expandAll();
initTreePopup();
// Add collapse all, expand all, and feedback buttons.
if (toolWindow instanceof ToolWindowEx) {
final AnAction sendFeedbackAction = new AnAction("Send Feedback", "Send Feedback", FlutterIcons.Feedback) {
@Override
public void actionPerformed(AnActionEvent event) {
BrowserUtil.browse(FEEDBACK_URL);
}
};
final AnAction separator = new AnAction(AllIcons.General.Divider) {
@Override
public void actionPerformed(AnActionEvent event) {
}
};
final TreeExpander expander = new DefaultTreeExpander(tree);
final CommonActionsManager actions = CommonActionsManager.getInstance();
final AnAction expandAllAction = actions.createExpandAllAction(expander, tree);
expandAllAction.getTemplatePresentation().setIcon(AllIcons.General.ExpandAll);
final AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree);
collapseAllAction.getTemplatePresentation().setIcon(AllIcons.General.CollapseAll);
((ToolWindowEx) toolWindow).setTitleActions(sendFeedbackAction, separator, expandAllAction, collapseAllAction);
}
new TreeSpeedSearch(tree) {
@Override
protected String getElementText(Object element) {
final TreePath path = (TreePath) element;
final DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
final Object object = node.getUserObject();
if (object instanceof OutlineObject) {
return ((OutlineObject) object).getSpeedSearchString();
}
return null;
}
};
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
final TreePath selectionPath = tree.getSelectionPath();
if (selectionPath != null) {
selectPath(selectionPath, true);
}
}
}
});
tree.addTreeSelectionListener(treeSelectionListener);
scrollPane = ScrollPaneFactory.createScrollPane(tree);
previewArea = new PreviewArea(new PreviewArea.Listener() {
@Override
public void clicked(FlutterOutline outline) {
final ImmutableList<FlutterOutline> outlines = ImmutableList.of(outline);
updateActionsForOutlines(outlines);
applyOutlinesSelectionToTree(outlines);
jumpToOutlineInEditor(outline, false);
}
@Override
public void doubleClicked(FlutterOutline outline) {
final ImmutableList<FlutterOutline> outlines = ImmutableList.of(outline);
updateActionsForOutlines(outlines);
applyOutlinesSelectionToTree(outlines);
jumpToOutlineInEditor(outline, true);
}
@Override
public void resized(int width, int height) {
if (myRenderHelper != null) {
myRenderHelper.setSize(width, height);
}
}
});
splitter = new Splitter(true);
splitter.setProportion(getState().getSplitterProportion());
getState().addListener(e -> {
final float newProportion = getState().getSplitterProportion();
if (splitter.getProportion() != newProportion) {
splitter.setProportion(newProportion);
}
});
// noinspection Convert2Lambda
splitter.addPropertyChangeListener("proportion", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getState().setSplitterProportion(splitter.getProportion());
}
});
splitter.setFirstComponent(scrollPane);
windowPanel.setContent(splitter);
contentManager.addContent(content);
contentManager.setSelectedContent(content);
}
Aggregations