Example usage for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode

List of usage examples for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode DefaultMutableTreeNode.

Prototype

public DefaultMutableTreeNode() 

Source Link

Document

Creates a tree node that has no parent and no children, but which allows children.

Usage

From source file:com.wwidesigner.gui.StudyView.java

protected void updateView() {
    // Reset the Constraints category as needed.
    study.updateConstraints();/*from w  w w  .  ja  v a 2  s  . com*/

    // Build the selection tree.
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    List<TreePath> selectionPaths = new ArrayList<TreePath>();

    // Add all static categories and selection options to the tree.
    for (String category : study.getCategoryNames()) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(category);
        if (node != null) {
            node.setAllowsChildren(true);
            root.add(node);
        }
        String selectedSub = study.getSelectedSub(category);
        Map<String, String> toolTips = study.getCategory(category).getToolTips();
        for (String name : study.getSubcategories(category)) {
            TreeNodeWithToolTips childNode = new TreeNodeWithToolTips(name);
            if (childNode != null) {
                node.add(childNode);
                if (name.equals(selectedSub)) {
                    selectionPaths.add(new TreePath(childNode.getPath()));
                }
                String tip = toolTips.get(name);
                if (tip != null) {
                    childNode.setToolTip(tip);
                }
            }
        }
    }

    TreeModel model = new DefaultTreeModel(root);
    tree.setModel(model);
    TreeUtils.expandAll(tree);
    tree.setSelectionPaths(selectionPaths.toArray(new TreePath[0]));
    setStudyViewName();
    // Update on the appropriate thread
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            updateActions();
        }
    });
}

From source file:net.sf.jhylafax.addressbook.AddressBook.java

public AddressBook() {
    ContactModelFactory cmf = Pim.getContactModelFactory();

    JHylaFAX.initializeToolkit();//www . jav  a 2 s.  com
    initialize();

    ContactDatabase contactDatabase = Pim.getContactDBFactory().createContactDatabase();

    // initialize tree content
    DefaultMutableTreeNode localAddressBookTreeNode = new DefaultMutableTreeNode();
    localAddressBook = new ContactCollection(contactDatabase, i18n.tr("Local Address Book"));
    localAddressBookTreeNode.setUserObject(localAddressBook);
    rootNode.add(localAddressBookTreeNode);
    addressBookTree.expandPath(new TreePath(rootNode));
    addressBookTree.setSelectionRow(0);

    updateActions();
}

From source file:gtu._work.ui.LoadJspCheckTagUI.java

private void setTreeNode(Map<Tag, Set<File>> map) {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    DefaultMutableTreeNode child = null;
    DefaultMutableTreeNode childchild = null;
    List<Tag> list = new ArrayList<Tag>(map.keySet());
    List<File> childList = null;
    Collections.sort(list);//w  w  w  .j  av a  2  s.c om
    for (Tag tagName : list) {
        child = new DefaultMutableTreeNode();
        child.setUserObject(tagName);
        root.add(child);
        childList = new ArrayList<File>(map.get(tagName));
        Collections.sort(childList);
        for (File chfile : childList) {
            childchild = new DefaultMutableTreeNode();
            childchild.setUserObject(new ChieldNode(chfile));
            child.add(childchild);
        }
    }
    jTree1.setModel(new DefaultTreeModel(root));
}

From source file:gdt.jgui.entity.bookmark.JBookmarksFacetOpenItem.java

/**
 * Get children nodes of the facet node for the digest view.
 * @return the children nodes of the facet node.
 *//*from  w w  w  . ja va 2 s. c  o  m*/
@Override
public DefaultMutableTreeNode[] getDigest() {
    try {
        //         System.out.println("JBookmarksFacetOpenItem:getDigest:locator="+locator$);
        Properties locator = Locator.toProperties(locator$);
        entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack entity = entigrator.getEntityAtKey(entityKey$);
        Core[] ca = entity.elementGet("jbookmark");
        if (ca == null)
            return null;
        DefaultMutableTreeNode bookmarkNode;
        ArrayList<DefaultMutableTreeNode> nl = new ArrayList<DefaultMutableTreeNode>();
        String itemLocator$;
        for (Core aCa : ca) {
            bookmarkNode = new DefaultMutableTreeNode();
            itemLocator$ = aCa.value;
            itemLocator$ = Locator.append(itemLocator$, BaseHandler.HANDLER_CLASS, getClass().getName());
            bookmarkNode.setUserObject(itemLocator$);
            nl.add(bookmarkNode);
        }
        //      System.out.println("JBookmarkFacetOpenItem:getDigest:nl="+nl.size());
        return nl.toArray(new DefaultMutableTreeNode[0]);
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
    return null;
}

From source file:gdt.jgui.entity.webset.JWebsetFacetOpenItem.java

/**
 * Get children nodes of the facet node for the digest view.
 * @return the children nodes of the facet node.
 *//*from  ww w  .j  a va  2s .co  m*/
@Override
public DefaultMutableTreeNode[] getDigest() {
    try {
        //      System.out.println("JWebsetFacetOpenItem:getDigest:locator="+locator$);
        Properties locator = Locator.toProperties(locator$);
        entihome$ = locator.getProperty(Entigrator.ENTIHOME);
        entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY);
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack entity = entigrator.getEntityAtKey(entityKey$);
        Core[] ca = entity.elementGet("web");
        if (ca == null)
            return null;
        DefaultMutableTreeNode nameNode;
        DefaultMutableTreeNode valueNode;
        String locator$ = getLocator();
        String nameLocator$;
        String valueLocator$;
        String nameIcon$;//=icon$=Support.readHandlerIcon(JEntitiesPanel.class, "text.png");
        String valueIcon$ = Support.readHandlerIcon(null, JEntitiesPanel.class, "equal.png");
        ArrayList<DefaultMutableTreeNode> nl = new ArrayList<DefaultMutableTreeNode>();
        for (Core aCa : ca) {
            nameNode = new DefaultMutableTreeNode();
            nameLocator$ = Locator.append(locator$, Locator.LOCATOR_TITLE, aCa.type);
            nameLocator$ = Locator.append(nameLocator$, Locator.LOCATOR_TYPE, JWeblinksPanel.WEB_LINK_NAME);
            nameLocator$ = Locator.append(nameLocator$, JWeblinksPanel.WEB_LINK_NAME, aCa.type);
            nameLocator$ = Locator.append(nameLocator$, JWeblinksPanel.WEB_LINK_KEY, aCa.name);
            nameIcon$ = entity.getElementItemAt("web.icon", aCa.name);
            if (nameIcon$ != null)
                nameLocator$ = Locator.append(nameLocator$, Locator.LOCATOR_ICON, nameIcon$);
            nameLocator$ = Locator.append(nameLocator$, JEntityDigestDisplay.NODE_TYPE, NODE_TYPE_WEB_NAME);
            if (entihome$ != null)
                nameLocator$ = Locator.append(nameLocator$, Entigrator.ENTIHOME, entihome$);
            nameLocator$ = Locator.append(nameLocator$, JEntityDigestDisplay.NODE_TYPE, NODE_TYPE_WEB_ADDRESS);
            if (entityKey$ != null)
                nameLocator$ = Locator.append(nameLocator$, EntityHandler.ENTITY_KEY, entityKey$);

            nameNode.setUserObject(nameLocator$);
            valueNode = new DefaultMutableTreeNode();
            valueLocator$ = Locator.append(locator$, Locator.LOCATOR_TITLE, aCa.value);
            valueLocator$ = Locator.append(valueLocator$, JWeblinksPanel.WEB_LINK_NAME, aCa.type);
            valueLocator$ = Locator.append(valueLocator$, JWeblinksPanel.WEB_LINK_URL, aCa.value);
            valueLocator$ = Locator.append(valueLocator$, JWeblinksPanel.WEB_LINK_KEY, aCa.name);
            valueLocator$ = Locator.append(valueLocator$, Locator.LOCATOR_TYPE, LOCATOR_TYPE_WEB_ADDRESS);
            valueLocator$ = Locator.append(valueLocator$, Locator.LOCATOR_ICON, valueIcon$);
            valueLocator$ = Locator.append(valueLocator$, JEntityDigestDisplay.NODE_TYPE,
                    NODE_TYPE_WEB_ADDRESS);
            if (entihome$ != null)
                valueLocator$ = Locator.append(valueLocator$, Entigrator.ENTIHOME, entihome$);
            valueLocator$ = Locator.append(valueLocator$, JEntityDigestDisplay.NODE_TYPE,
                    NODE_TYPE_WEB_ADDRESS);
            if (entityKey$ != null)
                valueLocator$ = Locator.append(valueLocator$, EntityHandler.ENTITY_KEY, entityKey$);

            valueNode.setUserObject(valueLocator$);
            //            System.out.println("JFieldsFacetOpenItem:getDigest:VALUE locator="+valueLocator$);
            nameNode.add(valueNode);
            nl.add(nameNode);
        }
        return nl.toArray(new DefaultMutableTreeNode[0]);
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
    return null;
}

From source file:display.containers.FileManager.java

public Container getPane() {
    //if (gui==null) {

    fileSystemView = FileSystemView.getFileSystemView();
    desktop = Desktop.getDesktop();

    JPanel detailView = new JPanel(new BorderLayout(3, 3));
    //fileTableModel = new FileTableModel();

    table = new JTable();
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setAutoCreateRowSorter(true);// w w  w .j  a  va 2  s.c o m
    table.setShowVerticalLines(false);
    table.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() >= 2) {
                Point p = e.getPoint();
                int row = table.convertRowIndexToModel(table.rowAtPoint(p));
                int column = table.convertColumnIndexToModel(table.columnAtPoint(p));
                if (row >= 0 && column >= 0) {
                    mouseDblClicked(row, column);
                }
            }
        }
    });
    table.addKeyListener(new KeyListener() {

        @Override
        public void keyTyped(KeyEvent arg0) {

        }

        @Override
        public void keyReleased(KeyEvent arg0) {
            if (KeyEvent.VK_DELETE == arg0.getKeyCode()) {
                if (mode != 2) {
                    parentFrame.setLock(true);
                    parentFrame.getProgressBarPanel().setVisible(true);
                    Thread t = new Thread(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                deleteSelectedFiles();
                            } catch (IOException e) {
                                JOptionPane.showMessageDialog(parentFrame, "Error during the deletion.",
                                        "Deletion error", JOptionPane.ERROR_MESSAGE);
                                WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.", e);
                            } finally {
                                parentFrame.setLock(false);
                                refresh();
                                parentFrame.getProgressBarPanel().setVisible(false);
                            }
                        }
                    });
                    t.start();

                } else {
                    if (UserProfile.CURRENT_USER.getLevel() == 3) {
                        parentFrame.setLock(true);
                        parentFrame.getProgressBarPanel().setVisible(true);
                        Thread delThread = new Thread(new Runnable() {

                            @Override
                            public void run() {
                                int[] rows = table.getSelectedRows();
                                int[] columns = table.getSelectedColumns();
                                for (int i = 0; i < rows.length; i++) {
                                    if (!continueAction) {
                                        continueAction = true;
                                        return;
                                    }
                                    int row = table.convertRowIndexToModel(rows[i]);
                                    try {
                                        deleteServerFile(row);
                                    } catch (Exception e) {
                                        WindowManager.mwLogger.log(Level.SEVERE, "Error during the deletion.",
                                                e);
                                    }
                                }
                                refresh();
                                parentFrame.setLock(false);
                                parentFrame.getProgressBarPanel().setVisible(false);
                            }
                        });
                        delThread.start();

                    }
                }
            }
        }

        @Override
        public void keyPressed(KeyEvent arg0) {
            // TODO Auto-generated method stub

        }
    });
    table.getSelectionModel().addListSelectionListener(listSelectionListener);
    JScrollPane tableScroll = new JScrollPane(table);
    Dimension d = tableScroll.getPreferredSize();
    tableScroll.setPreferredSize(new Dimension((int) d.getWidth(), (int) d.getHeight() / 2));
    detailView.add(tableScroll, BorderLayout.CENTER);

    // the File tree
    DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    treeModel = new DefaultTreeModel(root);
    table.getRowSorter().addRowSorterListener(new RowSorterListener() {

        @Override
        public void sorterChanged(RowSorterEvent e) {
            ((FileTableModel) table.getModel()).fireTableDataChanged();
        }
    });

    // show the file system roots.
    File[] roots = fileSystemView.getRoots();
    for (File fileSystemRoot : roots) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(fileSystemRoot);
        root.add(node);
        //showChildren(node);
        //
        File[] files = fileSystemView.getFiles(fileSystemRoot, true);
        for (File file : files) {
            if (file.isDirectory()) {
                node.add(new DefaultMutableTreeNode(file));
            }
        }
        //
    }
    JScrollPane treeScroll = new JScrollPane();

    Dimension preferredSize = treeScroll.getPreferredSize();
    Dimension widePreferred = new Dimension(200, (int) preferredSize.getHeight());
    treeScroll.setPreferredSize(widePreferred);

    JPanel fileView = new JPanel(new BorderLayout(3, 3));

    detailView.add(fileView, BorderLayout.SOUTH);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treeScroll, detailView);

    JPanel simpleOutput = new JPanel(new BorderLayout(3, 3));
    progressBar = new JProgressBar();
    simpleOutput.add(progressBar, BorderLayout.EAST);
    progressBar.setVisible(false);
    showChildren(getCurrentDir().toPath());
    //table.setDragEnabled(true);
    table.setColumnSelectionAllowed(false);

    // Menu popup
    Pmenu = new JPopupMenu();
    changeProjectitem = new JMenuItem("Reassign");
    renameProjectitem = new JMenuItem("Rename");
    twitem = new JMenuItem("To workspace");
    tlitem = new JMenuItem("To local");
    processitem = new JMenuItem("Select for process");
    switch (mode) {
    case 0:
        Pmenu.add(twitem);
        twitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtnlocalTowork().doClick();
            }
        });
        break;
    case 1:
        Pmenu.add(tlitem);
        Pmenu.add(processitem);
        tlitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtnWorkTolocal().doClick();
            }
        });
        processitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        // Recupere les lignes selectionnees
                        int[] indices = table.getSelectedRows();
                        // On recupere les fichiers correspondants
                        ArrayList<File> files = new ArrayList<File>();
                        for (int i = 0; i < indices.length; i++) {
                            int row = table.convertRowIndexToModel(indices[i]);
                            File fi = ((FileTableModel) table.getModel()).getFile(row);
                            if (fi.isDirectory())
                                files.add(fi);
                        }
                        ImageProcessingFrame imf = new ImageProcessingFrame(files);
                    }
                });

            }
        });
        break;
    case 2:
        if (UserProfile.CURRENT_USER.getLevel() == 3) {
            Pmenu.add(changeProjectitem);
            Pmenu.add(renameProjectitem);
        }
        Pmenu.add(twitem);
        twitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtndistToWorkspace().doClick();
            }
        });
        Pmenu.add(tlitem);
        tlitem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                parentFrame.getBtndistToLocal().doClick();
            }
        });
        break;
    }
    changeProjectitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            table.setEnabled(false);
            File from = ((FileTableModel) table.getModel())
                    .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0]));

            ReassignProjectPanel reas = new ReassignProjectPanel(from.toPath()); // mode creation de liens
            Popup popup = PopupFactory.getSharedInstance().getPopup(WindowManager.MAINWINDOW, reas,
                    (int) WindowManager.MAINWINDOW.getX() + 200, (int) WindowManager.MAINWINDOW.getY() + 150);
            reas.setPopupWindow(popup);
            popup.show();
            table.setEnabled(true);
        }
    });
    renameProjectitem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            table.setEnabled(false);
            final File from = ((FileTableModel) table.getModel())
                    .getFile(table.convertRowIndexToModel(table.getSelectedRows()[0]));
            JDialog.setDefaultLookAndFeelDecorated(true);
            String s = (String) JOptionPane.showInputDialog(WindowManager.MAINWINDOW, "New project name ?",
                    "Rename project", JOptionPane.PLAIN_MESSAGE, null, null, from.getName());

            //If a string was returned, say so.
            if ((s != null) && (s.length() > 0)) {
                ProjectDAO pdao = new MySQLProjectDAO();
                if (new File(from.getParent() + File.separator + s).exists()) {
                    SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            JDialog.setDefaultLookAndFeelDecorated(true);
                            JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                    "Couldn't rename " + from.getName()
                                            + " (A file with this filename already exists)",
                                    "Renaming error", JOptionPane.ERROR_MESSAGE);
                        }
                    });
                    WindowManager.mwLogger.log(Level.SEVERE,
                            "Error during file project renaming (" + from.getName() + "). [Duplication error]");
                } else {
                    try {
                        boolean succeed = pdao.renameProject(from.getName(), s);
                        if (!succeed) {
                            SwingUtilities.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    JDialog.setDefaultLookAndFeelDecorated(true);
                                    JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                            "Couldn't rename " + from.getName()
                                                    + " (no project with this name)",
                                            "Renaming error", JOptionPane.ERROR_MESSAGE);
                                }
                            });
                        } else {
                            from.renameTo(new File(from.getParent() + File.separator + s));
                            // on renomme le repertoire nifti ou dicom correspondant si il existe
                            switch (from.getParentFile().getName()) {
                            case ServerInfo.NRI_ANALYSE_NAME:
                                if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_ANALYSE_NAME,
                                        ServerInfo.NRI_DICOM_NAME)).exists())
                                    try {
                                        Files.move(Paths.get(from.getAbsolutePath().replaceAll(
                                                ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)),
                                                Paths.get(from.getParent().replaceAll(
                                                        ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)
                                                        + File.separator + s));
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                        SwingUtilities.invokeLater(new Runnable() {

                                            @Override
                                            public void run() {
                                                JDialog.setDefaultLookAndFeelDecorated(true);
                                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                                        "Couldn't rename " + from.getName()
                                                                + " (error with file system)",
                                                        "Renaming error", JOptionPane.ERROR_MESSAGE);
                                            }
                                        });
                                        WindowManager.mwLogger.log(Level.SEVERE,
                                                "Error during file project renaming (" + from.getName() + ")",
                                                e);
                                    } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_ANALYSE_NAME, ServerInfo.NRI_DICOM_NAME)+File.separator+s));
                                break;
                            case ServerInfo.NRI_DICOM_NAME:
                                if (new File(from.getAbsolutePath().replaceAll(ServerInfo.NRI_DICOM_NAME,
                                        ServerInfo.NRI_ANALYSE_NAME)).exists())
                                    try {
                                        Files.move(Paths.get(from.getAbsolutePath().replaceAll(
                                                ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)),
                                                Paths.get(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME,
                                                        ServerInfo.NRI_ANALYSE_NAME) + File.separator + s));
                                    } catch (IOException e) {
                                        SwingUtilities.invokeLater(new Runnable() {

                                            @Override
                                            public void run() {
                                                JDialog.setDefaultLookAndFeelDecorated(true);
                                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                                        "Couldn't rename " + from.getName()
                                                                + " (error with file system)",
                                                        "Renaming error", JOptionPane.ERROR_MESSAGE);
                                            }
                                        });
                                        e.printStackTrace();
                                        WindowManager.mwLogger.log(Level.SEVERE,
                                                "Error during file project renaming (" + from.getName() + ")",
                                                e);
                                    } //from.renameTo(new File(from.getParent().replaceAll(ServerInfo.NRI_DICOM_NAME, ServerInfo.NRI_ANALYSE_NAME)+File.separator+s));
                                break;
                            }
                            refresh();
                        }
                    } catch (final SQLException e) {
                        WindowManager.mwLogger.log(Level.SEVERE, "Error during SQL project renaming", e);
                        SwingUtilities.invokeLater(new Runnable() {

                            @Override
                            public void run() {
                                JDialog.setDefaultLookAndFeelDecorated(true);
                                JOptionPane.showMessageDialog(WindowManager.MAINWINDOW,
                                        "Exception : " + e.toString(), "Openning error",
                                        JOptionPane.ERROR_MESSAGE);
                            }
                        });
                    }
                }
            }
            table.setEnabled(true);
        }
    });
    table.addMouseListener(new MouseListener() {

        public void mouseClicked(MouseEvent me) {

        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent me) {
            if (me.getButton() == 3 && table.getSelectedRowCount() > 0) {
                int row = table.convertRowIndexToModel(table.rowAtPoint(me.getPoint()));
                changeProjectitem.setVisible(isPatient(((FileTableModel) table.getModel()).getFile(row)));
                renameProjectitem.setVisible(isProject(((FileTableModel) table.getModel()).getFile(row)));
                Pmenu.show(me.getComponent(), me.getX(), me.getY());
            }
        }
    });
    //

    //}
    return tableScroll;
}

From source file:gdt.jgui.entity.contact.JContactFacetOpenItem.java

@Override
public DefaultMutableTreeNode[] getDigest() {
    try {/*from  w  w w. ja v  a  2s. co m*/
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack entity = entigrator.getEntityAtKey(entityKey$);
        contact$ = entity.getProperty("contact");
        String locator$ = getLocator();
        locator$ = Locator.append(locator$, Locator.LOCATOR_TITLE, contact$);
        DefaultMutableTreeNode contactNode = new DefaultMutableTreeNode();
        contactNode.setUserObject(locator$);
        return new DefaultMutableTreeNode[] { contactNode };

    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
    return null;
}

From source file:net.sf.jhylafax.addressbook.AddressBook.java

private void initializeContent() {
    horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    horizontalSplitPane.setBorder(GUIHelper.createEmptyBorder(5));

    rootNode = new DefaultMutableTreeNode();
    addressBookTreeModel = new DefaultTreeModel(rootNode);
    addressBookTree = new JTree(addressBookTreeModel);
    addressBookTree.setRootVisible(false);
    addressBookTree.setCellRenderer(new ContactCollectionCellRenderer());
    horizontalSplitPane.add(new JScrollPane(addressBookTree));

    JPanel contactPanel = new JPanel();
    contactPanel.setLayout(new BorderLayout(0, 10));
    horizontalSplitPane.add(contactPanel);

    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("min, 3dlu, min, 3dlu, pref:grow, 3dlu, min", ""));
    contactPanel.add(builder.getPanel(), BorderLayout.NORTH);

    searchTextField = new JTextField(10);
    EraseTextFieldAction eraseAction = new EraseTextFieldAction(searchTextField) {
        public void actionPerformed(ActionEvent event) {
            super.actionPerformed(event);
            filterAction.actionPerformed(event);
        };/*w  w  w  .ja v  a 2  s .  com*/
    };
    builder.append(new TabTitleButton(eraseAction));
    filterLabel = new JLabel();
    builder.append(filterLabel);
    builder.append(searchTextField);
    GUIHelper.bindEnterKey(searchTextField, filterAction);

    builder.append(Builder.createButton(filterAction));

    JPopupMenu tablePopupMenu = new JPopupMenu();
    tablePopupMenu.add(Builder.createMenuItem(newAction));
    tablePopupMenu.addSeparator();
    tablePopupMenu.add(Builder.createMenuItem(editAction));
    tablePopupMenu.addSeparator();
    tablePopupMenu.add(Builder.createMenuItem(deleteAction));

    contactTableModel = new AddressTableModel();
    TableSorter sorter = new TableSorter(contactTableModel);
    contactTable = new ColoredTable(sorter);
    contactTableLayoutManager = new TableLayoutManager(contactTable);
    contactTableLayoutManager.addColumnProperties("displayName", "", 180, true);
    contactTableLayoutManager.addColumnProperties("company", "", 80, true);
    contactTableLayoutManager.addColumnProperties("faxNumber", "", 60, true);
    contactTableLayoutManager.initializeTableLayout();
    contactPanel.add(new JScrollPane(contactTable), BorderLayout.CENTER);

    contactTable.setShowVerticalLines(true);
    contactTable.setShowHorizontalLines(false);
    contactTable.setAutoCreateColumnsFromModel(true);
    contactTable.setIntercellSpacing(new java.awt.Dimension(2, 1));
    contactTable.setBounds(0, 0, 50, 50);
    contactTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    contactTable.getSelectionModel().addListSelectionListener(this);
    contactTable.addMouseListener(new PopupListener(tablePopupMenu));
    contactTable.addMouseListener(new DoubleClickListener(new TableDoubleClickAction()));
    contactTable.setTransferHandler(new ContactTransferHandler());
    contactTable.setDragEnabled(true);

    contactTable.setDefaultRenderer(String.class, new StringCellRenderer());

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(horizontalSplitPane, BorderLayout.CENTER);
}

From source file:gdt.jgui.entity.email.JEmailFacetOpenItem.java

@Override
public DefaultMutableTreeNode[] getDigest() {
    try {/*from w ww.  j  a  v a2  s.  c  om*/
        Entigrator entigrator = console.getEntigrator(entihome$);
        Sack entity = entigrator.getEntityAtKey(entityKey$);
        String email$ = entity.getProperty("email");
        String locator$ = getLocator();
        locator$ = Locator.append(locator$, Locator.LOCATOR_TITLE, email$);
        DefaultMutableTreeNode emailNode = new DefaultMutableTreeNode();
        emailNode.setUserObject(locator$);
        return new DefaultMutableTreeNode[] { emailNode };

    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
    }
    return null;
}

From source file:com.enderville.enderinstaller.ui.Installer.java

private CheckBoxTree getModTree() {
    if (modTree == null) {
        modTreeRoot = new DefaultMutableTreeNode();
        treeNodeMap = new HashMap<String, DefaultMutableTreeNode>();
        try {/* w  w  w . j a v  a2  s.c  om*/
            File opt = new File(InstallerConfig.getExtraModsFolder());
            for (File mod : opt.listFiles()) {
                if (!mod.isDirectory()) {
                    continue;
                }
                String modName = mod.getName();
                DefaultMutableTreeNode child = new DefaultMutableTreeNode(modName);
                treeNodeMap.put(modName, child);
                modTreeRoot.add(child);
            }
            modTree = new CheckBoxTree(modTreeRoot);
            modTree.setRootVisible(false);
            modTree.getSelectionModel().addTreeSelectionListener(this);
            modTree.getCheckBoxTreeSelectionModel().addTreeSelectionListener(this);
        } catch (Exception e) {
            LOGGER.error("Error scanning and building optional mod tree.", e);
            JOptionPane.showMessageDialog(this, "Error scanning mods folder. It may not exists.", "Error",
                    JOptionPane.ERROR_MESSAGE);
            setVisible(false);
            dispose();
            return null;
        }
    }
    return modTree;
}