List of usage examples for javax.swing JTree getModel
public TreeModel getModel()
TreeModel
that is providing the data. From source file:it.unibas.spicygui.controllo.window.operator.ProjectTreeGenerator.java
public void generateTree(JTree jTree) { Scenarios scenarios = (Scenarios) modello.getBean(Costanti.SCENARIOS); DefaultMutableTreeNode nodeRoot = new DefaultMutableTreeNode( new TreeTopComponentAdapter(null, false, true, false)); for (IScenario scenario : scenarios.getListaSceneri()) { analizzaScenario(nodeRoot, (Scenario) scenario); }/*from w w w . ja va 2s . c o m*/ ((DefaultTreeModel) jTree.getModel()).setRoot(nodeRoot); jTree.setRootVisible(false); jTree.setShowsRootHandles(true); TreeRenderer rendererTree = new TreeRenderer(); jTree.setCellRenderer(rendererTree); return; }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private void expandTree(JTree tree, boolean expand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); expandAll(tree, new TreePath(root), expand); }
From source file:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java
private void registerMouseListener(final JTree tree) { MouseListener mouseAdapter = new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseEvent.BUTTON3) { final int selectedRow = tree.getRowForLocation(mouseEvent.getX(), mouseEvent.getY()); final TreePath selectedPath = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); if (selectedRow != -1) { final XmlDomAdapterNode clickedItem = (XmlDomAdapterNode) selectedPath .getLastPathComponent(); final boolean isLeaf = tree.getModel().isLeaf(selectedPath.getLastPathComponent()); // Do nothing on root element if (selectedPath.getPathCount() > 1) { // find the allowed actions, to know if a popup menu should be displayed and the content of the popup menu + action handlers if (clickedItem.node instanceof Element) { nodeActionAdd(mouseEvent, selectedRow, selectedPath, clickedItem, tree); } else if (isLeaf) { valueLeafActionEdit(mouseEvent, selectedPath, clickedItem, tree); }/*from w w w. j ava 2 s . co m*/ } } } } }; tree.addMouseListener(mouseAdapter); }
From source file:eu.europa.esig.dss.applet.view.validationpolicy.EditView.java
private void registerMouseListener(final JTree tree) { MouseListener mouseAdapter = new MouseAdapter() { @Override/*from ww w .j a v a2 s . c om*/ public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseEvent.BUTTON3) { final int selectedRow = tree.getRowForLocation(mouseEvent.getX(), mouseEvent.getY()); final TreePath selectedPath = tree.getPathForLocation(mouseEvent.getX(), mouseEvent.getY()); if (selectedRow != -1) { final XmlDomAdapterNode clickedItem = (XmlDomAdapterNode) selectedPath .getLastPathComponent(); final boolean isLeaf = tree.getModel().isLeaf(selectedPath.getLastPathComponent()); // Do nothing on root element if (selectedPath.getPathCount() > 1) { // find the allowed actions, to know if a popup menu should be displayed and the content of the popup menu + action handlers if (clickedItem.node instanceof Element) { nodeActionAdd(mouseEvent, selectedRow, selectedPath, clickedItem, tree); } else if (isLeaf) { valueLeafActionEdit(mouseEvent, selectedPath, clickedItem, tree); } } } } } }; tree.addMouseListener(mouseAdapter); }
From source file:de.tor.tribes.ui.views.DSWorkbenchSelectionFrame.java
public TreePath findByName(JTree tree, Village node) { TreeNode root = (TreeNode) tree.getModel().getRoot(); return find2(tree, new TreePath(root), node, 0); }
From source file:TreeDragTest.java
public void drop(DropTargetDropEvent dtde) { Point pt = dtde.getLocation(); DropTargetContext dtc = dtde.getDropTargetContext(); JTree tree = (JTree) dtc.getComponent(); TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y); DefaultMutableTreeNode parent = (DefaultMutableTreeNode) parentpath.getLastPathComponent(); if (parent.isLeaf()) { dtde.rejectDrop();//from w w w. ja v a 2s . com return; } try { Transferable tr = dtde.getTransferable(); DataFlavor[] flavors = tr.getTransferDataFlavors(); for (int i = 0; i < flavors.length; i++) { if (tr.isDataFlavorSupported(flavors[i])) { dtde.acceptDrop(dtde.getDropAction()); TreePath p = (TreePath) tr.getTransferData(flavors[i]); DefaultMutableTreeNode node = (DefaultMutableTreeNode) p.getLastPathComponent(); DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); model.insertNodeInto(node, parent, 0); dtde.dropComplete(true); return; } } dtde.rejectDrop(); } catch (Exception e) { e.printStackTrace(); dtde.rejectDrop(); } }
From source file:com.edduarte.protbox.ui.windows.RestoreFileWindow.java
private RestoreFileWindow(final PReg registry) { super();//www .j a v a 2s .c om setLayout(null); final JTextField searchField = new JTextField(); searchField.setLayout(null); searchField.setBounds(2, 2, 301, 26); searchField.setBorder(new LineBorder(Color.lightGray)); searchField.setFont(Constants.FONT); add(searchField); final JLabel noBackupFilesLabel = new JLabel("<html>No backups files were found!<br><br>" + "<font color=\"gray\">If you think there is a problem with the<br>" + "backup system, please create an issue here:<br>" + "<a href=\"#\">https://github.com/com.edduarte/protbox/issues</a></font></html>"); noBackupFilesLabel.setLayout(null); noBackupFilesLabel.setBounds(20, 50, 300, 300); noBackupFilesLabel.setFont(Constants.FONT.deriveFont(14f)); noBackupFilesLabel.addMouseListener((OnMouseClick) e -> { String urlPath = "https://github.com/com.edduarte/protbox/issues"; try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(new URI(urlPath)); } else { if (SystemUtils.IS_OS_WINDOWS) { Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + urlPath); } else { java.util.List<String> browsers = Lists.newArrayList("firefox", "opera", "safari", "mozilla", "chrome"); for (String browser : browsers) { if (Runtime.getRuntime().exec(new String[] { "which", browser }).waitFor() == 0) { Runtime.getRuntime().exec(new String[] { browser, urlPath }); break; } } } } } catch (Exception ex) { ex.printStackTrace(); } }); DefaultMutableTreeNode rootTreeNode = registry.buildEntryTree(); final JTree tree = new JTree(rootTreeNode); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); if (rootTreeNode.getChildCount() == 0) { searchField.setEnabled(false); add(noBackupFilesLabel); } expandTree(tree); tree.setLayout(null); tree.setRootVisible(false); tree.setEditable(false); tree.setCellRenderer(new SearchableTreeCellRenderer(searchField)); searchField.addKeyListener((OnKeyReleased) e -> { // update and expand tree DefaultTreeModel model = (DefaultTreeModel) tree.getModel(); model.nodeStructureChanged((TreeNode) model.getRoot()); expandTree(tree); }); final JScrollPane scroll = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setBorder(new DropShadowBorder()); scroll.setBorder(new LineBorder(Color.lightGray)); scroll.setBounds(2, 30, 334, 360); add(scroll); JLabel close = new JLabel(new ImageIcon(Constants.getAsset("close.png"))); close.setLayout(null); close.setBounds(312, 7, 18, 18); close.setFont(Constants.FONT); close.setForeground(Color.gray); close.addMouseListener((OnMouseClick) e -> dispose()); add(close); final JLabel permanentDeleteButton = new JLabel(new ImageIcon(Constants.getAsset("permanent.png"))); permanentDeleteButton.setLayout(null); permanentDeleteButton.setBounds(91, 390, 40, 39); permanentDeleteButton.setBackground(Color.black); permanentDeleteButton.setEnabled(false); permanentDeleteButton.addMouseListener((OnMouseClick) e -> { if (permanentDeleteButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (JOptionPane.showConfirmDialog(null, "Are you sure you wish to permanently delete '" + entry.realName() + "'?\nThis file and its " + "backup copies will be deleted immediately. You cannot undo this action.", "Confirm Cancel", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { registry.permanentDelete(entry); dispose(); RestoreFileWindow.getInstance(registry); } else { setVisible(true); } } }); add(permanentDeleteButton); final JLabel configBackupsButton = new JLabel(new ImageIcon(Constants.getAsset("config.png"))); configBackupsButton.setLayout(null); configBackupsButton.setBounds(134, 390, 40, 39); configBackupsButton.setBackground(Color.black); configBackupsButton.setEnabled(false); configBackupsButton.addMouseListener((OnMouseClick) e -> { if (configBackupsButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; JFrame frame = new JFrame("Choose backup policy"); Object option = JOptionPane.showInputDialog(frame, "Choose below the backup policy for this file:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, PbxFile.BackupPolicy.values(), pbxFile.getBackupPolicy()); if (option == null) { setVisible(true); return; } PbxFile.BackupPolicy pickedPolicy = PbxFile.BackupPolicy.valueOf(option.toString()); pbxFile.setBackupPolicy(pickedPolicy); } setVisible(true); } }); add(configBackupsButton); final JLabel restoreBackupButton = new JLabel(new ImageIcon(Constants.getAsset("restore.png"))); restoreBackupButton.setLayout(null); restoreBackupButton.setBounds(3, 390, 85, 39); restoreBackupButton.setBackground(Color.black); restoreBackupButton.setEnabled(false); restoreBackupButton.addMouseListener((OnMouseClick) e -> { if (restoreBackupButton.isEnabled()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); PbxEntry entry = (PbxEntry) node.getUserObject(); if (entry instanceof PbxFolder) { registry.restoreFolderFromEntry((PbxFolder) entry); } else if (entry instanceof PbxFile) { PbxFile pbxFile = (PbxFile) entry; java.util.List<String> snapshots = pbxFile.snapshotsToString(); if (snapshots.isEmpty()) { setVisible(true); return; } JFrame frame = new JFrame("Choose backup"); Object option = JOptionPane.showInputDialog(frame, "Choose below what backup snapshot would you like restore:", "Choose backup", JOptionPane.QUESTION_MESSAGE, null, snapshots.toArray(), snapshots.get(0)); if (option == null) { setVisible(true); return; } int pickedIndex = snapshots.indexOf(option.toString()); registry.restoreFileFromEntry((PbxFile) entry, pickedIndex); } dispose(); } }); add(restoreBackupButton); tree.addMouseListener((OnMouseClick) e -> { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { PbxEntry entry = (PbxEntry) node.getUserObject(); if ((entry instanceof PbxFolder && entry.areNativeFilesDeleted())) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(false); } else if (entry instanceof PbxFile) { permanentDeleteButton.setEnabled(true); restoreBackupButton.setEnabled(true); configBackupsButton.setEnabled(true); } else { permanentDeleteButton.setEnabled(false); restoreBackupButton.setEnabled(false); configBackupsButton.setEnabled(false); } } }); final JLabel cancel = new JLabel(new ImageIcon(Constants.getAsset("cancel.png"))); cancel.setLayout(null); cancel.setBounds(229, 390, 122, 39); cancel.setBackground(Color.black); cancel.addMouseListener((OnMouseClick) e -> dispose()); add(cancel); addWindowFocusListener(new WindowFocusListener() { private boolean gained = false; @Override public void windowGainedFocus(WindowEvent e) { gained = true; } @Override public void windowLostFocus(WindowEvent e) { if (gained) { dispose(); } } }); setSize(340, 432); setUndecorated(true); getContentPane().setBackground(Color.white); setResizable(false); getRootPane().setBorder(BorderFactory.createLineBorder(new Color(100, 100, 100))); Utils.setComponentLocationOnCenter(this); setVisible(true); }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param actionableTree/* w w w . j a v a 2 s . c o m*/ */ public void print(final JTree actionableTree) { /*if (true) { PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(OrientationRequested.LANDSCAPE); aset.add(new Copies(2)); aset.add(new JobName("My job", null)); // Create a print job PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(this); // locate a print service that can handle the request PrintService[] services = PrinterJob.lookupPrintServices(); if (services.length > 0) { System.out.println("selected printer " + services[0].getName()); try { pj.setPrintService(services[0]); pj.pageDialog(aset); if(pj.printDialog(aset)) { pj.print(aset); } } catch (PrinterException pe) { System.err.println(pe); } } return; }*/ DefaultMutableTreeNode clonedTree = GhostActionableTree .makeDeepCopy((DefaultMutableTreeNode) actionableTree.getModel().getRoot()); GhostActionableTree printTree = new GhostActionableTree(this, new DefaultTreeModel(clonedTree)); printTree.setRowHeight(ROW_HEIGHT); //printTree.setEditable(false); //printTree.setVisibleRowCount(15); ContainerTreeRenderer renderer = new ContainerTreeRenderer(null, false, false); renderer.setBGColor(Color.WHITE); renderer.setFont(getFont().deriveFont(8.0f)); //renderer.setLeafIcon(IconManager.getIcon(CollectionObject.class.getSimpleName(), IconManager.IconSize.Std32)); //renderer.setVerticalTextPosition(SwingConstants.CENTER); printTree.setCellRenderer(renderer); for (int row = 0; row < printTree.getRowCount(); row++) { printTree.expandRow(row); } PrintablePanel p = new PrintablePanel(new BorderLayout(), printTree); p.add(printTree, BorderLayout.CENTER); PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); //PrinterResolution pr = new PrinterResolution(300, 300, PrinterResolution.DPI); //MediaPrintableArea mpa = new MediaPrintableArea(8,21, 210-16, 296-42, MediaPrintableArea.MM); //aset.add( MediaSizeName.IS); //aset.add( pr ); //aset.add( mpa ); aset.add(new Copies(1)); aset.add(OrientationRequested.PORTRAIT); aset.add(PrintQuality.HIGH); PrinterJob job = PrinterJob.getPrinterJob(); /*PageFormat pageFormat = job.defaultPage(); Paper paper = pageFormat.getPaper(); paper.setSize(pageFormat.getWidth(), pageFormat.getHeight()); paper.setImageableArea( 0, 0, pageFormat.getWidth(), pageFormat.getHeight() ); //aset.add( Fidelity.FIDELITY_TRUE ); pageFormat.setPaper(paper); Book book = new Book(); book.append(p, pageFormat, 1); job.setPageable(book);*/ job.setPrintable(p); boolean ok = job.printDialog(); if (ok) { try { job.print(aset); } catch (PrinterException ex) { ex.printStackTrace(); /* The job did not successfully complete */ } } }
From source file:base.BasePlayer.AddGenome.java
public AddGenome() { super(new BorderLayout()); makeGenomes();/*from w w w . j a va2 s.c om*/ tree = new JTree(root); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); sizeError.setForeground(Draw.redColor); sizeError.setVisible(true); treemodel = (DefaultTreeModel) tree.getModel(); remscroll = new JScrollPane(remtable); tree.setCellRenderer(new DefaultTreeCellRenderer() { private static final long serialVersionUID = 1L; private Icon collapsedIcon = UIManager.getIcon("Tree.collapsedIcon"); private Icon expandedIcon = UIManager.getIcon("Tree.expandedIcon"); // private Icon leafIcon = UIManager.getIcon("Tree.leafIcon"); private Icon addIcon = UIManager.getIcon("Tree.closedIcon"); // private Icon saveIcon = UIManager.getIcon("OptionPane.informationIcon"); @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean isLeaf, int row, boolean focused) { Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused); if (!isLeaf) { //setFont(getFont().deriveFont(Font.PLAIN)); if (expanded) { setIcon(expandedIcon); } else { setIcon(collapsedIcon); } /* if(((DefaultMutableTreeNode) value).getUserObject().toString().equals("Annotations")) { this.setFocusable(false); setFont(getFont().deriveFont(Font.BOLD)); setIcon(null); } */ } else { if (((DefaultMutableTreeNode) value).getUserObject().toString().equals("Annotations")) { // setFont(getFont().deriveFont(Font.PLAIN)); setIcon(null); } else if (((DefaultMutableTreeNode) value).getUserObject().toString().startsWith("Add new")) { // setFont(getFont().deriveFont(Font.PLAIN)); setIcon(addIcon); } else { // setFont(getFont().deriveFont(Font.ITALIC)); setIcon(null); // setIcon(leafIcon); } } return c; } }); tree.addMouseListener(this); tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { try { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) return; selectedNode = node; if (node.isLeaf()) { checkUpdates.setEnabled(false); } else { checkUpdates.setEnabled(true); } if (node.toString().startsWith("Add new") || node.toString().equals("Annotations")) { remove.setEnabled(false); } else { remove.setEnabled(true); } genometable.clearSelection(); download.setEnabled(false); } catch (Exception ex) { ex.printStackTrace(); } } }); tree.setToggleClickCount(1); tree.setRootVisible(false); treescroll = new JScrollPane(tree); checkGenomes(); genomeFileText = new JLabel("Select reference fasta-file"); annotationFileText = new JLabel("Select annotation gff3-file"); genomeName = new JTextField("Give name of the genome"); openRef = new JButton("Browse"); openAnno = new JButton("Browse"); add = new JButton("Add"); download = new JButton("Download"); checkEnsembl = new JButton("Ensembl fetch"); checkEnsembl.setMinimumSize(Main.buttonDimension); checkEnsembl.addActionListener(this); getLinks = new JButton("Get file links."); remove = new JButton("Remove"); checkUpdates = new JButton("Check updates"); download.setEnabled(false); getLinks.setEnabled(false); getLinks.addActionListener(this); remove.setEnabled(false); download.addActionListener(this); remove.addActionListener(this); panel.setBackground(Draw.sidecolor); checkUpdates.addActionListener(this); this.setBackground(Draw.sidecolor); frame.getContentPane().setBackground(Draw.sidecolor); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.insets = new Insets(2, 4, 2, 4); c.gridwidth = 2; genometable.setSelectionMode(0); genometable.setShowGrid(false); remtable.setSelectionMode(0); remtable.setShowGrid(false); JScrollPane scroll = new JScrollPane(); scroll.getViewport().setBackground(Color.white); scroll.getViewport().add(genometable); remscroll.getViewport().setBackground(Color.white); genometable.addMouseListener(this); remtable.addMouseListener(this); // panel.add(welcomeLabel,c); // c.gridy++; c.anchor = GridBagConstraints.NORTHWEST; panel.add(new JLabel("Download genome reference and annotation"), c); c.gridx++; c.anchor = GridBagConstraints.NORTHEAST; panel.add(checkEnsembl, c); c.anchor = GridBagConstraints.NORTHWEST; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy++; //c.fill = GridBagConstraints.NONE; panel.add(scroll, c); c.gridy++; c.fill = GridBagConstraints.NONE; panel.add(download, c); c.gridx = 1; panel.add(sizeError, c); c.gridx = 1; panel.add(getLinks, c); c.gridy++; c.gridx = 0; c.fill = GridBagConstraints.BOTH; panel.add(new JLabel("Add/Remove installed genomes manually"), c); c.gridy++; panel.add(treescroll, c); c.gridy++; c.fill = GridBagConstraints.NONE; c.gridwidth = 1; remove.setMinimumSize(Main.buttonDimension); panel.add(remove, c); c.gridx = 1; panel.add(checkUpdates, c); checkUpdates.setMinimumSize(Main.buttonDimension); checkUpdates.setEnabled(false); c.gridwidth = 2; c.gridx = 0; c.gridy++; try { if (Main.genomeDir != null) { genomedirectory.setText(Main.genomeDir.getCanonicalPath()); } genomedirectory.setEditable(false); genomedirectory.setBackground(Color.white); genomedirectory.setForeground(Color.black); } catch (IOException e1) { e1.printStackTrace(); } panel.add(new JLabel("Genome directory:"), c); c.gridy++; panel.add(genomedirectory, c); /* c.fill = GridBagConstraints.BOTH; c.gridy++; panel.add(new JLabel("Add genome manually"),c); c.gridy++; c.gridwidth = 2; panel.add(new JSeparator(),c); c.gridwidth = 1; c.gridy++; panel.add(genomeFileText, c); c.fill = GridBagConstraints.NONE; c.gridx = 1; panel.add(openRef, c); c.gridx = 0; openRef.addActionListener(this); c.gridy++; panel.add(annotationFileText,c); c.gridx=1; panel.add(openAnno, c); c.gridy++; panel.add(add,c); openAnno.addActionListener(this); add.addActionListener(this); add.setEnabled(false); */ add(panel, BorderLayout.NORTH); if (Main.drawCanvas != null) { setFonts(Main.menuFont); } /* html.append("<a href=http:Homo_sapiens_GRCh37:Ensembl_genes> Homo sapiens GRCh37 with Ensembl</a> or <a href=http:Homo_sapiens_GRCh37:RefSeq_genes>RefSeq</a> gene annotations<br>"); html.append("<a href=http:Homo_sapiens_GRCh38:Ensembl_genes> Homo sapiens GRCh38 with Ensembl</a> or <a href=http:Homo_sapiens_GRCh38:RefSeq_genes>RefSeq</a> gene annotations<br><br>"); html.append("<a href=http:Mus_musculus_GRCm38:Ensembl_genes> Mus musculus GRCm38 with Ensembl</a> or <a href=http:Mus_musculus_GRCm38:RefSeq_genes>RefSeq</a> gene annotations<br>"); html.append("<a href=http:Rattus_norvegicus:Ensembl_genes> Rattus norvegicus with Ensembl gene annotations</a><br>"); html.append("<a href=http:Saccharomyces_cerevisiae:Ensembl_genes> Saccharomyces cerevisiae with Ensembl gene annotation</a><br>"); html.append("<a href=http:Ciona_intestinalis:Ensembl_genes> Ciona intestinalis with Ensembl gene annotation</a><br>"); Object[] row = {"Homo_sapiens_GRCh37"}; Object[] row = {"Homo_sapiens_GRCh38"}; model.addRow(row); /* genomeName.setPreferredSize(new Dimension(300,20)); this.add(genomeName); this.add(new JSeparator()); this.add(openRef); openRef.addActionListener(this); this.add(genomeFileText); this.add(openAnno); openAnno.addActionListener(this); this.add(annotationFileText); this.add(add); add.addActionListener(this); if(annotation) { openRef.setVisible(false); genomeFileText.setVisible(false); genomeName.setEditable(false); } genomeFileText.setEditable(false); annotationFileText.setEditable(false);*/ }
From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java
private void addSubParametersToTree(final SubmodelInfo sInfo, final JTree tree, final DefaultMutableTreeNode node) { try {/* w w w .j ava2s .com*/ final List<ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?>> subparameters = ParameterTreeUtils .fetchSubparameters(currentModelHandler, sInfo); final List<ParameterInfo> convertedSubparameters = new ArrayList<ParameterInfo>(subparameters.size()); for (ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> parameterInfo : subparameters) { final ParameterInfo converted = InfoConverter.parameterInfo2ParameterInfo(parameterInfo); converted.setRuns(0); convertedSubparameters.add(converted); } Collections.sort(convertedSubparameters); final DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel(); if (node.getChildCount() > 0) { node.removeAllChildren(); treeModel.nodeStructureChanged(node); } for (final ParameterInfo pInfo : convertedSubparameters) { final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode( new ParameterInATree(pInfo, currentModelHandler.getModelClass())); treeModel.insertNodeInto(newNode, node, node.getChildCount()); if (pInfo instanceof SubmodelInfo) { final SubmodelInfo ssInfo = (SubmodelInfo) pInfo; if (ssInfo.getActualType() != null) addSubParametersToTree(ssInfo, tree, newNode); } } //tree.expandPath(new TreePath(treeModel.getPathToRoot(node))); } catch (final ModelInformationException e) { sInfo.setActualType(null, null); JOptionPane.showMessageDialog(wizard, new JLabel(e.getMessage()), "Error while analyizing model", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); submodelTypeBox.setSelectedIndex(0); } }