/**
  * The close last method should be called only for the last clone. If there are still existing
  * clones this method must return false. The implementation from the FormEditor always returns
  * true but this is not the expected behavior. The intention is to close the editor support once
  * the last editor has been closed, using the silent close to avoid displaying a new dialog which
  * is already being displayed via the close handler.
  */
 @Override
 protected boolean closeLast() {
   CasaDataEditorSupport support = mDataObject.getEditorSupport();
   JEditorPane[] editors = support.getOpenedPanes();
   if (editors == null || editors.length == 0) {
     return support.silentClose();
   }
   return false;
 }
 @Override
 public void componentHidden() {
   super.componentHidden();
   CasaDataEditorSupport editor = mDataObject.getEditorSupport();
   // Sync model before having undo manager listen to the model,
   // lest we get redundant undoable edits added to the queue.
   if (mDataObject.isModified()) {
     editor.syncModel();
   }
   //        editor.removeUndoManagerFromDocument();
 }
 @Override
 public void componentDeactivated() {
   super.componentDeactivated();
   CasaDataEditorSupport editor = mDataObject.getEditorSupport();
   // Sync model before having undo manager listen to the model,
   // lest we get redundant undoable edits added to the queue.
   if (mDataObject.isModified()) {
     editor.syncModel();
   }
   CasaMultiViewFactory.updateGroupVisibility(CasaMultiViewFactory.SOURCE_PREFERRED_ID);
   //        editor.removeUndoManagerFromDocument();
 }
 public CloseOperationState canCloseElement() {
   // if this is not the last cloned xml editor component, closing is OK
   if (!mDataObject.getEditorSupport().isModified()
       || !CasaDataEditorSupport.isLastView(multiViewObserver.getTopComponent())) {
     return CloseOperationState.STATE_OK;
   }
   AbstractAction save =
       new AbstractAction() {
         public void actionPerformed(ActionEvent arg0) {
           // save changes
           try {
             mDataObject.getEditorSupport().saveDocument();
             mDataObject.setModified(false);
           } catch (IOException ex) {
           }
         }
       };
   save.putValue(
       Action.LONG_DESCRIPTION,
       NbBundle.getMessage(
           DataObject.class,
           "MSG_SaveFile", // NOI18N
           mDataObject.getPrimaryFile().getNameExt()));
   return MultiViewFactory.createUnsafeCloseState(
       "ID_CASA_CLOSING", // NOI18N
       save,
       MultiViewFactory.NOOP_CLOSE_ACTION);
   // return a placeholder state - to be sure our CloseHandler is called
   /*return MultiViewFactory.createUnsafeCloseState(
   "ID_TEXT_CLOSING", // dummy ID // NOI18N
   MultiViewFactory.NOOP_CLOSE_ACTION,
   MultiViewFactory.NOOP_CLOSE_ACTION);*/
 }