JBoss Tools SVN: r16143 - in trunk/vpe/plugins/org.jboss.tools.vpe: src/org/jboss/tools/vpe/editor/util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2009-06-23 10:43:48 -0400 (Tue, 23 Jun 2009)
New Revision: 16143
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4510, doctype processing for files from jar archive was updated.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2009-06-23 14:13:55 UTC (rev 16142)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2009-06-23 14:43:48 UTC (rev 16143)
@@ -76,6 +76,7 @@
org.jboss.tools.vpe.resref,
org.jboss.tools.common.el.core,
org.jboss.tools.common.el.ui,
- org.eclipse.core.expressions;bundle-version="3.4.100"
+ org.eclipse.core.expressions;bundle-version="3.4.100",
+ org.eclipse.jdt.ui
Bundle-Version: 2.1.0
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2009-06-23 14:13:55 UTC (rev 16142)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2009-06-23 14:43:48 UTC (rev 16143)
@@ -11,7 +11,9 @@
package org.jboss.tools.vpe.editor.util;
+
import java.io.File;
+import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -22,10 +24,15 @@
import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.filebuffers.LocationKind;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.internal.core.JarEntryFile;
+import org.eclipse.jdt.internal.ui.javaeditor.JarEntryEditorInput;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
@@ -44,6 +51,8 @@
public class DocTypeUtil {
+ private static final String TEMP_FILE_NAME = "VPE-Temporally-"; //$NON-NLS-1$
+
static private List<String> urlTags;
static {
@@ -65,24 +74,97 @@
* @return
*/
public static String getDoctype(IEditorInput editorInput) {
-
-
- // if opened file is located in eclipse workspace
+ /*
+ * https://jira.jboss.org/jira/browse/JBIDE-4510
+ * Doctype string should always have some value:
+ * empty value or doctype value, but not 'null'
+ * because this string is displayed on VPE page.
+ */
+ String doctype = Constants.EMPTY;
+ /*
+ * if opened file is located in eclipse workspace
+ */
if (editorInput instanceof IFileEditorInput) {
IFile f = ((IFileEditorInput) editorInput).getFile();
- return (f == null || !f.exists()) ? null : getDoctype(f,null);
+ if ((f != null) && f.exists()) {
+ doctype = getDoctype(f,null);
+ }
}
- // if opened file is not located in eclipse workspace
+ /*
+ * if opened file is not located in eclipse workspace
+ */
else if (editorInput instanceof ILocationProvider) {
IPath path = ((ILocationProvider) editorInput).getPath(editorInput);
- if (path == null || path.segmentCount() < 1)
- return null;
- //TODO SDzmitrovich Fix This Method, convert to IPath to IFile,
- //or smht. else, should be only one getDoctype(IFile, List<IFile>);
- return getDoctype(path.toFile());
+ if (path != null && path.segmentCount() > 0) {
+ //TODO SDzmitrovich Fix This Method, convert to IPath to IFile,
+ //or smht. else, should be only one getDoctype(IFile, List<IFile>);
+ doctype = getDoctype(path.toFile());
+ }
+ }
+ /*
+ * https://jira.jboss.org/jira/browse/JBIDE-4510
+ * When file is opened from jar archive.
+ */
+ else if (editorInput instanceof JarEntryEditorInput) {
+ /*
+ * To determine the doctype of a file from jar archive
+ * by means of eclipse's StructuredModelManager
+ * file should be an IFile type and should exists in the workspace.
+ * To achieve that conditions temporally IFile will be created
+ * in the root project folder.
+ * After doctype processing temporally file will be deleted.
+ */
+ JarEntryEditorInput input = ((JarEntryEditorInput) editorInput);
+ IStorage storage = input.getStorage();
+ JarEntryFile jarFile = null;
+ IFile iFile = null;
+ if (storage instanceof JarEntryFile) {
+ jarFile = (JarEntryFile) storage;
+ try {
+ /*
+ * Get the content of a file from jar archive.
+ */
+ InputStream is = jarFile.getContents();
+ /*
+ * Find the eclipse project that contains selected jar archive.
+ */
+ IJavaProject javaProject = jarFile.getPackageFragmentRoot().getJavaProject();
+ if (javaProject != null) {
+ IProject project = javaProject.getProject();
+ /*
+ * Create temporally IFile.
+ */
+ iFile = project.getFile(TEMP_FILE_NAME + jarFile.getName());
+ /*
+ * Delete any previously saved file.
+ */
+ if ((iFile != null) && (iFile.exists())){
+ iFile.delete(true, false, null);
+ }
+ /*
+ * Create new file with a content of the file from jar library.
+ */
+ iFile.create(is, true, null);
+ /*
+ * Get doctype for this file, store it.
+ */
+ doctype = getDoctype(iFile, null);
+ /*
+ * Delete temporally file.
+ */
+ if (iFile != null) {
+ iFile.delete(true, false, null);
+ }
+ }
+ } catch (CoreException e) {
+ /*
+ * Log any possible errors.
+ */
+ VpePlugin.getPluginLog().logError(e);
+ }
+ }
}
- return null;
-
+ return doctype;
}
/**
@@ -92,83 +174,59 @@
* @return
*/
private static String getDoctype(IFile file, List<IFile> previousFiles) {
-
- String docTypeValue = null;
-
- // get document
+ String docTypeValue = Constants.EMPTY;
Document document = null;
try {
-
document = VpeCreatorUtil.getDocumentForRead(file);
-
if (document != null) {
-
- /*
- * if there is "component" element (ui:composition or ui:component )
- * so we don't use doctype from current page (as all text outside
- * this elements will be removed)
- */
-
// find "component" element
Element componentElement = FaceletUtil
.findComponentElement(document.getDocumentElement());
- // if "component" element was not found return doctype from current
- // page
- if (componentElement == null) {
-
- IDOMDocumentType documentType = (IDOMDocumentType) document
- .getDoctype();
-
- if (documentType != null)
- docTypeValue = documentType.getSource();
-
- }
-
- // if "component" element was not found return doctype from current
- // page
- else if ((componentElement != null)
- && (FaceletUtil.TAG_COMPOSITION.equals(componentElement
- .getLocalName()))
- && (componentElement
- .hasAttribute(FaceletUtil.ATTR_TEMPLATE))) {
-
+ /*
+ * if there is "component" element (ui:composition or ui:component)
+ * so we don't use doctype from current page
+ * (as all text outside this elements will be removed)
+ */
+ if ((componentElement != null)
+ && (FaceletUtil.TAG_COMPOSITION.equals(componentElement.getLocalName()))
+ && (componentElement.hasAttribute(FaceletUtil.ATTR_TEMPLATE))) {
// get attribute "template"
Attr attr = ((Element) componentElement)
.getAttributeNode(FaceletUtil.ATTR_TEMPLATE);
-
if (attr.getNodeValue().trim().length() > 0) {
-
// get name of template file
String fileName = attr.getNodeValue().trim();
-
// get file
IFile templateFile = FileUtil.getFile(fileName, file);
-
if (templateFile != null) {
//if it's was first call of DOCTYPE function
if(previousFiles==null) {
-
previousFiles = new ArrayList<IFile>();
}
//Added by Max Areshkau JBIDE-2434
if(!previousFiles.contains(templateFile)) {
-
- previousFiles.add(templateFile);
- docTypeValue = getDoctype(templateFile,previousFiles);
+ previousFiles.add(templateFile);
+ docTypeValue = getDoctype(templateFile,previousFiles);
}
}
}
-
+ } else {
+ /*
+ * if "component" element was not found
+ * return doctype from current page
+ */
+ IDOMDocumentType documentType = (IDOMDocumentType) document.getDoctype();
+ if (documentType != null)
+ docTypeValue = documentType.getSource();
}
}
} finally {
if(document!=null) {
-
VpeCreatorUtil.releaseDocumentFromRead(document);
}
}
- return docTypeValue != null ? docTypeValue.trim() : ""; //$NON-NLS-1$
+ return (docTypeValue != null) ? docTypeValue.trim() : Constants.EMPTY;
}
/**
@@ -178,65 +236,45 @@
* @return
*/
private static String getDoctype(File file) {
-
- String docTypeValue = null;
-
- // get document
+ String docTypeValue = Constants.EMPTY;
IDOMDocument document = getDocument(file);
-
if (document != null) {
-
- /*
- * if there is "component" element (ui:composition or ui:component )
- * so we don't use doctype from current page (as all text outside
- * this elements will be removed)
- */
-
// find "component" element
Element componentElement = FaceletUtil
.findComponentElement(document.getDocumentElement());
-
- // if "component" element was not found return doctype from current
- // page
- if (componentElement == null) {
-
- IDOMDocumentType documentType = (IDOMDocumentType) document
- .getDoctype();
-
- if (documentType != null)
- docTypeValue = documentType.getSource();
-
- }
-
- // if "component" element was not found return doctype from current
- // page
- else if ((componentElement != null)
+ /*
+ * if there is "component" element (ui:composition or ui:component)
+ * so we don't use doctype from current page
+ * (as all text outside this elements will be removed)
+ */
+ if ((componentElement != null)
&& (FaceletUtil.TAG_COMPOSITION.equals(componentElement
.getLocalName()))
&& (componentElement
.hasAttribute(FaceletUtil.ATTR_TEMPLATE))) {
-
// get attribute "template"
Attr attr = ((Element) componentElement)
.getAttributeNode(FaceletUtil.ATTR_TEMPLATE);
-
if (attr.getNodeValue().trim().length() > 0) {
-
// get name of template file
String fileName = attr.getNodeValue().trim();
-
// get file
File templateFile = new File(file.getParent(), fileName);
-
- if (templateFile.exists())
+ if (templateFile.exists()) {
docTypeValue = getDoctype(templateFile);
-
+ }
}
-
+ } else {
+ /*
+ * if "component" element was not found
+ * return doctype from current page
+ */
+ IDOMDocumentType documentType = (IDOMDocumentType) document.getDoctype();
+ if (documentType != null)
+ docTypeValue = documentType.getSource();
}
}
- return docTypeValue != null ? docTypeValue.trim() : ""; //$NON-NLS-1$
-
+ return (docTypeValue != null) ? docTypeValue.trim() : Constants.EMPTY;
}
/**
@@ -266,25 +304,20 @@
// return null;
IDOMModel model = null;
-
ITextFileBufferManager bufferManager = FileBuffers
.getTextFileBufferManager();
IPath location = new Path(file.getAbsolutePath());
-
try {
bufferManager.connect(location, LocationKind.LOCATION,
new NullProgressMonitor());
-
ITextFileBuffer buffer = bufferManager.getTextFileBuffer(location,
LocationKind.LOCATION);
if (buffer != null) {
-
IDocument bufferDocument = buffer.getDocument();
if (bufferDocument instanceof IStructuredDocument) {
model = (IDOMModel) FileBufferModelManager.getInstance()
.getModel((IStructuredDocument) bufferDocument);
} else {
-
bufferManager.disconnect(location, LocationKind.IFILE,
new NullProgressMonitor());
}
@@ -292,7 +325,6 @@
} catch (CoreException e) {
VpePlugin.getPluginLog().logError(e);
}
-
return model.getDocument();
}
@@ -315,50 +347,33 @@
* @return
*/
public static String getContentInitFile(File initFile) {
-
IDOMDocument document = getDocument(initFile);
-
if (document != null) {
// for each tag's name
for (String tag : urlTags) {
-
NodeList list = document.getElementsByTagName(tag);
-
for (int i = 0; i < list.getLength(); i++) {
-
Element element = (Element) list.item(i);
-
// for each attribute's name
for (String attributeName : urlAttributes) {
-
if (element.hasAttribute(attributeName)) {
-
Attr attr = element.getAttributeNode(attributeName);
-
try {
URI uri = new URI(attr.getValue().replace('\\', '/'));
if (!uri.isAbsolute()) {
// corrected path
attr.setValue(Constants.FILE_PREFIX + initFile.getParent()
+ File.separator + attr.getValue());
-
}
} catch (URISyntaxException e) {
VpePlugin.getPluginLog().logError(e.getMessage());
}
-
}
-
}
-
}
-
}
-
- return (document).getSource();
+ return document.getSource();
}
-
- return ""; //$NON-NLS-1$
-
+ return Constants.EMPTY;
}
}
15 years, 6 months
JBoss Tools SVN: r16142 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2009-06-23 10:13:55 -0400 (Tue, 23 Jun 2009)
New Revision: 16142
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java
Log:
RESOLVED - issue https://jira.jboss.org/jira/browse/JBIDE-4397 : Context menu on the Visual Pane works wrong with Insert, Replace commands.
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-06-23 14:12:09 UTC (rev 16141)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/InsertContributionItem.java 2009-06-23 14:13:55 UTC (rev 16142)
@@ -11,6 +11,7 @@
import java.util.List;
import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
@@ -27,7 +28,9 @@
import org.jboss.tools.jst.web.tld.URIConstants;
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.menu.action.ComplexAction;
import org.jboss.tools.vpe.editor.menu.action.InsertAction2;
+import org.jboss.tools.vpe.editor.menu.action.SelectThisTagAction;
import org.jboss.tools.vpe.editor.util.Constants;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
@@ -35,10 +38,11 @@
/**
* @author Sergey Dzmitrovich
- *
+ * @author yradtsevich
*/
public class InsertContributionItem extends ContributionItem {
+ private final Node node;
private final StructuredTextEditor sourceEditor;
private final VpePageContext pageContext;
private final static String NAME_PROPERTY = "name"; //$NON-NLS-1$
@@ -51,10 +55,24 @@
private final static String LEFT_ANGLE_BRACKET = "<"; //$NON-NLS-1$
private final static String RIGHT_ANGLE_BRACKET = ">"; //$NON-NLS-1$
+ /**
+ * Creates an {@code InsertContributionItem}
+ * to make insert actions on the currently selected node.
+ */
public InsertContributionItem() {
- final JSPMultiPageEditor editor = (JSPMultiPageEditor) PlatformUI
- .getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .getActiveEditor();
+ this(null);
+ }
+
+ /**
+ * Creates an {@code InsertContributionItem}
+ * to make insert actions on the given {@code node}.
+ */
+ public InsertContributionItem(final Node node) {
+ this.node = node;
+
+ final JSPMultiPageEditor editor = (JSPMultiPageEditor)
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().getActiveEditor();
this.sourceEditor = editor.getSourceEditor();
this.pageContext = ((VpeEditorPart) editor.getVisualEditor())
.getController().getPageContext();
@@ -115,6 +133,9 @@
prefix = getPrefix(modelObject);
}
+ final IAction selectNodeAction =
+ node == null ? null : new SelectThisTagAction(node);
+
for (final XModelObject modelObjectChild : modelObjectChildren) {
if (Constants.YES_STRING.equals(
modelObjectChild.getAttributeValue(HIDDEN_PROPERTY))) {
@@ -138,8 +159,18 @@
.getAttributeValue(NAME_PROPERTY)
+ RIGHT_ANGLE_BRACKET;
- manager.add(new InsertAction2(name, modelObjectChild,
- sourceEditor, insertionType));
+ final InsertAction2 insertAction = new InsertAction2(
+ name, modelObjectChild,
+ sourceEditor, insertionType);
+
+ final IAction action;
+ if (selectNodeAction == null) {
+ action = insertAction;
+ } else {
+ action = new ComplexAction(insertAction.getText(),
+ selectNodeAction, insertAction);
+ }
+ manager.add(action);
}
} else {
final MenuManager subMenu = new InsertSubMenuManager(
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java 2009-06-23 14:12:09 UTC (rev 16141)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/menu/VpeMenuCreator.java 2009-06-23 14:13:55 UTC (rev 16142)
@@ -83,7 +83,7 @@
}
addSeparator();
- menuManager.add(new InsertContributionItem());
+ menuManager.add(new InsertContributionItem(node));
addIfEnabled(new StripTagAction(node));
addSeparator();
15 years, 6 months
JBoss Tools SVN: r16141 - in trunk/jsf/plugins/org.jboss.tools.jsf: src/org/jboss/tools/jsf/model and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-06-23 10:12:09 -0400 (Tue, 23 Jun 2009)
New Revision: 16141
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-2920 messages in jsf
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2009-06-23 14:08:28 UTC (rev 16140)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2009-06-23 14:12:09 UTC (rev 16141)
@@ -430,4 +430,11 @@
resolver-class="org.jboss.tools.jsf.model.JSFELCompletionEngine"/>
</el-resolver>
</extension>
+ <extension
+ point="org.jboss.tools.common.el.core.elResolver">
+ <el-resolver id="jsfMessageELResolver">
+ <project-nature id="org.jboss.tools.jsf.jsfnature"
+ resolver-class="org.jboss.tools.jsf.model.JSFMessageELCompletionEngine"/>
+ </el-resolver>
+ </extension>
</plugin>
Added: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2009-06-23 14:12:09 UTC (rev 16141)
@@ -0,0 +1,434 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserFactory;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.ELOperandResolveStatus;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jsf.JSFModelPlugin;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.IResourceBundle;
+import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+
+public class JSFMessageELCompletionEngine implements ELResolver {
+ private static final Image JSF_EL_PROPOSAL_IMAGE = JSFModelPlugin.getDefault().getImage(JSFModelPlugin.CA_JSF_EL_IMAGE_PATH);
+
+ public Image getELProposalImage() {
+ return JSF_EL_PROPOSAL_IMAGE;
+ }
+
+ private static ELParserFactory factory = ELParserUtil.getDefaultFactory();
+
+ public JSFMessageELCompletionEngine() {}
+
+ public ELParserFactory getParserFactory() {
+ return factory;
+ }
+
+ protected void log(Exception e) {
+ JSFModelPlugin.getPluginLog().logError(e);
+ }
+
+ protected ELOperandResolveStatus newELOperandResolveStatus(ELInvocationExpression tokens) {
+ return new ELOperandResolveStatus(tokens);
+ }
+
+ public List<TextProposal> getCompletions(String elString,
+ boolean returnEqualedVariablesOnly, int position, ELContext context) {
+ IDocument document = null;
+ IResourceBundle[] bundles = new IResourceBundle[0];
+ if(context instanceof IPageContext) {
+ IPageContext pageContext = (IPageContext)context;
+ document = pageContext.getDocument();
+ bundles = pageContext.getResourceBundles();
+ }
+
+ List<TextProposal> proposals = null;
+ try {
+ proposals = getCompletions(context.getResource(), document, elString.subSequence(0, elString.length()), position, returnEqualedVariablesOnly, bundles);
+ } catch (StringIndexOutOfBoundsException e) {
+ log(e);
+ } catch (BadLocationException e) {
+ log(e);
+ }
+ return proposals;
+ }
+
+ public ELOperandResolveStatus resolveELOperand(ELExpression operand,
+ ELContext context, boolean returnEqualedVariablesOnly) {
+ ELOperandResolveStatus status = null;
+ IResourceBundle[] bundles = new IResourceBundle[0];
+ if(context instanceof IPageContext) {
+ IPageContext pageContext = (IPageContext)context;
+ bundles = pageContext.getResourceBundles();
+ }
+ try {
+ status = resolveELOperand(context.getResource(), operand, returnEqualedVariablesOnly, bundles);
+ } catch (StringIndexOutOfBoundsException e) {
+ log(e);
+ } catch (BadLocationException e) {
+ log(e);
+ }
+ return status;
+ }
+
+ public List<TextProposal> getCompletions(IFile file, IDocument document, CharSequence prefix,
+ int position, boolean returnEqualedVariablesOnly, IResourceBundle[] bundles) throws BadLocationException, StringIndexOutOfBoundsException {
+ List<TextProposal> completions = new ArrayList<TextProposal>();
+
+ ELOperandResolveStatus status = resolveELOperand(file, parseOperand("" + prefix), returnEqualedVariablesOnly, bundles);
+ if (status.isOK()) {
+ completions.addAll(status.getProposals());
+ }
+
+ return completions;
+ }
+
+ public ELExpression parseOperand(String operand) {
+ if(operand == null) return null;
+ String el = (operand.indexOf("#{") < 0 && operand.indexOf("${") < 0) ? "#{" + operand + "}" : operand;
+ ELParser p = getParserFactory().createParser();
+ ELModel model = p.parse(el);
+ List<ELInstance> is = model.getInstances();
+ if(is.isEmpty()) return null;
+ return is.get(0).getExpression();
+ }
+
+ public ELOperandResolveStatus resolveELOperand(IFile file,
+ ELExpression operand, boolean returnEqualedVariablesOnly, IResourceBundle[] bundles)
+ throws BadLocationException, StringIndexOutOfBoundsException {
+ if(!(operand instanceof ELInvocationExpression) || file == null) {
+ return newELOperandResolveStatus(null);
+ }
+
+ ELInvocationExpression expr = (ELInvocationExpression)operand;
+ boolean isIncomplete = expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION
+ && ((ELPropertyInvocation)expr).getName() == null;
+ boolean isArgument = expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION;
+
+ ELOperandResolveStatus status = newELOperandResolveStatus(expr);
+ ELInvocationExpression left = expr;
+
+ List<Variable> resolvedVariables = new ArrayList<Variable>();
+
+ if (expr.getLeft() != null && isArgument) {
+ left = expr.getLeft();
+ resolvedVariables = resolveVariables(file, left, bundles, false,
+ true); // is Final and equal names are because of
+ // we have no more to resolve the parts of expression,
+ // but we have to resolve arguments of probably a message component
+ } else if (expr.getLeft() == null && isIncomplete) {
+ resolvedVariables = resolveVariables(file, expr, bundles, true,
+ returnEqualedVariablesOnly);
+ } else {
+ while(left != null) {
+ List<Variable>resolvedVars = new ArrayList<Variable>();
+ resolvedVars = resolveVariables(file,
+ left, bundles, left == expr,
+ returnEqualedVariablesOnly);
+ if (resolvedVars != null && !resolvedVars.isEmpty()) {
+ resolvedVariables = resolvedVars;
+ status.setLastResolvedToken(left);
+ break;
+ }
+ left = (ELInvocationExpression)left.getLeft();
+ }
+ }
+
+ if (status.getResolvedTokens() == null &&
+ !returnEqualedVariablesOnly &&
+ expr != null &&
+ isIncomplete) {
+ // no vars are resolved
+ // the tokens are the part of var name ended with a separator (.)
+ resolvedVariables = resolveVariables(file, expr, bundles, true, returnEqualedVariablesOnly);
+ Set<TextProposal> proposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
+ for (Variable var : resolvedVariables) {
+ String varName = var.getName();
+ if(varName.startsWith(operand.getText())) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(varName.substring(operand.getLength()));
+ setImage(proposal);
+ proposals.add(proposal);
+ }
+ }
+ status.setProposals(proposals);
+ return status;
+ }
+
+ // Here we have a list of vars for some part of expression
+ // OK. we'll proceed with members of these vars
+ if (status.getResolvedTokens() == status.getTokens()) {
+ // First segment is the last one
+ Set<TextProposal> proposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
+ for (Variable var : resolvedVariables) {
+ String varName = var.getName();
+ if(operand.getLength()<=varName.length()) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(varName.substring(operand.getLength()));
+ setImage(proposal);
+ proposals.add(proposal);
+ } else if(returnEqualedVariablesOnly) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(varName);
+ setImage(proposal);
+ proposals.add(proposal);
+ }
+ }
+ status.setLastResolvedToken(expr);
+ status.setProposals(proposals);
+ return status;
+ }
+
+ //process segments one by one
+ if(left != null) while(left != expr) {
+ left = (ELInvocationExpression)left.getParent();
+ if (left != expr) { // inside expression
+ return status;
+ } else { // Last segment
+ resolveLastSegment((ELInvocationExpression)operand, resolvedVariables, status, returnEqualedVariablesOnly);
+ break;
+ }
+ }
+
+ return status;
+ }
+
+ public List<Variable> resolveVariables(IFile file, ELInvocationExpression expr, IResourceBundle[] bundles, boolean isFinal, boolean onlyEqualNames) {
+ List<Variable> result = new ArrayList<Variable>();
+ if(expr.getLeft() != null) return result;
+ IModelNature n = EclipseResourceUtil.getModelNature(file.getProject());
+ if(n == null) return result;
+ XModel model = n.getModel();
+ String varName = expr.toString();
+ for (IResourceBundle b: bundles) {
+ String name = b.getVar();
+ if(!isFinal || onlyEqualNames) {
+ if(!name.equals(varName)) continue;
+ }
+ if(!varName.startsWith(name)) continue;
+ Variable v = new Variable(name, b.getBasename(), file);
+ result.add(v);
+ }
+ List l = WebPromptingProvider.getInstance().getList(model, WebPromptingProvider.JSF_REGISTERED_BUNDLES, null, null);
+ if(l != null && l.size() > 0 && (l.get(0) instanceof Map)) {
+ Map map = (Map)l.get(0);
+ Iterator it = map.keySet().iterator();
+ while(it.hasNext()) {
+ String name = it.next().toString();
+ String basename = map.get(name).toString();
+ if(!isFinal || onlyEqualNames) {
+ if(!name.equals(varName)) continue;
+ }
+ Variable v = new Variable(name, basename, file);
+ result.add(v);
+ }
+ }
+
+ return result;
+ }
+
+ protected void setImage(TextProposal kbProposal) {
+ kbProposal.setImage(getELProposalImage());
+ }
+
+ protected void resolveLastSegment(ELInvocationExpression expr,
+ List<Variable> members,
+ ELOperandResolveStatus status,
+ boolean returnEqualedVariablesOnly) {
+ Set<TextProposal> kbProposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
+
+ if (expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION && ((ELPropertyInvocation)expr).getName() == null) {
+ // return all the methods + properties
+ for (Variable mbr : members) {
+ processSingularMember(mbr, kbProposals);
+ }
+ } else
+ if(expr.getType() != ELObjectType.EL_ARGUMENT_INVOCATION) {
+ Set<String> proposalsToFilter = new TreeSet<String>();
+ for (Variable mbr : members) {
+ filterSingularMember(mbr, proposalsToFilter);
+ }
+ for (String proposal : proposalsToFilter) {
+ // We do expect nothing but name for method tokens (No round brackets)
+ String filter = expr.getMemberName();
+ if(filter == null) filter = "";
+ if(returnEqualedVariablesOnly) {
+ // This is used for validation.
+ if (proposal.equals(filter)) {
+ TextProposal kbProposal = new TextProposal();
+ kbProposal.setReplacementString(proposal);
+
+ setImage(kbProposal);
+
+ kbProposals.add(kbProposal);
+
+ break;
+ }
+ } else if (proposal.startsWith(filter)) {
+ // This is used for CA.
+ TextProposal kbProposal = new TextProposal();
+ kbProposal.setReplacementString(proposal.substring(filter.length()));
+ kbProposal.setImage(getELProposalImage());
+
+ kbProposals.add(kbProposal);
+ }
+ }
+ } else if(expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION) {
+ Set<String> proposalsToFilter = new TreeSet<String>();
+ boolean isMessages = false;
+ for (Variable mbr : members) {
+ isMessages = true;
+ filterSingularMember(mbr, proposalsToFilter);
+ }
+
+ String filter = expr.getMemberName();
+ boolean bSurroundWithQuotes = false;
+ if(filter == null) {
+ filter = "";
+ bSurroundWithQuotes = true;
+ } else {
+ if((filter.startsWith("'") || filter.startsWith("\""))
+ && (filter.endsWith("'") || filter.endsWith("\""))) {
+ filter = filter.substring(1, filter.length() - 1);
+ } else {
+ //Value is set as expression itself, we cannot compute it
+ if(isMessages) status.setMapOrCollectionOrBundleAmoungTheTokens();
+ return;
+ }
+ }
+
+ for (String proposal : proposalsToFilter) {
+ if(returnEqualedVariablesOnly) {
+ // This is used for validation.
+ if (proposal.equals(filter)) {
+ TextProposal kbProposal = new TextProposal();
+ kbProposal.setReplacementString(proposal);
+
+ setImage(kbProposal);
+
+ kbProposals.add(kbProposal);
+
+ break;
+ }
+ } else if (proposal.startsWith(filter)) {
+ // This is used for CA.
+ TextProposal kbProposal = new TextProposal();
+
+ String replacementString = proposal.substring(filter.length());
+ if (bSurroundWithQuotes) {
+ replacementString = "'" + replacementString + "']";
+ }
+
+ kbProposal.setReplacementString(replacementString);
+ kbProposal.setImage(getELProposalImage());
+
+ kbProposals.add(kbProposal);
+ }
+ }
+ }
+ status.setProposals(kbProposals);
+ if (status.isOK()){
+ status.setLastResolvedToken(expr);
+ }
+ }
+
+ protected void processSingularMember(Variable mbr, Set<TextProposal> kbProposals) {
+ // Surround the "long" keys containing the dots with [' ']
+ TreeSet<String> keys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
+ keys.addAll(mbr.getKeys());
+ Iterator<String> sortedKeys = keys.iterator();
+ while(sortedKeys.hasNext()) {
+ String key = sortedKeys.next();
+ if (key == null || key.length() == 0)
+ continue;
+ if (key.indexOf('.') != -1) {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString("['" + key + "']");
+ setImage(proposal);
+
+ kbProposals.add(proposal);
+ } else {
+ TextProposal proposal = new TextProposal();
+ proposal.setReplacementString(key);
+ setImage(proposal);
+
+ kbProposals.add(proposal);
+ }
+ }
+ }
+
+ protected void filterSingularMember(Variable mbr, Set<String> proposalsToFilter) {
+ Collection<String> keys = mbr.getKeys();
+ for (String key : keys) {
+ proposalsToFilter.add(key);
+ }
+ }
+
+ static class Variable {
+ IFile f;
+ String name;
+ String basename;
+
+ public Variable(String name, String basename, IFile f) {
+ this.name = name;
+ this.basename = basename;
+ this.f = f;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getBasename() {
+ return basename;
+ }
+
+ public Collection<String> getKeys() {
+ TreeSet<String> result = new TreeSet<String>();
+ IModelNature n = EclipseResourceUtil.getModelNature(f.getProject());
+ if(n == null) return result;
+ XModel model = n.getModel();
+
+ List l = WebPromptingProvider.getInstance().getList(model, WebPromptingProvider.JSF_BUNDLE_PROPERTIES, basename, null);
+ for (int i = 0; i < l.size(); i++) {
+ result.add(l.get(i).toString());
+ }
+ return result;
+ }
+ }
+
+}
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 6 months
JBoss Tools SVN: r16139 - trunk/portlet/docs/reference/en/modules.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2009-06-23 10:04:22 -0400 (Tue, 23 Jun 2009)
New Revision: 16139
Modified:
trunk/portlet/docs/reference/en/modules/installation.xml
Log:
JBDS-670 broken link is fixed
Modified: trunk/portlet/docs/reference/en/modules/installation.xml
===================================================================
--- trunk/portlet/docs/reference/en/modules/installation.xml 2009-06-23 13:56:25 UTC (rev 16138)
+++ trunk/portlet/docs/reference/en/modules/installation.xml 2009-06-23 14:04:22 UTC (rev 16139)
@@ -20,7 +20,7 @@
<listitem>
<para>Next, download the JBoss Portal + JBoss AS bundle from <ulink
- url="http://www.jboss.org/jbossportal/download.html">JBoss Portal Download
+ url="http://www.jboss.org/jbossportal/download/index.html">JBoss Portal Download
page</ulink></para>
<note>
15 years, 6 months
JBoss Tools SVN: r16138 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2009-06-23 09:56:25 -0400 (Tue, 23 Jun 2009)
New Revision: 16138
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
Log:
JBIDE-4390: EL isn't highlighted while making OpenOn action on JSP pages.
The problem is that class org.eclipse.jst.jsp.ui.StructuredTextViewerConfigurationJSP class is probably modified in WTP 3.1M7. So, it doesn't define the LineStyleProvider for the partitionType == "org.eclipse.jst.jsp.SCRIPT.JSP_EL2". This breaks the text regions styling (underlining for our case) for #{...} -like EL regions.
The workaround is performed by providing a "org.eclipse.jst.jsp.SCRIPT.JSP_EL"-like LineStyleProvider for "org.eclipse.jst.jsp.SCRIPT.JSP_EL2" partitions
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2009-06-23 12:40:54 UTC (rev 16137)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2009-06-23 13:56:25 UTC (rev 16138)
@@ -22,9 +22,12 @@
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jst.jsp.core.text.IJSPPartitions;
import org.eclipse.jst.jsp.ui.StructuredTextViewerConfigurationJSP;
+import org.eclipse.jst.jsp.ui.internal.style.jspel.LineStyleProviderForJSPEL;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.wst.css.core.text.ICSSPartitions;
import org.eclipse.wst.html.core.text.IHTMLPartitions;
+import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
import org.eclipse.wst.xml.core.text.IXMLPartitions;
import org.osgi.framework.Bundle;
@@ -94,7 +97,50 @@
return (IContentAssistProcessor[])processors.toArray(new IContentAssistProcessor[0]);
}
+
/*
+ * JBIDE-4390:
+ * The line style provider for partition type == "org.eclipse.jst.jsp.SCRIPT.JSP_EL2",
+ * which is ommitted (forgotten ?) in superclass
+ */
+ private LineStyleProvider fLineStyleProviderForJSPEL2;
+
+ /*
+ * JBIDE-4390:
+ * The method is overriden to provide a line style provider for partition type == "org.eclipse.jst.jsp.SCRIPT.JSP_EL2",
+ * which is ommitted (forgotten ?) in superclass
+ */
+ private LineStyleProvider getLineStyleProviderForJSPEL2() {
+ if (fLineStyleProviderForJSPEL2 == null) {
+ fLineStyleProviderForJSPEL2 = new LineStyleProviderForJSPEL();
+ }
+ return fLineStyleProviderForJSPEL2;
+ }
+
+ /*
+ * JBIDE-4390:
+ * The method is overriden to provide a line style provider for partition type == "org.eclipse.jst.jsp.SCRIPT.JSP_EL2",
+ * which is ommitted (forgotten ?) in superclass
+ *
+ *
+ * (non-Javadoc)
+ * @see org.eclipse.jst.jsp.ui.StructuredTextViewerConfigurationJSP#getLineStyleProviders(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
+ */
+ public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
+ LineStyleProvider[] providers = null;
+
+ if (partitionType == IJSPPartitions.JSP_DEFAULT_EL2) {
+ providers = new LineStyleProvider[]{getLineStyleProviderForJSPEL2()};
+ }
+ else {
+ providers = super.getLineStyleProviders(sourceViewer, partitionType);
+ }
+
+ return providers;
+ }
+
+
+ /*
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
* @since 3.1
*/
15 years, 6 months
JBoss Tools SVN: r16136 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-06-23 07:32:41 -0400 (Tue, 23 Jun 2009)
New Revision: 16136
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2920 getResourceBundles implemented
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-06-23 11:31:50 UTC (rev 16135)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-06-23 11:32:41 UTC (rev 16136)
@@ -15,6 +15,8 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.IContextInformation;
@@ -25,24 +27,30 @@
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
+import org.eclipse.wst.xml.core.internal.document.NodeContainer;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
+import org.jboss.tools.jst.jsp.support.kb.WTPTextJspKbConnector.LoadBundleInfo;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
import org.jboss.tools.jst.web.kb.internal.JspContextImpl;
+import org.jboss.tools.jst.web.kb.internal.ResourceBundle;
import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.jboss.tools.jst.web.kb.taglib.ITagLibrary;
import org.jboss.tools.jst.web.kb.taglib.TagLibriryManager;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
public class JspContentAssistProcessor extends XmlContentAssistProcessor {
@@ -59,11 +67,11 @@
JspContextImpl context = new JspContextImpl();
context.setResource(superContext.getResource());
context.setElResolvers(superContext.getElResolvers());
+ context.setDocument(getDocument());
setVars(context);
- context.setResourceBundles(getResourceBundles());
- context.setDocument(getDocument());
setNameSpaces(context);
context.setLibraries(getTagLibraries(context));
+ context.setResourceBundles(getResourceBundles(context));
return context;
}
@@ -153,11 +161,72 @@
*
* @return
*/
- protected IResourceBundle[] getResourceBundles() {
- // TODO
- return null;
+ protected IResourceBundle[] getResourceBundles(IPageContext context) {
+ List<IResourceBundle> list = new ArrayList<IResourceBundle>();
+ IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
+ if (sModel == null)
+ return new IResourceBundle[0];
+ try {
+ Document dom = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel).getDocument() : null;
+ if (dom != null) {
+ Element element = dom.getDocumentElement();
+ NodeList children = (NodeContainer)dom.getChildNodes();
+ if (element != null) {
+ for (int i = 0; children != null && i < children.getLength(); i++) {
+ IDOMNode xmlnode = (IDOMNode)children.item(i);
+ update((IDOMNode)xmlnode, context, list);
+ }
+ }
+ }
+ }
+ finally {
+ if (sModel != null) {
+ sModel.releaseFromRead();
+ }
+ }
+
+ return list.toArray(new IResourceBundle[list.size()]);
}
+
+ private void update(IDOMNode element, IPageContext context, List<IResourceBundle> list) {
+ if (element != null) {
+ registerBundleForNode(element, context, list);
+ for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child instanceof IDOMNode) {
+ update((IDOMNode)child, context, list);
+ }
+ }
+ }
+ }
+ private void registerBundleForNode(IDOMNode node, IPageContext context, List<IResourceBundle> list) {
+ if (node == null) return;
+ String name = node.getNodeName();
+ if (name == null) return;
+ if (!name.endsWith("loadBundle")) return;
+ if (name.indexOf(':') == -1) return;
+ String prefix = name.substring(0, name.indexOf(':'));
+
+ Map<String, INameSpace> ns = context.getNameSpaces(node.getStartOffset());
+ if (!containsPrefix(ns, prefix)) return;
+
+ NamedNodeMap attributes = node.getAttributes();
+ if (attributes == null) return;
+ String basename = (attributes.getNamedItem("basename") == null ? null : attributes.getNamedItem("basename").getNodeValue());
+ String var = (attributes.getNamedItem("var") == null ? null : attributes.getNamedItem("var").getNodeValue());
+ if (basename == null || basename.length() == 0 ||
+ var == null || var.length() == 0) return;
+
+ list.add(new ResourceBundle(basename, var));
+ }
+ private boolean containsPrefix(Map<String, INameSpace> ns, String prefix) {
+ for (INameSpace n: ns.values()) {
+ if(prefix.equals(n.getPrefix())) return true;
+ }
+ return false;
+ }
+
+
/**
* Returns the <code>org.jboss.tools.common.el.core.resolver.ELContext</code> instance
*
15 years, 6 months
JBoss Tools SVN: r16135 - trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-06-23 07:31:50 -0400 (Tue, 23 Jun 2009)
New Revision: 16135
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/ResourceBundle.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2808
Added: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/ResourceBundle.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/ResourceBundle.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/ResourceBundle.java 2009-06-23 11:31:50 UTC (rev 16135)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jst.web.kb.internal;
+
+import org.jboss.tools.jst.web.kb.IResourceBundle;
+
+public class ResourceBundle implements IResourceBundle {
+ String basename;
+ String var;
+
+ public ResourceBundle(String basename, String var) {
+ this.basename = basename;
+ this.var = var;
+ }
+
+ public String getBasename() {
+ return basename;
+ }
+
+ public String getVar() {
+ return var;
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/ResourceBundle.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 6 months
JBoss Tools SVN: r16133 - in trunk/as/plugins: org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-06-23 05:47:04 -0400 (Tue, 23 Jun 2009)
New Revision: 16133
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.core/META-INF/MANIFEST.MF
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java
trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java
Log:
Export a package in override.core.
Further development on the property page... specifically removing the first column and making sure everything still turns up properly with the extra information for the remaining columns. ArchiveName can now also be set for all reference types instead of only allowing deploy path
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.core/META-INF/MANIFEST.MF 2009-06-23 09:22:43 UTC (rev 16132)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.core/META-INF/MANIFEST.MF 2009-06-23 09:47:04 UTC (rev 16133)
@@ -9,3 +9,4 @@
org.eclipse.wst.server.core;bundle-version="1.1.101"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.jboss.ide.eclipse.as.wtp.override.core.modules
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-06-23 09:22:43 UTC (rev 16132)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/AddModuleDependenciesPropertiesPage.java 2009-06-23 09:47:04 UTC (rev 16133)
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.jboss.ide.eclipse.as.wtp.override.ui.propertypage;
+import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -96,9 +97,8 @@
public class AddModuleDependenciesPropertiesPage implements Listener,
IModuleDependenciesControl {
- private static final String REFERENCE_PROPERTY = new Integer(0).toString();
- private static final String DEPLOY_PATH_PROPERTY = new Integer(1).toString();
- private static final String SOURCE_PROPERTY = new Integer(2).toString();
+ private static final String DEPLOY_PATH_PROPERTY = new Integer(0).toString();
+ private static final String SOURCE_PROPERTY = new Integer(1).toString();
protected final String PATH_SEPARATOR = ComponentDependencyContentProvider.PATH_SEPARATOR;
@@ -349,15 +349,21 @@
}
protected boolean canEdit(Object data) {
- return !(data != null && data instanceof VirtualArchiveComponent
- && isPhysicallyAdded((VirtualArchiveComponent)data));
+ if( data == null ) return false;
+ if( !(data instanceof VirtualArchiveComponent)) return true;
+
+ VirtualArchiveComponent d2 = (VirtualArchiveComponent)data;
+ boolean sameProject = d2.getWorkspaceRelativePath() != null
+ && d2.getWorkspaceRelativePath().segment(0)
+ .equals(rootComponent.getProject().getName());
+ return !(sameProject && isPhysicallyAdded(d2));
}
protected void addDoubleClickListener() {
availableComponentsViewer.setColumnProperties(new String[] {
- REFERENCE_PROPERTY, DEPLOY_PATH_PROPERTY, SOURCE_PROPERTY
- });
- CellEditor[] editors = new CellEditor[] { new TextCellEditor(),
+ DEPLOY_PATH_PROPERTY, SOURCE_PROPERTY });
+
+ CellEditor[] editors = new CellEditor[] {
new TextCellEditor(availableComponentsViewer.getTable()),
new TextCellEditor()};
availableComponentsViewer.setCellEditors(editors);
@@ -389,14 +395,7 @@
if( property.equals(DEPLOY_PATH_PROPERTY)) {
if (element instanceof VirtualArchiveComponent) {
try {
- boolean sameProject = ((VirtualArchiveComponent) element)
- .getWorkspaceRelativePath() != null
- && ((VirtualArchiveComponent) element)
- .getWorkspaceRelativePath().segment(0)
- .equals(
- rootComponent.getProject()
- .getName());
- return !(sameProject && isPhysicallyAdded(((VirtualArchiveComponent) element)));
+ return canEdit(element);
} catch (IllegalArgumentException iae) {
}
}
@@ -440,7 +439,10 @@
IProject selected = (IProject) d.getFirstResult();
Object selected2 = ModuleCoreNature.isFlexibleProject(selected) ?
ComponentCore.createComponent(selected) : selected;
- objectToRuntimePath.put(selected2, "/");
+ IPath path = new Path("/");
+ path = path.append(selected2 instanceof IVirtualComponent ?
+ getVirtualComponentNameWithExtension((IVirtualComponent)selected2) : selected.getName() + ".jar");
+ objectToRuntimePath.put(selected2, path.toString());
refresh();
TableItem[] items = availableComponentsViewer.getTable().getItems();
for (int i = 0; i < items.length; i++)
@@ -539,18 +541,19 @@
}
}
- // only add the archive as a potentialy new reference if it does not
- // already exist
- // also force check it
+ // only add the archive as a potentialy new reference
+ // if it does not already exist
if (!refAlreadyExists) {
- this.objectToRuntimePath.put(archive, new Path("/").toString());
+ String name = new Path(archive.getName()).lastSegment();
+ if( archive instanceof VirtualArchiveComponent &&
+ ((VirtualArchiveComponent)archive).getArchiveType()
+ .equals(VirtualArchiveComponent.VARARCHIVETYPE)) {
+ File f = ((VirtualArchiveComponent)archive).getUnderlyingDiskFile();
+ if( f != null )
+ name = new Path(f.getAbsolutePath()).lastSegment();
+ }
+ this.objectToRuntimePath.put(archive, new Path("/").append(name).toString());
availableComponentsViewer.add(archive);
- TableItem[] items = availableComponentsViewer.getTable().getItems();
- for (int i = 0; i < items.length; i++) {
- if (items[i].getData().equals(archive))
- items[i].setChecked(true);
- }
-
} else {
// TODO should inform user that they selected an already referenced
// archive?
@@ -622,24 +625,18 @@
// set up table layout
TableLayout tableLayout = new org.eclipse.jface.viewers.TableLayout();
- tableLayout.addColumnData(new ColumnWeightData(300, true));
- tableLayout.addColumnData(new ColumnWeightData(300, true));
- tableLayout.addColumnData(new ColumnWeightData(200, true));
+ tableLayout.addColumnData(new ColumnWeightData(400, true));
+ tableLayout.addColumnData(new ColumnWeightData(500, true));
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
availableComponentsViewer.setSorter(null);
- // table columns
- TableColumn fileNameColumn = new TableColumn(table, SWT.NONE, 0);
- fileNameColumn.setText("Reference");
- fileNameColumn.setResizable(true);
-
- TableColumn bndColumn = new TableColumn(table, SWT.NONE, 1);
+ TableColumn bndColumn = new TableColumn(table, SWT.NONE, 0);
bndColumn.setText("Deploy Path");
bndColumn.setResizable(true);
- TableColumn projectColumn = new TableColumn(table, SWT.NONE, 2);
+ TableColumn projectColumn = new TableColumn(table, SWT.NONE, 1);
projectColumn.setText("Source");
projectColumn.setResizable(true);
@@ -711,9 +708,10 @@
protected void initialize() {
IVirtualReference[] refs = rootComponent.getReferences();
IVirtualComponent comp;
- for( int i = 0; i < refs.length; i++ ) {
+ for( int i = 0; i < refs.length; i++ ) {
comp = refs[i].getReferencedComponent();
- String val = refs[i].getRuntimePath().toString();
+ String archiveName = refs[i].getArchiveName();
+ String val = refs[i].getRuntimePath().append(refs[i].getArchiveName()).toString();
objectToRuntimePath.put(comp, val);
oldComponentToRuntimePath.put((IVirtualComponent) comp, val);
}
@@ -848,13 +846,20 @@
}
protected IDataModelOperation getRemoveComponentOperation(IVirtualComponent component) {
+ String path, archiveName;
+ path = new Path(oldComponentToRuntimePath.get(component)).removeLastSegments(1).toString();
+ archiveName = new Path(oldComponentToRuntimePath.get(component)).lastSegment();
+
IDataModelProvider provider = getRemoveReferenceDataModelProvider(component);
IDataModel model = DataModelFactory.createDataModel(provider);
model.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, rootComponent);
List modHandlesList = (List) model.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
modHandlesList.add(component);
model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modHandlesList);
- model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, oldComponentToRuntimePath.get(component));
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
+ Map uriMap = new HashMap();
+ uriMap.put(component, archiveName);
+ model.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
return model.getDefaultOperation();
}
@@ -909,10 +914,11 @@
Iterator<IProject> i = projects.iterator();
IProject proj;
Set moduleProjects = new HashSet();
- String path;
+ String path, archiveName;
while(i.hasNext()) {
proj = i.next();
- path = objectToRuntimePath.get(proj);
+ path = new Path(objectToRuntimePath.get(proj)).removeLastSegments(1).toString();
+ archiveName = new Path(objectToRuntimePath.get(proj)).lastSegment();
try {
moduleProjects.add(proj);
IDataModel migrationdm = DataModelFactory.createDataModel(new JavaProjectMigrationDataModelProvider());
@@ -930,10 +936,10 @@
refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, targetCompList);
refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
+ Map uriMap = new HashMap();
+ uriMap.put(targetcomponent, archiveName);
+ refdm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
- // referenced java projects should have archiveName attribute
- ((Map)refdm.getProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP)).put(targetcomponent, proj.getName().replace(' ', '_') + IJ2EEModuleConstants.JAR_EXT);
-
refdm.getDefaultOperation().execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
J2EEUIPlugin.logError(e);
@@ -957,6 +963,10 @@
}
protected void addOneComponent(IVirtualComponent component) throws CoreException {
+ String path, archiveName;
+ path = new Path(objectToRuntimePath.get(component)).removeLastSegments(1).toString();
+ archiveName = new Path(objectToRuntimePath.get(component)).lastSegment();
+
IDataModelProvider provider = getAddReferenceDataModelProvider(component);
IDataModel dm = DataModelFactory.createDataModel(provider);
@@ -965,9 +975,9 @@
//[Bug 238264] the uri map needs to be manually set correctly
Map uriMap = new HashMap();
- uriMap.put(component, getVirtualComponentNameWithExtension(component));
+ uriMap.put(component, archiveName);
dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_TO_URI_MAP, uriMap);
- dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, objectToRuntimePath.get(component));
+ dm.setProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH, path);
IStatus stat = dm.validateProperty(ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
if (stat != OK_STATUS)
@@ -985,7 +995,7 @@
* @param virtComp the IVirtualComponent to get the name of with the correct extension
* @return the name of the given IVirtualComponent with the correct extension
*/
- private String getVirtualComponentNameWithExtension(IVirtualComponent virtComp) {
+ protected String getVirtualComponentNameWithExtension(IVirtualComponent virtComp) {
String virtCompURIMapName = this.getURIMappingName(virtComp);
boolean linkedToEAR = true;
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java 2009-06-23 09:22:43 UTC (rev 16132)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.wtp.override.ui/src/org/jboss/ide/eclipse/as/wtp/override/ui/propertypage/ComponentDependencyContentProvider.java 2009-06-23 09:47:04 UTC (rev 16133)
@@ -30,8 +30,8 @@
* are IProject or IVirtualComponent objects. The runtime paths portion is
* shared with the preference page itself where they can both modify the data.
*
- * The pref page should initialize its data first so that this provider can
- * spit out the proper information.
+ * This provider no longer "meddles" in to the content as it used to,
+ * but rather serves as only a view of it.
*/
public class ComponentDependencyContentProvider extends LabelProvider implements IStructuredContentProvider, ITableLabelProvider {
@@ -61,24 +61,22 @@
public String getColumnText(Object element, int columnIndex) {
if (element instanceof IVirtualComponent) {
IVirtualComponent comp = (IVirtualComponent)element;
- if( columnIndex == 0 ){
- return comp.getName();
- } else if (columnIndex == 1) {
+ if (columnIndex == 0) {
if( runtimePaths == null || runtimePaths.get(element) == null) {
return new Path(PATH_SEPARATOR).toString();
}
return runtimePaths.get(element);
- } else if (columnIndex == 2) {
+ } else if (columnIndex == 1) {
return comp.getProject().getName();
}
} else if (element instanceof IProject){
- if (columnIndex != 1) {
- return ((IProject)element).getName();
- } else {
+ if (columnIndex == 0) {
if( runtimePaths == null || runtimePaths.get(element) == null) {
return new Path(PATH_SEPARATOR).toString();
}
return runtimePaths.get(element);
+ } else {
+ return ((IProject)element).getName();
}
}
return null;
15 years, 6 months