org.netbeans.core.multiview/1 1.29

org.netbeans.core.spi.multiview.text
Class MultiViewEditorElement

java.lang.Object
  extended by org.netbeans.core.spi.multiview.text.MultiViewEditorElement
All Implemented Interfaces:
Serializable, MultiViewElement, CloneableEditorSupport.Pane

public class MultiViewEditorElement
extends Object
implements MultiViewElement, CloneableEditorSupport.Pane, Serializable

Standard MultiViewElement to integrate editor with MultiViews. It can be used directly via a factory method:

 @MultiViewElement.Registration(
   displayName = "#BUNDLE_KEY",
   iconBase = "path/to/some-icon.png",
   mimeType = "text/yourmime",
   persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED,
   preferredID = "yourId",
   position = 1000
 )
 public static MultiViewEditorElement createEditor(Lookup lkp) {
   return new MultiViewEditorElement(lkp);
 }
Or one can subclass the class, override some methods (it is recommended to continue to call super implementation) and register the subclass.

Since:
1.24
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.netbeans.core.spi.multiview.MultiViewElement
MultiViewElement.Registration
 
Constructor Summary
MultiViewEditorElement(Lookup lookup)
          Constructor suitable for use with MultiViewElement.Registration annotation.
 
Method Summary
 CloseOperationState canCloseElement()
          Element decides if it can be safely closed.
 void componentActivated()
          Called when this multi view element is activated.
 void componentClosed()
          Called only when multi view top component was closed.
 void componentDeactivated()
          Called when this multi view element is deactivated.
 void componentHidden()
          Called when this MultiViewElement was hidden.
 void componentOpened()
          Called only when enclosing multi view top component was closed before and now is opened again for the first time.
 void componentShowing()
          Called when this MultiViewElement is about to be shown.
 void ensureVisible()
           
 Action[] getActions()
          Gets the actions which will appear in the popup menu of this component.
 CloneableTopComponent getComponent()
           
 JEditorPane getEditorPane()
           
 Lookup getLookup()
          Lookup for the MultiViewElement.
 JComponent getToolbarRepresentation()
          Returns the visual component with the multi view element's toolbar.Should be relatively fast as it's called everytime the current perspective is switched.
 UndoRedo getUndoRedo()
          UndoRedo support, Get the undo/redo support for this element.
 JComponent getVisualRepresentation()
          Returns Swing visual representation of this multi view element.
 void setMultiViewCallback(MultiViewElementCallback callback)
          Use the passed in callback instance for manipulating the enclosing multiview component, keep the instance around during lifecycle of the component if you want to automatically switch to this component etc.
 void updateName()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiViewEditorElement

public MultiViewEditorElement(Lookup lookup)
Constructor suitable for use with MultiViewElement.Registration annotation. The Lookup parameter is expected to contain CloneableEditorSupport, otherwise it yields an exception

Parameters:
lookup - context for the editor. Should contain instance of CloneableEditorSupport class
Throws:
IllegalArgumentException - if CloneableEditorSupport is not present in provided Lookup
Method Detail

getVisualRepresentation

public JComponent getVisualRepresentation()
Description copied from interface: MultiViewElement
Returns Swing visual representation of this multi view element. Should be relatively fast and always return the same component.

Specified by:
getVisualRepresentation in interface MultiViewElement

getToolbarRepresentation

public JComponent getToolbarRepresentation()
Description copied from interface: MultiViewElement
Returns the visual component with the multi view element's toolbar.Should be relatively fast as it's called everytime the current perspective is switched.

Specified by:
getToolbarRepresentation in interface MultiViewElement

getActions

public Action[] getActions()
Description copied from interface: MultiViewElement
Gets the actions which will appear in the popup menu of this component.

Subclasses are encouraged to use add the default TopComponent actions to the array of their own. These are accessible by calling MultiViewElementCallback.createDefaultActions()

 
          public Action[] getActions() {
             Action[] retValue;
             // the multiviewObserver was passed to the element in setMultiViewCallback() method.
             if (multiViewObserver != null) {
                 retValue = multiViewObserver.createDefaultActions();
                 // add you own custom actions here..
             } else {
                 // fallback..
                 retValue = super.getActions();
             }
             return retValue;
         }
   

Specified by:
getActions in interface MultiViewElement
Returns:
array of actions for this component

getLookup

public Lookup getLookup()
Description copied from interface: MultiViewElement
Lookup for the MultiViewElement. Will become part of the TopComponent's lookup.

Specified by:
getLookup in interface MultiViewElement
Returns:
the lookup to use when the MultiViewElement is active.

componentOpened

public void componentOpened()
Description copied from interface: MultiViewElement
Called only when enclosing multi view top component was closed before and now is opened again for the first time. The intent is to provide subclasses information about multi view TopComponent's life cycle. Subclasses will usually perform initializing tasks here.

Specified by:
componentOpened in interface MultiViewElement

componentClosed

public void componentClosed()
Description copied from interface: MultiViewElement
Called only when multi view top component was closed. The intent is to provide subclasses information about TopComponent's life cycle. Subclasses will usually perform cleaning tasks here.

Specified by:
componentClosed in interface MultiViewElement

componentShowing

public void componentShowing()
Description copied from interface: MultiViewElement
Called when this MultiViewElement is about to be shown. That can happen when switching the current perspective/view or when the topcomonent itself is shown for the first time.

Specified by:
componentShowing in interface MultiViewElement

componentHidden

public void componentHidden()
Description copied from interface: MultiViewElement
Called when this MultiViewElement was hidden. This happens when other view replaces this one as the selected view or when the whole topcomponent gets hidden (eg. when user selects anothe topcomponent in the current mode).

Specified by:
componentHidden in interface MultiViewElement

componentActivated

public void componentActivated()
Description copied from interface: MultiViewElement
Called when this multi view element is activated. This happens when the parent window of this component gets focus (and this component is the preferred one in it), or when this component is selected in its window (and its window was already focused).

Specified by:
componentActivated in interface MultiViewElement

componentDeactivated

public void componentDeactivated()
Description copied from interface: MultiViewElement
Called when this multi view element is deactivated. This happens when the parent window of this component loses focus (and this component is the preferred one in the parent), or when this component loses preference in the parent window (and the parent window is focussed).

Specified by:
componentDeactivated in interface MultiViewElement

getUndoRedo

public UndoRedo getUndoRedo()
Description copied from interface: MultiViewElement
UndoRedo support, Get the undo/redo support for this element.

Specified by:
getUndoRedo in interface MultiViewElement
Returns:
undoable edit for this component, null if not implemented.

setMultiViewCallback

public void setMultiViewCallback(MultiViewElementCallback callback)
Description copied from interface: MultiViewElement
Use the passed in callback instance for manipulating the enclosing multiview component, keep the instance around during lifecycle of the component if you want to automatically switch to this component etc. The enclosing window enviroment attaches the callback right after creating the element from the description. Same applies for deserialization of MultiViewTopComponent, thus MultiViewElement implementors shall not attempt to serialize the passed instance.

Specified by:
setMultiViewCallback in interface MultiViewElement

canCloseElement

public CloseOperationState canCloseElement()
Description copied from interface: MultiViewElement
Element decides if it can be safely closed. The element shall just return a value (created by MultiViewFactory.createCloseState() factory method), not open any UI, that is a semantical difference from TopComponent.canClose(). The CloseOperationHandler is the centralized place to show dialogs to the user. In cases when the element is consistent, just return CloseOperationState.STATE_OK.

Specified by:
canCloseElement in interface MultiViewElement

getEditorPane

public JEditorPane getEditorPane()
Specified by:
getEditorPane in interface CloneableEditorSupport.Pane

getComponent

public CloneableTopComponent getComponent()
Specified by:
getComponent in interface CloneableEditorSupport.Pane

updateName

public void updateName()
Specified by:
updateName in interface CloneableEditorSupport.Pane

ensureVisible

public void ensureVisible()
Specified by:
ensureVisible in interface CloneableEditorSupport.Pane

org.netbeans.core.multiview/1 1.29

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.