Package javax.swing.tree

Examples of javax.swing.tree.DefaultMutableTreeNode$BreadthFirstEnumeration$Queue


     *
     * @return tree for selection the transformation target.
     */
    private JTree createTree() {
        DefaultTreeModel treeModel = new DefaultTreeModel(
                new DefaultMutableTreeNode("root"));
        JTree result = new JTree(treeModel);
        result.addTreeSelectionListener(this);
        result.setCellRenderer(new TreeRenderer());
        result.getSelectionModel().setSelectionMode(
                TreeSelectionModel.SINGLE_TREE_SELECTION);
        HashMap lang2list = new HashMap();
        TransformTarget[] available = (TransformTarget[]) XslTransformer
                .getTransformTargets().toArray(new TransformTarget[0]);
        Arrays.sort(available, new LangTypeComp());
        for (int i = 0; i < available.length; i++) {
            String lang = available[i].getLanguage();
            ArrayList list = (ArrayList) lang2list.get(lang);
            if (list == null) {
                list = new ArrayList();
                lang2list.put(lang, list);
            }
            list.add(available[i]);
        }
        String[] languages = (String[]) lang2list.keySet().toArray(
                new String[0]);
        Arrays.sort(languages);
        TreePath tp = null;
        for (int i = 0; i < languages.length; i++) {
            DefaultMutableTreeNode langNode = new DefaultMutableTreeNode(
                    languages[i]);
            ((DefaultMutableTreeNode) result.getModel().getRoot())
                    .add(langNode);
            langNode.setAllowsChildren(true);
            TransformTarget[] targets = (TransformTarget[]) ((ArrayList) lang2list
                    .get(languages[i])).toArray(new TransformTarget[0]);
            Arrays.sort(targets);
            for (int j = 0; j < targets.length; j++) {
                DefaultMutableTreeNode tt = new DefaultMutableTreeNode(
                        targets[j]);
                langNode.add(tt);
                if (targets[j].equals(transformTask.getConfiguration()
                        .getTransformTarget())) {
                    tp = new TreePath(new Object[] {
View Full Code Here


     * @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent)
     */
    public void valueChanged(TreeSelectionEvent e) {
        TransformTarget selected = null;
        if (e.getPath().getLastPathComponent() instanceof DefaultMutableTreeNode) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath()
                    .getLastPathComponent();
            if (node.getUserObject() instanceof TransformTarget) {
                selected = (TransformTarget) node.getUserObject();
                try {
                    description.getDocument().remove(0,
                            description.getDocument().getLength());
                    description.getDocument().insertString(0,
                            selected.getDescription(),
View Full Code Here

        /** Expansion */
        public void treeExpanded(TreeExpansionEvent e) {
            if (area != null) {
                area.repaint();
            }
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) (e.getPath()
                    .getLastPathComponent());
            Task task = (Task) node.getUserObject();

            /*
             * if(!expand.contains(new Integer(task.getTaskID()))) {
             * expand.add(new Integer(task.getTaskID()));
             * appli.setAskForSave(true); }
View Full Code Here

        public void treeCollapsed(TreeExpansionEvent e) {
            if (area != null) {
                area.repaint();
            }

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) (e.getPath()
                    .getLastPathComponent());
            Task task = (Task) node.getUserObject();

            /*
             * int index = expand.indexOf(new Integer(task.getTaskID())); if
             * (index >= 0) { expand.remove(index); appli.setAskForSave(true); }
             */
 
View Full Code Here

        }

        /** Insert a new node. */
        public void treeNodesInserted(TreeModelEvent e) {

            DefaultMutableTreeNode node = (DefaultMutableTreeNode) (e
                    .getTreePath().getLastPathComponent());
            Task task = (Task) node.getUserObject();

            /*
             * if (!expand.contains(new Integer(task.getTaskID()))) {
             * expand.add(new Integer(task.getTaskID())); }
             */
 
View Full Code Here

    }

    /** Construct the menu settings. */
    public void constructSections() {
        addPagesFromProviders();
        DefaultMutableTreeNode projectNode = addObject(GanttProject
                .correctLabel(language.getText("project")), null);
        DefaultMutableTreeNode generalNode = addObject(language
                .getText("general"), null);
        DefaultMutableTreeNode exportNode = addObject(GanttProject
                .correctLabel(language.getText("export")), null);
        DefaultMutableTreeNode roleNode = addObject(language
                .getText("resourceRole"), null);

        // general section
        addObject(language.getText("parameters"), generalNode);
        addObject(language.getText("looknfeel"), generalNode);
View Full Code Here

    /** Callback for the tree selection event. */
    public void valueChanged(TreeSelectionEvent e) {
        if (reinit)
            return;
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) (e.getPath()
                .getLastPathComponent());
        boolean bHasChange = settingPanel.applyChanges(true);

        // construct the sections
        if ((settingPanel instanceof LanguageSettingsPanel) && bHasChange) {
            reinit = true;
            rootNode.removeAllChildren();
            treeModel.setRoot(rootNode);
            treeModel.reload();
            constructSections();
            reinit = false;
        }

        // - remove the settingPanel
        mainPanel2.remove(0);
       
        Box vb = Box.createVerticalBox();       
        Object userObject = node.getUserObject();
        if (userObject instanceof OptionPageProvider) {
            settingPanel = new OptionPageProviderPanel((OptionPageProvider) userObject, getProject(), getUIFacade());
        }
        else {

        // - ask the settingPanel if parameters are changed

        // - Create the new panel
            String sNode = (String) (node.getUserObject());
            if (sNode.equals(language.getText("languages")))
                settingPanel = new LanguageSettingsPanel(appli);
   
            else if (sNode.equals(GanttProject.correctLabel(language
                    .getText("project"))))
View Full Code Here

                DataFlavor flavor = flavors[i];
                if (flavor
                        .isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) {
                    try {
                        Point pt = dtde.getLocation();
                        DefaultMutableTreeNode target = (DefaultMutableTreeNode) treetable
                                .getTree()
                                .getClosestPathForLocation(pt.x, pt.y)
                                .getLastPathComponent();
                        TreePath pathSource = (TreePath) transferable
                                .getTransferData(flavor);
                        DefaultMutableTreeNode source = (DefaultMutableTreeNode) pathSource
                                .getLastPathComponent();

                        TreePath pathNewChild = null;

                        TreeNode sourceFather = source.getParent();
                        int index = sourceFather.getIndex(source);
                        source.removeFromParent();

                        treeModel.nodesWereRemoved(sourceFather,
                                new int[] { index }, new Object[] { source });

                        ((GanttTreeTableModel) treeModel).insertNodeInto(
View Full Code Here

    }

    /** Create a new Human */
    public void newHuman(HumanResource people) {
        if (people != null) {
            DefaultMutableTreeNode result = model.addResource(people);
            table.getTree().scrollPathToVisible(new TreePath(result.getPath()));
        }
    }
View Full Code Here

      }
    }

    public void saveSelectionToClipboard(boolean cut)
    {
      DefaultMutableTreeNode selectedNodes[] = this.table.getSelectedNodes();

      if(selectedNodes == null)
        return;

      /*count instances of ResourceNode*/
 
View Full Code Here

TOP

Related Classes of javax.swing.tree.DefaultMutableTreeNode$BreadthFirstEnumeration$Queue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.