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);*/ }
@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(); }
/** * 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; }
public CasaSourceMultiViewElement(Lookup lookup) { super(lookup.lookup(CasaDataObject.class).getEditorSupport()); this.mDataObject = lookup.lookup(CasaDataObject.class); // XXX: Please explain why this is being done. setActivatedNodes(new Node[] {mDataObject.getNodeDelegate()}); // Initialize the editor support properly, which only needs to be // done when the editor is created (deserialization is working // due to CloneableEditor.readResolve() initializing the editor). // Note that this relies on the source view being the first in the // array of MultiViewDescription instances in WSDLMultiViewFactory, // since that results in the source view being created and opened // by default, only to be hidden when the DataObject default action // makes the tree view appear. // This initialization fixes CR 6380287 by ensuring that the Node // listener is registered with the DataObject Node delegate. mDataObject.getEditorSupport().initializeCloneableEditor(this); initialize(); }
public static CloneableTopComponent createMultiView(CasaDataObject obj) { /*CloneableTopComponent multiview = MultiViewFactory.createCloneableMultiView( views, views[1], new CasaDataEditorSupport.CloseHandler(obj));*/ CloneableTopComponent multiview = MultiViews.createCloneableMultiView(CasaDataLoader.CASA_MIME, obj); // IZ 84440 - show file name with extension String name = obj.getNodeDelegate().getDisplayName(); multiview.setDisplayName(name); multiview.setName(name); return multiview; }
private void initialize() { // create and associate lookup ProxyLookup lookup = new ProxyLookup( new Lookup[] { Lookups.fixed( new Object[] { // Need ActionMap in lookup so editor actions work. getActionMap(), // Need the data object registered in the lookup so that the // projectui code will close our open editor windows when the // project is closed. mDataObject }), mDataObject.getNodeDelegate().getLookup(), }); associateLookup(lookup); }