JBoss Tools SVN: r17663 - in trunk/jst/plugins/org.jboss.tools.jst.jsp: META-INF and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-18 11:03:39 -0400 (Fri, 18 Sep 2009)
New Revision: 17663
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileDropCommand.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileTagProposalLoader.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPTagProposalFactory.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteDropCommand.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/TagProposal.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/DefaultDropCommandRunner.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Initial moving jsp related dnd to jst.jsp
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2009-09-18 15:02:38 UTC (rev 17662)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/META-INF/MANIFEST.MF 2009-09-18 15:03:39 UTC (rev 17663)
@@ -16,6 +16,7 @@
org.jboss.tools.jst.jsp.editor,
org.jboss.tools.jst.jsp.format,
org.jboss.tools.jst.jsp.jspeditor,
+ org.jboss.tools.jst.jsp.jspeditor.dnd,
org.jboss.tools.jst.jsp.messages,
org.jboss.tools.jst.jsp.outline,
org.jboss.tools.jst.jsp.outline.cssdialog,
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-09-18 15:02:38 UTC (rev 17662)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2009-09-18 15:03:39 UTC (rev 17663)
@@ -396,6 +396,10 @@
class="org.jboss.tools.jst.jsp.outline.VpeProperties"/>
<xclass id="org.jboss.tools.jst.jsp.outline.DefaultDropCommandRunner"
class="org.jboss.tools.jst.jsp.outline.DefaultDropCommandRunner"/>
+ <xclass id="org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteDropCommand"
+ class="org.jboss.tools.jst.jsp.jspeditor.dnd.PaletteDropCommand"/>
+ <xclass id="org.jboss.tools.jst.jsp.jspeditor.dnd.FileDropCommand"
+ class="org.jboss.tools.jst.jsp.jspeditor.dnd.FileDropCommand"/>
</extension>
<extension
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2009-09-18 15:02:38 UTC (rev 17662)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2009-09-18 15:03:39 UTC (rev 17663)
@@ -103,8 +103,7 @@
import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
import org.jboss.tools.common.model.ui.editors.dnd.DropData;
import org.jboss.tools.common.model.ui.editors.dnd.IDropCommand;
-import org.jboss.tools.common.model.ui.editors.dnd.JSPTagProposalFactory;
-import org.jboss.tools.common.model.ui.editors.dnd.TagProposal;
+import org.jboss.tools.common.model.ui.editors.dnd.ITagProposal;
import org.jboss.tools.common.model.ui.editors.dnd.DropUtils.AttributeDescriptorValueProvider;
import org.jboss.tools.common.model.ui.editors.dnd.composite.TagAttributesComposite;
import org.jboss.tools.common.model.ui.editors.dnd.composite.TagAttributesComposite.AttributeDescriptorValue;
@@ -127,6 +126,8 @@
import org.jboss.tools.jst.jsp.editor.ITextFormatter;
import org.jboss.tools.jst.jsp.editor.IVisualContext;
import org.jboss.tools.jst.jsp.editor.IVisualController;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPTagProposalFactory;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.TagProposal;
import org.jboss.tools.jst.jsp.outline.JSPContentOutlineConfiguration;
import org.jboss.tools.jst.jsp.outline.JSPPropertySheetConfiguration;
import org.jboss.tools.jst.jsp.outline.ValueHelper;
@@ -768,10 +769,10 @@
JspContentAssistProcessor processor;
IPageContext pageContext;
- public void setProposal(TagProposal proposal) {
+ public void setProposal(ITagProposal proposal) {
if(this.proposal == proposal) return;
- this.proposal = proposal;
- query = createQuery(proposal);
+ this.proposal = (TagProposal)proposal;
+ query = createQuery(this.proposal);
ValueHelper valueHelper = new ValueHelper();
processor = valueHelper.createContentAssistProcessor();
pageContext = valueHelper.createPageContext(processor, query.getOffset());
@@ -897,6 +898,7 @@
event.detail = DND.DROP_NONE;
return;
}
+ JSPTagProposalFactory.getInstance();
dropContext.setDropTargetEvent(event);
if (dropContext.getFlavor() == null) {
event.detail = DND.DROP_NONE;
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileDropCommand.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileDropCommand.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileDropCommand.java 2009-09-18 15:03:39 UTC (rev 17663)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.jst.jsp.jspeditor.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.editors.dnd.DefaultDropCommand;
+import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
+import org.jboss.tools.common.model.ui.editors.dnd.DropData;
+import org.jboss.tools.common.model.ui.editors.dnd.ElementGeneratorFactory;
+import org.jboss.tools.common.model.ui.editors.dnd.ExternalDropWizardModel;
+import org.jboss.tools.common.model.ui.editors.dnd.IDropWizardModel;
+import org.jboss.tools.common.model.ui.editors.dnd.IElementGenerator;
+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 {
+ String uri = ((TagProposal)getDefaultModel().getTagProposal()).getUri();
+
+ generator = ElementGeneratorFactory.getInstance().getElementGenerator(uri);
+ 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, uri);
+ String version = ((TagProposal)getDefaultModel().getTagProposal()).getLibraryVersion();
+ properties.put(PaletteInsertHelper.PROPOPERTY_TAGLIBRARY_VERSION, version);
+ 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
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileTagProposalLoader.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileTagProposalLoader.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/FileTagProposalLoader.java 2009-09-18 15:03:39 UTC (rev 17663)
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * 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.jst.jsp.jspeditor.dnd;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.tools.common.model.ui.editors.dnd.AbsoluteFilePathAttributeValueLoader;
+import org.jboss.tools.common.model.ui.editors.dnd.CssLinkAttributeValueLoader;
+import org.jboss.tools.common.model.ui.editors.dnd.DropURI;
+import org.jboss.tools.common.model.ui.editors.dnd.IAttributeValueLoader;
+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.ITagProposalLoader;
+import org.jboss.tools.common.model.ui.editors.dnd.LoadBundleBaseNameAttributeValueLoader;
+import org.jboss.tools.common.model.ui.editors.dnd.context.DropContext;
+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,
+ ITagProposal.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,
+ ITagProposal.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$
+ )
+ }
+ );
+
+ DropContext.mappedExtensions.addAll(extensionMap.keySet());
+ }
+
+ 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
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPTagProposalFactory.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPTagProposalFactory.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/JSPTagProposalFactory.java 2009-09-18 15:03:39 UTC (rev 17663)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.jst.jsp.jspeditor.dnd;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
+import org.jboss.tools.common.model.ui.editors.dnd.ITagProposalFactory;
+import org.jboss.tools.common.model.ui.editors.dnd.ITagProposalLoader;
+
+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, FileTagProposalLoader.class.getName());
+ loaderMap.put(DropCommandFactory.kURLMime, FileTagProposalLoader.class.getName());
+ new FileTagProposalLoader();
+ }
+
+ 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;
+ }
+}
+
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteDropCommand.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteDropCommand.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/PaletteDropCommand.java 2009-09-18 15:03:39 UTC (rev 17663)
@@ -0,0 +1,335 @@
+/*******************************************************************************
+ * 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.jst.jsp.jspeditor.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.DropData;
+import org.jboss.tools.common.model.ui.editors.dnd.DropWizard;
+import org.jboss.tools.common.model.ui.editors.dnd.IDropWizard;
+import org.jboss.tools.common.model.ui.editors.dnd.IDropWizardModel;
+import org.jboss.tools.common.model.ui.editors.dnd.PaletteDropWizardModel;
+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().getDetails().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
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/TagProposal.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/TagProposal.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/dnd/TagProposal.java 2009-09-18 15:03:39 UTC (rev 17663)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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.jst.jsp.jspeditor.dnd;
+
+import org.jboss.tools.common.model.ui.editors.dnd.IAttributeValueLoader;
+import org.jboss.tools.common.model.ui.editors.dnd.IDropWizardModel;
+import org.jboss.tools.common.model.ui.editors.dnd.ITagProposal;
+
+public class TagProposal implements ITagProposal {
+
+ public static final String EMPTY_URI = ""; //$NON-NLS-1$
+
+ 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;
+ }
+
+ public String getDisplayString() {
+ return getPrefix() == ITagProposal.EMPTY_PREFIX ? getName() : getPrefix() + ":" + getName(); //$NON-NLS-1$
+ }
+
+ public String getDetails() {
+ return getUri();
+ }
+
+}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/DefaultDropCommandRunner.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/DefaultDropCommandRunner.java 2009-09-18 15:02:38 UTC (rev 17662)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/DefaultDropCommandRunner.java 2009-09-18 15:03:39 UTC (rev 17663)
@@ -24,8 +24,8 @@
import org.jboss.tools.common.meta.action.SpecialWizard;
import org.jboss.tools.common.model.ui.editors.dnd.DropCommandFactory;
import org.jboss.tools.common.model.ui.editors.dnd.DropData;
-import org.jboss.tools.common.model.ui.editors.dnd.JSPTagProposalFactory;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
+import org.jboss.tools.jst.jsp.jspeditor.dnd.JSPTagProposalFactory;
public class DefaultDropCommandRunner implements SpecialWizard {
String flavor;
15 years, 4 months
JBoss Tools SVN: r17662 - trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-09-18 11:02:38 -0400 (Fri, 18 Sep 2009)
New Revision: 17662
Added:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleListener.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/ICSSViewListner.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java
Removed:
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java
trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4849
Deleted: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java 2009-09-18 13:27:39 UTC (rev 17661)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.jst.css.common;
-
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.INullSelectionListener;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.jboss.tools.jst.css.CssPlugin;
-
-public class CSSSelectionListener implements ISelectionListener {
-
- private static CSSSelectionListener instance;
-
- private ListenerList listeners = new ListenerList();
-
- CSSStyleManager styleManager = new CSSStyleManager();
-
- private CSSSelectionListener() {
- }
-
- public synchronized static CSSSelectionListener getInstance() {
-
- if (instance == null) {
- instance = new CSSSelectionListener();
- }
- return instance;
- }
-
- public void addSelectionListener(ISelectionListener listener) {
-
- // if added the first listener start listing
- if (listeners.size() == 0)
- startListening();
-
- listeners.add(listener);
- }
-
- public void removeSelectionListener(ISelectionListener listener) {
- listeners.remove(listener);
-
- // if removed last listener start listing
- if (listeners.size() == 0)
- stopListening();
- }
-
- private void startListening() {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getSelectionService().addPostSelectionListener(this);
-// PlatformUI.getWorkbench().getActiveWorkbenchWindow()
-// .getSelectionService().addSelectionListener(this);
- }
-
- private void stopListening() {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getSelectionService().removePostSelectionListener(this);
- // PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- // .getSelectionService().addSelectionListener(this);
-
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-
- StyleContainer styleContainer = styleManager
- .recognizeCSSStyle(selection);
-
- ISelection selectionToLiteners = null;
-
- if (styleContainer != null) {
- selectionToLiteners = new StructuredSelection(styleContainer);
- } else {
- selectionToLiteners = StructuredSelection.EMPTY;
- }
-
- Object[] array = listeners.getListeners();
- for (int i = 0; i < array.length; i++) {
- final ISelectionListener l = (ISelectionListener) array[i];
- if ((part != null && selection != null)
- || l instanceof INullSelectionListener) {
-
- try {
- l.selectionChanged(part, selectionToLiteners);
- } catch (Exception e) {
- CssPlugin.log(e.getLocalizedMessage());
- }
- }
-
- }
-
- }
-}
Copied: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleListener.java (from rev 17608, trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSSelectionListener.java)
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleListener.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleListener.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jst.css.common;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.jboss.tools.jst.css.CssPlugin;
+
+public class CSSStyleListener implements ISelectionListener, INodeAdapter,
+ IPartListener {
+
+ private static CSSStyleListener instance;
+
+ private ListenerList listeners = new ListenerList();
+
+ private CSSStyleManager styleManager = new CSSStyleManager();
+
+ private StyleContainer currentStyle;
+
+ private IWorkbenchPart currentPart;
+
+ private CSSStyleListener() {
+ }
+
+ public synchronized static CSSStyleListener getInstance() {
+
+ if (instance == null) {
+ instance = new CSSStyleListener();
+ }
+ return instance;
+ }
+
+ public void addSelectionListener(ICSSViewListner listener) {
+
+ // if added the first listener start listing
+ if (listeners.size() == 0)
+ startListening();
+
+ listeners.add(listener);
+ }
+
+ public void removeSelectionListener(ICSSViewListner listener) {
+ listeners.remove(listener);
+
+ // if removed last listener start listing
+ if (listeners.size() == 0)
+ stopListening();
+ }
+
+ private void startListening() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService()
+ .addPartListener(this);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getSelectionService().addPostSelectionListener(this);
+
+ // PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ // .getSelectionService().addSelectionListener(this);
+ }
+
+ private void stopListening() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService()
+ .removePartListener(this);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getSelectionService().removePostSelectionListener(this);
+ // PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ // .getSelectionService().addSelectionListener(this);
+
+ }
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+
+ StyleContainer newStyle = styleManager.recognizeCSSStyle(selection);
+
+ if (isImportant(part)
+ && ((currentStyle == null) || !(currentStyle.equals(newStyle)))) {
+
+ disconnect(currentStyle);
+ connect(newStyle);
+ currentStyle = newStyle;
+
+ ISelection selectionToLiteners = null;
+
+ if (newStyle != null) {
+ selectionToLiteners = new StructuredSelection(newStyle);
+ } else {
+ selectionToLiteners = StructuredSelection.EMPTY;
+ }
+
+ Object[] array = listeners.getListeners();
+ for (int i = 0; i < array.length; i++) {
+ final ICSSViewListner l = (ICSSViewListner) array[i];
+ if ((part != null) && (l != currentPart) && (selection != null)) {
+
+ try {
+ l.selectionChanged(part, selectionToLiteners);
+ } catch (Exception e) {
+ CssPlugin.log(e.getLocalizedMessage());
+ }
+ }
+
+ }
+
+ }
+
+ }
+
+ protected boolean isImportant(IWorkbenchPart part) {
+ if ((part instanceof IEditorPart) || (part instanceof ContentOutline))
+ return true;
+ return false;
+ }
+
+ private void connect(StyleContainer style) {
+
+ if (style != null) {
+ style.addNodeListener(this);
+ }
+
+ }
+
+ private void disconnect(StyleContainer style) {
+ if (style != null) {
+ style.removeNodelListener(this);
+ }
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return type.equals(CSSStyleListener.class);
+ }
+
+ public void notifyChanged(INodeNotifier notifier, int eventType,
+ Object changedFeature, Object oldValue, Object newValue, int pos) {
+ Object[] array = listeners.getListeners();
+ for (int i = 0; i < array.length; i++) {
+ final ICSSViewListner l = (ICSSViewListner) array[i];
+
+ if (currentPart != l) {
+ try {
+ l.styleChanged(currentStyle);
+ } catch (Exception e) {
+ CssPlugin.log(e.getLocalizedMessage());
+ }
+ }
+
+ }
+
+ }
+
+ public void partActivated(IWorkbenchPart part) {
+ currentPart = part;
+ Object[] array = listeners.getListeners();
+ for (int i = 0; i < array.length; i++) {
+ final ICSSViewListner l = (ICSSViewListner) array[i];
+
+ if (l instanceof IPartListener) {
+ try {
+ ((IPartListener) l).partActivated(part);
+ } catch (Exception e) {
+ CssPlugin.log(e.getLocalizedMessage());
+ }
+ }
+ }
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ partActivated(part);
+ }
+
+ public void partClosed(IWorkbenchPart part) {
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {
+ }
+
+ public void partOpened(IWorkbenchPart part) {
+ }
+}
Deleted: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java 2009-09-18 13:27:39 UTC (rev 17661)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.css.common;
-
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
-import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-import org.w3c.dom.css.CSSStyleRule;
-import org.w3c.dom.css.CSSStyleSheet;
-import org.w3c.dom.css.ElementCSSInlineStyle;
-
-/**
- * @author Sergey Dzmitrovich
- *
- */
-public class CSSStyleManager {
-
- public static final String STYLE_TAG_NAME = "style"; //$NON-NLS-1$
-
- public static final String STYLE_ATTRIBUTE_NAME = "style"; //$NON-NLS-1$
-
- /**
- *
- * @param selection
- * @return
- */
- public StyleContainer recognizeCSSStyle(ISelection selection) {
-
- StyleContainer container = null;
- if (selection instanceof IStructuredSelection) {
-
- Object selectedObject = ((IStructuredSelection) selection)
- .getFirstElement();
-
- // if selected object is node in css file
- if (selectedObject instanceof ICSSNode) {
-
- CSSStyleRule styleRule = getStyleRule((ICSSNode) selectedObject);
-
- if (styleRule != null)
- container = new CSSStyleRuleContainer(styleRule);
-
- } else if ((selectedObject instanceof Element)
- || (selectedObject instanceof Attr)) {
-
- Element selectedElement = null;
-
- if (selectedObject instanceof Attr)
- selectedElement = ((Attr) selectedObject).getOwnerElement();
- else
- selectedElement = (Element) selectedObject;
-
- if (isSuitableElement(selectedElement)) {
-
- container = new StyleAttribyteContainer(selectedElement);
-
- }
- } else if (selectedObject instanceof Text) {
-
- Text styleText = (Text) selectedObject;
-
- Node parentNode = styleText.getParentNode();
-
- if ((parentNode != null)
- && STYLE_TAG_NAME.equalsIgnoreCase(parentNode
- .getNodeName())) {
-
- int offset = getRelationalOffset(styleText,
- ((ITextSelection) selection).getOffset());
-
- CSSStyleSheet sheet = getSheet(parentNode);
-
- ICSSNode node = getNode(sheet, offset);
-
- CSSStyleRule styleRule = getStyleRule(node);
-
- if (styleRule != null) {
- container = new CSSStyleRuleContainer(styleRule);
- }
- }
- }
- }
- return container;
- }
-
- /**
- *
- * @param styleContainer
- * @return
- */
- private CSSStyleSheet getSheet(Node styleContainer) {
-
- if (styleContainer instanceof INodeNotifier) {
-
- INodeNotifier notifier = (INodeNotifier) styleContainer;
-
- IStyleSheetAdapter adapter = (IStyleSheetAdapter) notifier
- .getAdapterFor(IStyleSheetAdapter.class);
-
- if (adapter != null) {
-
- return (CSSStyleSheet) adapter.getSheet();
- }
-
- }
- return null;
- }
-
- /**
- *
- * @param sheet
- * @param offset
- * @return
- */
- private ICSSNode getNode(CSSStyleSheet sheet, int offset) {
-
- ICSSModel model = ((ICSSDocument) sheet).getModel();
-
- if (model != null)
-
- return (ICSSNode) model.getIndexedRegion(offset);
-
- return null;
-
- }
-
- /**
- *
- * @param element
- * @return
- */
- private boolean isSuitableElement(Element element) {
-
- if (element instanceof ElementCSSInlineStyle
- && isAttributeAvailable(element, STYLE_TAG_NAME)) {
- return true;
- }
-
- return false;
- }
-
- /**
- *
- * @param node
- * @return
- */
- private CSSStyleRule getStyleRule(ICSSNode node) {
-
- while (node != null) {
-
- if (node instanceof CSSStyleRule)
- return (CSSStyleRule) node;
-
- node = node.getParentNode();
- }
-
- return null;
- }
-
- /**
- *
- * @param selection
- * @param styleText
- * @return
- */
- private int getRelationalOffset(Node basicNode, int absoluteOffset) {
-
- return absoluteOffset - ((IndexedRegion) basicNode).getStartOffset();
- }
-
-
- /**
- * @param element
- * @param attrName
- * @return
- */
- private static boolean isAttributeAvailable(Element element, String attrName) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element
- .getOwnerDocument());
- if (modelQuery != null) {
- CMElementDeclaration decl = modelQuery
- .getCMElementDeclaration(element);
- if (decl != null) {
- CMNamedNodeMap map = decl.getAttributes();
- if ((CMAttributeDeclaration) map.getNamedItem(attrName) != null) {
- return true;
- }
- }
- }
-
- return false;
- }
-}
Copied: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java (from rev 17608, trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java)
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleManager.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.css.common;
+
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSDocument;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSModel;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNode;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.Text;
+import org.w3c.dom.css.CSSStyleRule;
+import org.w3c.dom.css.CSSStyleSheet;
+import org.w3c.dom.css.ElementCSSInlineStyle;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class CSSStyleManager {
+
+ public static final String STYLE_TAG_NAME = "style"; //$NON-NLS-1$
+
+ public static final String STYLE_ATTRIBUTE_NAME = "style"; //$NON-NLS-1$
+
+ /**
+ *
+ * @param selection
+ * @return
+ */
+ public StyleContainer recognizeCSSStyle(ISelection selection) {
+
+ StyleContainer container = null;
+ if (selection instanceof IStructuredSelection) {
+
+ Object selectedObject = ((IStructuredSelection) selection)
+ .getFirstElement();
+
+ // if selected object is node in css file
+ if (selectedObject instanceof ICSSNode) {
+
+ CSSStyleRule styleRule = getStyleRule((ICSSNode) selectedObject);
+
+ if (styleRule != null)
+ container = new CSSStyleRuleContainer(styleRule);
+
+ } else if ((selectedObject instanceof Element)
+ || (selectedObject instanceof Attr)) {
+
+ Element selectedElement = null;
+
+ if (selectedObject instanceof Attr)
+ selectedElement = ((Attr) selectedObject).getOwnerElement();
+ else
+ selectedElement = (Element) selectedObject;
+
+ if (isSuitableElement(selectedElement)) {
+
+ container = new StyleAttribyteContainer(selectedElement);
+
+ }
+ } else if ((selectedObject instanceof Text)
+ && (selection instanceof ITextSelection)) {
+
+ Text styleText = (Text) selectedObject;
+
+ Node parentNode = styleText.getParentNode();
+
+ if ((parentNode != null)
+ && STYLE_TAG_NAME.equalsIgnoreCase(parentNode
+ .getNodeName())) {
+
+ int offset = getRelationalOffset(styleText,
+ ((ITextSelection) selection).getOffset());
+
+ CSSStyleSheet sheet = getSheet(parentNode);
+
+ ICSSNode node = getNode(sheet, offset);
+
+ CSSStyleRule styleRule = getStyleRule(node);
+
+ if (styleRule != null) {
+ container = new CSSStyleRuleContainer(styleRule);
+ }
+ }
+ }
+ }
+ return container;
+ }
+
+ /**
+ *
+ * @param styleContainer
+ * @return
+ */
+ private CSSStyleSheet getSheet(Node styleContainer) {
+
+ if (styleContainer instanceof INodeNotifier) {
+
+ INodeNotifier notifier = (INodeNotifier) styleContainer;
+
+ IStyleSheetAdapter adapter = (IStyleSheetAdapter) notifier
+ .getAdapterFor(IStyleSheetAdapter.class);
+
+ if (adapter != null) {
+
+ return (CSSStyleSheet) adapter.getSheet();
+ }
+
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param sheet
+ * @param offset
+ * @return
+ */
+ private ICSSNode getNode(CSSStyleSheet sheet, int offset) {
+
+ ICSSModel model = ((ICSSDocument) sheet).getModel();
+
+ if (model != null)
+
+ return (ICSSNode) model.getIndexedRegion(offset);
+
+ return null;
+
+ }
+
+ /**
+ *
+ * @param element
+ * @return
+ */
+ private boolean isSuitableElement(Element element) {
+
+ if (element instanceof ElementCSSInlineStyle
+ && isAttributeAvailable(element, STYLE_TAG_NAME)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ * @param node
+ * @return
+ */
+ private CSSStyleRule getStyleRule(ICSSNode node) {
+
+ while (node != null) {
+
+ if (node instanceof CSSStyleRule)
+ return (CSSStyleRule) node;
+
+ node = node.getParentNode();
+ }
+
+ return null;
+ }
+
+ /**
+ *
+ * @param selection
+ * @param styleText
+ * @return
+ */
+ private int getRelationalOffset(Node basicNode, int absoluteOffset) {
+
+ return absoluteOffset - ((IndexedRegion) basicNode).getStartOffset();
+ }
+
+ /**
+ * @param element
+ * @param attrName
+ * @return
+ */
+ private static boolean isAttributeAvailable(Element element, String attrName) {
+ ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element
+ .getOwnerDocument());
+ if (modelQuery != null) {
+ CMElementDeclaration decl = modelQuery
+ .getCMElementDeclaration(element);
+ if (decl != null) {
+ CMNamedNodeMap map = decl.getAttributes();
+ if ((CMAttributeDeclaration) map.getNamedItem(attrName) != null) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+}
Deleted: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java 2009-09-18 13:27:39 UTC (rev 17661)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.css.common;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
-import org.w3c.dom.css.CSSStyleDeclaration;
-import org.w3c.dom.css.CSSStyleRule;
-
-/**
- * @author Sergey Dzmitrovich
- *
- */
-public class CSSStyleRuleContainer extends StyleContainer {
-
- private CSSStyleRule styleRule;
-
- public CSSStyleRuleContainer(CSSStyleRule styleRule) {
- this.styleRule = styleRule;
- }
-
- public void applyStyleAttributes(Map<String, String> attributes) {
-
- final CSSStyleDeclaration declaration = styleRule.getStyle();
-
- // set properties
-
- if (attributes != null) {
-
- if ((attributes.size() == 0) && (declaration.getLength() > 0)) {
- declaration.setCssText(Constants.EMPTY);
- } else {
- for (final Map.Entry<String, String> me : attributes.entrySet()) {
- if ((me.getValue() == null)
- || (me.getValue().length() == 0)) {
- declaration.removeProperty(me.getKey());
- } else if (!me.getValue().equals(
- declaration.getPropertyValue(me.getKey()))) {
- declaration.setProperty(me.getKey(), me.getValue(),
- Constants.EMPTY);
- }
- }
-
- }
- }
-
- }
-
- public Map<String, String> getStyleAttributes() {
- CSSStyleDeclaration declaration = styleRule.getStyle();
- Map<String, String> styleMap = new HashMap<String, String>();
- for (int i = 0; i < declaration.getLength(); i++) {
- String propperty = declaration.item(i);
- String value = declaration.getPropertyValue(propperty);
- styleMap.put(propperty, value);
- }
-
- return styleMap;
- }
-
- public Object getStyleObject() {
- return styleRule;
- }
-
-}
Copied: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java (from rev 17608, trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java)
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/CSSStyleRuleContainer.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.css.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSNodeList;
+import org.eclipse.wst.css.core.internal.provisional.document.ICSSStyleDeclaration;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.css.CSSStyleRule;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class CSSStyleRuleContainer extends StyleContainer {
+
+ private CSSStyleRule styleRule;
+
+ public CSSStyleRuleContainer(CSSStyleRule styleRule) {
+ this.styleRule = styleRule;
+ }
+
+ public void applyStyleAttributes(Map<String, String> attributes) {
+
+ final CSSStyleDeclaration declaration = styleRule.getStyle();
+
+ // set properties
+
+ if (attributes != null) {
+
+ if ((attributes.size() == 0) && (declaration.getLength() > 0)) {
+ declaration.setCssText(Constants.EMPTY);
+ } else {
+ for (final Map.Entry<String, String> me : attributes.entrySet()) {
+ if ((me.getValue() == null)
+ || (me.getValue().length() == 0)) {
+ declaration.removeProperty(me.getKey());
+ } else if (!me.getValue().equals(
+ declaration.getPropertyValue(me.getKey()))) {
+ declaration.setProperty(me.getKey(), me.getValue(),
+ Constants.EMPTY);
+ }
+ }
+
+ }
+ }
+
+ }
+
+ public Map<String, String> getStyleAttributes() {
+ CSSStyleDeclaration declaration = styleRule.getStyle();
+ Map<String, String> styleMap = new HashMap<String, String>();
+ for (int i = 0; i < declaration.getLength(); i++) {
+ String propperty = declaration.item(i);
+ String value = declaration.getPropertyValue(propperty);
+ styleMap.put(propperty, value);
+ }
+
+ return styleMap;
+ }
+
+ public Object getStyleObject() {
+ return styleRule;
+ }
+
+ @Override
+ public void addNodeListener(INodeAdapter adapter) {
+ ICSSStyleDeclaration declaration = (ICSSStyleDeclaration) styleRule
+ .getStyle();
+ addNodeAdapter(declaration, adapter);
+ ICSSNodeList nodeList = declaration.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ addNodeAdapter(nodeList.item(i), adapter);
+ }
+
+ }
+
+ @Override
+ public void removeNodelListener(INodeAdapter adapter) {
+
+ ICSSStyleDeclaration declaration = (ICSSStyleDeclaration) styleRule
+ .getStyle();
+ removeNodeAdapter(declaration, adapter);
+ ICSSNodeList nodeList = declaration.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ removeNodeAdapter(nodeList.item(i), adapter);
+ }
+
+ }
+
+}
Added: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/ICSSViewListner.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/ICSSViewListner.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/ICSSViewListner.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -0,0 +1,9 @@
+package org.jboss.tools.jst.css.common;
+
+import org.eclipse.ui.ISelectionListener;
+
+public interface ICSSViewListner extends ISelectionListener {
+
+ public void styleChanged(StyleContainer styleContainer);
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/ICSSViewListner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Deleted: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java 2009-09-18 13:27:39 UTC (rev 17661)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.css.common;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
-import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
-import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
-import org.w3c.dom.Element;
-
-/**
- * @author Sergey Dzmitrovich
- *
- */
-public class StyleAttribyteContainer extends StyleContainer {
-
- public static final String STYLE_ATTRIBUTE_NAME = "style"; //$NON-NLS-1$
-
- private Element element;
-
- public StyleAttribyteContainer(Element element) {
- this.element = element;
- }
-
- public void applyStyleAttributes(Map<String, String> attributes) {
-
- StringBuffer buf = new StringBuffer();
- for (Map.Entry<String, String> me : attributes.entrySet()) {
-
- if ((me.getValue() != null) && (me.getValue().length() != 0))
- buf.append(me.getKey() + Constants.COLON + me.getValue()
- + Constants.SEMICOLON);
- }
-
- element.setAttribute(STYLE_ATTRIBUTE_NAME, buf.toString());
-
- }
-
- public Map<String, String> getStyleAttributes() {
-
- String styleString = element.getAttribute(STYLE_ATTRIBUTE_NAME);
-
- Map<String, String> styleMap = new HashMap<String, String>();
-
- if ((styleString != null) && (styleString.length() > 0)) {
-
- String[] styles = styleString.split(Constants.SEMICOLON);
- for (String styleElement : styles) {
- String[] styleElementParts = styleElement.trim().split(
- Constants.COLON);
- if ((styleElementParts != null)
- && (styleElementParts.length == 2)
- && Util.searchInElement(styleElementParts[0],
- CSSConstants.CSS_STYLES_MAP)) {
-
- styleMap.put(styleElementParts[0], styleElementParts[1]);
- }
- }
-
- }
-
- return styleMap;
- }
-
- public Object getStyleObject() {
- return element;
- }
-
-}
Copied: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java (from rev 17608, trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java)
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleAttribyteContainer.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.css.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Util;
+import org.w3c.dom.Element;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public class StyleAttribyteContainer extends StyleContainer {
+
+ public static final String STYLE_ATTRIBUTE_NAME = "style"; //$NON-NLS-1$
+
+ private Element element;
+
+ public StyleAttribyteContainer(Element element) {
+ this.element = element;
+ }
+
+ public void applyStyleAttributes(Map<String, String> attributes) {
+
+ StringBuffer buf = new StringBuffer();
+ for (Map.Entry<String, String> me : attributes.entrySet()) {
+
+ if ((me.getValue() != null) && (me.getValue().length() != 0))
+ buf.append(me.getKey() + Constants.COLON + me.getValue()
+ + Constants.SEMICOLON);
+ }
+
+ element.setAttribute(STYLE_ATTRIBUTE_NAME, buf.toString());
+
+ }
+
+ public Map<String, String> getStyleAttributes() {
+
+ String styleString = element.getAttribute(STYLE_ATTRIBUTE_NAME);
+
+ Map<String, String> styleMap = new HashMap<String, String>();
+
+ if ((styleString != null) && (styleString.length() > 0)) {
+
+ String[] styles = styleString.split(Constants.SEMICOLON);
+ for (String styleElement : styles) {
+ String[] styleElementParts = styleElement.trim().split(
+ Constants.COLON);
+ if ((styleElementParts != null)
+ && (styleElementParts.length == 2)
+ && Util.searchInElement(styleElementParts[0],
+ CSSConstants.CSS_STYLES_MAP)) {
+
+ styleMap.put(styleElementParts[0], styleElementParts[1]);
+ }
+ }
+
+ }
+
+ return styleMap;
+ }
+
+ public Object getStyleObject() {
+ return element;
+ }
+
+ @Override
+ public void addNodeListener(INodeAdapter adapter) {
+ addNodeAdapter(element, adapter);
+
+ }
+
+ @Override
+ public void removeNodelListener(INodeAdapter adapter) {
+ removeNodeAdapter(element, adapter);
+
+ }
+
+}
Deleted: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java 2009-09-18 13:27:39 UTC (rev 17661)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007-2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jst.css.common;
-
-import java.util.Map;
-
-/**
- * @author Sergey Dzmitrovich
- *
- */
-public abstract class StyleContainer {
-
- public abstract Map<String, String> getStyleAttributes();
-
- public abstract void applyStyleAttributes(Map<String, String> attributes);
-
- public abstract Object getStyleObject();
-
- public boolean equals(Object obj) {
- if (obj instanceof StyleContainer)
- obj = ((StyleContainer) obj).getStyleObject();
- return getStyleObject().equals(obj);
- }
-
-}
Copied: trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java (from rev 17608, trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java)
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.css/src/org/jboss/tools/jst/css/common/StyleContainer.java 2009-09-18 15:02:38 UTC (rev 17662)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.css.common;
+
+import java.util.Map;
+
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ */
+public abstract class StyleContainer {
+
+ public abstract Map<String, String> getStyleAttributes();
+
+ public abstract void applyStyleAttributes(Map<String, String> attributes);
+
+ public abstract Object getStyleObject();
+
+ public boolean equals(Object obj) {
+ if (obj instanceof StyleContainer)
+ obj = ((StyleContainer) obj).getStyleObject();
+ return getStyleObject().equals(obj);
+ }
+
+ protected void addNodeAdapter(Object node, INodeAdapter adapter) {
+
+ if (node instanceof INodeNotifier)
+ ((INodeNotifier) node).addAdapter(adapter);
+
+ }
+
+ protected void removeNodeAdapter(Object node, INodeAdapter adapter) {
+ if (node instanceof INodeNotifier)
+ ((INodeNotifier) node).removeAdapter(adapter);
+
+ }
+
+ public abstract void addNodeListener(INodeAdapter adapter);
+
+ public abstract void removeNodelListener(INodeAdapter adapter);
+
+}
15 years, 4 months
JBoss Tools SVN: r17661 - in trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar: format and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-09-18 09:27:39 -0400 (Fri, 18 Sep 2009)
New Revision: 17661
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/SplitToolBar.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/TextFormattingToolBar.java
Log:
RESOLVED - issue JBIDE-4735: Set items in expanded formatting tool bar into Vertical position.
https://jira.jboss.org/jira/browse/JBIDE-4735
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/SplitToolBar.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/SplitToolBar.java 2009-09-18 12:42:33 UTC (rev 17660)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/SplitToolBar.java 2009-09-18 13:27:39 UTC (rev 17661)
@@ -22,9 +22,9 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -97,8 +97,9 @@
* bounds, then it is partially hidden, and all
* remaining tools are completely hidden.
*/
- if (!intersection.equals(toolBounds))
+ if (!intersection.equals(toolBounds)) {
break;
+ }
i++;
}
@@ -108,24 +109,48 @@
*/
final Shell floatingShell = new Shell(coolBar.getShell(),
SWT.ON_TOP);
- floatingShell.setLayout(new GridLayout());
- final ToolBar floatingBar = new ToolBar(floatingShell,
- SWT.FLAT | SWT.WRAP);
+ FillLayout shellLayout = new FillLayout(SWT.VERTICAL);
+ shellLayout.marginHeight = 5;
+ shellLayout.marginWidth = 5;
+ shellLayout.spacing = 5;
+
+ floatingShell.setLayout(shellLayout);
SelectionListener selectionListener = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
floatingShell.dispose();
}
};
+
+ ToolBar floatingBar = null;
for (int j = i; j < tools.length; j++) {
- cloneToolItem(floatingBar, tools[j], selectionListener);
+ ToolItem tool = tools[j];
+ int style = tool.getStyle();
+
+ if ((style & SWT.SEPARATOR) != 0) {
+ Control control = tool.getControl();
+ if (control instanceof Combo) {
+ cloneCombo(floatingShell, selectionListener,
+ (Combo) control);
+ }
+ } else {
+ if (floatingBar == null) {
+ floatingBar = new ToolBar(floatingShell,
+ SWT.FLAT | SWT.WRAP);
+ }
+ cloneItem(floatingBar, tool, selectionListener);
+ }
}
+// Point size = floatingBar.computeSize (300, SWT.DEFAULT);
+// System.out.println(size);
+// floatingBar.setSize (size);
+// floatingBar.pack();
+ floatingShell.pack();
/*
* Drop down the menu below the chevron, with the left edges
* aligned.
*/
pt = coolBar.toDisplay(new Point(event.x, event.y));
- floatingShell.pack();
arrange(floatingShell, pt);
floatingShell.setVisible(true);
floatingShell.setFocus();
@@ -235,31 +260,30 @@
* Creates a copy of {@code item} in the {@code destBar} and
* adds given {@code selectionListener} to the created control.
*/
- protected void cloneToolItem(ToolBar destBar, ToolItem item,
+ protected void cloneItem(ToolBar destBar, ToolItem item,
SelectionListener selectionListener) {
- int style = item.getStyle();
+ ToolItem copiedItem = createToolItem(destBar, item.getStyle(),
+ item.getImage(), item.getToolTipText());
+ copiedItem.setEnabled(item.getEnabled());
+ copiedItem.setSelection(item.getSelection());
+ copySelectionListeners(item, copiedItem);
+ copiedItem.addSelectionListener(selectionListener);
+ }
- if ((style & SWT.SEPARATOR) != 0) {
- Control control = item.getControl();
- if (control instanceof Combo) {
- Combo combo = (Combo) control;
- Combo copiedCombo = createComboToolItem(destBar, combo.getStyle(),
- combo.getToolTipText(),
- Arrays.asList(combo.getItems()),
- combo.getSelectionIndex());
- copiedCombo.setEnabled(combo.getEnabled());
- copiedCombo.setVisible(combo.getVisible());
- copySelectionListeners(combo, copiedCombo);
- copiedCombo.addSelectionListener(selectionListener);
- }
- } else {
- ToolItem copiedItem = createToolItem(destBar, item.getStyle(),
- item.getImage(), item.getToolTipText());
- copiedItem.setEnabled(item.getEnabled());
- copiedItem.setSelection(item.getSelection());
- copySelectionListeners(item, copiedItem);
- copiedItem.addSelectionListener(selectionListener);
- }
+ /**
+ * Creates a copy of {@code combo} in the {@code parent} and
+ * adds given {@code selectionListener} to the created control.
+ */
+ protected void cloneCombo(Composite parent,
+ SelectionListener selectionListener, Combo combo) {
+ Combo copiedCombo = createCombo(parent, combo.getStyle(),
+ combo.getToolTipText(),
+ Arrays.asList(combo.getItems()),
+ combo.getSelectionIndex());
+ copiedCombo.setEnabled(combo.getEnabled());
+ copiedCombo.setVisible(combo.getVisible());
+ copySelectionListeners(combo, copiedCombo);
+ copiedCombo.addSelectionListener(selectionListener);
}
/**
@@ -292,21 +316,22 @@
*/
protected Combo createComboToolItem(ToolBar bar, int style,
String toolTipText, List<String> comboItems, int selectionIndex) {
- Combo combo = createCombo(bar, style, comboItems);
+ Combo combo = createCombo(bar, style,
+ toolTipText, comboItems, selectionIndex);
ToolItem sep = new ToolItem(bar, SWT.SEPARATOR);
sep.setWidth(combo.getSize().x);
- combo.setToolTipText(toolTipText);
- combo.select(selectionIndex);
sep.setControl(combo);
return combo;
}
protected Combo createCombo(Composite parent, int style,
- List<String> comboItems) {
+ String toolTipText, List<String> comboItems, int selectionIndex) {
Combo combo = new Combo(parent, style);
- combo.setLayoutData(new RowData());
+// combo.setLayoutData(new RowData());
combo.setItems(comboItems.toArray(new String[comboItems.size()]));
+ combo.setToolTipText(toolTipText);
+ combo.select(selectionIndex);
combo.pack();
return combo;
}
@@ -343,3 +368,4 @@
return result;
}
}
+
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/TextFormattingToolBar.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/TextFormattingToolBar.java 2009-09-18 12:42:33 UTC (rev 17660)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/toolbar/format/TextFormattingToolBar.java 2009-09-18 13:27:39 UTC (rev 17661)
@@ -41,7 +41,10 @@
*/
public class TextFormattingToolBar extends SplitToolBar {
- private static final String NORMAL_FONT = "Normal"; //$NON-NLS-1$
+ private static final String NORMAL_BLOCK_FORMAT
+ = "- Block Format -"; //$NON-NLS-1$
+ private static final String NORMAL_FONT = "- Font Name -"; //$NON-NLS-1$
+ private static final String NORMAL_SIZE = "- Font Size -"; //$NON-NLS-1$
private static final String ID = "TEXT_FORMATTING_TOOLBAR"; //$NON-NLS-1$
@@ -92,7 +95,7 @@
emptySeparator.setWidth(1);
List<String> blockFormatItems = new ArrayList<String>();
- blockFormatItems.add("Normal"); //$NON-NLS-1$
+ blockFormatItems.add(NORMAL_BLOCK_FORMAT);
blockFormatItems.add("Address"); //$NON-NLS-1$
// blockFormatItems.add("Numbered List");
// blockFormatItems.add("Bulleted List");
@@ -122,7 +125,7 @@
// itemDescriptors.add(new ToolItemDescriptor(sep, false, null, false));
List<String> fontSizes = new ArrayList<String>();
- fontSizes.add(NORMAL_FONT);
+ fontSizes.add(NORMAL_SIZE);
for (int i = 1; i < 8; i++) {
fontSizes.add(Integer.toString(i)); //$NON-NLS-1$
}
15 years, 4 months
JBoss Tools SVN: r17660 - in trunk: jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4853 and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-09-18 08:42:33 -0400 (Fri, 18 Sep 2009)
New Revision: 17660
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4853/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4853/SelectAllAndCut.html
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/SelectAllAndCut_JBIDE4853.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/ve/init.html
Log:
RESOLVED - issue JBIDE-4853: AutoRefresh doesn't work after Select All and source edit
https://jira.jboss.org/jira/browse/JBIDE-4853
- reverted back the changes of JBIDE-4816: Dump Source give us different results before and after refresh
- fixed JBIDE-4816 in an another way
- written JUnit test for JBIDE-4853
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4853/SelectAllAndCut.html
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4853/SelectAllAndCut.html (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/4853/SelectAllAndCut.html 2009-09-18 12:42:33 UTC (rev 17660)
@@ -0,0 +1 @@
+<div id="cut-div">abc</div>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-09-18 12:29:24 UTC (rev 17659)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-09-18 12:42:33 UTC (rev 17660)
@@ -76,6 +76,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide2170Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide2362Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.OpenOnCssClassTest_JBIDE4775;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.SelectAllAndCut_JBIDE4853;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.VPERefreshTest;
import org.jboss.tools.tests.ImportBean;
import org.jboss.tools.vpe.ui.test.VpeTestSetup;
@@ -102,6 +103,7 @@
suite.addTestSuite(Jsf20ComponentContentTest.class);
suite.addTestSuite(JBIDE3519Test.class);
suite.addTestSuite(ContextMenuDoubleInsertionTest_JBIDE3888.class);
+ suite.addTestSuite(SelectAllAndCut_JBIDE4853.class);
suite.addTestSuite(JBIDE4037Test.class);
suite.addTestSuite(JBIDE3734Test.class);
suite.addTestSuite(JBIDE3617Test.class);
@@ -188,7 +190,5 @@
projectToImport.add(jbide3247TestProject);
return new VpeTestSetup(suite, projectToImport);
-
}
-
}
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/SelectAllAndCut_JBIDE4853.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/SelectAllAndCut_JBIDE4853.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/SelectAllAndCut_JBIDE4853.java 2009-09-18 12:42:33 UTC (rev 17660)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.eclipse.swt.custom.StyledText;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMDocument;
+
+/**
+ * Tests for JIRA issue JBIDE-4859: AutoRefresh doesn't work after
+ * Select All and source edit.
+ * (https://jira.jboss.org/jira/browse/JBIDE-4859 )
+ *
+ * @author yradtsevich
+ */
+public class SelectAllAndCut_JBIDE4853 extends VpeTest {
+ private static final String TEST_PAGE_NAME
+ = "JBIDE/4853/SelectAllAndCut.html"; //$NON-NLS-1$
+ private static final String CUT_ELEMENT_ID = "cut-div"; //$NON-NLS-1$
+
+ public SelectAllAndCut_JBIDE4853(String name) {
+ super(name);
+ }
+
+ public void testSelectAllAndCut() throws Throwable {
+ VpeController vpeController = openInVpe(JsfAllTests.IMPORT_PROJECT_NAME,
+ TEST_PAGE_NAME);
+ StyledText textWidget = vpeController.getSourceEditor()
+ .getTextViewer().getTextWidget();
+
+ textWidget.selectAll();
+ textWidget.cut();
+ TestUtil.waitForIdle();
+
+ nsIDOMDocument document = vpeController.getXulRunnerEditor()
+ .getDOMDocument();
+ assertNull("Element with id='" + CUT_ELEMENT_ID //$NON-NLS-1$
+ + "' has been cut, but still" //$NON-NLS-1$
+ + " exists in the visual part.", //$NON-NLS-1$
+ document.getElementById(CUT_ELEMENT_ID));
+ }
+}
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2009-09-18 12:29:24 UTC (rev 17659)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2009-09-18 12:42:33 UTC (rev 17660)
@@ -251,11 +251,7 @@
nsIDOMNodeList children = getContentArea().getChildNodes();
long len = children.getLength();
for (long i = len - 1; i >= 0; i--) {
- //added by Maksim Areshkau as fix for https://jira.jboss.org/jira/browse/JBIDE-4816
- //for XR-1.8 addes <BR _MOZ_EDITOR_BOGUS_NODE="TRUE" _MOZ_DIRTY=""/> node in document and it's should be deleted
- if(PSEUDO_ELEMENT.equalsIgnoreCase(children.item(i).getNodeName())) {
- getContentArea().removeChild(children.item(i));
- }
+ getContentArea().removeChild(children.item(i));
}
if (sourceDocument != null) {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/ve/init.html
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/ve/init.html 2009-09-18 12:29:24 UTC (rev 17659)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/ve/init.html 2009-09-18 12:42:33 UTC (rev 17660)
@@ -68,7 +68,6 @@
<body id="__content__area__">
-<!--This comment is of JBIDE-3396 -->
</body>
</html>
15 years, 4 months
JBoss Tools SVN: r17659 - trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-18 08:29:24 -0400 (Fri, 18 Sep 2009)
New Revision: 17659
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4909
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java 2009-09-18 11:59:51 UTC (rev 17658)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolver.java 2009-09-18 12:29:24 UTC (rev 17659)
@@ -79,14 +79,16 @@
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException, java.io.IOException {
InputSource source = null;
-
+ boolean ok = false;
if (publicId != null) {
String url = publicEntities.getProperty(publicId);
if (url != null) {
source = new InputSource(url);
source.setPublicId(publicId);
+ ok = true;
}
- } else if (systemId != null) {
+ }
+ if (!ok && systemId != null) {
String url = systemEntities.getProperty(systemId);
if (url != null) {
source = new InputSource(url);
15 years, 4 months
JBoss Tools SVN: r17658 - in trunk/seam/plugins: org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-09-18 07:59:51 -0400 (Fri, 18 Sep 2009)
New Revision: 17658
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4771 added search scope support
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2009-09-18 10:32:52 UTC (rev 17657)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2009-09-18 11:59:51 UTC (rev 17658)
@@ -20,8 +20,10 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.BadLocationException;
@@ -79,6 +81,7 @@
protected IFile baseFile;
protected String propertyName;
protected IJavaElement javaElement;
+ protected IJavaSearchScope searchScope;
public SeamRefactorSearcher(IFile baseFile, String propertyName){
this.baseFile = baseFile;
@@ -89,6 +92,10 @@
this(baseFile, propertyName);
this.javaElement = javaElement;
}
+
+ public void setSearchScope(IJavaSearchScope searchScope){
+ this.searchScope = searchScope;
+ }
public void findELReferences(){
if(baseFile == null)
@@ -100,6 +107,9 @@
for (IProject project : projects) {
if(project == null) continue;
+ if(!containsInSearchScope(project))
+ continue;
+
IJavaProject javaProject = EclipseResourceUtil.getJavaProject(project);
// searching java, xml and property files in source folders
@@ -367,6 +377,17 @@
return methodName.startsWith(SET);
}
+ private boolean containsInSearchScope(IProject project){
+ if(searchScope == null)
+ return true;
+ IPath[] paths = searchScope.enclosingProjectsAndJars();
+ for(IPath path : paths){
+ if(path.equals(project.getFullPath()))
+ return true;
+ }
+ return false;
+ }
+
private void resolve(IFile file, ELExpression operand, int offset, int length){
ELResolver[] resolvers = ELResolverFactoryManager.getInstance().getResolvers(file);
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java 2009-09-18 10:32:52 UTC (rev 17657)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/search/SeamELReferencesQueryParticipant.java 2009-09-18 11:59:51 UTC (rev 17658)
@@ -51,6 +51,7 @@
String name = ELSearcher.getPropertyName(qs.getElement().getElementName());
searcher = new ELSearcher(requestor, qs.getElement(), file, name);
+ searcher.setSearchScope(qs.getScope());
searcher.findELReferences();
}
@@ -68,7 +69,7 @@
class ELSearcher extends SeamRefactorSearcher{
ISearchRequestor requestor;
public ELSearcher(ISearchRequestor requestor, IJavaElement element, IFile file, String name){
- super(file, name, element);
+ super(file, name/*, element*/);
this.requestor = requestor;
}
15 years, 4 months
JBoss Tools SVN: r17657 - in trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui: attribute/editor and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-18 06:32:52 -0400 (Fri, 18 Sep 2009)
New Revision: 17657
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/JavaClassContentAssistProvider.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/JavaHyperlinkCellEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/ControlDragDrop.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropData.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Direct reference to palette adopt from jst.web removed.
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/JavaClassContentAssistProvider.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/JavaClassContentAssistProvider.java 2009-09-18 10:25:02 UTC (rev 17656)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/adapter/JavaClassContentAssistProvider.java 2009-09-18 10:32:52 UTC (rev 17657)
@@ -10,12 +10,21 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.attribute.adapter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.ListIterator;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.pde.internal.ui.editor.contentassist.TypeContentProposalProvider;
+import org.eclipse.pde.internal.ui.editor.contentassist.TypeContentProposal;
+import org.eclipse.pde.internal.ui.editor.contentassist.TypePackageCompletionProcessor;
+import org.eclipse.swt.graphics.Image;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.ui.attribute.IAttributeContentProposalProvider;
@@ -56,3 +65,174 @@
}
}
+
+
+
+class TypeContentProposalProvider extends TypePackageCompletionProcessor implements IContentProposalProvider {
+ public static final char F_DOT = '.';
+ private IProject fProject;
+ private int fTypeScope;
+ private ArrayList fInitialContentProposals;
+ private String fInitialContent;
+ private Comparator fComparator;
+
+ /**
+ *
+ */
+ public TypeContentProposalProvider(IProject project, int scope) {
+ fProject = project;
+ fTypeScope = scope;
+ fComparator = new TypeComparator();
+
+ reset();
+ }
+
+ /**
+ * TypeComparator
+ *
+ */
+ private static class TypeComparator implements Comparator {
+ /**
+ *
+ */
+ public TypeComparator() {
+ // NO-OP
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object arg0, Object arg1) {
+ String proposalSortKey1 = ((IContentProposal) arg0).getLabel();
+ String proposalSortKey2 = ((IContentProposal) arg1).getLabel();
+ return proposalSortKey1.compareToIgnoreCase(proposalSortKey2);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String, int)
+ */
+ public IContentProposal[] getProposals(String contents, int position) {
+ // Generate a list of proposals based on the current contents
+ ArrayList currentContentProposals = null;
+ // Determine method to obtain proposals based on current field contents
+ if (position == 0) {
+ // If the document offset is at the 0 position (i.e. no input entered),
+ // do not perform content assist. The operation is too expensive
+ // because all classes and interfaces (depending on the specified scope)
+ // will need to be resolved as proposals
+ currentContentProposals = null;
+ } else if ((fInitialContentProposals == null) || (!contents.startsWith(fInitialContent)) || (endsWithDot(contents))) {
+ // Generate new proposals if the content assist session was just
+ // started
+ // Or generate new proposals if the current contents of the field
+ // is less than the initial contents of the field used to
+ // generate the original proposals; thus, widening the search
+ // scope. This can occur when the user types backspace
+ // Or generate new proposals if the current contents ends with a
+ // dot
+ currentContentProposals = generateContentProposals(contents.substring(0, position));
+ } else {
+ // Filter existing proposals from a prevous search; thus, narrowing
+ // the search scope. This can occur when the user types additional
+ // characters in the field causing new characters to be appended to
+ // the initial field contents
+ currentContentProposals = filterContentProposals(contents);
+ }
+
+ return convertResultsToSortedProposals(currentContentProposals);
+ }
+
+ /**
+ *
+ */
+ public void reset() {
+ fInitialContentProposals = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.pde.internal.ui.editor.contentassist.TypePackageCompletionProcessor#addProposalToCollection(java.util.Collection, int, int, java.lang.String, java.lang.String, org.eclipse.swt.graphics.Image)
+ */
+ protected void addProposalToCollection(Collection collection, int startOffset, int length, String label, String content, Image image) {
+ // Create content proposals for field assist
+ // start offset and length not required
+ IContentProposal proposal = new TypeContentProposal(label, content, null, image);
+ // Add the proposal to the list of proposals
+ collection.add(proposal);
+ }
+
+ /**
+ * @param string
+ * @return
+ */
+ private boolean endsWithDot(String string) {
+ int index = string.lastIndexOf(F_DOT);
+ if ((index + 1) == string.length()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @param currentContent
+ * @return
+ */
+ private ArrayList generateContentProposals(String currentContent) {
+ fInitialContentProposals = new ArrayList();
+ // Store the initial field contents to determine if we need to
+ // widen the scope later
+ fInitialContent = currentContent;
+ generateTypePackageProposals(currentContent, fProject, fInitialContentProposals, 0, fTypeScope, true);
+ return fInitialContentProposals;
+ }
+
+ /**
+ * @param list
+ * @return
+ */
+ private IContentProposal[] convertResultsToSortedProposals(ArrayList list) {
+ IContentProposal[] proposals = null;
+ if ((list != null) && (list.size() != 0)) {
+ // Convert the results array list into an array of completion
+ // proposals
+ proposals = (IContentProposal[]) list.toArray(new IContentProposal[list.size()]);
+ // Sort the proposals alphabetically
+ Arrays.sort(proposals, fComparator);
+ } else {
+ proposals = new IContentProposal[0];
+ }
+ return proposals;
+ }
+
+ /**
+ * @param currentContent
+ * @return
+ */
+ private ArrayList filterContentProposals(String currentContent) {
+ String lowerCaseCurrentContent = currentContent.toLowerCase();
+ ListIterator iterator = fInitialContentProposals.listIterator();
+ // Maintain a list of filtered search results
+ ArrayList filteredContentProposals = new ArrayList();
+ // Iterate over the initial search results
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ IContentProposal proposal = (IContentProposal) object;
+ String compareString = null;
+ if (lowerCaseCurrentContent.indexOf(F_DOT) == -1) {
+ // Use only the type name
+ compareString = proposal.getLabel().toLowerCase();
+ } else {
+ // Use the fully qualified type name
+ compareString = proposal.getContent().toLowerCase();
+ }
+ // Filter out any proposal not matching the current contents
+ // except for the edge case where the proposal is identical to the
+ // current contents
+ if (compareString.startsWith(lowerCaseCurrentContent, 0)) {
+ filteredContentProposals.add(proposal);
+ }
+ }
+ return filteredContentProposals;
+ }
+
+}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/JavaHyperlinkCellEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/JavaHyperlinkCellEditor.java 2009-09-18 10:25:02 UTC (rev 17656)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/JavaHyperlinkCellEditor.java 2009-09-18 10:32:52 UTC (rev 17657)
@@ -14,14 +14,11 @@
import org.jboss.tools.common.model.ui.IValueChangeListener;
import org.jboss.tools.common.model.ui.IValueProvider;
import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
-import org.eclipse.jdt.core.*;
-import org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
import org.eclipse.swt.widgets.*;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.util.XModelObjectUtil;
-import org.jboss.tools.common.model.ui.templates.ControlContentAssistHelper;
public class JavaHyperlinkCellEditor extends DialogCellEditorEx
implements JavaHyperlinkCueLabelProvider.JavaClassHolder {
@@ -73,15 +70,6 @@
// setChangeButtonText(JFaceResources.getString("openBrowse"));
}
- IPackageFragmentRoot root = (project == null) ? null : JavaAdapter.getInstance().getPackageFragmentRoot(project);
- if (root != null) {
- JavaTypeCompletionProcessor contentAssistentProcessor = new JavaTypeCompletionProcessor(false, false);
- IPackageFragment currentPackage = root.getPackageFragment(""); //$NON-NLS-1$
- contentAssistentProcessor.setPackageFragment(currentPackage);
- Text text = getTextField();
- text.setData("JavaHyperlinkLineFieldEditor", this); //$NON-NLS-1$
- ControlContentAssistHelper.createTextContentAssistant(getTextField(), contentAssistentProcessor, JavaHyperlinkCueLabelProvider.INSTANCE);
- }
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/ControlDragDrop.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/ControlDragDrop.java 2009-09-18 10:25:02 UTC (rev 17656)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/dnd/ControlDragDrop.java 2009-09-18 10:32:52 UTC (rev 17657)
@@ -17,6 +17,7 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.*;
+import org.jboss.tools.common.model.options.impl.PaletteAdopt;
import org.jboss.tools.common.model.ui.navigator.TreeViewerDragDropProvider;
import org.jboss.tools.common.meta.XAdoptManager;
@@ -31,12 +32,9 @@
static XAdoptManager paletteAdopt;
static {
- try {
- if(Platform.getBundle("org.jboss.tools.jst.web") != null) { //$NON-NLS-1$
- paletteAdopt = (XAdoptManager)ModelFeatureFactory.getInstance().createFeatureInstance("org.jboss.tools.jst.web.tld.model.handlers.JSPAdopt"); //$NON-NLS-1$
- }
- } catch (ClassCastException e) {
- ModelUIPlugin.getPluginLog().logError(e);
+ XAdoptManager[] ms = new PaletteAdopt().getManagers();
+ if(ms != null && ms.length > 0) {
+ paletteAdopt = ms[0];
}
}
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropData.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropData.java 2009-09-18 10:25:02 UTC (rev 17656)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/editors/dnd/DropData.java 2009-09-18 10:32:52 UTC (rev 17657)
@@ -20,7 +20,6 @@
import org.w3c.dom.Node;
import org.jboss.tools.common.model.ui.editors.dnd.DropUtils.AttributeDescriptorValueProvider;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
public class DropData {
15 years, 4 months
JBoss Tools SVN: r17656 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-09-18 06:25:02 -0400 (Fri, 18 Sep 2009)
New Revision: 17656
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4771
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2009-09-18 10:10:35 UTC (rev 17655)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/SeamRefactorSearcher.java 2009-09-18 10:25:02 UTC (rev 17656)
@@ -380,6 +380,10 @@
context.setElResolvers(resolvers);
List<Var> vars = ElVarSearcher.findAllVars(context, offset, resolver);
+
+ if(vars == null)
+ continue;
+
context.setVars(vars);
ELResolution resolution = resolver.resolve(context, operand);
15 years, 4 months
JBoss Tools SVN: r17655 - trunk/struts/plugins/org.jboss.tools.struts.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-18 06:10:35 -0400 (Fri, 18 Sep 2009)
New Revision: 17655
Modified:
trunk/struts/plugins/org.jboss.tools.struts/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Extension point jspAdopt moved to jst.web.
Modified: trunk/struts/plugins/org.jboss.tools.struts/plugin.xml
===================================================================
--- trunk/struts/plugins/org.jboss.tools.struts/plugin.xml 2009-09-18 10:09:55 UTC (rev 17654)
+++ trunk/struts/plugins/org.jboss.tools.struts/plugin.xml 2009-09-18 10:10:35 UTC (rev 17655)
@@ -30,7 +30,7 @@
</run>
</runtime>
</extension>
- <extension point="org.jboss.tools.common.model.jspAdopt">
+ <extension point="org.jboss.tools.jst.web.jspAdopt">
<jspAdopt class="org.jboss.tools.struts.model.handlers.JSPAdopt"/>
<jspAdopt class="org.jboss.tools.struts.tiles.model.handlers.JSPAdopt"/>
</extension>
15 years, 4 months
JBoss Tools SVN: r17654 - trunk/jsf/plugins/org.jboss.tools.jsf.ui.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-09-18 06:09:55 -0400 (Fri, 18 Sep 2009)
New Revision: 17654
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4913
Extension point jspAdopt moved to jst.web.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2009-09-18 10:09:22 UTC (rev 17653)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/plugin.xml 2009-09-18 10:09:55 UTC (rev 17654)
@@ -242,7 +242,7 @@
<natureType id="jsf">
</natureType>
</extension>
- <extension point="org.jboss.tools.common.model.jspAdopt">
+ <extension point="org.jboss.tools.jst.web.jspAdopt">
<jspAdopt class="org.jboss.tools.jsf.ui.adopt.JSPAdopt"/>
</extension>
<extension
15 years, 4 months