Example usage for javax.swing JRootPane JRootPane

List of usage examples for javax.swing JRootPane JRootPane

Introduction

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

Prototype

public JRootPane() 

Source Link

Document

Creates a JRootPane, setting up its glassPane, layeredPane, and contentPane.

Usage

From source file:edu.harvard.i2b2.eclipse.plugins.query.views.QueryView.java

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it./*from w  w  w  .j  ava  2s  . c o m*/
 */
@Override
public void createPartControl(Composite parent) {

    // setup context help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, QUERY_VIEW_CONTEXT_ID);
    addHelpButtonToToolBar();

    log.info("Query Tool plugin version 1.7.0");
    GridLayout topGridLayout = new GridLayout(1, false);
    topGridLayout.numColumns = 1;
    topGridLayout.marginWidth = 2;
    topGridLayout.marginHeight = 2;
    parent.setLayout(topGridLayout);

    queryComposite = new Composite(parent, SWT.NONE);
    queryComposite.setLayout(new FillLayout(SWT.VERTICAL));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    queryComposite.setLayoutData(gridData2);

    Composite rightComp = new Composite(queryComposite, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect);
    /* Create and setting up frame */
    ////for mac fix
    //if ( System.getProperty("os.name").toLowerCase().startsWith("mac"))
    //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame";
    Frame frame = SWT_AWT.new_Frame(rightComp);
    Panel panel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    oAwtContainer = root.getContentPane();

    if (mode_ == 0) {
        queryToolPanel = new QueryToolInvestigatorPanel(this);
    } else {
        queryToolPanel = new QueryToolPanel();
    }

    oAwtContainer.add(queryToolPanel);

}

From source file:edu.harvard.i2b2.query.QueryC.java

/**
 * @param args//from w  w w .  ja v  a 2s . c  om
 */
protected Control createContents(Composite parent) {
    //log.info("Starting Query Mode");
    GridLayout topGridLayout = new GridLayout(1, false);
    topGridLayout.numColumns = 1;
    topGridLayout.marginWidth = 2;
    topGridLayout.marginHeight = 2;
    setLayout(topGridLayout);

    Composite queryComposite = new Composite(this, SWT.NONE);
    queryComposite.setLayout(new FillLayout(SWT.VERTICAL));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    queryComposite.setLayoutData(gridData2);

    // the horizontal sash form
    SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL);
    horizontalForm.setOrientation(SWT.HORIZONTAL);
    horizontalForm.setLayout(new GridLayout());

    //left sash form
    SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    leftVerticalForm.setOrientation(SWT.VERTICAL);
    leftVerticalForm.setLayout(new GridLayout());

    if (bWantStatusLine) {
        slm.createControl(this, SWT.NULL);
    }
    slm.setMessage("i2b2 Explorer Version 2.0");
    slm.update(true);

    // Create the tab folder
    final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    // Create each tab and set its text, tool tip text,
    // image, and control
    TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE);
    oTreeTab.setText("Concept trees");
    oTreeTab.setToolTipText("Hierarchically organized patient characteristics");
    oTreeTab.setControl(getQueryTabControl(oTabFolder));

    //TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE);
    //oFindTab.setText("Find");
    //oFindTab.setToolTipText("Free-form find tool for patient characteristics");
    //FindTool find = new FindTool(slm);

    //oFindTab.setControl(find.getFindTabControl(oTabFolder));

    // Select the first tab (index is zero-based)
    oTabFolder.setSelection(0);

    // Create the tab folder
    final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE);
    previousRunTab.setText("Patient Sets and Previous Queries");
    previousRunTab.setToolTipText("Patient Sets & Previous Queries");
    final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED);
    previousRunTab.setControl(composite);

    /* Create and setting up frame */
    Frame runFrame = SWT_AWT.new_Frame(composite);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    oAwtContainer_left = runRoot.getContentPane();

    //runTreePanel = new QueryPreviousRunsPanel(this, null);
    //oAwtContainer_left.add(runTreePanel);

    // Select the first tab (index is zero-based)
    queryRunFolder.setSelection(0);

    final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    verticalForm.setOrientation(SWT.VERTICAL);
    verticalForm.setLayout(null);

    Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect);
    /* Create and setting up frame */
    Frame frame = SWT_AWT.new_Frame(rightComp);
    Panel panel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    oAwtContainer = root.getContentPane();

    if (mode_ == 0) {
        queryPanel = new QueryPanelInvestigator(this);
    } else {
        queryPanel = new QueryPanel(this);
    }

    oAwtContainer.add(queryPanel);
    queryPanel.setSplitBounds(oAwtContainer.getBounds());

    if (mode_ == 0) {
        //bottomC = new ExplorerC(verticalForm, false);
        verticalForm.setWeights(new int[] { 40, 50 });
    }
    verticalForm.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            if (mode_ == 0) {
                int height = verticalForm.getBounds().height;
                //System.out.println("Height: "+height);
                if (height > 285) {
                    try {
                        verticalForm.setWeights(new int[] { 285, height - 285 });
                    } catch (Exception e) {
                        return;
                    }
                }
            }
        }
    });

    horizontalForm.setWeights(new int[] { 20, 70 });
    return parent;
}

From source file:edu.harvard.i2b2.query.ui.QueryC.java

/**
 * @param args//from ww  w .  j av a  2  s  .  c  o m
 */
protected Control createContents(Composite parent) {
    // log.info("Starting Query Mode");
    GridLayout topGridLayout = new GridLayout(1, false);
    topGridLayout.numColumns = 1;
    topGridLayout.marginWidth = 2;
    topGridLayout.marginHeight = 2;
    setLayout(topGridLayout);

    Composite queryComposite = new Composite(this, SWT.NONE);
    queryComposite.setLayout(new FillLayout(SWT.VERTICAL));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    queryComposite.setLayoutData(gridData2);

    // the horizontal sash form
    SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL);
    horizontalForm.setOrientation(SWT.HORIZONTAL);
    horizontalForm.setLayout(new GridLayout());

    // left sash form
    SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    leftVerticalForm.setOrientation(SWT.VERTICAL);
    leftVerticalForm.setLayout(new GridLayout());

    if (bWantStatusLine) {
        slm.createControl(this, SWT.NULL);
    }
    slm.setMessage("i2b2 Explorer Version 1.6.0");
    slm.update(true);

    // Create the tab folder
    final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    // Create each tab and set its text, tool tip text,
    // image, and control
    TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE);
    oTreeTab.setText("Concept trees");
    oTreeTab.setToolTipText("Hierarchically organized patient characteristics");
    oTreeTab.setControl(getQueryTabControl(oTabFolder));

    // TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE);
    // oFindTab.setText("Find");
    // oFindTab.setToolTipText(
    // "Free-form find tool for patient characteristics");
    // FindTool find = new FindTool(slm);

    // oFindTab.setControl(find.getFindTabControl(oTabFolder));

    // Select the first tab (index is zero-based)
    oTabFolder.setSelection(0);

    // Create the tab folder
    final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE);
    previousRunTab.setText("Patient Sets and Previous Queries");
    previousRunTab.setToolTipText("Patient Sets & Previous Queries");
    final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED);
    previousRunTab.setControl(composite);

    /* Create and setting up frame */
    Frame runFrame = SWT_AWT.new_Frame(composite);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    oAwtContainer_left = runRoot.getContentPane();

    // runTreePanel = new QueryPreviousRunsPanel(this, null);
    // oAwtContainer_left.add(runTreePanel);

    // Select the first tab (index is zero-based)
    queryRunFolder.setSelection(0);

    final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    verticalForm.setOrientation(SWT.VERTICAL);
    verticalForm.setLayout(null);

    Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect);
    /* Create and setting up frame */
    Frame frame = SWT_AWT.new_Frame(rightComp);
    Panel panel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    oAwtContainer = root.getContentPane();

    if (mode_ == 0) {
        queryToolPanel = new QueryToolInvestigatorPanel(this);
    } else {
        queryToolPanel = new QueryToolPanel(this);
    }

    oAwtContainer.add(queryToolPanel);
    queryToolPanel.setSplitBounds(oAwtContainer.getBounds());

    if (mode_ == 0) {
        // bottomC = new ExplorerC(verticalForm, false);
        verticalForm.setWeights(new int[] { 40, 50 });
    }
    verticalForm.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            if (mode_ == 0) {
                int height = verticalForm.getBounds().height;
                // System.out.println("Height: "+height);
                if (height > 285) {
                    try {
                        verticalForm.setWeights(new int[] { 285, height - 285 });
                    } catch (Exception e) {
                        return;
                    }
                }
            }
        }
    });

    horizontalForm.setWeights(new int[] { 20, 70 });
    return parent;
}

From source file:edu.harvard.i2b2.previousquery.QueryC.java

/**
 * @param args//from www. j a v  a 2 s  .  c  om
 */
protected Control createContents(Composite parent) {
    //log.info("Starting Query Mode");
    GridLayout topGridLayout = new GridLayout(1, false);
    topGridLayout.numColumns = 1;
    topGridLayout.marginWidth = 2;
    topGridLayout.marginHeight = 2;
    setLayout(topGridLayout);

    Composite queryComposite = new Composite(this, SWT.NONE);
    queryComposite.setLayout(new FillLayout(SWT.VERTICAL));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    gridData2.grabExcessVerticalSpace = true;
    queryComposite.setLayoutData(gridData2);

    // the horizontal sash form
    SashForm horizontalForm = new SashForm(queryComposite, SWT.HORIZONTAL);
    horizontalForm.setOrientation(SWT.HORIZONTAL);
    horizontalForm.setLayout(new GridLayout());

    //left sash form
    SashForm leftVerticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    leftVerticalForm.setOrientation(SWT.VERTICAL);
    leftVerticalForm.setLayout(new GridLayout());

    if (bWantStatusLine) {
        slm.createControl(this, SWT.NULL);
    }
    slm.setMessage("i2b2 Explorer Version 2.0");
    slm.update(true);

    // Create the tab folder
    final TabFolder oTabFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    // Create each tab and set its text, tool tip text,
    // image, and control
    TabItem oTreeTab = new TabItem(oTabFolder, SWT.NONE);
    oTreeTab.setText("Concept trees");
    oTreeTab.setToolTipText("Hierarchically organized patient characteristics");
    oTreeTab.setControl(getQueryTabControl(oTabFolder));

    TabItem oFindTab = new TabItem(oTabFolder, SWT.NONE);
    oFindTab.setText("Find");
    oFindTab.setToolTipText("Free-form find tool for patient characteristics");
    //FindTool find = new FindTool(slm);

    //oFindTab.setControl(find.getFindTabControl(oTabFolder));

    // Select the first tab (index is zero-based)
    oTabFolder.setSelection(0);

    // Create the tab folder
    final TabFolder queryRunFolder = new TabFolder(leftVerticalForm, SWT.NONE);

    TabItem previousRunTab = new TabItem(queryRunFolder, SWT.NONE);
    previousRunTab.setText("Patient Sets and Previous Queries");
    previousRunTab.setToolTipText("Patient Sets & Previous Queries");
    final Composite composite = new Composite(queryRunFolder, SWT.EMBEDDED);
    previousRunTab.setControl(composite);

    /* Create and setting up frame */
    Frame runFrame = SWT_AWT.new_Frame(composite);
    Panel runPanel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    runFrame.add(runPanel);
    JRootPane runRoot = new JRootPane();
    runPanel.add(runRoot);
    oAwtContainer_left = runRoot.getContentPane();

    runTreePanel = new QueryPreviousRunsPanel(this);//, null);
    oAwtContainer_left.add(runTreePanel);

    // Select the first tab (index is zero-based)
    queryRunFolder.setSelection(0);

    final SashForm verticalForm = new SashForm(horizontalForm, SWT.VERTICAL);
    verticalForm.setOrientation(SWT.VERTICAL);
    verticalForm.setLayout(null);

    Composite rightComp = new Composite(verticalForm, SWT.BORDER | SWT.EMBEDDED | SWT.DragDetect);
    /* Create and setting up frame */
    Frame frame = SWT_AWT.new_Frame(rightComp);
    Panel panel = new Panel(new BorderLayout());
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        System.out.println("Error setting native LAF: " + e);
    }

    frame.add(panel);
    JRootPane root = new JRootPane();
    panel.add(root);
    oAwtContainer = root.getContentPane();

    if (mode_ == 0) {
        //queryPanel = new QueryPanelInvestigator(this);
    } else {
        queryPanel = new QueryPanel(this);
    }

    oAwtContainer.add(queryPanel);
    queryPanel.setSplitBounds(oAwtContainer.getBounds());

    if (mode_ == 0) {
        //bottomC = new ExplorerC(verticalForm, false);
        verticalForm.setWeights(new int[] { 40, 50 });
    }
    verticalForm.addListener(SWT.Resize, new Listener() {
        public void handleEvent(Event event) {
            if (mode_ == 0) {
                int height = verticalForm.getBounds().height;
                //System.out.println("Height: "+height);
                if (height > 285) {
                    try {
                        verticalForm.setWeights(new int[] { 285, height - 285 });
                    } catch (Exception e) {
                        return;
                    }
                }
            }
        }
    });

    horizontalForm.setWeights(new int[] { 20, 70 });
    return parent;
}

From source file:LayeredPaneDemo2.java

protected void populateInnerFrame() {
    m_rootPane = new JRootPane();
    m_frameContentPanel = new JPanel();
    m_frameContentPanel.setLayout(new BorderLayout());
    createTitleBar();/*  ww  w .ja v a 2 s. c  o m*/
    m_contentPanel = new JPanel(new BorderLayout());
    m_rootPane.setContentPane(m_contentPanel);
    m_frameContentPanel.add(m_titlePanel, BorderLayout.NORTH);
    m_frameContentPanel.add(m_rootPane, BorderLayout.CENTER);
    setupCapturePanel();
    super.add(m_frameContentPanel, BorderLayout.CENTER);
}

From source file:com.projity.dialog.AbstractDialog.java

protected JRootPane createRootPane() {
    ActionListener escapeListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            onCancel();/* ww w .  j  a  va  2s .  co  m*/

        }
    };
    ActionListener enterListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            onOk();

        }
    };

    ActionListener helpListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            onHelp();

        }

    };
    JRootPane rootPane = new JRootPane();
    KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rootPane.registerKeyboardAction(escapeListener, escapeStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    rootPane.registerKeyboardAction(enterListener, enterStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    KeyStroke f1Stroke = KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0);
    rootPane.registerKeyboardAction(helpListener, f1Stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}

From source file:LayeredPaneDemo4.java

protected void populateInnerFrame() {
    m_rootPane = new JRootPane();
    m_frameContentPanel = new JPanel();
    m_frameContentPanel.setLayout(new BorderLayout());
    createTitleBar();//from   w w w  . j  a  v  a 2 s  .co  m
    m_contentPanel = new JPanel(new BorderLayout());
    setContentPane(m_contentPanel);
    m_frameContentPanel.add(m_titlePanel, BorderLayout.NORTH);
    m_frameContentPanel.add(m_rootPane, BorderLayout.CENTER);
    setupCapturePanel();
    super.add(m_frameContentPanel, BorderLayout.CENTER);
}

From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java

/**
 * Close dialog when pressing escape/*from   w w  w. j  av  a  2s .  c  o m*/
 */
@Override
protected JRootPane createRootPane() {
    ActionListener actionListener = actionEvent -> setVisible(false);
    JRootPane rPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    return rPane;
}

From source file:org.pmedv.core.dialogs.AbstractNiceDialog.java

protected JRootPane createRootPane() {
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {

            result = OPTION_CANCEL;/* ww w  .j a  va  2 s .c o m*/

            setVisible(false);
        }
    };
    JRootPane rootPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}

From source file:src.gui.ItTabbedPane.java

public void openTab(Element diagram, String id, String title, String type, Element project, Element commonData,
        Element projectHeader, String language) {
    String diagramType = diagram.getName();

    // Checks whether the diagram is already open      
    String xpath = "";
    if (language.equals("UML")) {
        if (diagramType.equals("objectDiagram")) {
            xpath = "openTab[@language='" + language + "' and @projectID='"
                    + projectHeader.getAttributeValue("id") + "' and @diagramID='" + id + "' and type='"
                    + diagramType + "' and problem='"
                    + diagram.getParentElement().getParentElement().getAttributeValue("id") + "' and domain='"
                    + diagram.getParentElement().getParentElement().getParentElement().getParentElement()
                            .getAttributeValue("id")
                    + "']";
        } else if (diagramType.equals("repositoryDiagram")) {
            xpath = "openTab[@language='" + language + "' and @projectID='"
                    + projectHeader.getAttributeValue("id") + "' and @diagramID='" + id + "' and type='"
                    + diagramType + "' and domain='"
                    + diagram.getParentElement().getParentElement().getAttributeValue("id") + "']";
        } else {//from w  w  w. jav  a 2 s .co  m
            xpath = "openTab[@language='" + language + "' and @projectID='"
                    + projectHeader.getAttributeValue("id") + "' and @diagramID='" + id + "' and type='"
                    + diagramType + "']";
        }
    } else if (language.equals("PDDL")) {
        if (diagramType.equals("domain")) {
            xpath = "openTab[@language='" + language + "' and @projectID='"
                    + projectHeader.getAttributeValue("id") + "' and @diagramID='" + id + "' and type='"
                    + diagramType + "']";
        } else if (diagramType.equals("problem")) {
            xpath = "openTab[@language='" + language + "' and @projectID='"
                    + projectHeader.getAttributeValue("id") + "' and @diagramID='" + id + "' and type='"
                    + diagramType + "' and domain='"
                    + diagram.getParentElement().getParentElement().getAttributeValue("id") + "']";
        }
    } else if (language.equals("PetriNet")) {
        xpath = "openTab[@language='" + language + "' and @projectID='" + projectHeader.getAttributeValue("id")
                + "' and @diagramID='" + id + "' and type='" + diagramType + "']";
    } else {
        xpath = "openTab[@language='" + language + "' and @projectID='" + projectHeader.getAttributeValue("id")
                + "' and @diagramID='" + id + "' and type='" + diagramType + "']";
    }

    //Checks if it is already opened
    Element openingDiagram = null;
    try {
        XPath path = new JDOMXPath(xpath);
        openingDiagram = (Element) path.selectSingleNode(openTabs);
    } catch (JaxenException e2) {
        e2.printStackTrace();
    }

    if (openingDiagram != null) {
        // select the tab if it is already open
        setSelectedIndex(openingDiagram.getParent().indexOf(openingDiagram));

    } else {

        //New Tab
        Document newDoc = null;
        try {
            newDoc = XMLUtilities.readFromFile("resources/settings/commonData.xml");
        } catch (JDOMException e) {

            e.printStackTrace();
        } catch (IOException e) {

            e.printStackTrace();
        }
        Element openTab = ((Element) newDoc.getRootElement().getChild("internalUse").getChild("openTab")
                .clone());

        Icon icon = null;
        JRootPane panel = null;

        //Check Language Type
        if (language.equals("UML")) {
            // Open the tab if not
            if (type.equals("useCaseDiagram") || type.equals("classDiagram")
                    || type.equals("stateMachineDiagram") || type.equals("repositoryDiagram")
                    || type.equals("objectDiagram") || type.equals("activityDiagram")) {

                //tool bar
                ItToolBar toolBar = new ItToolBar(type, "UML");
                toolBar.setName(title);
                //graph (jgraph)
                GraphModel model = new DefaultGraphModel();
                GraphLayoutCache view = new GraphLayoutCache(model, new ItCellViewFactory());
                ItGraph diagramGraph = new ItGraph(view, toolBar, propertiesPane, project, diagram, commonData,
                        language);
                toolBar.setGraph(diagramGraph);
                diagramGraph.setVisible(false);
                JScrollPane graphScrollPane = new JScrollPane(diagramGraph);
                panel = new JRootPane();
                panel.setLayout(new BorderLayout());
                panel.add(toolBar, BorderLayout.NORTH);
                panel.add(graphScrollPane, BorderLayout.CENTER);

                diagramGraph.buildDiagram();
                diagramGraph.setBackground(Color.WHITE);
                diagramGraph.setVisible(true);

            } else if (type.equals("timingDiagram")) {

                panel = new JRootPane();
                panel.setLayout(new BorderLayout());

                TimingDiagramPanel timingdiagrampanel = new TimingDiagramPanel(diagram, project);
                panel.add(timingdiagrampanel, BorderLayout.CENTER);
                //JScrollPane listScrollPane = new JScrollPane(timingdiagrampanel);
                //panel.add(listScrollPane, BorderLayout.CENTER);

                /*
                //1. get type and context
                String dtype = diagram.getChildText("type");
                String context = diagram.getChildText("context");
                //the frame and lifeline nodes
                Element frame = diagram.getChild("frame");
                Element lifelines = frame.getChild("lifelines");
                String durationStr = frame.getChildText("duration");
                String lifelineName = "";
                String yAxisName = "";
                        
                        
                //condition lifeline
                if (dtype.equals("condition")){
                        
                    //check if the context is a action
                    if (context.equals("action")){
                        
                        //get action/operator
                        Element operatorRef = diagram.getChild("action");
                        Element operator = null;
                        try {
                            XPath path = new JDOMXPath("elements/classes/class[@id='"+operatorRef.getAttributeValue("class")+"']/operators/operator[@id='"+ operatorRef.getAttributeValue("id") +"']");
                            operator = (Element)path.selectSingleNode(project);
                        } catch (JaxenException e2) {
                            e2.printStackTrace();
                        }
                        
                        if (operator !=null){
                            System.out.println(operator.getChildText("name"));
                        
                            //check every lifeline
                            for (Iterator<Element> it = lifelines.getChildren("lifeline").iterator(); it.hasNext();) {
                                Element lifeline = it.next();
                                System.out.println("Life line id "+ lifeline.getAttributeValue("id"));
                        
                                //get the object (can be a parametr. literal, or object)
                                Element objRef = lifeline.getChild("object");
                                Element attrRef = lifeline.getChild("attribute");
                        
                                //get object class
                                Element objClass = pddlScrollPanenull;
                                try {
                                    XPath path = new JDOMXPath("elements/classes/class[@id='"+objRef.getAttributeValue("class")+"']");
                                    objClass = (Element)path.selectSingleNode(project);
                                } catch (JaxenException e2) {
                                    e2.printStackTrace();
                                }
                        
                                Element attribute = null;
                                try {
                                    XPath path = new JDOMXPath("elements/classes/class[@id='"+attrRef .getAttributeValue("class")+"']/attributes/attribute[@id='"+ attrRef.getAttributeValue("id") +"']");
                                    attribute = (Element)path.selectSingleNode(project);
                                } catch (JaxenException e2) {
                                    e2.printStackTrace();
                                }
                        
                                yAxisName = attribute.getChildText("name");
                        
                                //if (objClass!=null)
                                Element object = null;
                        
                                //check what is this object (parameterof an action, object, literal)
                                if (objRef.getAttributeValue("element").equals("parameter")){
                                    //get parameter in the action
                        
                                    try {
                                        XPath path = new JDOMXPath("parameters/parameter[@id='"+objRef.getAttributeValue("id")+"']");
                                        object = (Element)path.selectSingleNode(operator);
                                    } catch (JaxenException e2) {
                                        e2.printStackTrace();
                                    }
                                    String parameterStr = object.getChildText("name");
                        
                                    lifelineName = parameterStr + ":" + objClass.getChildText("name");
                                }
                                //
                        
                        
                                //Boolean attribute
                                if (attribute.getChildText("type").equals("1")){
                                    lifelineName += " - " + attribute.getChildText("name");
                        
                                    Element timeIntervals = lifeline.getChild("timeIntervals");
                        
                        
                                    XYSeriesCollection dataset = new XYSeriesCollection();
                                    XYSeries series = new XYSeries("Boolean");
                                    int stepIndex = 0;
                                    for (Iterator<Element> it1 = timeIntervals.getChildren().iterator(); it1.hasNext();) {
                                        Element timeInterval = it1.next();
                                        boolean insertPoint = true;
                        
                                        Element durationConstratint = timeInterval.getChild("durationConstratint");
                                        Element lowerbound = durationConstratint.getChild("lowerbound");
                                        Element upperbound = durationConstratint.getChild("upperbound");
                                        Element value = timeInterval.getChild("value");
                        
                                        //Add for both lower and upper bound
                        
                                        //lower bound
                                        float lowerTimePoint = 0;
                                        try {
                                             lowerTimePoint = Float.parseFloat(lowerbound.getAttributeValue("value"));
                                        } catch (Exception e) {
                                            insertPoint = false;
                                        }
                                        System.out.println("    > point     x= "+ Float.toString(lowerTimePoint)+ " ,  y= "+ lowerbound.getAttributeValue("value"));
                                        if (insertPoint){
                                            series.add(lowerTimePoint, (value.getText().equals("false") ?0 :1));
                                        }
                        
                                        //upper bound
                                        float upperTimePoint = 0;
                                        try {
                                             upperTimePoint = Float.parseFloat(upperbound.getAttributeValue("value"));
                                        } catch (Exception e) {
                                            insertPoint = false;
                                        }
                                        System.out.println("    > point     x= "+ Float.toString(upperTimePoint)+ " ,  y= "+ lowerbound.getAttributeValue("value"));
                                        if (insertPoint){
                                            series.add(upperTimePoint, (value.getText().equals("false") ?0 :1));
                                        }
                        
                                    }
                                    dataset.addSeries(series);
                        
                                    JFreeChart chart = ChartFactory.createXYStepChart(lifelineName, "time", "value", dataset, PlotOrientation.VERTICAL, false, true, false);
                                    chart.setBackgroundPaint(Color.WHITE);
                        
                                    XYPlot plot = (XYPlot)chart.getPlot();
                                    plot.setBackgroundPaint(Color.WHITE);
                        
                        
                                    NumberAxis domainAxis = new NumberAxis("Time");
                                    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
                                    domainAxis.setAutoRangeIncludesZero(false);
                                    domainAxis.setUpperBound(30.0);
                                    plot.setDomainAxis(domainAxis);
                        
                                    String[] values = {"false", "true"};
                                    //SymbolAxis rangeAxis = new SymbolAxis("Values", values);
                                    SymbolAxis rangeAxis = new SymbolAxis(yAxisName, values);
                                    plot.setRangeAxis(rangeAxis);
                        
                                    ChartPanel chartPanel = new ChartPanel(chart);
                                    chartPanel.setPreferredSize(new Dimension(chartPanel.getSize().width, 175));
                        
                                    panel.add(chartPanel, BorderLayout.CENTER);
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                //                                            XYSeries series = new XYSeries(lifelineName);
                //                                            int stepIndex = 0;
                //
                //                                            for (Iterator<Element> it1 = timeIntervals.getChildren().iterator(); it1.hasNext();) {
                //                                                Element timeInterval = it1.next();
                //
                //                                                Element durationConstratint = timeInterval.getChild("durationConstratint");
                //                                                Element lowerbound = durationConstratint.getChild("lowerbound");
                //                                                Element upperbound = durationConstratint.getChild("upperbound");
                //                                                Element value = timeInterval.getChild("value");
                //
                //
                //                                                series.add(stepIndex++, (value.getText().equals("false") ?0 :1));
                //
                //
                //                                            }
                //
                //                                            XYSeriesCollection dataset = new XYSeriesCollection(series);
                //                                            JFreeChart chart = ChartFactory.createXYLineChart(lifelineName, "Steps",  "Values", dataset, PlotOrientation.VERTICAL, false, true, false);
                //                                            //JFreeChart chart = ChartFactory.createXYStepChart("test", "Values", "Steps", dataset, PlotOrientation.VERTICAL, false, true, false);
                //                                            //JFreeChart chart = ChartFactory.createAreaChart("test", "x", "y", dataset, PlotOrientation.VERTICAL, false, true, false);
                //                                            ChartPanel chartPanel = new ChartPanel(chart);
                //                                            panel.add(chartPanel, BorderLayout.CENTER);
                        
                                    //build graph true/false
                        
                        
                        
                                }
                        
                        
                        
                            }
                        }
                        
                        
                    }
                    //if this is a possible sequence of action being modeled to a condition
                    else if (context.equals("general")){
                        
                    }
                        
                        
                }
                else if (dtype.equals("state")){
                        
                        
                        
                        
                }
                */

                /*
                panel = new JRootPane();
                panel.setLayout(new BorderLayout());
                panel.add(new Label("TIMING DIAGRAM"), BorderLayout.NORTH);
                String chartTitle = "Timing diagram";
                        
                XYSeries series = new XYSeries("Average Size");
                series.add(20.0, 10.0);
                series.add(40.0, 20.0);
                series.add(70.0, 50.0);
                XYSeriesCollection dataset = new XYSeriesCollection(series);
                JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, "Steps",  "Values", dataset, PlotOrientation.VERTICAL, false, true, false);
                //JFreeChart chart = ChartFactory.createXYStepChart("test", "Values", "Steps", dataset, PlotOrientation.VERTICAL, false, true, false);
                //JFreeChart chart = ChartFactory.createAreaChart("test", "x", "y", dataset, PlotOrientation.VERTICAL, false, true, false);
                ChartPanel chartPanel = new ChartPanel(chart);
                panel.add(chartPanel, BorderLayout.CENTER);
                 */

            }

            // Prepare Tab Icon
            icon = new ImageIcon("resources/images/" + diagram.getName() + ".png");
            //Set Tab properties
            openTab.setAttribute("language", language);
            openTab.setAttribute("diagramID", id);
            openTab.setAttribute("projectID", projectHeader.getAttributeValue("id"));
            openTab.getChild("type").setText(type);

            if (type.equals("objectDiagram")) {
                //object diagrams      problem
                openTab.getChild("problem")
                        .setText(diagram.getParentElement().getParentElement().getAttributeValue("id"));
                //  object diagrams    problem           planningProblems     domain
                openTab.getChild("domain").setText(diagram.getParentElement().getParentElement()
                        .getParentElement().getParentElement().getAttributeValue("id"));
            }

            else if (type.equals("repositoryDiagram")) {
                //  repositoryDiagrams  domain
                openTab.getChild("domain")
                        .setText(diagram.getParentElement().getParentElement().getAttributeValue("id"));
            }

        } else if (language.equals("PDDL")) {

            ItToolBar toolBar = new ItToolBar(type, "PDDL");
            toolBar.setName(title);

            ItHilightedDocument pddlDocument = new ItHilightedDocument();
            pddlDocument.setHighlightStyle(ItHilightedDocument.PDDL_STYLE);
            JTextPane pddlTextPane = new JTextPane(pddlDocument);
            pddlTextPane.setFont(new Font("Courier", 0, 12));

            toolBar.setTextPane(pddlTextPane);

            JScrollPane pddlScrollPane = new JScrollPane(pddlTextPane);
            panel = new JRootPane();
            panel.setLayout(new BorderLayout());
            panel.add(toolBar, BorderLayout.NORTH);
            panel.add(pddlScrollPane, BorderLayout.CENTER);

            icon = new ImageIcon("resources/images/" + diagram.getName() + ".png");

            if (type.equals("domain")) {
                //PlanningDomains  diagrams           project
                Element projectDomain = diagram.getParentElement().getParentElement().getParentElement();
                //                   TODO PDDL 3.0 was made default, but the user should be able to chose it
                Element xpddlDomain = ToXPDDL.XMLToXPDDLDomain(projectDomain, ToXPDDL.PDDL_3_0, null);
                String domainText = XPDDLToPDDL.parseXPDDLToPDDL(xpddlDomain, "  ");

                pddlTextPane.setText(domainText);
            } else if (type.equals("problem")) {
                Element xpddlProblem = ToXPDDL.XMLToXPDDLProblem(diagram, ToXPDDL.PDDL_3_0);
                String problemText = XPDDLToPDDL.parseXPDDLToPDDL(xpddlProblem, "  ");
                pddlTextPane.setText(problemText);
            }

            //   Set Tab properties
            openTab.setAttribute("language", language);
            openTab.setAttribute("diagramID", id);
            openTab.setAttribute("projectID", projectHeader.getAttributeValue("id"));
            openTab.getChild("type").setText(type);

            if (type.equals("problem")) {
                // planningProblems  domains
                openTab.getChild("domain")
                        .setText(diagram.getParentElement().getParentElement().getAttributeValue("id"));
            }

        } else if (language.equals("PetriNet")) {
            // Open the tab if not
            ItToolBar toolBar = new ItToolBar(type, "PetriNet");
            toolBar.setName(title);
            GraphModel model = new DefaultGraphModel();
            GraphLayoutCache view = new GraphLayoutCache(model, new ItCellViewFactory());
            ItGraph diagramGraph = new ItGraph(view, toolBar, propertiesPane, project, diagram, commonData,
                    language);
            toolBar.setGraph(diagramGraph);
            diagramGraph.buildDiagram();
            diagramGraph.setBackground(Color.WHITE);
            diagramGraph.setVisible(false);
            diagramGraph.setInfoPane(src.gui.ItSIMPLE.getInstance().getInfoEditorPane());
            JScrollPane graphScrollPane = new JScrollPane(diagramGraph);
            panel = new JRootPane();
            panel.setLayout(new BorderLayout());
            panel.add(toolBar, BorderLayout.NORTH);
            panel.add(graphScrollPane, BorderLayout.CENTER);
            //panel.setContentPane(graphScrollPane);

            diagramGraph.buildDiagram();
            diagramGraph.setVisible(true);
            // Prepare Tab Icon
            icon = new ImageIcon("resources/images/" + diagram.getName() + ".png");

            //Set Tab properties
            openTab.setAttribute("language", language);
            openTab.setAttribute("diagramID", id);
            openTab.setAttribute("projectID", projectHeader.getAttributeValue("id"));
            openTab.getChild("type").setText(type);

        }

        if (icon != null && panel != null) {
            // add the tab
            openTabs.addContent(openTab);
            addTab(title, icon, panel);
            if (getTabCount() > 1) {
                setSelectedIndex(getTabCount() - 1);
            }
        }

    }

}