Example usage for javax.swing JToolBar setRollover

List of usage examples for javax.swing JToolBar setRollover

Introduction

In this page you can find the example usage for javax.swing JToolBar setRollover.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "Will draw rollover button borders in the toolbar.")
public void setRollover(boolean rollover) 

Source Link

Document

Sets the rollover state of this toolbar.

Usage

From source file:src.gui.ItSIMPLE.java

/**
 * @return Returns the PetriContainer.//w  w w.j a  va2s  .  co  m
 */
private JXTaskPaneContainer getPetriContainer() {
    if (projectPetriContainer == null) {
        projectPetriContainer = new JXTaskPaneContainer();

        //project
        projectPetriTaskPane = new JXTaskPane();
        projectPetriTaskPane.setTitle("Project");
        projectPetriTaskPane.setIcon(new ImageIcon("resources/images/projects.png"));
        projectPetriTaskPane.setSpecial(true);

        //state chart diagrams
        stateMachinePetriTaskPane = new JXTaskPane();
        stateMachinePetriTaskPane.setTitle("State Chart Diagrams");
        stateMachinePetriTaskPane.setIcon(new ImageIcon("resources/images/planningProblem.png"));
        stateMachinePetriTaskPane.setLayout(new BorderLayout());
        stateMachinePetriPanel = new JPanel(new BorderLayout());

        stateMachineJList = new JList(new DefaultListModel());
        ItListRenderer renderer = new ItListRenderer();
        renderer.setIcon(new ImageIcon("resources/images/stateMachineDiagram.png"));
        stateMachineJList.setCellRenderer(renderer);

        stateMachinePetriPanel.add(stateMachineJList, BorderLayout.CENTER);
        JToolBar toolBar = new JToolBar();
        toolBar.setRollover(true);
        stateMachineButton = new JButton(openPetriNetGroup);
        toolBar.add(stateMachineButton);

        stateMachinePetriTaskPane.add(stateMachinePetriPanel, BorderLayout.CENTER);
        stateMachinePetriTaskPane.add(toolBar, BorderLayout.SOUTH);
        /*petriCheckBoxList = new CheckBoxList();
        stateMachinePetriTaskPane.add(petriCheckBoxList, BorderLayout.CENTER);*/

        //details
        detailPetriTaskPane = new JXTaskPane();
        detailPetriTaskPane.setTitle("Details");
        detailPetriTaskPane.setIcon(new ImageIcon("resources/images/details.png"));

        detailPetriTaskPane.add(getPetriDetailsTextPane());
        petriDetailsTextPane.setBackground(petriDetailsTextPane.getParent().getBackground());

        projectPetriContainer.add(projectPetriTaskPane);
        projectPetriContainer.add(stateMachinePetriTaskPane);
        projectPetriContainer.add(detailPetriTaskPane);

    }

    return projectPetriContainer;
}

From source file:src.gui.ItSIMPLE.java

/**
 * Creates the main content panel in the main analysis panel
 * @return /*from w  ww . j a  v  a2  s.c  o m*/
 */
private JPanel getAnalysisMainContentPane() {

    JPanel anPanel = new JPanel(new BorderLayout());

    ItFramePanel mainContentPanel = new ItFramePanel(":: Analysis Techniques and Results",
            ItFramePanel.NO_MINIMIZE_MAXIMIZE);

    //Content of the FramePanel            
    JPanel resultsPanel = new JPanel(new BorderLayout());

    JToolBar analysisToolSetBar = new JToolBar();
    analysisToolSetBar.setRollover(true);

    JButton TorchlightButton = new JButton("TorchLight", new ImageIcon("resources/images/compare.png"));
    TorchlightButton.setToolTipText(
            "<html>Run TorchLight system. <br>TorchLight analyzes h+ search space topology without actually running any search</html>");
    TorchlightButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            new Thread() {
                public void run() {

                    ItTreeNode selectedNode = (ItTreeNode) projectAnalysisTree.getLastSelectedPathComponent();

                    if (selectedNode.getData() != null
                            && selectedNode.getData().getName().indexOf("problem") != -1) {
                        appendAnalysisOutputPanelText(
                                "(!) Know more about TorchLight at http://www.loria.fr/~hoffmanj/ \n");
                        appendAnalysisOutputPanelText(">> Calling TorchLight System... \n");
                        analysisStatusBar.setText("Status: Running Tourchlight ...");

                        String pddlVersion = pddlButtonsGroup.getSelection().getActionCommand();

                        //Call TorchLight
                        TorchLightAnalyzer.getTorchLightAnalysis(selectedNode, pddlVersion);

                        appendAnalysisOutputPanelText(">> TorchLight analysis done!'\n");
                        appendAnalysisOutputPanelText(" \n");
                        analysisStatusBar.setText("Status: Tourchlight analysis done!");
                    } else {
                        JOptionPane.showMessageDialog(ItSIMPLE.this,
                                "<html>Please chose a problem node at the 'Project Selection' tree. </html>");
                    }

                }
            }.start();

        }
    });
    analysisToolSetBar.add(TorchlightButton);

    //Results output
    outputAnalysisEditorPane = new JTextArea();
    //analysisInfoEditorPane.setContentType("text/html");
    outputAnalysisEditorPane.setEditable(false);
    outputAnalysisEditorPane.setLineWrap(true);
    outputAnalysisEditorPane.setWrapStyleWord(true);
    outputAnalysisEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR));
    outputAnalysisEditorPane.setBackground(Color.WHITE);

    //analysisInfoEditorPane = new JEditorPane();
    //analysisInfoEditorPane.setContentType("text/html");
    //analysisInfoEditorPane.setEditable(false);
    //analysisInfoEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR));
    //analysisInfoEditorPane.setBackground(Color.WHITE);                    

    resultsPanel.add(analysisToolSetBar, BorderLayout.NORTH);
    resultsPanel.add(new JScrollPane(outputAnalysisEditorPane), BorderLayout.CENTER);

    mainContentPanel.setContent(resultsPanel, false);
    //mainContentPanel.setParentSplitPane(petriEditorSplitPane);           
    anPanel.add(mainContentPanel, BorderLayout.CENTER);

    return anPanel;
}

From source file:src.gui.ItSIMPLE.java

private JToolBar getRationaleDatabaseToolBar() {

    JToolBar rationaleDatabaseToolBar = new JToolBar();
    rationaleDatabaseToolBar.setRollover(true);

    // create the buttons

    //select rationales from data base
    JButton searchButton = new JButton("Search", new ImageIcon("resources/images/searchdatabase.png"));
    searchButton.setToolTipText("Search rationales in the database");
    searchButton.addActionListener(new java.awt.event.ActionListener() {
        @Override//from  w  w w .ja  v a  2s  . c om
        public void actionPerformed(ActionEvent e) {
            //RUN search plan from database
            searchRationaleInDatabaseAction.actionPerformed(e);
        }
    });
    rationaleDatabaseToolBar.add(searchButton);

    rationaleDatabaseToolBar.addSeparator();

    /*
    //insert new rationale into data base
    JButton addRationaleToDatabaseButton = new JButton("Add Plan",  new ImageIcon("resources/images/addplantodatabase.png"));
    addRationaleToDatabaseButton.setToolTipText("Add current plan to the database");
    addRationaleToDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //RUN plan evaluation edit
                insertPlanIntoDatabaseAction.actionPerformed(e);
            }
    });
    rationaleDatabaseToolBar.add(addRationaleToDatabaseButton);
     */

    //edit rationale from database
    JButton editRatioanleFromDatabaseButton = new JButton("Edit Rationale",
            new ImageIcon("resources/images/editrationalefromdatabase.png"));
    editRatioanleFromDatabaseButton.setToolTipText("Edit selected rationale");
    editRatioanleFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN editing plan
            editRationaleFromDatabaseAction.actionPerformed(e);
        }
    });
    rationaleDatabaseToolBar.add(editRatioanleFromDatabaseButton);

    //delete rationale from database
    JButton deleteRationaleFromDatabaseButton = new JButton("Delete Rationale",
            new ImageIcon("resources/images/deleteplanfromdatabase.png"));
    deleteRationaleFromDatabaseButton.setToolTipText("Delete selected rationale");
    deleteRationaleFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN loading plan
            deleteRationaleFromDatabaseAction.actionPerformed(e);
        }
    });
    rationaleDatabaseToolBar.add(deleteRationaleFromDatabaseButton);

    rationaleDatabaseToolBar.addSeparator();

    //load reference plan from database
    JButton loadReferencePlanFromDatabaseButton = new JButton("Load Plan",
            new ImageIcon("resources/images/getfromdatabase.png"));
    loadReferencePlanFromDatabaseButton.setToolTipText("Load reference plan of the selected rationale");
    loadReferencePlanFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN editing plan
            loadReferencePlanFromDatabaseAction.actionPerformed(e);
        }
    });
    rationaleDatabaseToolBar.add(loadReferencePlanFromDatabaseButton);

    return rationaleDatabaseToolBar;
}

From source file:src.gui.ItSIMPLE.java

private JToolBar getPlanDatabaseToolBar() {

    JToolBar planDatabaseToolBar = new JToolBar();
    planDatabaseToolBar.setRollover(true);

    // create the buttons

    //select plans from data base

    JButton searchButton = new JButton("Search", new ImageIcon("resources/images/searchdatabase.png"));
    searchButton.setToolTipText("Search plans in the database");
    searchButton.addActionListener(new java.awt.event.ActionListener() {
        @Override/*from ww  w .j  a  v  a 2s . c o  m*/
        public void actionPerformed(ActionEvent e) {
            //RUN search plan from database
            searchPlanInDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(searchButton);

    final JButton filterButton = new JButton("Filter",
            new ImageIcon("resources/images/filtersearchdatabase.png"));
    filterButton
            .setToolTipText("Filter the search for plans in the database (use colunms of table 'plan' only)");
    filterButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //hide/show filter panel
            if (planFilterPanel.isVisible()) {
                planFilterPanel.setVisible(false);
                filterButton.setText("Filter");
            } else {
                planFilterPanel.setVisible(true);
                filterButton.setText("Don't filter");
            }
        }
    });
    planDatabaseToolBar.add(filterButton);

    planDatabaseToolBar.addSeparator();

    //insert plan into data base
    JButton addPlanToDatabaseButton = new JButton("Add Plan",
            new ImageIcon("resources/images/addplantodatabase.png"));
    addPlanToDatabaseButton.setToolTipText("Add current plan to the database");
    addPlanToDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation edit
            insertPlanIntoDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(addPlanToDatabaseButton);

    //load plan from data base
    JButton loadPlanFromDatabaseButton = new JButton("Load Plan",
            new ImageIcon("resources/images/getfromdatabase.png"));
    loadPlanFromDatabaseButton.setToolTipText("Load selected plan into itSIMPLE");
    loadPlanFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN loading plan
            loadPlanFromDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(loadPlanFromDatabaseButton);

    //delete plan from data base
    JButton deletePlanFromDatabaseButton = new JButton("Delete Plan",
            new ImageIcon("resources/images/deleteplanfromdatabase.png"));
    deletePlanFromDatabaseButton.setToolTipText("Delete selected plan");
    deletePlanFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN loading plan
            deletePlanFromDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(deletePlanFromDatabaseButton);

    //update plan from data base
    JButton updatePlanFromDatabaseButton = new JButton("Update Plan",
            new ImageIcon("resources/images/updateplanfromdatabase.png"));
    updatePlanFromDatabaseButton.setToolTipText("Update current plan");
    updatePlanFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN update plan
            updatePlanFromDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(updatePlanFromDatabaseButton);

    return planDatabaseToolBar;
}

From source file:src.gui.ItSIMPLE.java

private JToolBar getPlanEvaluationToolBar() {

    JToolBar planEvaluationToolBar = new JToolBar();
    planEvaluationToolBar.setRollover(true);

    // create the buttons

    // plan evaluation

    JButton planEvaluationButton = new JButton("Evaluate Plan", new ImageIcon("resources/images/eval.png"));
    planEvaluationButton.setToolTipText(
            "<html>Evaluate current plan based on the specified metrics. <br> This is restricted to non-time-based domain only.</html>");
    planEvaluationButton.addActionListener(new java.awt.event.ActionListener() {
        @Override/*  w  w  w. j a  va2  s  .  c o m*/
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation
            quickEvaluation.actionPerformed(e);
        }
    });
    planEvaluationToolBar.add(planEvaluationButton);

    JButton planEvaluationReportButton = new JButton("Evaluation Report",
            new ImageIcon("resources/images/viewreport.png"));
    planEvaluationReportButton.setToolTipText(
            "<html>Generate a html plan evaluation in the planReport. <br> This is restricted to non-time-based domain only.</html>");
    planEvaluationReportButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation
            generateEvaluationReport.actionPerformed(e);
        }
    });
    planEvaluationToolBar.add(planEvaluationReportButton);

    JButton editEvaluationButton = new JButton("Edit Evaluation", new ImageIcon("resources/images/edit.png"));
    editEvaluationButton.setToolTipText("<html>Modify plan classification and its metrics evaluation.</html>");
    editEvaluationButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation edit
            changePlanEvaluationAction.actionPerformed(e);
        }
    });
    planEvaluationToolBar.add(editEvaluationButton);

    //JButton applyNewEvaluationButton = new JButton("Apply Modified Evaluation",  new ImageIcon("resources/images/apply.png"));
    //planEvaluationToolBar.add(applyNewEvaluationButton);

    planEvaluationToolBar.addSeparator();

    JButton insertRationaleButton = new JButton("Insert Rationale",
            new ImageIcon("resources/images/feedbackrationale.png"));
    insertRationaleButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation edit
            insertPlanEvaluationRationaleAction.actionPerformed(e);
        }
    });
    planEvaluationToolBar.add(insertRationaleButton);

    checkExistingRationaleButton = new JButton("Reuse Existing Rationales",
            new ImageIcon("resources/images/feedbackrationale.png"));
    checkExistingRationaleButton.setActionCommand("reuse");
    checkExistingRationaleButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN rationales reuse
            if (checkExistingRationaleButton.getActionCommand().equals("reuse")) {
                checkExistingRationaleButton.setActionCommand("stop");
                checkExistingRationaleButton.setText("Stop Reasoning");
                reuseRationalesAction.actionPerformed(e);
            } else {
                //stop the thread
                if (reuserationaleThread.isAlive()) {
                    try {
                        // waits for the thread to return
                        reuserationaleThread.join(2000);// 2 seconds time-out
                    } catch (InterruptedException e1) {
                        e1.printStackTrace();
                    }
                    if (reuserationaleThread.isAlive()) {
                        reuserationaleThread.interrupt();
                    }
                }
                checkExistingRationaleButton.setActionCommand("reuse");
                checkExistingRationaleButton.setText("Reuse Existing Rationales");
                planSimStatusBar.setText("Status: Reasoning process stopped.");

            }

            /*
            try {
                    
                        
                String theoryText = "casa(a1). \n"+
                "casa(a2).\n"+
                "casa(a3).\n";
                         
                Prolog engine = new Prolog();
                Theory t = new Theory(new java.io.FileInputStream("/home/tiago/Desktop/base.pl"));
                //Theory t = new Theory(theoryText);
                engine.setTheory(t);
                //SolveInfo answer = engine.solve("casa(X).");
                        
                SolveInfo answer = engine.solve("teste(p1,_).");
                while (answer.isSuccess()) {
                    System.out.println("solution: " + answer.getSolution() + " - bindings: " + answer);                                
                    System.out.println("X: " + answer.getTerm("X"));
                    if (engine.hasOpenAlternatives()) {
                try {
                    answer = engine.solveNext();
                } catch (NoMoreSolutionException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                }
                    } else {
                        break;
                    }
                }
                    
                //engine.solveHalt();
                    
                        
            } catch (UnknownVarException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            } catch (NoSolutionException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            } catch (MalformedGoalException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InvalidTheoryException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            }
            */

        }
    });
    planEvaluationToolBar.add(checkExistingRationaleButton);

    //JButton addPlanToDatabaseButton = new JButton("Add Plan to Database",  new ImageIcon("resources/images/addplantodatabase.png"));
    //addPlanToDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
    //        @Override
    //        public void actionPerformed(ActionEvent e) {
    //            //RUN plan evaluation edit
    //            insertPlanIntoDatabaseAction.actionPerformed(e);
    //        }
    //});
    //planEvaluationToolBar.add(addPlanToDatabaseButton);

    return planEvaluationToolBar;
}

From source file:src.gui.ItSIMPLE.java

/**
 * This method initializes movieMakerToolBar
 *
 * @return javax.swing.JToolBar/*  ww w .j  a v  a  2  s .c  o  m*/
 */
private JToolBar getMovieMakerToolBar() {

    JToolBar movieMakerToolBar = new JToolBar();
    movieMakerToolBar.setRollover(true);

    // create the buttons

    // generate movie
    JButton generateMovieButton = new JButton("Generate Movie",
            new ImageIcon("resources/images/makemovie.png"));
    generateMovieButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {

            // the thread is created so the status bar can be refreshed
            new Thread() {
                public void run() {
                    ItTreeNode selectedNode = (ItTreeNode) problemsPlanTree.getLastSelectedPathComponent();
                    if (selectedNode != null && selectedNode.getLevel() == 3) {

                        Element problem = selectedNode.getData();
                        movie = PlanSimulator.getMovie(xmlPlan, problem);
                        //XMLUtilities.printXML(xmlPlan);
                        //XMLUtilities.printXML(movie);

                        //IN CASE WE WANT TO RUN THE METRICS WITH SIMULATION
                        //Element domain = problem.getParentElement().getParentElement();
                        //Element metrics = PlanSimulator.createMetricsNode(problem, domain);
                        //if(metrics.getChildren().size() > 0){
                        //    PlanSimulator.createMetricDatasets(metrics, xmlPlan, problem, domain, movie);
                        //}
                        //XMLUtilities.printXML(metrics);

                        PlanNavigationList.getInstance().setList(xmlPlan, movie,
                                problem.getParentElement().getParentElement(),
                                (JPanel) movieMakerSplitPane.getLeftComponent(),
                                (JPanel) movieMakerSplitPane.getRightComponent());
                        replanMenu.setEnabled(true);
                    }
                }
            }.start();
        }
    });
    movieMakerToolBar.add(generateMovieButton);

    // back
    JButton backButton = new JButton("Backward", new ImageIcon("resources/images/backward.png"));
    backButton.setToolTipText("Backward");
    backButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JList navigationList = PlanNavigationList.getInstance().getPlanList();
            final int selected = navigationList.getSelectedIndex();
            if (selected > 0) {
                navigationList.setSelectedIndex(selected - 1);
            }
        }

    });
    movieMakerToolBar.add(backButton);

    // forward
    JButton forwardButton = new JButton("Forward", new ImageIcon("resources/images/forward.png"));
    forwardButton.setToolTipText("Forward");
    forwardButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JList navigationList = PlanNavigationList.getInstance().getPlanList();
            final int selected = navigationList.getSelectedIndex();
            if (selected > -1 && selected < navigationList.getModel().getSize() - 1) {
                navigationList.setSelectedIndex(selected + 1);
            }
        }

    });
    movieMakerToolBar.add(forwardButton);

    movieMakerToolBar.addSeparator();

    // zoom in
    //JButton zoomInButton = new JButton("Zoom In",new ImageIcon("resources/images/zoomIN.png"));
    JButton zoomInButton = new JButton(new ImageIcon("resources/images/zoomIN.png"));
    zoomInButton.setToolTipText("Zoom In");
    zoomInButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {

            try {
                ItGraph leftGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getLeftComponent())
                        .getComponent(0)).getViewport().getView();
                leftGraph.setScale(leftGraph.getScale() * 1.25);

                ItGraph rightGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getRightComponent())
                        .getComponent(0)).getViewport().getView();
                rightGraph.setScale(rightGraph.getScale() * 1.25);
            } catch (Exception e1) {
            }

        }
    });
    movieMakerToolBar.add(zoomInButton);

    // zoom out
    //JButton zoomOutButton = new JButton("Zoom Out",new ImageIcon("resources/images/zoomOUT.png"));
    JButton zoomOutButton = new JButton(new ImageIcon("resources/images/zoomOUT.png"));
    zoomOutButton.setToolTipText("Zoom Out");
    zoomOutButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {

            try {
                ItGraph leftGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getLeftComponent())
                        .getComponent(0)).getViewport().getView();
                leftGraph.setScale(leftGraph.getScale() * 0.8);

                ItGraph rightGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getRightComponent())
                        .getComponent(0)).getViewport().getView();
                rightGraph.setScale(rightGraph.getScale() * 0.8);
            } catch (Exception e1) {
            }

        }
    });
    movieMakerToolBar.add(zoomOutButton);

    // 1:1
    JButton oneToOneScaleButton = new JButton("1:1");
    oneToOneScaleButton.setToolTipText("1:1");
    oneToOneScaleButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {

            try {
                ItGraph leftGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getLeftComponent())
                        .getComponent(0)).getViewport().getView();
                leftGraph.setScale(1.0);

                ItGraph rightGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getRightComponent())
                        .getComponent(0)).getViewport().getView();
                rightGraph.setScale(1.0);
            } catch (Exception e1) {
            }

        }
    });
    movieMakerToolBar.add(oneToOneScaleButton);

    movieMakerToolBar.addSeparator();

    // edit state
    JButton editStateButton = new JButton("Edit", new ImageIcon("resources/images/edit.png"));
    editStateButton.setToolTipText("Edit current state");
    editStateButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // take the current state
            Element currentState = PlanNavigationList.getInstance().getCurrentState();

            ItTreeNode problemNode = (ItTreeNode) problemsPlanTree.getLastSelectedPathComponent();
            ItTreeNode domainNode = (ItTreeNode) problemNode.getParent();
            ItTreeNode projectNode = (ItTreeNode) domainNode.getParent();

            // the object diagram must have parent
            //add the current state to the domain
            Element currentStateClone = (Element) currentState.clone();
            problemNode.getData().getChild("objectDiagrams").addContent(currentStateClone);

            graphTabbedPane.openEditStateTab(currentStateClone, domainNode.getData(), projectNode.getData());

            //mainTabbedPane.setSelectedIndex(0);
            CardLayout cl = (CardLayout) (mainTabbedPane.getLayout());
            cl.show(mainTabbedPane, "UML");
        }
    });
    movieMakerToolBar.add(editStateButton);

    movieMakerToolBar.addSeparator();
    // plan evaluation

    /*
    JButton planEvaluationButton = new JButton("Evaluate Plan", new ImageIcon("resources/images/eval.png"));
    planEvaluationButton.setToolTipText("<html>Generate a plan evaluation in the planReport. <br> This is restricted to non-time-based domain only.</html>");
    planEvaluationButton.addActionListener(new java.awt.event.ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        //RUN plan evaluation
    generateEvaluatioReport.actionPerformed(e);
    }
    });
    movieMakerToolBar.add( planEvaluationButton);
     */

    // virtual reality

    JButton virtualRealityButton = new JButton("Virtual Prototyping",
            new ImageIcon("resources/images/virtualprototype.png"));
    virtualRealityButton.setToolTipText("Generate virtual prototype files");
    virtualRealityButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ItTreeNode problemNode = (ItTreeNode) problemsPlanTree.getLastSelectedPathComponent();
            ItTreeNode domainNode = (ItTreeNode) problemNode.getParent();
            //ItTreeNode projectNode = (ItTreeNode)domainNode.getParent();
            try {

                VirtualPrototypingBlender.generatePrototypeFiles(domainNode.getData(), problemNode.getData(),
                        xmlPlan);
                //VirtualRealityRobotNavigationDomain.generateBackgroundFile(problemNode.getData(), xmlPlan);
            } catch (IOException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            }
            //VirtualRealityRobotNavigationDomain.generateBackgroundFile(problemNode.getData(), xmlPlan);
        }
    });
    movieMakerToolBar.add(virtualRealityButton);

    return movieMakerToolBar;
}

From source file:src.gui.ItSIMPLE.java

/**
 * @return Returns the planAnalysisFramePanel.
 *//*  ww  w  . ja  v a  2s  .co  m*/
private ItFramePanel getPlanAnalysisFramePanel() {
    if (planAnalysisFramePanel == null) {
        planAnalysisFramePanel = new ItFramePanel(":: Plan Analysis", ItFramePanel.NO_MINIMIZE_MAXIMIZE);

        // tool bar
        JToolBar chartsToolBar = new JToolBar();
        chartsToolBar.add(new JButton(drawChartAction));

        // charts panel
        chartsPanel = new JPanel();
        chartsPanel.setLayout(new BoxLayout(chartsPanel, BoxLayout.Y_AXIS));

        ItFramePanel variableSelectionPanel = new ItFramePanel(".: Select variables to be tracked",
                ItFramePanel.NO_MINIMIZE_MAXIMIZE);
        //variableSelectionPanel.setBackground(new Color(151,151,157));

        JSplitPane split = new JSplitPane();
        split.setContinuousLayout(true);
        split.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        split.setDividerLocation(2 * screenSize.height / 3);

        split.setDividerSize(8);
        //split.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50));
        //split.setPreferredSize(new Dimension(screenSize.width/4-20, 120));
        split.setLeftComponent(new JScrollPane(variablesPlanTree));
        split.setRightComponent(new JScrollPane(selectedVariablesPlanTree));

        variableSelectionPanel.setContent(split, false);
        //variableSelectionPanel.setParentSplitPane()

        //JPanel variableSelectionPanel  = new JPanel(new BorderLayout());
        //variableSelectionPanel.add(new JScrollPane(variablesPlanTree), BorderLayout.CENTER);
        //variableSelectionPanel.add(new JScrollPane(selectedVariablesPlanTree), BorderLayout.EAST);

        ItFramePanel variableGraphPanel = new ItFramePanel(".: Chart", ItFramePanel.NO_MINIMIZE_MAXIMIZE);
        variableGraphPanel.setContent(chartsPanel, true);

        JSplitPane mainvariablesplit = new JSplitPane();
        mainvariablesplit.setContinuousLayout(true);
        mainvariablesplit.setOrientation(JSplitPane.VERTICAL_SPLIT);
        mainvariablesplit.setDividerLocation(150);
        mainvariablesplit.setDividerSize(8);
        //mainvariablesplit.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50));
        mainvariablesplit.setTopComponent(variableSelectionPanel);
        mainvariablesplit.setBottomComponent(variableGraphPanel);

        // main charts panel - used to locate the tool bar above the charts panel
        JPanel mainChartsPanel = new JPanel(new BorderLayout());
        mainChartsPanel.add(chartsToolBar, BorderLayout.NORTH);
        //mainChartsPanel.add(new JScrollPane(chartsPanel), BorderLayout.CENTER);
        mainChartsPanel.add(mainvariablesplit, BorderLayout.CENTER);

        //Results
        planInfoEditorPane = new JEditorPane();
        planInfoEditorPane.setContentType("text/html");
        planInfoEditorPane.setEditable(false);
        planInfoEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        planInfoEditorPane.setBackground(Color.WHITE);

        JPanel resultsPanel = new JPanel(new BorderLayout());

        JToolBar resultsToolBar = new JToolBar();
        resultsToolBar.setRollover(true);

        JButton planReportButton = new JButton("View Full Report",
                new ImageIcon("resources/images/viewreport.png"));
        planReportButton.setToolTipText("<html>View full plan report.<br> For multiple plans you will need "
                + "access to the Internet.<br> The components used in the report require such access (no data is "
                + "sent through the Internet).</html>");
        planReportButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //Opens html with defaut browser
                String path = "resources/report/Report.html";
                File report = new File(path);
                path = report.getAbsolutePath();
                try {
                    BrowserLauncher launcher = new BrowserLauncher();
                    launcher.openURLinBrowser("file://" + path);
                } catch (BrowserLaunchingInitializingException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                    appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n");
                } catch (UnsupportedOperatingSystemException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                    appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n");
                }
            }
        });
        resultsToolBar.add(planReportButton);

        resultsToolBar.addSeparator();
        JButton planReportDataButton = new JButton("Save Report Data",
                new ImageIcon("resources/images/savePDDL.png"));
        planReportDataButton.setToolTipText("<html>Save report data to file</html>");
        planReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //Save report data
                if (solveResult != null) {
                    Element lastOpenFolderElement = itSettings.getChild("generalSettings")
                            .getChild("lastOpenFolder");
                    JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText());
                    fc.setDialogTitle("Save Report Data");
                    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                    fc.setFileFilter(new XMLFileFilter());

                    int returnVal = fc.showSaveDialog(ItSIMPLE.this);
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                        File selectedFile = fc.getSelectedFile();
                        String path = selectedFile.getPath();

                        if (!path.toLowerCase().endsWith(".xml")) {
                            path += ".xml";
                        }
                        //save file (xml)
                        try {
                            FileWriter file = new FileWriter(path);
                            file.write(XMLUtilities.toString(solveResult));
                            file.close();
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }

                        //Save as a last open folder
                        String folder = selectedFile.getParent();
                        //Element lastOpenFolderElement = itSettings.getChild("generalSettings").getChild("lastOpenFolder");
                        lastOpenFolderElement.setText(folder);
                        XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());

                        //Ask if the user wants to save plans individually too.
                        boolean needToSavePlans = false;
                        int option = JOptionPane.showOptionDialog(instance,
                                "<html><center>Do you also want to save the plans"
                                        + "<br>in individual files?</center></html>",
                                "Save plans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                                null, null);
                        switch (option) {
                        case JOptionPane.YES_OPTION: {
                            needToSavePlans = true;
                        }
                            break;
                        case JOptionPane.NO_OPTION: {
                            needToSavePlans = false;
                        }
                            break;
                        }

                        if (needToSavePlans) {
                            //Close Open tabs
                            List<?> problems = null;
                            try {
                                XPath ppath = new JDOMXPath("project/domains/domain/problems/problem");
                                problems = ppath.selectNodes(solveResult);
                            } catch (JaxenException e2) {
                                e2.printStackTrace();
                            }

                            for (int i = 0; i < problems.size(); i++) {
                                Element problem = (Element) problems.get(i);
                                //create a folder for each problem and put all plans inside as xml files
                                String folderName = problem.getChildText("name");
                                String folderPath = selectedFile.getAbsolutePath()
                                        .replace(selectedFile.getName(), folderName);
                                //System.out.println(folderPath);
                                File planfolder = new File(folderPath);
                                boolean canSavePlan = false;
                                try {
                                    if (planfolder.mkdir()) {
                                        System.out.println("Directory '" + folderPath + "' created.");
                                        canSavePlan = true;
                                    } else {
                                        System.out.println("Directory '" + folderPath + "' was not created.");
                                    }

                                } catch (Exception ep) {
                                    ep.printStackTrace();
                                }

                                if (canSavePlan) {
                                    Element plans = problem.getChild("plans");
                                    for (Iterator<Element> it = plans.getChildren("xmlPlan").iterator(); it
                                            .hasNext();) {
                                        Element eaplan = it.next();
                                        Element theplanner = eaplan.getChild("planner");
                                        //save file (xml)
                                        String planFileName = "solution" + theplanner.getChildText("name") + "-"
                                                + theplanner.getChildText("version") + "-"
                                                + Integer.toString(plans.getChildren().indexOf(eaplan))
                                                + ".xml";
                                        String planPath = folderPath + File.separator + planFileName;
                                        /*
                                        try {
                                            FileWriter planfile = new FileWriter(planPath);
                                            planfile.write(XMLUtilities.toString(eaplan));
                                            planfile.close();
                                            System.out.println("File '" + planPath + "' created.");
                                        } catch (IOException e1) {
                                            e1.printStackTrace();
                                        }
                                        *
                                        */
                                        if (eaplan.getChild("plan").getChildren().size() > 0) {

                                            //TODO: save the plan in PDDL too. It should be done through the XPDDL/PDDL classes
                                            String pddlplan = ToXPDDL.XMLtoXPDDLPlan(eaplan);
                                            String planFileNamePDDL = "solution"
                                                    + theplanner.getChildText("name") + "-"
                                                    + theplanner.getChildText("version") + "-"
                                                    + Integer.toString(plans.getChildren().indexOf(eaplan))
                                                    + ".pddl";
                                            String planPathPDDL = folderPath + File.separator
                                                    + planFileNamePDDL;

                                            //String cfolderPath = selectedFile.getAbsolutePath().replace(selectedFile.getName(), "");
                                            //String planFileNamePDDL = theplanner.getChildText("name")+"-"+theplanner.getChildText("version") + "-" + folderName+"-solution.pddl";
                                            //String planPathPDDL = cfolderPath + File.separator + planFileNamePDDL;
                                            //if (!theplanner.getChildText("name").contains("MIPS")){
                                            try {
                                                FileWriter planfile = new FileWriter(planPathPDDL);
                                                planfile.write(pddlplan);
                                                planfile.close();
                                                System.out.println("File '" + planPathPDDL + "' created.");
                                            } catch (IOException e1) {
                                                e1.printStackTrace();
                                            }
                                        } //}

                                    }

                                }

                            }
                        }

                    }
                } else {
                    appendOutputPanelText(">> No report data available to save! \n");
                }

            }
        });
        resultsToolBar.add(planReportDataButton);

        JButton openPlanReportDataButton = new JButton("Open Report Data",
                new ImageIcon("resources/images/openreport.png"));
        openPlanReportDataButton.setToolTipText("<html>Open report data to file</html>");
        openPlanReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                planSimStatusBar.setText("Status: Opening File...");
                appendOutputPanelText(">> Opening File... \n");
                //Open report data
                Element lastOpenFolderElement = itSettings.getChild("generalSettings")
                        .getChild("lastOpenFolder");
                JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText());
                fc.setDialogTitle("Open Report Data");
                fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                fc.setFileFilter(new XMLFileFilter());

                int returnVal = fc.showOpenDialog(ItSIMPLE.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {

                    File file = fc.getSelectedFile();
                    // Get itSIMPLE itSettings from itSettings.xml
                    org.jdom.Document resultsDoc = null;
                    try {
                        resultsDoc = XMLUtilities.readFromFile(file.getPath());
                        solveResult = resultsDoc.getRootElement();
                        //XMLUtilities.printXML(solveResult);
                        if (solveResult.getName().equals("projects")) {

                            String report = PlanAnalyzer.generatePlannersComparisonReport(solveResult);
                            String comparisonReport = PlanAnalyzer
                                    .generateFullPlannersComparisonReport(solveResult);
                            //Save Comparison Report file
                            saveFile("resources/report/Report.html", comparisonReport);
                            setPlanInfoPanelText(report);
                            setPlanEvaluationInfoPanelText("");
                            appendOutputPanelText(">> Report data read! \n");

                            //My experiments
                            PlanAnalyzer.myAnalysis(itPlanners.getChild("planners"), solveResult);
                        }
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                    //Save as a last open folder
                    String folder = fc.getSelectedFile().getParent();
                    lastOpenFolderElement.setText(folder);
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());

                } else {
                    planSimStatusBar.setText("Status:");
                    appendOutputPanelText(">> Canceled \n");
                }

            }
        });
        resultsToolBar.add(openPlanReportDataButton);

        JButton compareProjectReportDataButton = new JButton("Compare Project Data",
                new ImageIcon("resources/images/compare.png"));
        compareProjectReportDataButton.setToolTipText(
                "<html>Compare different project report data <br> This is commonly use to compare diferent domain models with different adjustments.<br>"
                        + "One project data must be chosen as a reference; others will be compared to this referencial one.</html>");
        compareProjectReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                final ProjectComparisonDialog dialog = new ProjectComparisonDialog();
                dialog.setVisible(true);

                final List<String> files = dialog.getFiles();

                if (files.size() > 1) {

                    new Thread() {
                        public void run() {
                            appendOutputPanelText(">> Project comparison report requested. Processing... \n");

                            planSimStatusBar.setText("Status: Reading files ...");
                            appendOutputPanelText(">> Reading files ... \n");

                            //base project file
                            String baseFileName = files.get(0);
                            appendOutputPanelText(">> Reading file '" + baseFileName + "' \n");
                            org.jdom.Document baseProjectDoc = null;
                            try {
                                baseProjectDoc = XMLUtilities.readFromFile(baseFileName);
                            } catch (Exception ec) {
                                ec.printStackTrace();
                            }
                            Element baseProject = null;
                            if (baseProjectDoc != null) {
                                baseProject = baseProjectDoc.getRootElement().getChild("project");
                            }

                            //The comparible projects
                            List<Element> comparableProjects = new ArrayList<Element>();

                            for (int i = 1; i < files.size(); i++) {
                                String eafile = files.get(i);
                                appendOutputPanelText(">> Reading file '" + eafile + "' \n");
                                org.jdom.Document eaProjectDoc = null;
                                try {
                                    eaProjectDoc = XMLUtilities.readFromFile(eafile);
                                } catch (Exception ec) {
                                    ec.printStackTrace();
                                }
                                if (eaProjectDoc != null) {
                                    comparableProjects.add(eaProjectDoc.getRootElement().getChild("project"));
                                }

                            }
                            appendOutputPanelText(">> Files read. Building report... \n");

                            String comparisonReport = PlanAnalyzer.generateProjectComparisonReport(baseProject,
                                    comparableProjects);
                            saveFile("resources/report/Report.html", comparisonReport);
                            appendOutputPanelText(
                                    ">> Project comparison report generated. Press 'View Full Report'\n");
                            appendOutputPanelText(" \n");

                        }
                    }.start();

                }

            }
        });
        resultsToolBar.add(compareProjectReportDataButton);

        resultsPanel.add(resultsToolBar, BorderLayout.NORTH);
        resultsPanel.add(new JScrollPane(planInfoEditorPane), BorderLayout.CENTER);

        JTabbedPane planAnalysisTabbedPane = new JTabbedPane();
        planAnalysisTabbedPane.addTab("Results", resultsPanel);
        planAnalysisTabbedPane.addTab("Variable Tracking", mainChartsPanel);
        planAnalysisTabbedPane.addTab("Movie Maker", getMovieMakerPanel());
        planAnalysisTabbedPane.addTab("Plan Evaluation", getPlanEvaluationPanel());
        planAnalysisTabbedPane.addTab("Plan Database", getPlanDatabasePanel());
        planAnalysisTabbedPane.addTab("Rationale Database", getRationaleDatabasePanel());

        JPanel planAnalysisPanel = new JPanel(new BorderLayout());
        //planAnalysisPanel.add(chartsToolBar, BorderLayout.NORTH);
        planAnalysisPanel.add(planAnalysisTabbedPane, BorderLayout.CENTER);
        planAnalysisFramePanel.setContent(planAnalysisPanel, false);

    }

    return planAnalysisFramePanel;
}

From source file:org.domainmath.gui.MainFrame.java

private void histPanel() {
    JPanel p = new JPanel(new BorderLayout());
    JToolBar b = new JToolBar("");
    b.setFloatable(false);/*  w  w w .ja  v  a2 s  .  co m*/
    b.setRollover(true);
    JButton saveButton = new JButton();
    JButton runButton = new JButton();

    saveButton.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/org/domainmath/gui/icons/script_save.png")));
    runButton.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/org/domainmath/gui/icons/terminal.png")));
    b.add(saveButton);
    b.add(runButton);
    p.add(b, BorderLayout.PAGE_START);
    p.add(this.histScrollPane, BorderLayout.CENTER);

    saveButton.addActionListener((ActionEvent e) -> {
        saveHistoryAs();
    });

    runButton.addActionListener((ActionEvent e) -> {
        runHistory();
    });
    historyView = new View("History", null, p);
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.DocComponent.java

/** Builds and lays out the UI. */
private void buildGUI() {
    setBackground(UIUtilities.BACKGROUND_COLOR);
    setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    add(label);/*from  w w  w.j  a  va2  s .  c om*/
    JToolBar bar = new JToolBar();
    bar.setBackground(UIUtilities.BACKGROUND_COLOR);
    bar.setFloatable(false);
    bar.setRollover(true);
    bar.setBorder(null);
    bar.setOpaque(true);
    boolean b = setControlsEnabled(data != null);
    int count = 0;
    if (editButton != null)
        count++;
    if (unlinkButton != null)
        count++;
    if (downloadButton != null)
        count++;
    if (infoButton != null)
        count++;
    if (openButton != null)
        count++;
    if (count > 0 && data != null) {
        menuButton.setEnabled(true);
        if (model.isAcrossGroups())
            menuButton.setEnabled(false);
        bar.add(menuButton);
        if (!b)
            bar.add(Box.createHorizontalStrut(8));
        add(bar);
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.OriginalMetadataComponent.java

/** 
 * Builds the tool bar.//from  www. j av  a 2s  . co m
 * 
 * @return See above.
 */
private JComponent buildToolBar() {
    JToolBar bar = new JToolBar();
    bar.setFloatable(false);
    bar.setRollover(true);
    bar.setBorder(null);
    bar.add(downloadButton);
    return bar;
}