Example usage for javax.swing JRootPane getComponent

List of usage examples for javax.swing JRootPane getComponent

Introduction

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

Prototype

public Component getComponent(int n) 

Source Link

Document

Gets the nth component in this container.

Usage

From source file:src.gui.ItTabbedPane.java

/**
 * Repaints all objects in an open diagram of the specified type
 * @param diagramType the type of diagrams to be painted
 *///w  w w  .  j a v a2s  .  c o m
public void repaintOpenDiagrams(String diagramType) {
    // get all open repository or object diagrams
    List<?> openDiagrams = null;
    try {
        XPath path = new JDOMXPath("openTab[type='" + diagramType + "']");
        openDiagrams = path.selectNodes(openTabs);
    } catch (JaxenException e2) {
        e2.printStackTrace();
    }

    // repaint the elements
    for (Iterator<?> iter = openDiagrams.iterator(); iter.hasNext();) {
        Element openTab = (Element) iter.next();
        JRootPane rootPane = (JRootPane) getComponentAt(openTabs.indexOf(openTab));
        ItGraph openGraph = (ItGraph) ((JScrollPane) rootPane.getComponent(3)).getViewport().getView();
        openGraph.repaintAllElements();
    }
}

From source file:src.gui.ItTabbedPane.java

/**
    * Repaints all objects in an open diagram of the specified type
    * @param diagramType the type of diagrams to be painted
    *//*from ww  w.  j av a2 s  .com*/
public void reBuildOpenDiagrams(String diagramType) {
    // get all open repository or object diagrams
    List<?> openDiagrams = null;
    try {
        XPath path = new JDOMXPath("openTab[type='" + diagramType + "']");
        openDiagrams = path.selectNodes(openTabs);
    } catch (JaxenException e2) {
    }

    // repaint the elements
    for (Iterator<?> iter = openDiagrams.iterator(); iter.hasNext();) {
        Element openTab = (Element) iter.next();
        JRootPane rootPane = (JRootPane) getComponentAt(openTabs.indexOf(openTab));
        ItGraph openGraph = (ItGraph) ((JScrollPane) rootPane.getComponent(3)).getViewport().getView();

        //openGraph.removeAll();
        openGraph.buildDiagram();
        openGraph.repaintAllElements();
        ;
    }
}

From source file:src.gui.ItTabbedPane.java

public void stateChanged(ChangeEvent e) {
    // TODO Auto-generated method stub   
    selectedTabIndex = getSelectedIndex();

    // this is done because the sizes may be different
    // they are different when a tab is closed
    // TODO deal the tab closing case
    if (selectedTabIndex > -1 && openTabs.getChildren().size() == getTabCount()) {
        Element selectedTab = (Element) openTabs.getChildren().get(selectedTabIndex);

        Element project = ItSIMPLE.getInstance().getItTree()
                .getProject(selectedTab.getAttributeValue("projectID"));

        String type = selectedTab.getChildText("type");
        if (type.equals("objectDiagram")) {
            Element diagram = null;
            try {
                XPath path = new JDOMXPath("diagrams/planningDomains/domain[@id='"
                        + selectedTab.getChildText("domain") + "']/planningProblems/problem[@id='"
                        + selectedTab.getChildText("problem") + "']/objectDiagrams/objectDiagram[@id='"
                        + selectedTab.getAttributeValue("diagramID") + "']");
                diagram = (Element) path.selectSingleNode(project);
            } catch (JaxenException e2) {
                e2.printStackTrace();//from   w ww. ja va  2 s. c  o m
            }
            if (diagram != null) {
                // get the current jgraph
                JRootPane panel = (JRootPane) getComponentAt(selectedTabIndex);
                JScrollPane scroll = (JScrollPane) panel.getComponent(3);// don't know exactly why the scrool pane is added in this position
                ItGraph graph = (ItGraph) scroll.getViewport().getView();

                AdditionalPropertiesTabbedPane.getInstance().showAdditionalProperties(diagram, graph);
            }
        } else {
            AdditionalPropertiesTabbedPane.getInstance().setNoSelection();
        }
    }

}