/**
  * Update the visibility of the CASA window group
  *
  * @param preferredId
  */
 public static void updateGroupVisibility(String preferredId) {
   WindowManager wm = WindowManager.getDefault();
   TopComponentGroup group = wm.findTopComponentGroup("casa_ui"); // NOI18N
   if (group == null) {
     return; // group not found (should not happen)
   }
   //
   boolean isDesignViewSelected = false;
   for (Mode mode : wm.getModes()) {
     TopComponent selected = mode.getSelectedTopComponent();
     if (selected != null) {
       MultiViewHandler mvh = MultiViews.findMultiViewHandler(selected);
       if (mvh != null) {
         MultiViewPerspective mvp = mvh.getSelectedPerspective();
         if (mvp != null) {
           String id = mvp.preferredID();
           if (preferredId.equals(id)) {
             isDesignViewSelected = true;
             break;
           }
         }
       }
     }
   }
   synchronized (groupVisible) {
     if (isDesignViewSelected && !groupVisible) {
       group.open();
       groupVisible = Boolean.TRUE;
     } else if (!isDesignViewSelected && groupVisible) {
       group.close();
       groupVisible = Boolean.FALSE;
     }
   }
 }
    public JComponent[] getMenuPresenters() {
      assert SwingUtilities.isEventDispatchThread() : "Must be called from AWT";
      removeAll();
      final TopComponent tc = WindowManager.getDefault().getRegistry().getActivated();
      if (tc != null) {
        setEnabled(true);
        MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
        if (handler != null) {
          ButtonGroup group = new ButtonGroup();
          MultiViewPerspective[] pers = handler.getPerspectives();
          final String[] names = new String[pers.length];
          for (int i = 0; i < pers.length; i++) {
            MultiViewPerspective thisPers = pers[i];

            JRadioButtonMenuItem item = new JRadioButtonMenuItem();
            names[i] = thisPers.getDisplayName();
            Mnemonics.setLocalizedText(item, thisPers.getDisplayName());
            item.setActionCommand(thisPers.getDisplayName());
            item.addActionListener(
                new ActionListener() {
                  public void actionPerformed(ActionEvent event) {
                    MultiViewHandler handler = MultiViews.findMultiViewHandler(tc);
                    if (handler == null) {
                      return;
                    }
                    MultiViewPerspective thisPers = null;
                    MultiViewPerspective[] pers = handler.getPerspectives();
                    assert pers.length == names.length : "Arrays must have the same length";
                    for (int i = 0; i < pers.length; i++) {
                      if (event.getActionCommand().equals(names[i])) {
                        thisPers = pers[i];
                        break;
                      }
                    }
                    if (thisPers != null) {
                      handler.requestActive(thisPers);
                    }
                  }
                });
            if (thisPers
                .getDisplayName()
                .equals(handler.getSelectedPerspective().getDisplayName())) {
              item.setSelected(true);
            }
            group.add(item);
            add(item);
          }
        } else { // handler == null
          // No reason to enable action on any TC because now it was enabled even for Welcome page
          setEnabled(false);
          /*JRadioButtonMenuItem but = new JRadioButtonMenuItem();
          Mnemonics.setLocalizedText(but, NbBundle.getMessage(EditorsAction.class, "EditorsAction.source"));
          but.setSelected(true);
          add(but);*/
        }
      } else { // tc == null
        setEnabled(false);
      }
      return new JComponent[] {this};
    }
 /**
  * Shows the desired multiview element. Must be called after the editor has been opened (i.e.
  * WSDLEditorSupport.open()) so the TopComponent will be the active one in the registry.
  *
  * @param id identifier of the multiview element.
  */
 public static void requestMultiviewActive(String id) {
   TopComponent activeTC = TopComponent.getRegistry().getActivated();
   MultiViewHandler handler = MultiViews.findMultiViewHandler(activeTC);
   if (handler != null) {
     MultiViewPerspective[] perspectives = handler.getPerspectives();
     for (MultiViewPerspective perspective : perspectives) {
       if (perspective.preferredID().equals(id)) {
         handler.requestActive(perspective);
       }
     }
   }
 }