diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfig.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfig.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfig.java 2010-06-13 09:00:12.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfig.java 2010-07-28 21:02:29.625000000 +0700 @@ -38,7 +38,7 @@ * Link types: external link (default for any unrecognized link), internal link targeting an existent page, * internal link targeting a new page, link targeting an attached file, external link to an email address. */ - EXTERNAL, NEW_WIKIPAGE, WIKIPAGE, ATTACHMENT, EMAIL + EXTERNAL, NEW_WIKIPAGE, WIKIPAGE, ATTACHMENT, EMAIL, XMPP, MAGNET }; /** diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfigDOMReader.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfigDOMReader.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfigDOMReader.java 2010-06-13 09:00:12.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfigDOMReader.java 2010-08-01 10:40:58.437500000 +0700 @@ -98,11 +98,17 @@ return LinkType.NEW_WIKIPAGE; } if ("wikiexternallink".equals(wrappingSpanClass)) { - if (reference.startsWith("mailto")) { - return LinkType.EMAIL; - } else if (reference.startsWith("attach")) { - return LinkType.ATTACHMENT; + LinkType result = LinkType.EXTERNAL; + if (reference.startsWith("mailto:")) { + result = LinkType.EMAIL; + //} else if (reference.startsWith("xmpp:")) { + // return LinkType.XMPP; + } else if (reference.startsWith("magnet:")) { + result = LinkType.MAGNET; + } else if (reference.startsWith("attach:")) { + result = LinkType.ATTACHMENT; } + return result; } return LinkType.EXTERNAL; } diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfigDOMWriter.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfigDOMWriter.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfigDOMWriter.java 2010-06-13 09:00:12.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkConfigDOMWriter.java 2010-07-28 21:04:25.328125000 +0700 @@ -57,6 +57,8 @@ CLASS_NAME_MAPPING.put(LinkType.EXTERNAL, "wikiexternallink"); CLASS_NAME_MAPPING.put(LinkType.ATTACHMENT, CLASS_NAME_MAPPING.get(LinkType.EXTERNAL)); CLASS_NAME_MAPPING.put(LinkType.EMAIL, CLASS_NAME_MAPPING.get(LinkType.EXTERNAL)); + CLASS_NAME_MAPPING.put(LinkType.XMPP, CLASS_NAME_MAPPING.get(LinkType.EXTERNAL)); + CLASS_NAME_MAPPING.put(LinkType.MAGNET, CLASS_NAME_MAPPING.get(LinkType.EXTERNAL)); } /** diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkMenuExtension.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkMenuExtension.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkMenuExtension.java 2010-06-13 09:00:12.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkMenuExtension.java 2010-07-28 21:20:38.250000000 +0700 @@ -100,6 +100,14 @@ } }); + MenuItem magnetLink = new MenuItem(Strings.INSTANCE.linkToMagnet(), new com.google.gwt.user.client.Command() + { + public void execute() + { + plugin.onLinkInsert(LinkType.MAGNET); + } + }); + MenuItem wikiPageLink = new MenuItem(Strings.INSTANCE.linkToWikiPage(), new com.google.gwt.user.client.Command() { @@ -124,6 +132,7 @@ createLinkMenus.add(new MenuItemSeparator()); createLinkMenus.add(webPageLink); createLinkMenus.add(emailLink); + createLinkMenus.add(magnetLink); MenuItem editLink = new MenuItem(Strings.INSTANCE.linkEdit(), new com.google.gwt.user.client.Command() { diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkPlugin.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkPlugin.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkPlugin.java 2010-06-13 09:00:12.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/LinkPlugin.java 2010-08-01 10:20:59.515625000 +0700 @@ -200,6 +200,9 @@ case EMAIL: getLinkWizard().start(LinkWizardStep.EMAIL.toString(), linkConfig); break; + case MAGNET: + getLinkWizard().start(LinkWizardStep.MAGNET_NEW.toString(), linkConfig); + break; case EXTERNAL: default: getLinkWizard().start(LinkWizardStep.WEB_PAGE.toString(), linkConfig); diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/AbstractExternalLinkWizardStep.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/AbstractExternalLinkWizardStep.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/AbstractExternalLinkWizardStep.java 2010-06-13 09:00:12.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/AbstractExternalLinkWizardStep.java 2010-08-02 14:28:05.046875000 +0700 @@ -67,9 +67,11 @@ Panel urlLabel = new FlowPanel(); urlLabel.setStyleName(INFO_LABEL_STYLE); urlLabel.add(new InlineLabel(getURLLabel())); - InlineLabel mandatoryLabel = new InlineLabel(Strings.INSTANCE.mandatory()); - mandatoryLabel.addStyleName("xMandatory"); - urlLabel.add(mandatoryLabel); + if (isURLMandatory()) { + InlineLabel mandatoryLabel = new InlineLabel(Strings.INSTANCE.mandatory()); + mandatoryLabel.addStyleName("xMandatory"); + urlLabel.add(mandatoryLabel); + } Label helpUrlLabel = new Label(getURLHelpLabel()); helpUrlLabel.setStyleName(HELP_LABEL_STYLE); @@ -147,7 +149,7 @@ // validate everything: super first boolean result = super.validateForm(); // then this form - if (urlTextBox.getText().trim().length() == 0) { + if ((urlTextBox.getText().trim().length() == 0) && isURLMandatory()) { displayURLError(getURLErrorMessage()); result = false; } @@ -206,6 +208,15 @@ } /** + * @return True if URL must be non-empty. Magnet link wizard allows link improving in another wizard step, so + * it is OK to leave this field empty. + */ + protected boolean isURLMandatory() + { + return true; + } + + /** * {@inheritDoc} */ @Override diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkConfigWizardStep.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkConfigWizardStep.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkConfigWizardStep.java 2010-06-13 09:00:12.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkConfigWizardStep.java 2010-08-02 14:32:41.296875000 +0700 @@ -160,9 +160,11 @@ Panel labelLabel = new FlowPanel(); labelLabel.setStyleName(INFO_LABEL_STYLE); labelLabel.add(new InlineLabel(Strings.INSTANCE.linkLabelLabel())); - InlineLabel mandatoryLabel = new InlineLabel(Strings.INSTANCE.mandatory()); - mandatoryLabel.addStyleName("xMandatory"); - labelLabel.add(mandatoryLabel); + if (isLabelMandatory()) { + InlineLabel mandatoryLabel = new InlineLabel(Strings.INSTANCE.mandatory()); + mandatoryLabel.addStyleName("xMandatory"); + labelLabel.add(mandatoryLabel); + } Label helpLabelLabel = new Label(getLabelTextBoxTooltip()); helpLabelLabel.setStyleName(HELP_LABEL_STYLE); @@ -282,6 +284,14 @@ } /** + * @return True if label must be non-empty. There is little point in magnet link labels. + */ + protected boolean isLabelMandatory() + { + return true; + } + + /** * @return the tooltipTextBox */ public TextBox getTooltipTextBox() @@ -322,7 +332,7 @@ */ protected boolean validateForm() { - if (labelTextBox.getText().trim().length() == 0) { + if ((labelTextBox.getText().trim().length() == 0) && isLabelMandatory()) { displayLabelError(Strings.INSTANCE.linkNoLabelError()); return false; } diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkWizard.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkWizard.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkWizard.java 2010-06-13 09:00:12.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkWizard.java 2010-08-01 14:47:04.359375000 +0700 @@ -29,8 +29,6 @@ import org.xwiki.gwt.wysiwyg.client.Images; import org.xwiki.gwt.wysiwyg.client.Strings; import org.xwiki.gwt.wysiwyg.client.plugin.link.LinkConfig; -import org.xwiki.gwt.wysiwyg.client.widget.wizard.util.AttachmentSelectorAggregatorWizardStep; -import org.xwiki.gwt.wysiwyg.client.widget.wizard.util.LinkUploadWizardStep; import org.xwiki.gwt.wysiwyg.client.wiki.EntityLink; import org.xwiki.gwt.wysiwyg.client.wiki.EntityReference; import org.xwiki.gwt.wysiwyg.client.wiki.WikiServiceAsync; @@ -55,7 +53,11 @@ /** * Steps managed by this wizard. */ - WEB_PAGE, EMAIL, WIKI_PAGE, WIKI_PAGE_CREATOR, ATTACHMENT, ATTACHMENT_UPLOAD, WIKI_PAGE_CONFIG + WEB_PAGE, EMAIL, WIKI_PAGE, WIKI_PAGE_CREATOR, ATTACHMENT, ATTACHMENT_UPLOAD, WIKI_PAGE_CONFIG, + /** + * Magnet link management wizard steps. + */ + MAGNET_NEW, MAGNET_CONFIG }; /** @@ -106,63 +108,74 @@ */ public WizardStep getStep(String name) { - LinkWizardStep requestedStep = parseStepName(name); - WizardStep step = stepsMap.get(requestedStep); - if (step == null) { - switch (requestedStep) { - case EMAIL: - step = new EmailAddressLinkWizardStep(wikiService); - break; - case WIKI_PAGE: - step = new PageSelectorWizardStep(wikiService); - break; - case WIKI_PAGE_CREATOR: - step = new CreateNewPageWizardStep(wikiService); - break; - case ATTACHMENT: - step = createAttachmentSelectorWizardStep(); - break; - case ATTACHMENT_UPLOAD: - LinkUploadWizardStep attachmentUploadStep = - new LinkUploadWizardStep(wikiService); - attachmentUploadStep.setFileHelpLabel(Strings.INSTANCE.linkAttachmentUploadHelpLabel()); - attachmentUploadStep.setNextStep(LinkWizardStep.WIKI_PAGE_CONFIG.toString()); - step = attachmentUploadStep; - break; - case WIKI_PAGE_CONFIG: - step = new LinkConfigWizardStep(wikiService); - break; - case WEB_PAGE: - step = new WebPageLinkWizardStep(wikiService); - break; - default: - // nothing here, leave it null - break; - } - // if something has been created, add it in the map - if (step != null) { - stepsMap.put(requestedStep, step); - } - } - // return the found or newly created step - return step; + return LinkWizardSteps.getStep(name, stepsMap, wikiService, config); } - /** - * @return the wizard step to be used for selecting an attachment - */ - private WizardStep createAttachmentSelectorWizardStep() - { - boolean selectionLimitedToCurrentPage = "currentpage".equals(config.getParameter("linkfiles")); - AttachmentSelectorAggregatorWizardStep attachmentSelector = - new AttachmentSelectorAggregatorWizardStep(selectionLimitedToCurrentPage, wikiService); - attachmentSelector.setStepTitle(Strings.INSTANCE.imageSelectImageTitle()); - attachmentSelector.setCurrentPageSelector(new CurrentPageAttachmentSelectorWizardStep(wikiService)); - if (!selectionLimitedToCurrentPage) { - attachmentSelector.setAllPagesSelector(new AttachmentExplorerWizardStep(wikiService)); - } - return attachmentSelector; - } +// public WizardStep getStep(String name) +// { +// LinkWizardStep requestedStep = parseStepName(name); +// WizardStep step = stepsMap.get(requestedStep); +// if (step == null) { +// switch (requestedStep) { +// case EMAIL: +// step = new EmailAddressLinkWizardStep(wikiService); +// break; +// case WIKI_PAGE: +// step = new PageSelectorWizardStep(wikiService); +// break; +// case WIKI_PAGE_CREATOR: +// step = new CreateNewPageWizardStep(wikiService); +// break; +// case ATTACHMENT: +// step = createAttachmentSelectorWizardStep(); +// break; +// case ATTACHMENT_UPLOAD: +// LinkUploadWizardStep attachmentUploadStep = +// new LinkUploadWizardStep(wikiService); +// attachmentUploadStep.setFileHelpLabel(Strings.INSTANCE.linkAttachmentUploadHelpLabel()); +// attachmentUploadStep.setNextStep(LinkWizardStep.WIKI_PAGE_CONFIG.toString()); +// step = attachmentUploadStep; +// break; +// case WIKI_PAGE_CONFIG: +// step = new LinkConfigWizardStep(wikiService); +// break; +// case WEB_PAGE: +// step = new WebPageLinkWizardStep(wikiService); +// break; +// case MAGNET_NEW: +// step = new MagnetNewLinkWizardStep(wikiService); +// break; +// case MAGNET_CONFIG: +// step = new MagnetConfigLinkWizardStep(wikiService); +// break; +// default: +// // nothing here, leave it null +// break; +// } +// // if something has been created, add it in the map +// if (step != null) { +// stepsMap.put(requestedStep, step); +// } +// } +// // return the found or newly created step +// return step; +// } + +// /** +// * @return the wizard step to be used for selecting an attachment +// */ +// private WizardStep createAttachmentSelectorWizardStep() +// { +// boolean selectionLimitedToCurrentPage = "currentpage".equals(config.getParameter("linkfiles")); +// AttachmentSelectorAggregatorWizardStep attachmentSelector = +// new AttachmentSelectorAggregatorWizardStep(selectionLimitedToCurrentPage, wikiService); +// attachmentSelector.setStepTitle(Strings.INSTANCE.imageSelectImageTitle()); +// attachmentSelector.setCurrentPageSelector(new CurrentPageAttachmentSelectorWizardStep(wikiService)); +// if (!selectionLimitedToCurrentPage) { +// attachmentSelector.setAllPagesSelector(new AttachmentExplorerWizardStep(wikiService)); +// } +// return attachmentSelector; +// } /** * {@inheritDoc} @@ -203,7 +216,7 @@ * @return the {@link LinkWizardStep} {@code enum} value corresponding to the passed name, or {@code null} if no * such value exists. */ - private LinkWizardStep parseStepName(String name) + public static LinkWizardStep parseStepName(String name) { // let's be careful about this LinkWizardStep requestedStep = null; diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkWizardSteps.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkWizardSteps.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkWizardSteps.java 1970-01-01 06:00:00.000000000 +0600 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/LinkWizardSteps.java 2010-08-02 15:39:32.046875000 +0700 @@ -0,0 +1,146 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.gwt.wysiwyg.client.plugin.link.ui; + +import java.util.Map; + +import org.xwiki.gwt.user.client.Config; +import org.xwiki.gwt.user.client.ui.wizard.WizardStep; + +import org.xwiki.gwt.wysiwyg.client.Strings; +import org.xwiki.gwt.wysiwyg.client.wiki.WikiServiceAsync; +import org.xwiki.gwt.wysiwyg.client.widget.wizard.util.AttachmentSelectorAggregatorWizardStep; +import org.xwiki.gwt.wysiwyg.client.widget.wizard.util.LinkUploadWizardStep; +import org.xwiki.gwt.wysiwyg.client.plugin.link.LinkConfig; + +import org.xwiki.gwt.wysiwyg.client.plugin.link.ui.LinkWizard.LinkWizardStep; + +/** + * An utility class converting step name into corresponding wizard step instance. + * + * @version $Id: LinkWizardSteps.java 2010-08-01 15:58:00Z octagram $ + */ +final class LinkWizardSteps +{ + /** + * Private constructor. + */ + private LinkWizardSteps() + { + } + + /** + * Creates a wizard step. + * + * @param requestedStep An identifier of the step being requested + * @param wikiService A proxy for the server wikiService. + * @param config f i x m e + * @return Created wizard step. + */ + private static WizardStep createStep(LinkWizardStep requestedStep, + WikiServiceAsync wikiService, Config config) + { + WizardStep step = null; + switch (requestedStep) { + case EMAIL: + step = new EmailAddressLinkWizardStep(wikiService); + break; + case WIKI_PAGE: + step = new PageSelectorWizardStep(wikiService); + break; + case WIKI_PAGE_CREATOR: + step = new CreateNewPageWizardStep(wikiService); + break; + case ATTACHMENT: + step = createAttachmentSelectorWizardStep(wikiService, config); + break; + case ATTACHMENT_UPLOAD: + LinkUploadWizardStep attachmentUploadStep = + new LinkUploadWizardStep(wikiService); + attachmentUploadStep.setFileHelpLabel(Strings.INSTANCE.linkAttachmentUploadHelpLabel()); + attachmentUploadStep.setNextStep(LinkWizardStep.WIKI_PAGE_CONFIG.toString()); + step = attachmentUploadStep; + break; + case WIKI_PAGE_CONFIG: + step = new LinkConfigWizardStep(wikiService); + break; + case WEB_PAGE: + step = new WebPageLinkWizardStep(wikiService); + break; + case MAGNET_NEW: + step = new MagnetNewLinkWizardStep(wikiService); + break; + case MAGNET_CONFIG: + step = new MagnetConfigLinkWizardStep(wikiService); + break; + default: + // nothing here, leave it null + break; + } + return step; + } + + /** + * Lazily creates wizard step instance. + * + * @see WizardStepProvider#getStep(String) + * + * @param name A name of the step being requested + * @param stepsMap Map from step id to instance + * @param wikiService A proxy for the server wikiService. + * @param config f i x m e + * @return Wizard step. + */ + public static WizardStep getStep(String name, + Map stepsMap, + WikiServiceAsync wikiService, Config config) + { + LinkWizard.LinkWizardStep requestedStep = LinkWizard.parseStepName(name); + WizardStep step = stepsMap.get(requestedStep); + if (step == null) { + step = createStep(requestedStep, wikiService, config); + // if something has been created, add it in the map + if (step != null) { + stepsMap.put(requestedStep, step); + } + } + // return the found or newly created step + return step; + } + + /** + * @return the wizard step to be used for selecting an attachment + * @param wikiService A proxy for the server wikiService. + * @param config f i x m e + */ + private static WizardStep createAttachmentSelectorWizardStep(WikiServiceAsync wikiService, Config config) + { + boolean selectionLimitedToCurrentPage = "currentpage".equals(config.getParameter("linkfiles")); + AttachmentSelectorAggregatorWizardStep attachmentSelector = + new AttachmentSelectorAggregatorWizardStep(selectionLimitedToCurrentPage, wikiService); + attachmentSelector.setStepTitle(Strings.INSTANCE.imageSelectImageTitle()); + attachmentSelector.setCurrentPageSelector(new CurrentPageAttachmentSelectorWizardStep(wikiService)); + if (!selectionLimitedToCurrentPage) { + attachmentSelector.setAllPagesSelector(new AttachmentExplorerWizardStep(wikiService)); + } + return attachmentSelector; + } + +} \ No newline at end of file diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetConfigLinkWizardStep.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetConfigLinkWizardStep.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetConfigLinkWizardStep.java 1970-01-01 06:00:00.000000000 +0600 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetConfigLinkWizardStep.java 2010-08-02 08:00:44.265625000 +0700 @@ -0,0 +1,116 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.gwt.wysiwyg.client.plugin.link.ui; + +import org.xwiki.gwt.wysiwyg.client.Strings; +import org.xwiki.gwt.wysiwyg.client.wiki.WikiServiceAsync; + +/** + * Wizard step to create a magnet link (the magnet: scheme). + * + * @version $Id: MagnetConfigLinkWizardStep.java 28844 2010-08-01 20:49:39Z octagram $ + */ +public class MagnetConfigLinkWizardStep extends AbstractExternalLinkWizardStep +{ + /** + * URI protocol constant. + */ + private static final String MAGNET = "magnet:"; + + /** + * URI query delimiter ("?"). + */ + private static final String URI_QUERY_DELIMITER = "?"; + + /** + * Creates a new wizard step for configuring a magnet link. + * + * @param wikiService the service to be used for parsing the image reference when the link label is an image + */ + MagnetConfigLinkWizardStep(WikiServiceAsync wikiService) + { + super(wikiService); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#buildURL() + */ + protected String buildURL() + { + String magnetLink = getUrlTextBox().getText().trim(); + // If url does not start with the desired protocol, add it + if (!magnetLink.startsWith(MAGNET)) { + if (!magnetLink.startsWith(URI_QUERY_DELIMITER)) { + magnetLink = URI_QUERY_DELIMITER + magnetLink; + } + magnetLink = MAGNET + magnetLink; + } + return magnetLink; + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLTextBoxTooltip() + */ + protected String getURLTextBoxTooltip() + { + return Strings.INSTANCE.linkURLToMagnetTextBoxTooltip(); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLErrorMessage() + */ + protected String getURLErrorMessage() + { + return Strings.INSTANCE.linkMagnetError(); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLLabel() + */ + protected String getURLLabel() + { + return Strings.INSTANCE.linkMagnetLabel(); + } + + /** + * {@inheritDoc} + */ + @Override + protected String getURLHelpLabel() + { + return Strings.INSTANCE.linkMagnetHelpLabel(); + } + + /** + * {@inheritDoc} + */ + public String getStepTitle() + { + return Strings.INSTANCE.linkToMagnet(); + } +} diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetNewLinkWizardStep.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetNewLinkWizardStep.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetNewLinkWizardStep.java 1970-01-01 06:00:00.000000000 +0600 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetNewLinkWizardStep.java 2010-08-02 23:22:58.812500000 +0700 @@ -0,0 +1,144 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.gwt.wysiwyg.client.plugin.link.ui; + +import org.xwiki.gwt.wysiwyg.client.Strings; +import org.xwiki.gwt.wysiwyg.client.wiki.WikiServiceAsync; +//import org.xwiki.gwt.wysiwyg.client.plugin.link.ui.LinkWizard.LinkWizardStep; + +/** + * Wizard step to create a magnet link (the magnet: scheme). + * + * @version $Id: MagnetNewLinkWizardStep 28844 2010-08-02 08:07:07Z octagram $ + */ +public class MagnetNewLinkWizardStep extends AbstractExternalLinkWizardStep +{ + /** + * URI protocol constant. + */ + private static final String MAGNET = "magnet:"; + + /** + * URI query delimiter ("?"). + */ + private static final String URI_QUERY_DELIMITER = "?"; + + /** + * Creates a new wizard step for configuring a link to an email address. + * + * @param wikiService the service to be used for parsing the image reference when the link label is an image + */ + MagnetNewLinkWizardStep(WikiServiceAsync wikiService) + { + super(wikiService); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#buildURL() + */ + protected String buildURL() + { + String magnetLink = getUrlTextBox().getText().trim(); + // If url does not start with the desired protocol, add it + if (!magnetLink.startsWith(MAGNET)) { + if (!magnetLink.startsWith(URI_QUERY_DELIMITER)) { + magnetLink = URI_QUERY_DELIMITER + magnetLink; + } + magnetLink = MAGNET + magnetLink; + } + return magnetLink; + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLTextBoxTooltip() + */ + protected String getURLTextBoxTooltip() + { + return Strings.INSTANCE.linkURLToMagnetTextBoxTooltip(); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLErrorMessage() + */ + protected String getURLErrorMessage() + { + return Strings.INSTANCE.linkMagnetError(); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLLabel() + */ + protected String getURLLabel() + { + return Strings.INSTANCE.linkMagnetLabel(); + } + + /** + * {@inheritDoc} + */ + @Override + protected String getURLHelpLabel() + { + return Strings.INSTANCE.linkMagnetHelpLabel(); + } + + // /** + // * {@inheritDoc} + // */ + // @Override + // protected boolean isURLMandatory() + // { + // return false; + // } + + // /** + // * {@inheritDoc} + // */ + // @Override + // protected boolean isLabelMandatory() + // { + // return false; + // } + + /** + * {@inheritDoc} + */ + public String getStepTitle() + { + return Strings.INSTANCE.linkToMagnet(); + } + + // /** + // * {@inheritDoc} + // */ + // @Override + // public String getNextStep() + // { + // return LinkWizardStep.MAGNET_CONFIG.toString(); + // } +} diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetNewLinkWizardStep.java.old xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetNewLinkWizardStep.java.old --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetNewLinkWizardStep.java.old 1970-01-01 06:00:00.000000000 +0600 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/plugin/link/ui/MagnetNewLinkWizardStep.java.old 2010-08-02 08:08:25.906250000 +0700 @@ -0,0 +1,116 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.gwt.wysiwyg.client.plugin.link.ui; + +import org.xwiki.gwt.wysiwyg.client.Strings; +import org.xwiki.gwt.wysiwyg.client.wiki.WikiServiceAsync; + +/** + * Wizard step to create a magnet link (the magnet: scheme). + * + * @version $Id: MagnetNewLinkWizardStep 28844 2010-08-02 08:07:07Z octagram $ + */ +public class MagnetNewLinkWizardStep extends AbstractExternalLinkWizardStep +{ + /** + * URI protocol constant. + */ + private static final String MAGNET = "magnet:"; + + /** + * URI query delimiter ("?"). + */ + private static final String URI_QUERY_DELIMITER = "?"; + + /** + * Creates a new wizard step for configuring a link to an email address. + * + * @param wikiService the service to be used for parsing the image reference when the link label is an image + */ + MagnetNewLinkWizardStep(WikiServiceAsync wikiService) + { + super(wikiService); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#buildURL() + */ + protected String buildURL() + { + String magnetLink = getUrlTextBox().getText().trim(); + // If url does not start with the desired protocol, add it + if (!magnetLink.startsWith(MAGNET)) { + if (!magnetLink.startsWith(URI_QUERY_DELIMITER)) { + magnetLink = URI_QUERY_DELIMITER + magnetLink; + } + magnetLink = MAGNET + magnetLink; + } + return magnetLink; + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLTextBoxTooltip() + */ + protected String getURLTextBoxTooltip() + { + return Strings.INSTANCE.linkURLToMagnetTextBoxTooltip(); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLErrorMessage() + */ + protected String getURLErrorMessage() + { + return Strings.INSTANCE.linkMagnetError(); + } + + /** + * {@inheritDoc} + * + * @see AbstractExternalLinkWizardStep#getURLLabel() + */ + protected String getURLLabel() + { + return Strings.INSTANCE.linkMagnetLabel(); + } + + /** + * {@inheritDoc} + */ + @Override + protected String getURLHelpLabel() + { + return Strings.INSTANCE.linkMagnetHelpLabel(); + } + + /** + * {@inheritDoc} + */ + public String getStepTitle() + { + return Strings.INSTANCE.linkToMagnet(); + } +} diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/Strings.java xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/Strings.java --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/java/org/xwiki/gwt/wysiwyg/client/Strings.java 2010-06-13 09:00:16.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/java/org/xwiki/gwt/wysiwyg/client/Strings.java 2010-08-02 08:31:13.953125000 +0700 @@ -194,6 +194,8 @@ String linkCreateLinkButton(); + String linkToMagnet(); + String linkToEmail(); String linkToWebPage(); @@ -216,10 +218,16 @@ String linkEmailLabel(); + String linkMagnetLabel(); + String linkEmailHelpLabel(); + String linkMagnetHelpLabel(); + String linkEmailAddressError(); + String linkMagnetError(); + String linkWebPageAddressError(); String linkNoLabelError(); @@ -230,6 +238,8 @@ String linkURLToEmailAddressTextBoxTooltip(); + String linkURLToMagnetTextBoxTooltip(); + String linkURLToWebPageTextBoxTooltip(); String linkWikipageSearchTooltip(); diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/resources/org/xwiki/gwt/wysiwyg/client/Strings.properties xwiki-gwt-wysiwyg-client/src/main/resources/org/xwiki/gwt/wysiwyg/client/Strings.properties --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/resources/org/xwiki/gwt/wysiwyg/client/Strings.properties 2010-06-13 09:00:17.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/resources/org/xwiki/gwt/wysiwyg/client/Strings.properties 2010-08-01 21:46:12.359375000 +0700 @@ -64,6 +64,7 @@ unlink=Remove Link linkCreateLinkButton=Create Link linkToEmail=Email Address... +linkToMagnet=Magnet Link... linkToWebPage=Web Page... linkToWikiPage=Wiki Page... linkToAttachment=Attached File... @@ -77,6 +78,9 @@ linkEmailHelpLabel=Type the email address you want to link to, e.g. 'example@domain.com'. linkEmailAddressError=The email address was not set linkWebPageAddressError=The web page address was not set +linkMagnetLabel=Magnet link +linkMagnetHelpLabel=Paste the magnet link here. Magnet links are usually being copied from p2p applications, e.g. GreyLink. +linkMagnetError=The magnet link was not entered linkNoLabelError=The label of the link cannot be empty linkSelectWikipageTitle=Select the page to link to linkSelectWikipageHelpLabel=Select a page to link to from the list below, by clicking it, and then advance to the next step, or double click an item to automatically select it and advance to the next step. @@ -100,6 +104,7 @@ linkConfigLabelTextBoxTooltip=Type the label of the created link. linkConfigTooltipTextBoxTooltip=Type the tooltip of the created link, which appears when mouse is over the link. linkURLToEmailAddressTextBoxTooltip=Email address +linkURLToMagnetTextBoxTooltip=Magnet link linkURLToWebPageTextBoxTooltip=Web page address linkWikipageSearchTooltip=Type a keyword to search for a wiki page diff -Nru xwiki-gwt-wysiwyg-client.before-magnet/src/main/resources/org/xwiki/gwt/wysiwyg/client/Strings_ru.properties xwiki-gwt-wysiwyg-client/src/main/resources/org/xwiki/gwt/wysiwyg/client/Strings_ru.properties --- xwiki-gwt-wysiwyg-client.before-magnet/src/main/resources/org/xwiki/gwt/wysiwyg/client/Strings_ru.properties 2010-06-13 09:00:17.000000000 +0700 +++ xwiki-gwt-wysiwyg-client/src/main/resources/org/xwiki/gwt/wysiwyg/client/Strings_ru.properties 2010-08-02 09:05:25.359375000 +0700 @@ -99,6 +99,9 @@ linkEmailAddressError=E-mail \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D linkEmailHelpLabel=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 e-mail, \u043D\u0430 \u043A\u043E\u0442\u043E\u0440\u044B\u0439 \u0441\u0434\u0435\u043B\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443. \u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, 'example@domain.com'. linkEmailLabel=E-mail +linkMagnetError=\u041C\u0430\u0433\u043D\u0438\u0442\u043D\u0430\u044F \u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 +linkMagnetHelpLabel=\u0412\u0441\u0442\u0430\u0432\u044C\u0442\u0435 \u043C\u0430\u0433\u043D\u0438\u0442\u043D\u0443\u044E \u0441\u0441\u044B\u043B\u043A\u0443. \u041C\u0430\u0433\u043D\u0438\u0442\u043D\u044B\u0435 \u0441\u0441\u044B\u043B\u043A\u0438 \u043E\u0431\u044B\u0447\u043D\u043E \u043A\u043E\u043F\u0438\u0440\u0443\u044E\u0442\u0441\u044F \u0438\u0437 p2p \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0439, \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, GreyLink. +linkMagnetLabel=\u041C\u0430\u0433\u043D\u0438\u0442\u043D\u0430\u044F \u0441\u0441\u044B\u043B\u043A\u0430 linkErrorLoadingData=\u041E\u0448\u0438\u0431\u043A\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0438 \u0434\u0430\u043D\u043D\u044B\u0445 linkLabelLabel=\u0422\u0435\u043A\u0441\u0442 \u043F\u043E\u0434 \u0441\u0441\u044B\u043B\u043A\u043E\u0439 linkNewPageError=\u0418\u043C\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B \u043D\u0435 \u0437\u0430\u0434\u0430\u043D\u043E @@ -116,10 +119,12 @@ linkSelectWikipageTitle=\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443, \u043D\u0430 \u043A\u043E\u0442\u043E\u0440\u0443\u044E \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u043F\u043E\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443 linkToAttachment=\u0412\u043B\u043E\u0436\u0435\u043D\u043D\u044B\u0439 \u0444\u0430\u0439\u043B... linkToEmail=E-mail... +linkToMagnet=\u041C\u0430\u0433\u043D\u0438\u0442\u043D\u0430\u044F \u0441\u0441\u044B\u043B\u043A\u0430... linkToWebPage=\u0412\u0435\u0431-\u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430... linkToWikiPage=Wiki \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430... linkTooltipLabel=\u0412\u0441\u043F\u043B\u044B\u0432\u0430\u044E\u0449\u0430\u044F \u043F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0430 linkURLToEmailAddressTextBoxTooltip=E-mail +linkURLToMagnetTextBoxTooltip=\u041C\u0430\u0433\u043D\u0438\u0442\u043D\u0430\u044F \u0441\u0441\u044B\u043B\u043A\u0430 linkURLToWebPageTextBoxTooltip=\u0410\u0434\u0440\u0435\u0441 \u0412\u0435\u0431-\u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B linkWebPageAddressError=\u0412\u0435\u0431-\u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 linkWebPageHelpLabel=\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0430\u0434\u0440\u0435\u0441 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B, \u043D\u0430 \u043A\u043E\u0442\u043E\u0440\u0443\u044E \u043D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u043E \u043F\u043E\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443. \u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, 'http\://www.example.com' \u0438\u043B\u0438 'www.example.com'.