private void createHolder() { // We display the views in a customised tab pane. // This means that if there are multiple views in // a particular area they get stacked and are accessible // to the user. tabbedHolder = new ViewTabbedPane(); tabbedHolder.setTabPlacement(SwingConstants.BOTTOM); // Set the minimum size of the holder so that the // split panes can be dragged around easily. We don't // want to set the size to zero, because this allows the // contents of the split pane to be completely hidden, // which could be confusing for the user. // tabbedHolder.setMinimumSize(new Dimension(10, 10)); tabbedHolder.addContainerListener( new ContainerListener() { public void componentAdded(ContainerEvent e) { if (tabbedHolder.getComponentCount() == 1) { ViewHolder.this.add(tabbedHolder); } } public void componentRemoved(ContainerEvent e) { if (tabbedHolder.getComponentCount() == 0) { ViewHolder.this.remove(tabbedHolder); } } }); }
/** * Sets up the main listeners that are required by the tab, including selection listeners, and * knowledgebase listeners. */ protected void setupListeners(final GraphComponent graphComponent) { /* * Listen to node clicks so that if there is a double click we can * display the Protege Info View */ graphComponent .getGraphView() .addNodeClickedListener( new NodeClickedListener() { /** * Invoked when a <code>Node</code> has been clicked by the mouse in the <code> * GraphView</code> * * @param evt The event associated with this action. */ public void nodeClicked(NodeClickedEvent evt) { // if(evt.getMouseEvent().getClickCount() == 2) { // Object selObj = graphComponent.getSelectedObject(); // if(selObj != null) { // if(selObj instanceof Instance) { // showInstance((Instance) selObj); // } // } // } } }); graphComponent.addGraphSelectionModelListener( new GraphSelectionModelListener() { public void selectionChanged(GraphSelectionModelEvent event) { Object selObj = event.getSource().getSelectedObject(); if (selObj instanceof OWLClass) { selectionModel.setSelectedClass((OWLClass) selObj); setGlobalSelection((OWLClass) selObj); } } }); tabbedPane.addContainerListener( new ContainerListener() { public void componentAdded(ContainerEvent e) { // Do nothing } public void componentRemoved(ContainerEvent e) { // Remove components from hash sets etc. componentGroupMap.remove(e.getChild()); closableTabs.remove(e.getChild()); graphComponents.remove(e.getChild()); OWLVizGraphPanel panel = (OWLVizGraphPanel) e.getChild(); panel.dispose(); } }); }
@NotNull private Content createContent(String contentName) { if (project == null) { throw new IllegalStateException("Project not opened"); } ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); ToolWindow wm = ToolWindowManager.getInstance(project).getToolWindow(QUERY_RESULT_PANE); if (wm == null) { wm = toolWindowManager.registerToolWindow(QUERY_RESULT_PANE, true, ToolWindowAnchor.BOTTOM); wm.setIcon(Icons.QUERY_RESULT_PANE); wm.setToHideOnEmptyContent(true); } Content content = wm.getContentManager().findContent(contentName); if (content == null) { JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addContainerListener(new JTabbedPaneListener()); tabbedPane.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { ((JComponent) e.getComponent()).putClientProperty(JTABBED_CONTROL, e.isControlDown()); } public void keyReleased(KeyEvent e) { ((JComponent) e.getComponent()).putClientProperty(JTABBED_CONTROL, e.isControlDown()); } }); tabbedPane.addFocusListener( new FocusAdapter() { public void focusGained(FocusEvent e) { Object source = e.getSource(); Component c = e.getOppositeComponent(); } public void focusLost(FocusEvent e) { ((JComponent) e.getSource()).putClientProperty(JTABBED_CONTROL, false); } }); JPanel jpanel = new JPanel(new BorderLayout()); DefaultActionGroup actionGroup = new DefaultActionGroup("PsiActionGroup22", false); actionGroup.add( new LocalToggleAction( "Refresh Query Result", "Refresh Query Result", Icons.REFRESH_RESULTSET, REFRESH_RESULTSET)); actionGroup.add(new LocalToggleAction("Copy", "Copy", Icons.EXPORT_DATA, EXPORT_DATA)); // todo -- problem with keeping sql markers and tabs in sync // actionGroup.add(new LocalToggleAction("Close", "Close", Icons.CLOSE_PANEL, // CLOSE_PANEL)); ActionManager actionManager = ActionManager.getInstance(); ActionToolbar toolBar = actionManager.createActionToolbar("DataGridActionToolbar", actionGroup, false); jpanel.add(toolBar.getComponent(), "West"); jpanel.add(tabbedPane, "Center"); // ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); // ContentFactory contentFactory = PeerFactory.getInstance().getContentFactory(); ContentFactory contentFactory = ContentFactoryEx.getContentFactory(); content = contentFactory.createContent(jpanel, contentName, false); // content.setActions(actionGroup, "UKNOWN", null); content.setIcon(Icons.DISCONNECT); wm.getContentManager().addContent(content); } return content; }