Example #1
0
  public void showTopComponent() {
    if (m_topComponent == null) {
      m_topComponent = getTopComponent();
      m_topComponent.open();
    }

    if (m_topComponent != null) {
      if (!m_topComponent.isOpened()) {
        m_topComponent = getTopComponent();
        m_topComponent.open();
      }

      m_topComponent.requestActive();

      // repeated on purpose to assert the display name
      m_topComponent.requestActive();

      m_topComponent.setDisplayName(m_name);
    }
  }
  private void openAndCloseMembers(Perspective perspective) {
    // Close other perspective based on group name
    for (Perspective g : perspectives) {
      if (g != perspective) {
        TopComponentGroup tpg = WindowManager.getDefault().findTopComponentGroup(g.getName());
        if (tpg != null) {
          tpg.close();
        }
      }
    }

    // Open perspective
    TopComponentGroup tpg = WindowManager.getDefault().findTopComponentGroup(perspective.getName());
    if (tpg != null) {
      tpg.open();
    }

    // Close members
    for (TopComponent c : WindowManager.getDefault().getRegistry().getOpened()) {
      String pId = WindowManager.getDefault().findTopComponentID((TopComponent) c);
      for (PerspectiveMember perspectiveMember : members) {
        if (pId.equals(perspectiveMember.getTopComponentId())
            && !perspectiveMember.isMemberOf(perspective)) {
          boolean closed = c.close();
        }
      }
    }

    // Open members
    for (PerspectiveMember perspectiveMember : members) {
      if (perspectiveMember.isMemberOf(perspective)) {
        String pId = perspectiveMember.getTopComponentId();
        TopComponent c = WindowManager.getDefault().findTopComponent(pId);
        if (c != null && !c.isOpened()) {
          c.open();
        }
      }
    }
  }