public ClassHierarchyTree(final WorkbookManager manager, OWLOntology ontology) {
    super(new ClassHierarchyTreeModel(manager.getOntologyManager(), ontology));

    this.ontology = ontology;
    this.workbookManager = manager;

    setModel(new ClassHierarchyTreeModel(workbookManager.getOntologyManager(), ontology));
    getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    addTreeSelectionListener(
        new TreeSelectionListener() {
          @Override
          public void valueChanged(TreeSelectionEvent e) {
            previewSelectedClass();
          }
        });

    setCellRenderer(new OntologyCellRenderer(workbookManager.getOntologyManager()));
  }
Exemplo n.º 2
0
 private void transmitSelectionToModel() {
   if (rebuildingTabs || updatingSelectionFromModel) {
     return;
   }
   try {
     transmittingSelectionToModel = true;
     Range range = getSelectedSheetPanel().getSelectedRange();
     manager.getSelectionModel().setSelectedRange(range);
   } finally {
     transmittingSelectionToModel = false;
   }
 }
Exemplo n.º 3
0
  public WorkbookPanel(WorkbookManager workbookManager) {
    this.manager = workbookManager;
    tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
    setLayout(new BorderLayout());
    add(tabbedPane, BorderLayout.CENTER);
    workbookChangeListener = new WorkbookChangeListenerImpl();
    manager.getWorkbook().addChangeListener(workbookChangeListener);
    rebuildTabs();
    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            transmitSelectionToModel();
          }
        });
    workbookManager
        .getSelectionModel()
        .addCellSelectionListener(
            new CellSelectionListener() {
              public void selectionChanged(Range range) {
                updateSelectionFromModel(range);
              }
            });
    workbookManager.addListener(
        new AbstractWorkbookManagerListener() {

          @Override
          public void workbookCreated() {
            rebuildTabs();
            transmitSelectionToModel();
          }

          @Override
          public void workbookLoaded() {
            rebuildTabs();
            transmitSelectionToModel();
          }
        });
  }
  private void previewSelectedClass() {
    logger.debug("In previewSelectedClass");

    TreePath[] selectedPaths = getSelectionPaths();
    if (selectedPaths == null) {
      return;
    }
    Set<OWLEntity> selectedEntities = new HashSet<OWLEntity>();

    for (TreePath path : selectedPaths) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
      if (node instanceof ClassHierarchyNode) {
        selectedEntities.addAll(((ClassHierarchyNode) node).getOWLClasses());
      } else {
        selectedEntities.add(
            (OWLNamedIndividual) ((ClassHierarchyIndividualNode) node).getUserObject());
      }
    }
    OWLEntity selectedEntity = selectedEntities.iterator().next();
    if (!workbookManager.getEntitySelectionModel().getSelectedEntity().equals(selectedEntity)) {
      workbookManager.getEntitySelectionModel().setSelectedEntity(selectedEntity);
    }
    workbookManager.previewValidation();
  }
Exemplo n.º 5
0
  private void rebuildTabs() {

    rebuildingTabs = true;
    for (int i = 0; i < tabbedPane.getTabCount(); i++) {
      SheetPanel sheetPanel = (SheetPanel) tabbedPane.getComponentAt(i);
      sheetPanel.dispose();
    }
    tabbedPane.removeAll();
    Workbook workbook = manager.getWorkbook();
    for (Sheet sheet : workbook.getSheets()) {
      if (!sheet.isHidden()) {
        SheetPanel sheetPanel = new SheetPanel(manager, sheet);
        tabbedPane.add(sheet.getName(), sheetPanel);
      }
    }
    rebuildingTabs = false;
  }