@Override public void valueChanged(TreeSelectionEvent e) { if (e.getSource() == colors && !locked) { TreeSelectionModel tsm = colors.getSelectionModel(); TreePath tp[] = tsm.getSelectionPaths(); if (tp == null) return; Vector<ClassedItem> tmp = new Vector<ClassedItem>(); for (TreePath element : tp) { try { Object[] path = element.getPath(); ClassedItem ci = new ClassedItem(path[1].toString(), path[2].toString()); tmp.add(ci); } catch (Exception exp) { // User did not select a leafnode } } if (sceneElement instanceof NenyaImageSceneElement) { ((NenyaImageSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0])); } if (sceneElement instanceof NenyaTileSceneElement) { ((NenyaTileSceneElement) sceneElement).setColorList(tmp.toArray(new ClassedItem[0])); } if (sceneElement instanceof NenyaComponentSceneElement) { ((NenyaComponentSceneElement) sceneElement) .getComponents()[itemList.getSelectedIndex()].setColorList( tmp.toArray(new ClassedItem[0])); } submitElement(sceneElement, null); } else { super.valueChanged(e); } }
public void uninstallUI(JComponent c) { HelpModel helpmodel = searchnav.getModel(); searchnav.removeComponentListener(this); searchnav.removePropertyChangeListener(this); TreeSelectionModel tsm = tree.getSelectionModel(); tsm.removeTreeSelectionListener(this); searchnav.setLayout(null); searchnav.removeAll(); if (helpmodel != null) { helpmodel.removeHelpModelListener(this); } searchnav = null; }
public void installUI(JComponent c) { searchnav = (JHelpSearchNavigator) c; HelpModel helpmodel = searchnav.getModel(); searchnav.setLayout(new BorderLayout()); searchnav.addPropertyChangeListener(this); searchnav.addComponentListener(this); if (helpmodel != null) { helpmodel.addHelpModelListener(this); } JLabel search = new JLabel(HelpUtilities.getString(HelpUtilities.getLocale(c), "search.findLabel")); searchparams = new JTextField("", 20); search.setLabelFor(searchparams); searchparams.addActionListener(searchAction); JPanel box = new JPanel(); box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS)); box.add(search); box.add(searchparams); searchnav.add("North", box); topNode = new DefaultMutableTreeNode(); lastTOCnode = null; tree = new JTree(topNode); // public String convertValueToText(Object val TreeSelectionModel tsm = tree.getSelectionModel(); tsm.addTreeSelectionListener(this); tree.setShowsRootHandles(false); tree.setRootVisible(false); sp = new JScrollPane(); sp.getViewport().add(tree); searchnav.add("Center", sp); reloadData(); }