com.xpn.xwiki.wysiwyg.client.plugin.link
Class LinkPlugin

java.lang.Object
  extended by com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPlugin
      extended by com.xpn.xwiki.wysiwyg.client.plugin.link.LinkPlugin
All Implemented Interfaces:
Plugin, WizardListener

public class LinkPlugin
extends com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPlugin
implements WizardListener

Rich text editor plug-in for inserting links, using a dialog to get link settings from the user. It installs a menu bar extension, with entries for all its actions.

Version:
$Id: LinkPlugin.java 26263 2010-01-20 17:34:36Z mflorea $

Constructor Summary
LinkPlugin(WikiServiceAsync wikiService)
          Creates a new link plugin that will use the specified wiki service.
 
Method Summary
 void destroy()
          Notifies the plug-in to release its resources before being unloaded from the WYSIWYG editor.
protected  void dispatchLinkWizard(LinkConfig linkParams)
          Instantiates and runs the correct wizard for the passed link.
protected  LinkConfig getCreateLinkParams()
          Prepares the link parameters for a link creation, i.e.
protected  LinkConfig getEditLinkParams(java.lang.String linkCommandParameter)
          Prepares the link parameters for a link edition, from the passed link parameter, as returned by the CreateLinkExecutable#getParameter(RichTextArea).
protected  LinkConfig getLinkParams()
           
 void init(RichTextArea textArea, Config config)
          Initialize the plug-in.
 void onCancel(Wizard sender)
          .
 void onFinish(Wizard sender, java.lang.Object result)
          .
 void onLinkEdit()
          Handles the edit of a link: prepares and shows the link wizard.
 void onLinkInsert(LinkConfig.LinkType linkType)
          Handles the creation of a link of the specified type: prepares and shows the link wizard.
 void onUnlink()
          Executed when the unlink button is clicked.
protected  void parseLabelFromImage(LinkConfig linkConfig, java.lang.String imageParam)
          Helper method to parse an image execution String parameter and fill the passed LinkConfig from it.
 
Methods inherited from class com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPlugin
getConfig, getTextArea, getUIExtensionList, getUIExtensions, saveRegistration, saveRegistrations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkPlugin

public LinkPlugin(WikiServiceAsync wikiService)
Creates a new link plugin that will use the specified wiki service.

Parameters:
wikiService - the service used to access the wiki
Method Detail

init

public void init(RichTextArea textArea,
                 Config config)
Initialize the plug-in. Plug-ins need to know the text area in order to provide only those feature that are supported.

Specified by:
init in interface Plugin
Overrides:
init in class com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPlugin
Parameters:
textArea - the text area of the editor
config - the configuration object
See Also:
AbstractPlugin.init(RichTextArea, Config)

destroy

public void destroy()
Notifies the plug-in to release its resources before being unloaded from the WYSIWYG editor.

Specified by:
destroy in interface Plugin
Overrides:
destroy in class com.xpn.xwiki.wysiwyg.client.plugin.internal.AbstractPlugin
See Also:
AbstractPlugin.destroy()

onLinkInsert

public void onLinkInsert(LinkConfig.LinkType linkType)
Handles the creation of a link of the specified type: prepares and shows the link wizard.

Parameters:
linkType - the type of link to insert

onLinkEdit

public void onLinkEdit()
Handles the edit of a link: prepares and shows the link wizard.


dispatchLinkWizard

protected void dispatchLinkWizard(LinkConfig linkParams)
Instantiates and runs the correct wizard for the passed link.

Parameters:
linkParams - the parameters of the link to be configured through the wizard

getLinkParams

protected LinkConfig getLinkParams()
Returns:
the link parameters for the current position of the cursor.

getEditLinkParams

protected LinkConfig getEditLinkParams(java.lang.String linkCommandParameter)
Prepares the link parameters for a link edition, from the passed link parameter, as returned by the CreateLinkExecutable#getParameter(RichTextArea).

Parameters:
linkCommandParameter - the parameter of the executed Command.CREATE_LINK command.
Returns:
the link parameters for link editing

getCreateLinkParams

protected LinkConfig getCreateLinkParams()
Prepares the link parameters for a link creation, i.e. sets the link labels.

Returns:
the link parameters for link creation

parseLabelFromImage

protected void parseLabelFromImage(LinkConfig linkConfig,
                                   java.lang.String imageParam)
Helper method to parse an image execution String parameter and fill the passed LinkConfig from it.

Parameters:
linkConfig - the link config to set the label to
imageParam - the image parameter, as returned by the command manager

onUnlink

public void onUnlink()
Executed when the unlink button is clicked.


onFinish

public void onFinish(Wizard sender,
                     java.lang.Object result)
. Handles wizard finish by creating the link HTML block from the LinkConfig setup through the wizard and executing the Command.CREATE_LINK with it.

Specified by:
onFinish in interface WizardListener

onCancel

public void onCancel(Wizard sender)
.

Specified by:
onCancel in interface WizardListener


Copyright © 2004-2010 XWiki. All Rights Reserved.