Ejemplo n.º 1
0
  /**
   * 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();
          }
        });
  }