Author: scabanovich
Date: 2009-09-18 11:06:17 -0400 (Fri, 18 Sep 2009)
New Revision: 17665
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposal.java
Removed:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommandRunner.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileDropCommand.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileTagProposalLoader.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/JSPTagProposalFactory.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/PaletteDropCommand.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/TagProposal.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommand.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropWizardModel.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultElementGenerator.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropCommandFactory.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropWizard.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ExternalDropWizardModel.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/IDropWizardModel.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposalLoader.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/NullProposalLoader.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/TagAttributesWizardPage.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagProposalsComposite.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Initial moving jsp related dnd to jst.jsp
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml 2009-09-18 15:03:45
UTC (rev 17664)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/plugin.xml 2009-09-18 15:06:17
UTC (rev 17665)
@@ -375,8 +375,6 @@
class="org.jboss.tools.common.model.ui.dnd.ModelTransfer"/>
<xclass id="org.jboss.tools.common.model.ui.editor.EditorPartWrapper"
class="org.jboss.tools.common.model.ui.editor.EditorPartWrapper"/>
- <xclass
id="org.jboss.tools.common.model.ui.editors.dnd.DefaultDropCommandRunner"
- class="org.jboss.tools.common.model.ui.editors.dnd.DefaultDropCommandRunner"/>
<xclass
id="org.jboss.tools.common.model.ui.editors.dnd.DropWizardMessages"
class="org.jboss.tools.common.model.ui.editors.dnd.DropWizardMessages"/>
<xclass id="org.jboss.tools.common.model.ui.forms.AnyElementForm"
@@ -452,6 +450,11 @@
<xclass id="org.jboss.tools.common.model.ui.wizard.newfile.WizardInvoker"
class="org.jboss.tools.common.model.ui.wizard.newfile.WizardInvoker"/>
+ <xclass
id="org.jboss.tools.common.model.ui.editors.dnd.UnknownDropCommand"
+ class="org.jboss.tools.common.model.ui.editors.dnd.UnknownDropCommand"/>
+ <xclass
id="org.jboss.tools.common.model.ui.editors.dnd.PlainTextDropCommand"
+ class="org.jboss.tools.common.model.ui.editors.dnd.PlainTextDropCommand"/>
+
</extension>
<extension
point="org.eclipse.ui.activities">
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommand.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommand.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommand.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -64,7 +64,7 @@
if(getDefaultModel().getDropData()==null) {
throw new IllegalStateException("Wizard model isn't intialized, call
setDropDataFirst"); //$NON-NLS-1$
}
- TagProposal[] proposals
+ ITagProposal[] proposals
= TagProposalsComposite.getTagProposals(
getDefaultModel().getDropData().getMimeType(),
getDefaultModel().getDropData().getMimeData(),
Deleted:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommandRunner.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommandRunner.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropCommandRunner.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.editors.dnd;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Properties;
-
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.jboss.tools.common.meta.action.SpecialWizard;
-
-public class DefaultDropCommandRunner implements SpecialWizard {
- String flavor;
- String data;
- ITextEditor textEditor;
-
- public boolean runDropCommand(final String flavor, final String data, ITextEditor te) {
- final IEditorInput ei = te.getEditorInput();
- final ISelectionProvider sp = te.getSelectionProvider();
- final ISourceViewer sv = getSourceViewer(te);
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
-// if(parentEditor.getVisualEditor().getController()!=null ) {
- DropCommandFactory.getInstance()
- .getDropCommand(flavor, JSPTagProposalFactory.getInstance())
- .execute(
- new DropData(
- flavor,
- data,
- ei,
- sv,
- sp
- )
- );
-// }
- }
- });
- return true;
- }
-
- ISourceViewer getSourceViewer(ITextEditor editor) {
- if(!(editor instanceof AbstractTextEditor)) return null;
- AbstractTextEditor ae = (AbstractTextEditor)editor;
- try {
- Method m = AbstractTextEditor.class.getDeclaredMethod("getSourceViewer", new
Class[0]); //$NON-NLS-1$
- m.setAccessible(true);
- return (ISourceViewer)m.invoke(ae, new Object[0]);
- } catch (NoSuchMethodException e1) {
- return null;
- } catch (InvocationTargetException e2) {
- return null;
- } catch (IllegalAccessException e2) {
- return null;
- }
- }
-
- public int execute() {
- boolean result = runDropCommand(flavor, data, textEditor);
- return result ? 0 : 1;
- }
-
- public void setObject(Object object) {
- Properties p = (Properties)object;
- flavor = p.getProperty("flavor"); //$NON-NLS-1$
- data = p.getProperty("data"); //$NON-NLS-1$
- textEditor = (ITextEditor)p.get("textEditor"); //$NON-NLS-1$
- }
-
-}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropWizardModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropWizardModel.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultDropWizardModel.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -20,7 +20,7 @@
public class DefaultDropWizardModel implements IDropWizardModel {
- TagProposal fSelectedTagProp = UNDEFINED_TAG_PROPOSAL;
+ ITagProposal fSelectedTagProp = UNDEFINED_TAG_PROPOSAL;
DropData fDropData;
List<AttributeDescriptorValue> fAttributeValues = new
ArrayList<AttributeDescriptorValue>();
boolean promptForTagAttributes = true;
@@ -31,15 +31,15 @@
this.tagProposalFactory = tagProposalFactory;
}
- public TagProposal getTagProposal() {
+ public ITagProposal getTagProposal() {
return fSelectedTagProp;
}
/**
* @see
org.jboss.tools.vpe.editor.dnd.IDnDWizardDataModel#setTagProposal(org.jboss.tools.vpe.editor.dnd.TagProposal)
*/
- public void setTagProposal(TagProposal selection) {
- TagProposal oldValue = fSelectedTagProp;
+ public void setTagProposal(ITagProposal selection) {
+ ITagProposal oldValue = fSelectedTagProp;
fSelectedTagProp = selection;
doLoadTagAttributeDescriptors();
doLoadDefaultAttributeValues();
@@ -174,9 +174,10 @@
return true;
}
}
+ if(values.length > 5) return true;
return isPromptForTagAttributesRequired();
} else if(getTagProposal()==UNDEFINED_TAG_PROPOSAL){
- TagProposal[] proposals
+ ITagProposal[] proposals
= TagProposalsComposite.getTagProposals(
getDropData().getMimeType(),
getDropData().getMimeData(),
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultElementGenerator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultElementGenerator.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DefaultElementGenerator.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -34,7 +34,7 @@
}
public String generateStartTag() {
- TagProposal proposal = getWizardDataModel().getTagProposal();
+ ITagProposal proposal = getWizardDataModel().getTagProposal();
AttributeDescriptorValueProvider valueProvider =
getWizardDataModel().getDropData().getValueProvider();
if(valueProvider != null) valueProvider.setProposal(proposal);
String tagName = valueProvider == null ? null : valueProvider.getTag();
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropCommandFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropCommandFactory.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropCommandFactory.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -13,6 +13,7 @@
import java.util.HashMap;
import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
+import org.jboss.tools.common.model.util.ModelFeatureFactory;
/**
* The Class DropCommandFactory.
@@ -49,30 +50,35 @@
/** The PACKAGE. */
static String PACKAGE = "org.jboss.tools.common.model.ui.editors.dnd.";
//$NON-NLS-1$
+
+ static String UNKNOWN_DROP_COMMAND =
"org.jboss.tools.common.model.ui.editors.dnd.UnknownDropCommand"; //$NON-NLS-1$
+ static String TEXT_DROP_COMMAND =
"org.jboss.tools.common.model.ui.editors.dnd.PlainTextDropCommand";
//$NON-NLS-1$
+ static String FILE_DROP_COMMAND =
"org.jboss.tools.jst.jsp.jspeditor.dnd.FileDropCommand"; //$NON-NLS-1$
+ static String PALETTE_DROP_COMMAND =
"org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteDropCommand"; //$NON-NLS-1$
static {
fMimeCommandMap.put(
////nsITransferable.kFileMime
- kFileMime, PACKAGE + "FileDropCommand" //$NON-NLS-1$
+ kFileMime, FILE_DROP_COMMAND
);
fMimeCommandMap.put(
////nsITransferable.kURLMime
- kURLMime, PACKAGE + "FileDropCommand" //$NON-NLS-1$
+ kURLMime, FILE_DROP_COMMAND
);
fMimeCommandMap.put(
- ModelTransfer.MODEL, PACKAGE + "PaletteDropCommand" //$NON-NLS-1$
+ ModelTransfer.MODEL, PALETTE_DROP_COMMAND
);
fMimeCommandMap.put(
- "text/plain", PACKAGE + "PlainTextDropCommand" //$NON-NLS-1$
//$NON-NLS-2$
+ "text/plain", TEXT_DROP_COMMAND
);
fMimeCommandMap.put(
////nsITransferable.kUnicodeMime
- kUnicodeMime, PACKAGE + "PlainTextDropCommand" //$NON-NLS-1$
+ kUnicodeMime, TEXT_DROP_COMMAND
);
- fMimeCommandMap.put(kHtmlText,PACKAGE + "PlainTextDropCommand");
//$NON-NLS-1$
+ fMimeCommandMap.put(kHtmlText, TEXT_DROP_COMMAND);
fMimeCommandMap.put(
- UNKNOWN_MIME_TYPE, PACKAGE + "UnknownDropCommand" //$NON-NLS-1$
+ UNKNOWN_MIME_TYPE, UNKNOWN_DROP_COMMAND
);
}
@@ -95,17 +101,13 @@
*/
public IDropCommand getDropCommand(String mimeType, ITagProposalFactory
tagProposalFactory) {
IDropCommand fInstance = UNKNOWN_MIME_COMMAND;
- try {
- String fClassName = (String)fMimeCommandMap.get(mimeType);
- Class newClass = this.getClass().getClassLoader().loadClass(fClassName);
- fInstance = (IDropCommand)newClass.newInstance();
+ String fClassName = (String)fMimeCommandMap.get(mimeType);
+ fInstance =
(IDropCommand)ModelFeatureFactory.getInstance().createFeatureInstance(fClassName);
+ if(fInstance == null) {
+ fInstance = new UnknownDropCommand();
+ }
+ if(fInstance != null) {
fInstance.setTagProposalFactory(tagProposalFactory);
- } catch (ClassNotFoundException e) {
- //ignore
- } catch (InstantiationException e) {
- //ignore
- } catch (IllegalAccessException e) {
- //ignore
}
return fInstance;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropUtils.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -20,17 +20,11 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.common.model.ui.editors.dnd.composite.TagAttributesComposite;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.web.tld.ITaglibMapping;
import org.jboss.tools.jst.web.tld.IWebProject;
import org.jboss.tools.jst.web.tld.WebProjectFactory;
@@ -43,37 +37,9 @@
public static final String HTML40_URI = ""; //$NON-NLS-1$
- /**
- * Get TLD's content.
- * @param input
- * @param uri
- * @return
- */
- public static String getTldContent(IEditorInput input, String uri) {
- String tldContent = null;
- XModel xModel = null;
- if(input instanceof IModelObjectEditorInput) {
- xModel = ((IModelObjectEditorInput)input).getXModelObject().getModel();
- } else if(input instanceof IFileEditorInput) {
- IFile f = ((IFileEditorInput)input).getFile();
- XModelObject o = EclipseResourceUtil.getObjectByResource(f);
- if(o != null) xModel = o.getModel();
- }
- if(xModel != null) {
- ITaglibMapping mapping =
WebProjectFactory.instance.getWebProject(xModel).getTaglibMapping();
- XModelObject xmo = mapping.getTaglibObject(uri);
- if(xmo != null) {
-// tldLocation = EclipseResourceUtil.getResource(xmo).getFullPath().toString();
- FileAnyImpl fai = (FileAnyImpl)xmo;
- tldContent = fai.getAsText();
- }
- }
- return tldContent;
- }
-
public static interface AttributeDescriptorValueProvider {
public void initContext(Properties context);
- public void setProposal(TagProposal proposal);
+ public void setProposal(ITagProposal proposal);
public String getTag();
public boolean canHaveBody();
public TagAttributesComposite.AttributeDescriptorValue[] getValues();
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropWizard.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropWizard.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -46,7 +46,7 @@
super.addPages();
page1 = new TagProposalsWizardPage();
page2 = new TagAttributesWizardPage();
- TagProposal[] proposals =
+ ITagProposal[] proposals =
TagProposalsComposite.getTagProposals(getMimeType(),getMimeData(),
fDropCommand.getTagProposalFactory());
if(TagProposalsComposite.areThereTagProposals(
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ExternalDropWizardModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ExternalDropWizardModel.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ExternalDropWizardModel.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -41,7 +41,7 @@
protected void doLoadTagAttributeDescriptors() {
if(getTagProposal()!=UNDEFINED_TAG_PROPOSAL) {
DropData data = getDropData();
- TagProposal proposal = getTagProposal();
+ ITagProposal proposal = getTagProposal();
AttributeDescriptorValueProvider valueProvider = data.getValueProvider();
if(valueProvider != null) valueProvider.setProposal(proposal);
AttributeDescriptorValue[] values = valueProvider == null ? new
AttributeDescriptorValue[0]
Deleted:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileDropCommand.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileDropCommand.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileDropCommand.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.editors.dnd;
-
-import java.io.File;
-import java.util.Properties;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.jboss.tools.common.meta.action.XActionInvoker;
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.model.ui.dnd.ModelTransfer;
-import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
-
-/**
- *
- * @author eskimo
- */
-
-// TODO - Eskimo - Think about inserting different type of tags
-// - HTML
-// - XML(XHTML,JSP)
-
-public class FileDropCommand extends DefaultDropCommand {
-
- IElementGenerator generator;
-
- public void run(IProgressMonitor monitor) throws CoreException {
-
- generator =
ElementGeneratorFactory.getInstance().getElementGenerator(getDefaultModel().getTagProposal().getUri());
- generator.setDataModel(getDefaultModel());
-
- Properties properties = new Properties();
- properties.put(PaletteInsertHelper.PROPOPERTY_TAG_NAME,getDefaultModel().getTagProposal().getName());
- properties.put(PaletteInsertHelper.PROPOPERTY_START_TEXT, generateStartText());
- properties.put(PaletteInsertHelper.PROPOPERTY_END_TEXT, generateEndText());
- properties.put(PaletteInsertHelper.PROPOPERTY_REFORMAT_BODY,
getReformatBodyProperty());
- properties.put(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_URI,getDefaultModel().getTagProposal().getUri());
- properties.put(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_VERSION,getDefaultModel().getTagProposal().getLibraryVersion());
- properties.put(PaletteInsertHelper.PROPOPERTY_DEFAULT_PREFIX,getDefaultModel().getTagProposal().getPrefix());
- properties.put(PaletteInsertHelper.PROPOPERTY_SELECTION_PROVIDER,
getDefaultModel().getDropData().getSelectionProvider());
- properties.put(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, "true");
//$NON-NLS-1$
- addCustomProperties(properties);
- PaletteInsertHelper.insertIntoEditor(
- getDefaultModel().getDropData().getSourceViewer(),
- properties
- );
- }
-
- protected void executeUnknownTag() {
- DropData data = getDefaultModel().getDropData();
- String type = data.getMimeType();
- String mime = data.getMimeData();
- /*nsITransferable.kFileMime*/
- if("application/x-moz-file".equals(type) && mime != null) {
//$NON-NLS-1$
- if(mime.startsWith("file:")) mime = mime.substring(5); //$NON-NLS-1$
- File f = new File(mime);
- IFile file = EclipseResourceUtil.getFile(f.getAbsolutePath());
- if(file == null) return;
- XModelObject o = EclipseResourceUtil.getObjectByResource(file);
- if(o == null) return;
- XActionInvoker.invoke("CopyActions.Copy", o, null); //$NON-NLS-1$
- data.setMimeType(ModelTransfer.MODEL);
- data.setMimeData(""); //$NON-NLS-1$
- DropCommandFactory.getInstance().getDropCommand(ModelTransfer.MODEL,
tagProposalFactory).execute(data);
- }
- }
-
- protected void addCustomProperties(Properties properties) {}
-
- protected String getReformatBodyProperty() {
- return "yes"; //$NON-NLS-1$
- }
-
- protected IDropWizardModel createSpecificModel() {
- return new ExternalDropWizardModel(tagProposalFactory);
- }
-
- protected String generateStartText() {
- return generator.generateStartTag();
- }
-
- protected String generateEndText() {
- return generator.generateEndTag();
- }
-}
\ No newline at end of file
Deleted:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileTagProposalLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileTagProposalLoader.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/FileTagProposalLoader.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.editors.dnd;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.tools.common.model.ui.views.palette.PaletteTaglibInserter;
-
-public class FileTagProposalLoader implements ITagProposalLoader {
-
- private static final Map<String,TagProposal[]> extensionMap = new
HashMap<String,TagProposal[]>();
-
- static TagProposal[] IMG_TAG_PROPOSALS = new TagProposal[]{
- new TagProposal(
- DropURI.JSF_HTML_URI,
- "h", //$NON-NLS-1$
- "graphicImage", //$NON-NLS-1$
- new AbsoluteFilePathAttributeValueLoader("value","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ),
- new TagProposal(
- DropURI.HTML_4_0_URI,
- TagProposal.EMPTY_PREFIX,
- "img", //$NON-NLS-1$
- new AbsoluteFilePathAttributeValueLoader("src","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ),
- new TagProposal(
- DropURI.STRUTS_HTML_URI,
- "html", //$NON-NLS-1$
- "img", //$NON-NLS-1$
- new AbsoluteFilePathAttributeValueLoader("page","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ),
- new TagProposal(
- DropURI.SEAM_URI,
- "s", //$NON-NLS-1$
- "graphicImage", //$NON-NLS-1$
- new AbsoluteFilePathAttributeValueLoader("url","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- )
-// yradtsevich: fix of JBIDE-3984: Exclude t:graphicImage option from Insert tag dialog
-// ,
-// new TagProposal(
-// DropURI.TOMOHAWK_URI,
-// "t",
-// "graphicImage",
-// new AbsoluteFilePathAttributeValueLoader("url","","")
-// )
- };
-
- static TagProposal[] CSS_TAG_PROPOSALS = new TagProposal[]{
- new TagProposal(
- DropURI.HTML_4_0_URI,
- TagProposal.EMPTY_PREFIX,
- "link", //$NON-NLS-1$
- new CssLinkAttributeValueLoader("href") //$NON-NLS-1$
- ),
- };
-
- static TagProposal JSP_INCLUDE = new TagProposal(
- DropURI.JSP_URI,
- "jsp", //$NON-NLS-1$
- "include", //$NON-NLS-1$
- new
AbsoluteFilePathAttributeValueLoader("page","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- );
-
- static TagProposal JSP_FORWARD = new TagProposal(
- DropURI.JSP_URI,
- "jsp", //$NON-NLS-1$
- "forward", //$NON-NLS-1$
- new AbsoluteFilePathAttributeValueLoader("page","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- );
-
- static TagProposal UI_INCLUDE = new TagProposal(
- PaletteTaglibInserter.faceletUri,
- "ui", //$NON-NLS-1$
- "include", //$NON-NLS-1$
- new
AbsoluteFilePathAttributeValueLoader("src","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- );
-
- static TagProposal S_DECORATE = new TagProposal(
- DropURI.SEAM_URI,
- "s", //$NON-NLS-1$
- "decorate", //$NON-NLS-1$
- new
AbsoluteFilePathAttributeValueLoader("template","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- );
-
- static TagProposal[] PAGE_TAG_PROPOSALS = new TagProposal[]{
- JSP_INCLUDE,
- JSP_FORWARD
- };
-
- static TagProposal[] XHTML_PAGE_TAG_PROPOSALS = new TagProposal[]{
- JSP_INCLUDE,
- JSP_FORWARD,
- UI_INCLUDE,
- S_DECORATE
- };
-
- static {
- // There is the question here what store HTML or TLD will been asked about
TagDescription
- extensionMap.put("jpg", IMG_TAG_PROPOSALS); //$NON-NLS-1$
-
- extensionMap.put("jpeg", IMG_TAG_PROPOSALS); //$NON-NLS-1$
-
- extensionMap.put("gif",IMG_TAG_PROPOSALS); //$NON-NLS-1$
-
- extensionMap.put("bmp",IMG_TAG_PROPOSALS); //$NON-NLS-1$
-
- extensionMap.put("png",IMG_TAG_PROPOSALS); //$NON-NLS-1$
-
- extensionMap.put("jsp",PAGE_TAG_PROPOSALS); //$NON-NLS-1$
- extensionMap.put("html",PAGE_TAG_PROPOSALS); //$NON-NLS-1$
- extensionMap.put("xhtml",XHTML_PAGE_TAG_PROPOSALS); //$NON-NLS-1$
-
- extensionMap.put(
- "properties",new TagProposal[]{ //$NON-NLS-1$
- new TagProposal(
- DropURI.JSF_CORE_URI,
- "f", //$NON-NLS-1$
- "loadBundle", //$NON-NLS-1$
- new LoadBundleBaseNameAttributeValueLoader()
- )
- }
- );
- extensionMap.put("css",CSS_TAG_PROPOSALS); //$NON-NLS-1$
- extensionMap.put(
- "inc", new TagProposal[]{ //$NON-NLS-1$
- new TagProposal(
- DropURI.JSP_URI,
- "jsp", //$NON-NLS-1$
- "include", //$NON-NLS-1$
- new
AbsoluteFilePathAttributeValueLoader("page","","")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- )
- }
- );
-
- }
-
- public static boolean isExtensionMapped(String extension) {
- return extension != null && extensionMap.containsKey(extension.toLowerCase());
- }
-
- public TagProposal[] getTagProposals(Object data) {
- String fileName = data.toString();
- String extension = fileName.substring(fileName.lastIndexOf(".")+1);
//$NON-NLS-1$
- TagProposal[] tagProposals = (TagProposal[])extensionMap.get(extension.toLowerCase());
- if(tagProposals==null) {
- tagProposals = new TagProposal[0];
- }
- return tagProposals;
- }
-
- public boolean isTagProposalExists(Object data) {
- return true;
- }
-
- public static class ImageFileAttributesValuesLoader implements IAttributeValueLoader {
-
- public void fillTagAttributes(IDropWizardModel model) {
- }
-
- }
-
- public static class JspFileAttributesValuesLoader implements IAttributeValueLoader {
-
- public void fillTagAttributes(IDropWizardModel model) {
- }
- }
-}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/IDropWizardModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/IDropWizardModel.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/IDropWizardModel.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -25,16 +25,35 @@
public static final String TAG_PROPOSAL = "tagProposal"; //$NON-NLS-1$
public static final String ATTRIBUTE_VALUE = "attributeValue"; //$NON-NLS-1$
-
- public static final TagProposal UNDEFINED_TAG_PROPOSAL = new
TagProposal("http://www.redhat.com/undefined","",&quo...;
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ public static final ITagProposal UNDEFINED_TAG_PROPOSAL = new ITagProposal() {
+ public IAttributeValueLoader getAttributesValueLoader() {
+ return EMPTY_ATTRIBUTE_VALUE_LOADER;
+ }
+ public String getDetails() {
+ return "http://www.redhat.com/undefined";
+ }
+ public String getDisplayString() {
+ return EMPTY_PREFIX;
+ }
+
+ public String getName() {
+ return EMPTY_PREFIX;
+ }
+
+ public String getPrefix() {
+ return EMPTY_PREFIX;
+ }
+
+ };
+
/*
* Methods
*/
- public TagProposal getTagProposal();
+ public ITagProposal getTagProposal();
- public void setTagProposal(TagProposal selection);
+ public void setTagProposal(ITagProposal selection);
public void setAttributeValue(AttributeDescriptorValue name, Object value);
Added:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposal.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposal.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposal.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -0,0 +1,21 @@
+package org.jboss.tools.common.model.ui.editors.dnd;
+
+public interface ITagProposal {
+ public static final IAttributeValueLoader EMPTY_ATTRIBUTE_VALUE_LOADER = new
IAttributeValueLoader() {
+ public void fillTagAttributes(IDropWizardModel model) {
+ // do nothing
+ }
+ };
+ public static String EMPTY_PREFIX = "";
+
+ public String getName();
+
+ public String getPrefix();
+
+ public IAttributeValueLoader getAttributesValueLoader();
+
+ public String getDisplayString();
+
+ public String getDetails();
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposal.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposalLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposalLoader.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/ITagProposalLoader.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -11,6 +11,6 @@
package org.jboss.tools.common.model.ui.editors.dnd;
public interface ITagProposalLoader {
- public TagProposal[] getTagProposals(Object data);
+ public ITagProposal[] getTagProposals(Object data);
public boolean isTagProposalExists(Object data);
}
Deleted:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/JSPTagProposalFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/JSPTagProposalFactory.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/JSPTagProposalFactory.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.editors.dnd;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-
-public class JSPTagProposalFactory implements ITagProposalFactory {
- private static final JSPTagProposalFactory INSTANCE = new JSPTagProposalFactory();
- public static Map<String,String> loaderMap = new HashMap<String,String>();
-
- static {
- loaderMap.put(DropCommandFactory.kFileMime, DropCommandFactory.PACKAGE +
"FileTagProposalLoader"); //$NON-NLS-1$
- loaderMap.put(DropCommandFactory.kURLMime, DropCommandFactory.PACKAGE +
"FileTagProposalLoader"); //$NON-NLS-1$
- }
-
- public static JSPTagProposalFactory getInstance() {
- return INSTANCE;
- }
-
- private JSPTagProposalFactory() {
- }
-
- public ITagProposalLoader getProposalLoader(String mimeType) {
- ITagProposalLoader fInstance = DEFAULT_PROPOSAL_LOADER;
- try {
- String fClassName = (String)loaderMap.get(mimeType);
- if(fClassName == null) {
- //No need to report, just there is no specific proposal loader for this myme type.
- return fInstance;
- }
- Class newClass = this.getClass().getClassLoader().loadClass(fClassName);
- fInstance = (ITagProposalLoader)newClass.newInstance();
- } catch (InstantiationException e) {
- ModelUIPlugin.getPluginLog().logError(e);
- } catch (IllegalAccessException e) {
- ModelUIPlugin.getPluginLog().logError(e);
- } catch (ClassNotFoundException e) {
- ModelUIPlugin.getPluginLog().logError(e);
- }
- return fInstance;
- }
-}
-
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/NullProposalLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/NullProposalLoader.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/NullProposalLoader.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -12,8 +12,8 @@
public class NullProposalLoader implements ITagProposalLoader {
- public TagProposal[] getTagProposals(Object data) {
- return new TagProposal[0];
+ public ITagProposal[] getTagProposals(Object data) {
+ return new ITagProposal[0];
}
public boolean isTagProposalExists(Object data) {
Deleted:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/PaletteDropCommand.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/PaletteDropCommand.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/PaletteDropCommand.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.editors.dnd;
-
-import java.util.Properties;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.xml.core.internal.document.ElementImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.options.PreferenceModelUtilities;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.model.ui.dnd.DnDUtil;
-import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
-import
org.jboss.tools.common.model.ui.editors.dnd.composite.TagAttributesComposite.AttributeDescriptorValue;
-import org.jboss.tools.common.model.ui.views.palette.PaletteInsertHelper;
-import org.jboss.tools.common.model.ui.views.palette.PaletteInsertManager;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jst.web.tld.IWebProject;
-import org.jboss.tools.jst.web.tld.TLDToPaletteHelper;
-import org.jboss.tools.jst.web.tld.URIConstants;
-import org.jboss.tools.jst.web.tld.WebProjectFactory;
-
-/**
- *
- * @author eskimo
- */
-public class PaletteDropCommand extends FileDropCommand {
- Properties initialValues = new Properties();
- String startText;
- String endText;
- String newLine;
- String reformat = "no"; //$NON-NLS-1$
-
- Properties properties = new Properties();
- boolean callPaletteWizard = false;
-
- /**
- *
- */
- protected IDropWizardModel createSpecificModel() {
- return new PaletteDropWizardModel(tagProposalFactory);
- }
-
- protected void addCustomProperties(Properties runningProperties) {
- newLine = properties.getProperty(PaletteInsertHelper.PROPOPERTY_NEW_LINE);
- if (newLine == null) newLine="true"; //$NON-NLS-1$
- runningProperties.setProperty(PaletteInsertHelper.PROPOPERTY_NEW_LINE, newLine);
- String addTaglib = properties.getProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB);
- if(addTaglib == null) addTaglib = "true"; //$NON-NLS-1$
- runningProperties.setProperty(PaletteInsertHelper.PROPOPERTY_ADD_TAGLIB, addTaglib);
- }
-
- public void execute() {
- if(getDefaultModel().getTagProposal() == IDropWizardModel.UNDEFINED_TAG_PROPOSAL) {
- if(startText == null && endText == null) return;
- int pos =
((ITextSelection)getDefaultModel().getDropData().getSelectionProvider().getSelection()).getOffset();
- getDefaultModel().getDropData().getSourceViewer().setSelectedRange(pos, 0);
- if(startText != null)
properties.setProperty(PaletteInsertHelper.PROPOPERTY_START_TEXT, startText);
- if(endText != null) properties.setProperty(PaletteInsertHelper.PROPOPERTY_END_TEXT,
endText);
- if(reformat != null)
properties.setProperty(PaletteInsertHelper.PROPOPERTY_REFORMAT_BODY, reformat);
- if(newLine != null) properties.setProperty(PaletteInsertHelper.PROPOPERTY_NEW_LINE,
newLine);
- PaletteInsertHelper.insertIntoEditor(
- getDefaultModel().getDropData().getSourceViewer(),
- properties
- );
- } else {
- DropData data = getDefaultModel().getDropData();
- ISourceViewer viewer = data.getSourceViewer();
- if(data.getContainer() != null){
- if (data.getContainer() instanceof ElementImpl) {
- ElementImpl container = (ElementImpl)data.getContainer();
- if(!container.hasEndTag()){
- try{
- IDocument document = viewer.getDocument();
- int containerOffset = container.getStartOffset();
- int containerLenght = container.getStartEndOffset()-containerOffset;
- String containerString = document.get(containerOffset, containerLenght);
- int slashPosition = containerString.lastIndexOf("/"); //$NON-NLS-1$
- if(slashPosition >= 0){
- int deltaOffset = (containerString.length()-1)-slashPosition;
- String text = ""; //$NON-NLS-1$
- for(int i=0; i < deltaOffset;i++) text += " "; //$NON-NLS-1$
- text += "></"+container.getNodeName()+">";
//$NON-NLS-1$ //$NON-NLS-2$
- document.replace(containerOffset+slashPosition,
containerString.length()-slashPosition, text);
- }
- }catch(BadLocationException ex){
- ModelUIPlugin.getPluginLog().logError(ex);
- }
- }
- }
- }
- super.execute();
- }
- }
-
- public void initialize() {
- DropData data = getDefaultModel().getDropData();
-
- IEditorInput input = data.getEditorInput();
- XModelObject target = null;
- IFile f = null;
- if(input instanceof IFileEditorInput) {
- f = ((IFileEditorInput)input).getFile();
- target = EclipseResourceUtil.getObjectByResource(f);
- if(target == null && f.exists()) {
- target = EclipseResourceUtil.createObjectForResource(f);
- }
- } else if(input instanceof IModelObjectEditorInput) {
- target = ((IModelObjectEditorInput)input).getXModelObject();
- }
- if(target == null) {
- initialize2();
- } else {
- ISourceViewer viewer = data.getSourceViewer();
-
- properties = new Properties();
- properties.put("viewer", viewer); //$NON-NLS-1$
- properties.setProperty("text", viewer.getDocument().get()); //$NON-NLS-1$
- properties.setProperty("isDrop", "true"); //$NON-NLS-1$
//$NON-NLS-2$
- properties.setProperty("actionSourceGUIComponentID", "editor");
//$NON-NLS-1$ //$NON-NLS-2$
- properties.setProperty("accepsAsString", "true"); //$NON-NLS-1$
//$NON-NLS-2$
-
- if(f != null) {
- properties.put("file", f); //$NON-NLS-1$
- }
- ISelection selection = data.getSelectionProvider().getSelection();
-
- int offset = 0;
- //int length = 0;
- if(selection instanceof ITextSelection) {
- offset = ((ITextSelection)selection).getOffset();
- //length = ((ITextSelection)selection).getLength();
- } else {
- offset = viewer.getTextWidget().getCaretOffset();
- }
- properties.setProperty("pos", "" + offset); //$NON-NLS-1$
//$NON-NLS-2$
- if(selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Object so = ((IStructuredSelection)selection).getFirstElement();
- if(so instanceof IDOMElement) {
- String en = ((IDOMElement)so).getNodeName();
- properties.setProperty("context:tagName", en); //$NON-NLS-1$
- String attrName = data.getAttributeName();
- if(attrName != null) {
- properties.setProperty("context:attrName", attrName); //$NON-NLS-1$
- }
- }
- }
- try {
- if(DnDUtil.isPasteEnabled(target)) {
- DnDUtil.paste(target, properties);
- } else {
- XModelObject s =
PreferenceModelUtilities.getPreferenceModel().getModelBuffer().source();
- if(s != null) {
- properties.setProperty("start text", "" + getDefaultText(s));
//$NON-NLS-1$ //$NON-NLS-2$
- properties.setProperty("end text", ""); //$NON-NLS-1$
//$NON-NLS-2$
- properties.setProperty("new line", "newLine"); //$NON-NLS-1$
//$NON-NLS-2$
- }
- }
- } catch (CoreException e) {
- ModelUIPlugin.getPluginLog().logError(e);
- }
- startText = properties.getProperty(TLDToPaletteHelper.START_TEXT);
- endText = properties.getProperty(TLDToPaletteHelper.END_TEXT);
- reformat = properties.getProperty(TLDToPaletteHelper.REFORMAT);
- String uri = properties.getProperty(URIConstants.LIBRARY_URI);
- String libraryVersion = properties.getProperty(URIConstants.LIBRARY_VERSION);
- String defaultPrefix = properties.getProperty(URIConstants.DEFAULT_PREFIX);
- String tagname = properties.getProperty("tag name"); //$NON-NLS-1$
-
- callPaletteWizard = PaletteInsertManager.getInstance().getWizardName(properties) !=
null;
-
- boolean isWizardEnabled =
(!"FileJAVA".equals(target.getModelEntity().getName())); //$NON-NLS-1$
- if(getDefaultModel() instanceof PaletteDropWizardModel) {
- ((PaletteDropWizardModel)getDefaultModel()).setWizardEnabled(isWizardEnabled);
- }
-
- if(uri == null || tagname == null) {
- getDefaultModel().setTagProposal(IDropWizardModel.UNDEFINED_TAG_PROPOSAL);
- } else {
- getDefaultModel().setTagProposal(new TagProposal(uri, libraryVersion, defaultPrefix,
tagname));
- insertInitialValues();
- }
- }
- }
-
- private void initialize2() {
- XModelObject object =
PreferenceModelUtilities.getPreferenceModel().getModelBuffer().source();
- String tagname = object.getAttributeValue("name"); //$NON-NLS-1$
- XModelObject parent = object.getParent();
- String uri = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_URI); //$NON-NLS-1$
- String libraryVersion = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.LIBRARY_VERSION); //$NON-NLS-1$
- String defaultPrefix = (parent == null) ? "" :
parent.getAttributeValue(URIConstants.DEFAULT_PREFIX); //$NON-NLS-1$
- this.getDefaultModel().setTagProposal(new TagProposal(uri,
libraryVersion,defaultPrefix,tagname));
- startText = object.getAttributeValue("start text"); //$NON-NLS-1$
- endText = object.getAttributeValue("end text"); //$NON-NLS-1$
- }
-
- private void insertInitialValues() {
- parseInitialValues(startText);
- AttributeDescriptorValue[] vs = getDefaultModel().getAttributeValueDescriptors();
- for (int i = 0; i < vs.length; i++) {
- String v = initialValues.getProperty(vs[i].getName());
- if(v != null) vs[i].setValue(v);
- }
- }
-
- private void parseInitialValues(String startText) {
- if(startText == null || startText.length() == 0) return;
- int bi = startText.indexOf('<');
- if(bi < 0) return;
- int ei = startText.indexOf('>', bi);
- if(ei < 0) return;
- String header = startText.substring(bi + 1, ei);
- int NOTHING = 0;
- int ATT_NAME = 1;
- int ATT_VALUE = 2;
- char quote = '\0';
- int state = NOTHING;
- String name = null;
- String value = null;
- for (int i = 0; i < header.length(); i++) {
- char c = header.charAt(i);
- if(state == NOTHING) {
- if(Character.isJavaIdentifierStart(c)) {
- name = "" + c; //$NON-NLS-1$
- state = ATT_NAME;
- }
- } else if(state == ATT_NAME) {
- if(Character.isJavaIdentifierPart(c) || c == ':') {
- name += c;
- } else if(c == '=') {
- state = ATT_VALUE;
- quote = '\0';
- }
- } else if(state == ATT_VALUE) {
- if(c == quote) {
- initialValues.setProperty(name, value);
- name = null;
- value = null;
- state = NOTHING;
- quote = '\0';
- } else if(c == '"' || c == '\'') {
- quote = c;
- value = ""; //$NON-NLS-1$
- } else if(quote != '\0') {
- value += c;
- }
- }
- }
- }
-
- protected String generateStartText() {
- startText = properties.getProperty("start text"); //$NON-NLS-1$
- if(getDefaultModel().getTagProposal()==IDropWizardModel.UNDEFINED_TAG_PROPOSAL
- || getDefaultModel().getTagProposal().getUri().length() == 0) {
- return startText;
- }
- String s1 = super.generateStartText();
- String s2 = startText;
- if(s2 == null) return s1;
- if(s1.indexOf('=') < 0) return s2; // no input
- int bi1 = s1.indexOf('<');
- int bi2 = s2.indexOf('<');
- if(bi2 < 0 || bi1 < 0) return s2;
- int ei1 = s1.indexOf('>', bi1);
- int ei2 = s2.indexOf('>', bi2);
- if(ei1 < 0 || ei2 < 0) return s1;
- boolean slash1 = s1.charAt(ei1 - 1) == '/';
- boolean slash2 = s2.charAt(ei2 - 1) == '/';
- if(slash1 && !slash2) {
- s2 = s2.substring(0, bi2) + s1.substring(bi1, ei1 - 1) + s2.substring(ei2);
- } else if(!slash1 && slash2) {
- s2 = s2.substring(0, bi2) + s1.substring(bi1, ei1) + s2.substring(ei2 - 1);
- } else {
- s2 = s2.substring(0, bi2) + s1.substring(bi1, ei1) + s2.substring(ei2);
- }
- return s2;
- }
-
- protected String generateEndText() {
- endText = properties.getProperty("end text"); //$NON-NLS-1$
- return (endText != null) ? endText : ""; //$NON-NLS-1$
- }
-
- protected String getReformatBodyProperty() {
- return reformat;
- }
-
- protected IDropWizard createDropWizard() {
- String wizardName = PaletteInsertManager.getInstance().getWizardName(properties);
-
- IDropWizard wizard = null;
- if(wizardName != null) {
- wizard =
(IDropWizard)PaletteInsertManager.getInstance().createWizardInstance(properties);
- }
- if(wizard == null) wizard = new DropWizard();
- wizard.setCommand(this);
- return wizard;
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- private String getDefaultText(XModelObject o) {
- if(o == null) return ""; //$NON-NLS-1$
- if(o.getFileType() != XModelObject.FILE) return o.getPresentationString();
- IWebProject p = WebProjectFactory.instance.getWebProject(o.getModel());
- String path = p.getPathInWebRoot(o);
- return path == null ? o.getPresentationString() : path;
- }
-}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/TagAttributesWizardPage.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/TagAttributesWizardPage.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/TagAttributesWizardPage.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -119,10 +119,10 @@
*
*/
protected void updateTitle() {
- TagProposal tagProposal = (TagProposal)getDropWizardModel().getTagProposal();
+ ITagProposal tagProposal = getDropWizardModel().getTagProposal();
StringBuffer titleText = new StringBuffer();
titleText.append("<"); //$NON-NLS-1$
- if(!TagProposal.EMPTY_PREFIX.equals(tagProposal.getPrefix())) {
+ if(!ITagProposal.EMPTY_PREFIX.equals(tagProposal.getPrefix())) {
titleText
.append(tagProposal.getPrefix())
.append(":"); //$NON-NLS-1$
Deleted:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/TagProposal.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/TagProposal.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/TagProposal.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.model.ui.editors.dnd;
-
-public class TagProposal {
-
- public static final String EMPTY_PREFIX = ""; //$NON-NLS-1$
- public static final String EMPTY_URI = ""; //$NON-NLS-1$
-
- public static final IAttributeValueLoader EMPTY_ATTRIBUTE_VALUE_LOADER = new
IAttributeValueLoader() {
- public void fillTagAttributes(IDropWizardModel model) {
- // do nothing
- }
- };
-
- String uri;
- String libraryVersion = ""; //$NON-NLS-1$
- String prefix;
- String name;
- IAttributeValueLoader attributeValueLoader = EMPTY_ATTRIBUTE_VALUE_LOADER;
-
- /**
- * TagProposal with empty attribute value loader
- *
- */
- public TagProposal(
- String uri,
- String prefix,
- String name
- ) {
- this(uri, "", prefix, name); //$NON-NLS-1$
- }
-
- public TagProposal(
- String uri,
- String libraryVersion,
- String prefix,
- String name
- ) {
- this.uri = uri;
- this.libraryVersion = (libraryVersion == null) ? "" : libraryVersion;
//$NON-NLS-1$
- this.prefix = prefix;
- this.name = name;
- }
-
- /**
- *
- *
- */
- public TagProposal(
- String uri,
- String prefix,
- String name,
- IAttributeValueLoader loader
- ) {
- this.uri = uri;
- this.prefix = prefix;
- this.name = name;
- this.attributeValueLoader = loader;
- }
-
- /**
- *
- * @return
- */
- public String getName() {
- return name;
- }
-
- /**
- *
- * @return
- */
- public String getPrefix() {
- return prefix;
- }
-
- /**
- *
- * @return
- */
- public String getUri() {
- return uri;
- }
-
- public String getLibraryVersion() {
- return libraryVersion;
- }
-
- public IAttributeValueLoader getAttributesValueLoader() {
- return attributeValueLoader;
- }
-}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagAttributesComposite.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -225,7 +225,7 @@
context.setProperty("attributeName", attrDescr.getName()); //$NON-NLS-1$
String tagName = "" + fWizardModel.getTagProposal().getName();
//$NON-NLS-1$
String prefix = fWizardModel.getTagProposal().getPrefix();
- if(prefix != null && prefix.length() > 0 &&
!tagName.startsWith("prefix" + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
+ if(prefix != null && prefix.length() > 0 &&
!tagName.startsWith(prefix + ":")) { //$NON-NLS-1$ //$NON-NLS-2$
tagName = prefix + ":" + tagName; //$NON-NLS-1$
}
context.setProperty("nodeName", tagName); //$NON-NLS-1$
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagProposalsComposite.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagProposalsComposite.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/composite/TagProposalsComposite.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -27,23 +27,16 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.jboss.tools.common.model.ui.editors.dnd.IDropWizardModel;
+import org.jboss.tools.common.model.ui.editors.dnd.ITagProposal;
import org.jboss.tools.common.model.ui.editors.dnd.ITagProposalFactory;
-import org.jboss.tools.common.model.ui.editors.dnd.TagProposal;
public class TagProposalsComposite extends Composite {
- private TagProposal selection = IDropWizardModel.UNDEFINED_TAG_PROPOSAL;
+ private ITagProposal selection = IDropWizardModel.UNDEFINED_TAG_PROPOSAL;
CheckboxTableViewer tableTreeViewer;
- TagProposal[] fTagProposals;
+ ITagProposal[] fTagProposals;
IDropWizardModel fModel;
-// public interface ITagProposalSelectionListener {
-// public void tagProposalSelected(TagProposal pproposal);
-// }
-
-// private ITagProposalSelectionListener listener = null;
-// private String fMimeType;
-
public TagProposalsComposite(Composite parent, int styles,IDropWizardModel model) {
super(parent,styles);
fModel = model;
@@ -90,7 +83,7 @@
tableTreeViewer.addCheckStateListener(
new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
- TagProposal proposal = (TagProposal) event.getElement();
+ ITagProposal proposal = (ITagProposal)event.getElement();
if (event.getChecked()) {
if(selection!=IDropWizardModel.UNDEFINED_TAG_PROPOSAL) {
tableTreeViewer.setChecked(selection, false);
@@ -130,13 +123,13 @@
}
public String getColumnText(Object element, int columnIndex) {
- TagProposal prop = (TagProposal)element;
+ ITagProposal prop = (ITagProposal)element;
switch (columnIndex) {
case TAG_NAME_INDEX:
- return
prop.getPrefix()==TagProposal.EMPTY_PREFIX?prop.getName():prop.getPrefix()+":"+prop.getName();
//$NON-NLS-1$
+ return prop.getDisplayString();
case TAG_URI_INDEX:
- return prop.getUri();
+ return prop.getDetails();
}
throw new IllegalArgumentException("Wrong column index for
LabelProvider"); //$NON-NLS-1$
}
@@ -162,7 +155,7 @@
/// listener = l;
/// }
- public TagProposal[] getTagProposals() {
+ public ITagProposal[] getTagProposals() {
return fTagProposals;
}
@@ -174,7 +167,7 @@
return
tagProposalFactory.getProposalLoader(mimeType).getTagProposals(dropData).length>0;
}
- public static TagProposal[] getTagProposals(String mimeType,String dropData,
ITagProposalFactory tagProposalFactory) {
+ public static ITagProposal[] getTagProposals(String mimeType,String dropData,
ITagProposalFactory tagProposalFactory) {
return tagProposalFactory.getProposalLoader(mimeType).getTagProposals(dropData);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java 2009-09-18
15:03:45 UTC (rev 17664)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/context/DropContext.java 2009-09-18
15:06:17 UTC (rev 17665)
@@ -12,6 +12,8 @@
import java.io.File;
import java.net.MalformedURLException;
+import java.util.HashSet;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -35,7 +37,6 @@
import org.jboss.tools.common.model.ui.dnd.VpeDnDEvent;
import org.jboss.tools.common.model.ui.dnd.VpeTextDropAction;
import org.jboss.tools.common.model.ui.editors.dnd.DropUtils;
-import org.jboss.tools.common.model.ui.editors.dnd.FileTagProposalLoader;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jst.web.tld.TLDUtil;
@@ -160,13 +161,19 @@
}
event = null;
}
+
+ //see FileTagProposalLoader
+ public static Set<String> mappedExtensions = new HashSet<String>();
+ public static boolean isExtensionMapped(String extension) {
+ return extension != null &&
mappedExtensions.contains(extension.toLowerCase());
+ }
private boolean dropAsFileObject(XModelObject o) {
if(o == null) return false;
if(o.getFileType() != XModelObject.FILE || isOverAttributeValue) return false;
if(TLDUtil.isTaglib(o)) return false;
String extension = o.getAttributeValue("extension"); //$NON-NLS-1$
- return extension != null &&
FileTagProposalLoader.isExtensionMapped(extension);
+ return extension != null && isExtensionMapped(extension);
}
class TransferHolder {