MCPcopy Create free account
hub / github.com/GateNLP/gate-core / stateChanged

Method stateChanged

src/main/java/gate/gui/MainFrame.java:1596–1647  ·  view source on GitHub ↗
(ChangeEvent e)

Source from the content-addressed store, hash-verified

1594
1595 mainTabbedPane.getModel().addChangeListener(new ChangeListener() {
1596 @Override
1597 public void stateChanged(ChangeEvent e) {
1598 // find the handle in the resources tree for the main view
1599 JComponent largeView =
1600 (JComponent)mainTabbedPane.getSelectedComponent();
1601 Enumeration<?> nodesEnum = resourcesTreeRoot.preorderEnumeration();
1602 boolean done = false;
1603 DefaultMutableTreeNode node = resourcesTreeRoot;
1604 while(!done && nodesEnum.hasMoreElements()) {
1605 node = (DefaultMutableTreeNode)nodesEnum.nextElement();
1606 done =
1607 node.getUserObject() instanceof Handle
1608 && ((Handle)node.getUserObject()).viewsBuilt()
1609 && ((Handle)node.getUserObject()).getLargeView() == largeView;
1610 }
1611 ActionMap actionMap =
1612 ((JComponent)instance.getContentPane()).getActionMap();
1613 if(done) {
1614 Handle handle = (Handle)node.getUserObject();
1615 if (Gate.getUserConfig().getBoolean(
1616 MainFrame.class.getName()+".viewselecttree")) {
1617 // synchronise the selection in the tabbed pane with
1618 // the one in the resources tree
1619 TreePath nodePath = new TreePath(node.getPath());
1620 resourcesTree.setSelectionPath(nodePath);
1621 resourcesTree.scrollPathToVisible(nodePath);
1622 }
1623 lowerScroll.getViewport().setView(handle.getSmallView());
1624
1625 // redefine MainFrame actionMaps for the selected tab
1626 JComponent resource =
1627 (JComponent)mainTabbedPane.getSelectedComponent();
1628 actionMap.put("Close resource",
1629 resource.getActionMap().get("Close resource"));
1630 actionMap.put("Close recursively",
1631 resource.getActionMap().get("Close recursively"));
1632 actionMap.put("Hide", new CloseViewAction(handle));
1633 actionMap.put("Hide all", new HideAllAction());
1634 actionMap.put("Save As XML",
1635 resource.getActionMap().get("Save As XML"));
1636 }
1637 else {
1638 // the selected item is not a resource (maybe the log area?)
1639 lowerScroll.getViewport().setView(null);
1640 // disabled actions on the selected tabbed pane
1641 actionMap.put("Close resource", null);
1642 actionMap.put("Close recursively", null);
1643 actionMap.put("Hide", null);
1644 actionMap.put("Hide all", null);
1645 actionMap.put("Save As XML", null);
1646 }
1647 }
1648 });
1649
1650 mainTabbedPane.addMouseListener(new MouseAdapter() {

Callers

nothing calls this directly

Calls 8

getUserConfigMethod · 0.95
getSmallViewMethod · 0.95
getBooleanMethod · 0.80
viewsBuiltMethod · 0.65
getLargeViewMethod · 0.65
getNameMethod · 0.65
getMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected