JBoss Tools SVN: r3967 - in branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp: src/org/jboss/tools/jst/jsp and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: ayukhovich
Date: 2007-10-02 11:36:48 -0400 (Tue, 02 Oct 2007)
New Revision: 3967
Added:
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/TLDEditorDocumentManager.java
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/XHTMLTaglibController.java
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/ModelHandlerForXHTML.java
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/XHTMLModelLoader.java
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/ModelQueryAdapterFactoryForXHTML.java
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/XHTMLModelQueryCMProvider.java
Modified:
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java
branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java
Log:
Initial commit
Modified: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties 2007-10-02 15:34:02 UTC (rev 3966)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/plugin.properties 2007-10-02 15:36:48 UTC (rev 3967)
@@ -7,3 +7,4 @@
occurrenceStructureProvidersExtensionPoint= Occurrence Structure Providers
defaultOccurrenceStructureProviderName= Default Occurrence Provider
+%Structured_XHTML_Document_Setup_participant.name=XHTML
Modified: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2007-10-02 15:34:02 UTC (rev 3966)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2007-10-02 15:36:48 UTC (rev 3967)
@@ -105,6 +105,23 @@
id="org.eclipse.wst.sse.ui.preferences.jsp.occurrences">
</page>
</extension>
+
+ <extension
+ id="XHTML_Document_Setup"
+ name="XHTML_Document_Setup"
+ point="org.eclipse.core.filebuffers.documentSetup">
+ <participant
+ extensions="xhtml"
+ class="org.jboss.tools.jst.jsp.jspeditor.XHTMLTaglibController" />
+ </extension>
+
+ <extension point="org.eclipse.wst.sse.core.modelHandler">
+ <modelHandler
+ class="org.jboss.tools.jst.jsp.modelhandler.ModelHandlerForXHTML"
+ associatedContentTypeId="org.eclipse.wst.html.core.htmlsource"
+ id="org.jboss.tools.jst.jsp.modelhandler.xhtml">
+ </modelHandler>
+ </extension>
<extension point="org.eclipse.ui.editors">
<editor
@@ -117,7 +134,8 @@
matchingStrategy = "org.jboss.tools.common.core.resources.MatchingStrategyImpl"
extensions="jsp, jsf, jspf, jspx, tag, tagf, inc">
<contentTypeBinding contentTypeId="org.eclipse.jst.jsp.core.jspsource"/>
- </editor>
+ </editor>
+
<editor
class="org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor"
contributorClass="org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageContributor"
@@ -147,7 +165,8 @@
id="StructureSelectNext"
label="Next Element">
</action>
- </editorContribution>
+ </editorContribution>
+
<editorContribution
id="ACleanupDocument"
targetID="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor">
@@ -300,6 +319,6 @@
class="org.jboss.tools.jst.jsp.outline.JSPCellEditorProviderImpl"/>
<xclass id="org.jboss.tools.jst.jsp.outline.VpeProperties"
class="org.jboss.tools.jst.jsp.outline.VpeProperties"/>
- </extension>
+ </extension>
-</plugin>
\ No newline at end of file
+</plugin>
Modified: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java 2007-10-02 15:34:02 UTC (rev 3966)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatHtmlContentAssistProcessor.java 2007-10-02 15:36:48 UTC (rev 3967)
@@ -20,11 +20,11 @@
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.wst.html.core.internal.contentmodel.HTMLElementDeclaration;
+import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties;
import org.eclipse.wst.html.ui.internal.HTMLUIPlugin;
import org.eclipse.wst.html.ui.internal.contentassist.HTMLContentAssistProcessor;
import org.eclipse.wst.html.ui.internal.preferences.HTMLUIPreferenceNames;
@@ -32,13 +32,19 @@
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
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.contentmodel.modelquery.ModelQueryAction;
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
import org.eclipse.wst.xml.core.internal.document.AttrImpl;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.eclipse.wst.xml.ui.internal.contentassist.NonValidatingModelQueryAction;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
@@ -56,6 +62,8 @@
import org.jboss.tools.common.reporting.ProblemReportingHelper;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.editor.TLDRegisterHelper;
+import org.jboss.tools.jst.jsp.jspeditor.TLDEditorDocumentManager;
+import org.jboss.tools.jst.jsp.jspeditor.XHTMLTaglibController;
import org.jboss.tools.jst.jsp.outline.ValueHelper;
import org.jboss.tools.jst.jsp.support.kb.FaceletsJsfCResource;
import org.jboss.tools.jst.jsp.support.kb.WTPKbdBeanMethodResource;
@@ -69,6 +77,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* @author Igels
@@ -398,6 +407,11 @@
} catch(Exception e) {
JspEditorPlugin.getPluginLog().logError(e);
}
+
+ if (kbProposals.size() == 0) {
+
+ }
+
for (Iterator iter = kbProposals.iterator(); iter.hasNext();) {
KbProposal kbProposal = (KbProposal) iter.next();
if(ignoreProposal(kbProposal)) {
@@ -481,7 +495,7 @@
public void updateActiveContentAssistProcessor(IDocument document) {
if(tldManager==null) {
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
+ TLDEditorDocumentManager manager = XHTMLTaglibController.getTLDCMDocumentManager(document);
if (manager != null) {
List list = manager.getTaglibTrackers();
for(int i=0; i<list.size(); i++) {
@@ -539,4 +553,93 @@
jspActiveCAP = new JSPActiveContentAssistProcessor();
jspActiveCAP.init();
}
+
+ protected List getAvailableChildrenAtIndex(Element parent, int index, int validityChecking) {
+ List list = new ArrayList();
+ List additionalElements = getAdditionalChildren(new ArrayList(), parent, index);
+ for (int i = 0; i < additionalElements.size(); i++) {
+ ModelQueryAction insertAction = new NonValidatingModelQueryAction((CMElementDeclaration) additionalElements.get(i), ModelQueryAction.INSERT, 0, parent.getChildNodes().getLength(), null);
+ list.add(insertAction);
+ }
+
+ // add allowed children of implicit tags that don't already exist
+ NodeList children = parent.getChildNodes();
+ List childNames = new ArrayList();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ childNames.add(child.getNodeName().toLowerCase());
+ }
+ }
+ List allActions = new ArrayList();
+ Iterator iterator = list.iterator();
+ ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
+ while (iterator.hasNext()) {
+ ModelQueryAction action = (ModelQueryAction) iterator.next();
+ allActions.add(action);
+ if (action.getCMNode() instanceof HTMLElementDeclaration) {
+ HTMLElementDeclaration ed = (HTMLElementDeclaration) action.getCMNode();
+ String ommission = (String) ed.getProperty(HTMLCMProperties.OMIT_TYPE);
+ if (!childNames.contains(ed.getNodeName().toLowerCase()) && ((ommission != null) && (ommission.equals(HTMLCMProperties.Values.OMIT_BOTH)))) {
+ List implicitValidActions = new ArrayList();
+ modelQuery.getInsertActions(parent, ed, 0, ModelQuery.INCLUDE_CHILD_NODES, ModelQuery.VALIDITY_NONE, implicitValidActions);
+ if (implicitValidActions != null) {
+ Iterator implicitValidActionsIterator = implicitValidActions.iterator();
+ while (implicitValidActionsIterator.hasNext()) {
+ ModelQueryAction insertAction = new NonValidatingModelQueryAction(((ModelQueryAction) implicitValidActionsIterator.next()).getCMNode(), ModelQueryAction.INSERT, 0, parent.getChildNodes().getLength(), null);
+ allActions.add(insertAction);
+ }
+ }
+ }
+ }
+ }
+ return allActions;
+ }
+
+ private List getAdditionalChildren(List elementDecls, Node node, int childIndex) {
+ if (node instanceof IDOMNode) {
+ /*
+ * find the location of the intended insertion as it will give us
+ * the correct offset for checking position dependent CMDocuments
+ */
+ int textInsertionOffset = 0;
+ NodeList children = node.getChildNodes();
+ if (children.getLength() >= childIndex && childIndex >= 0) {
+ Node nodeAlreadyAtIndex = children.item(childIndex);
+ if (nodeAlreadyAtIndex instanceof IDOMNode)
+ textInsertionOffset = ((IDOMNode) nodeAlreadyAtIndex).getEndOffset();
+ }
+ else {
+ textInsertionOffset = ((IDOMNode) node).getStartOffset();
+ }
+ TLDEditorDocumentManager mgr = XHTMLTaglibController.getTLDCMDocumentManager(((IDOMNode) node).getStructuredDocument());
+ if (mgr != null) {
+ List moreCMDocuments = mgr.getCMDocumentTrackers(textInsertionOffset);
+ if (moreCMDocuments != null) {
+ for (int i = 0; i < moreCMDocuments.size(); i++) {
+ CMDocument doc = (CMDocument) moreCMDocuments.get(i);
+ CMNamedNodeMap elements = doc.getElements();
+ if (elements != null) {
+ for (int j = 0; j < elements.getLength(); j++) {
+ CMElementDeclaration ed = (CMElementDeclaration) elements.item(j);
+ elementDecls.add(ed);
+ }
+ }
+ }
+ }
+ }
+
+ // get position dependent CMDocuments and insert their tags as
+ // proposals
+
+ ModelQueryAdapter mqAdapter = null;
+ if (node.getNodeType() == Node.DOCUMENT_NODE)
+ mqAdapter = (ModelQueryAdapter) ((IDOMNode) node).getAdapterFor(ModelQueryAdapter.class);
+ else
+ mqAdapter = (ModelQueryAdapter) ((IDOMNode) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
+ }
+ return elementDecls;
+ }
+
}
Modified: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java 2007-10-02 15:34:02 UTC (rev 3966)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/RedHatJSPContentAssistProcessor.java 2007-10-02 15:36:48 UTC (rev 3967)
@@ -23,12 +23,17 @@
import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+import org.eclipse.jst.jsp.core.internal.provisional.JSP12Namespace;
+import org.eclipse.jst.jsp.core.internal.provisional.JSP20Namespace;
import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
import org.eclipse.jst.jsp.ui.internal.contentassist.JSPContentAssistProcessor;
import org.eclipse.jst.jsp.ui.internal.preferences.JSPUIPreferenceNames;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.css.ui.internal.contentassist.CSSContentAssistProcessor;
+import org.eclipse.wst.html.core.internal.contentmodel.HTMLElementDeclaration;
+import org.eclipse.wst.html.core.internal.contentmodel.JSPCMDocument;
+import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties;
import org.eclipse.wst.javascript.ui.internal.common.contentassist.JavaScriptContentAssistProcessor;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
@@ -37,15 +42,21 @@
import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
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.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.eclipse.wst.xml.ui.internal.contentassist.NonValidatingModelQueryAction;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLContentModelGenerator;
import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
@@ -61,6 +72,8 @@
import org.jboss.tools.common.kb.wtp.TLDVersionHelper;
import org.jboss.tools.common.kb.wtp.WtpKbConnector;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.jsp.jspeditor.TLDEditorDocumentManager;
+import org.jboss.tools.jst.jsp.jspeditor.XHTMLTaglibController;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.jst.web.tld.VpeTaglibListener;
@@ -69,6 +82,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* @author Igels
@@ -196,7 +210,7 @@
public void updateActiveContentAssistProcessor(IDocument document) {
unregisterTagsFromActiveCAP();
if(tldManager == null) {
- TLDCMDocumentManager manager = TaglibController.getTLDCMDocumentManager(document);
+ TLDEditorDocumentManager manager = XHTMLTaglibController.getTLDCMDocumentManager(document);
if (manager != null) {
List list = manager.getTaglibTrackers();
for(int i=0; i<list.size(); i++) {
@@ -622,4 +636,93 @@
private boolean isCommentNode(IDOMNode node) {
return (node != null && node instanceof IDOMElement && ((IDOMElement) node).isCommentTag());
}
-}
\ No newline at end of file
+
+ protected List getAvailableChildrenAtIndex(Element parent, int index, int validityChecking) {
+ List list = new ArrayList();
+ List additionalElements = getAdditionalChildren(new ArrayList(), parent, index);
+ for (int i = 0; i < additionalElements.size(); i++) {
+ ModelQueryAction insertAction = new NonValidatingModelQueryAction((CMElementDeclaration) additionalElements.get(i), ModelQueryAction.INSERT, 0, parent.getChildNodes().getLength(), null);
+ list.add(insertAction);
+ }
+
+ // add allowed children of implicit tags that don't already exist
+ NodeList children = parent.getChildNodes();
+ List childNames = new ArrayList();
+ if (children != null) {
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ childNames.add(child.getNodeName().toLowerCase());
+ }
+ }
+ List allActions = new ArrayList();
+ Iterator iterator = list.iterator();
+ ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
+ while (iterator.hasNext()) {
+ ModelQueryAction action = (ModelQueryAction) iterator.next();
+ allActions.add(action);
+ if (action.getCMNode() instanceof HTMLElementDeclaration) {
+ HTMLElementDeclaration ed = (HTMLElementDeclaration) action.getCMNode();
+ String ommission = (String) ed.getProperty(HTMLCMProperties.OMIT_TYPE);
+ if (!childNames.contains(ed.getNodeName().toLowerCase()) && ((ommission != null) && (ommission.equals(HTMLCMProperties.Values.OMIT_BOTH)))) {
+ List implicitValidActions = new ArrayList();
+ modelQuery.getInsertActions(parent, ed, 0, ModelQuery.INCLUDE_CHILD_NODES, ModelQuery.VALIDITY_NONE, implicitValidActions);
+ if (implicitValidActions != null) {
+ Iterator implicitValidActionsIterator = implicitValidActions.iterator();
+ while (implicitValidActionsIterator.hasNext()) {
+ ModelQueryAction insertAction = new NonValidatingModelQueryAction(((ModelQueryAction) implicitValidActionsIterator.next()).getCMNode(), ModelQueryAction.INSERT, 0, parent.getChildNodes().getLength(), null);
+ allActions.add(insertAction);
+ }
+ }
+ }
+ }
+ }
+ return allActions;
+ }
+
+ private List getAdditionalChildren(List elementDecls, Node node, int childIndex) {
+ if (node instanceof IDOMNode) {
+ /*
+ * find the location of the intended insertion as it will give us
+ * the correct offset for checking position dependent CMDocuments
+ */
+ int textInsertionOffset = 0;
+ NodeList children = node.getChildNodes();
+ if (children.getLength() >= childIndex && childIndex >= 0) {
+ Node nodeAlreadyAtIndex = children.item(childIndex);
+ if (nodeAlreadyAtIndex instanceof IDOMNode)
+ textInsertionOffset = ((IDOMNode) nodeAlreadyAtIndex).getEndOffset();
+ }
+ else {
+ textInsertionOffset = ((IDOMNode) node).getStartOffset();
+ }
+ TLDEditorDocumentManager mgr = XHTMLTaglibController.getTLDCMDocumentManager(((IDOMNode) node).getStructuredDocument());
+ if (mgr != null) {
+ List moreCMDocuments = mgr.getCMDocumentTrackers(textInsertionOffset);
+ if (moreCMDocuments != null) {
+ for (int i = 0; i < moreCMDocuments.size(); i++) {
+ CMDocument doc = (CMDocument) moreCMDocuments.get(i);
+ CMNamedNodeMap elements = doc.getElements();
+ if (elements != null) {
+ for (int j = 0; j < elements.getLength(); j++) {
+ CMElementDeclaration ed = (CMElementDeclaration) elements.item(j);
+ elementDecls.add(ed);
+ }
+ }
+ }
+ }
+ }
+
+ // get position dependent CMDocuments and insert their tags as
+ // proposals
+
+ ModelQueryAdapter mqAdapter = null;
+ if (node.getNodeType() == Node.DOCUMENT_NODE)
+ mqAdapter = (ModelQueryAdapter) ((IDOMNode) node).getAdapterFor(ModelQueryAdapter.class);
+ else
+ mqAdapter = (ModelQueryAdapter) ((IDOMNode) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
+ }
+ return elementDecls;
+ }
+
+}
Added: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/TLDEditorDocumentManager.java
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/TLDEditorDocumentManager.java (rev 0)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/TLDEditorDocumentManager.java 2007-10-02 15:36:48 UTC (rev 3967)
@@ -0,0 +1,840 @@
+/*******************************************************************************
+ * 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.jsp.jspeditor;
+
+import java.io.File;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Stack;
+
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.JSP11TLDNames;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.JSP12TLDNames;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.JSP20TLDNames;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument;
+import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration;
+import org.eclipse.jst.jsp.core.internal.regions.DOMJSPRegionContexts;
+import org.eclipse.jst.jsp.core.taglib.IJarRecord;
+import org.eclipse.jst.jsp.core.taglib.ITLDRecord;
+import org.eclipse.jst.jsp.core.taglib.ITagDirRecord;
+import org.eclipse.jst.jsp.core.taglib.ITaglibIndexDelta;
+import org.eclipse.jst.jsp.core.taglib.ITaglibIndexListener;
+import org.eclipse.jst.jsp.core.taglib.ITaglibRecord;
+import org.eclipse.jst.jsp.core.taglib.IURLRecord;
+import org.eclipse.jst.jsp.core.taglib.TaglibIndex;
+import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
+import org.eclipse.wst.sse.core.internal.ltk.parser.BlockMarker;
+import org.eclipse.wst.sse.core.internal.ltk.parser.StructuredDocumentRegionHandler;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
+import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser;
+import org.eclipse.wst.xml.core.internal.parser.regions.AttributeNameRegion;
+import org.eclipse.wst.xml.core.internal.parser.regions.AttributeValueRegion;
+import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
+import org.eclipse.wst.xml.core.internal.text.XMLStructuredDocumentRegion;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.project.IModelNature;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+import org.jboss.tools.jst.web.project.WebProject;
+import org.jboss.tools.jst.web.tld.TaglibMapping;
+
+/**
+ * @author Sergey Vasilyev (svasilyev(a)exadel.com))
+ *
+ */
+public class TLDEditorDocumentManager implements ITaglibIndexListener, IDocumentListener {
+
+ class DirectiveStructuredDocumentRegionHandler implements StructuredDocumentRegionHandler {
+
+ public void nodeParsed(
+ IStructuredDocumentRegion coreStructuredDocumentRegion) {
+ if (coreStructuredDocumentRegion.getNumberOfRegions() > 4
+ && (coreStructuredDocumentRegion.getType() == DOMRegionContext.XML_TAG_NAME || coreStructuredDocumentRegion
+ .getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME)) {
+ parseXmlns(coreStructuredDocumentRegion);
+ }
+ }
+
+ public void resetNodes() {
+ }
+ }
+
+ /**
+ * An entry in the shared cache map
+ */
+ static class TLDCacheEntry {
+ CMDocument document;
+ long modificationStamp;
+ int referenceCount;
+ }
+
+ private static class TLDCMDocumentDescriptor {
+ Object cacheKey;
+ CMDocument document;
+
+ TLDCMDocumentDescriptor() {
+ super();
+ }
+ }
+
+ private class TLDCMDocumentReference {
+ String prefix;
+ String uri;
+ }
+
+ private XMLSourceParser sourceParser;
+ private DirectiveStructuredDocumentRegionHandler structuredDocumentRegionHandler;
+ private IStructuredDocument document;
+
+ private Stack<?> fIncludes = null;
+
+ /** banned prefixes */
+ protected static List<String> bannedPrefixes = null;
+ static {
+ bannedPrefixes = new ArrayList<String>();
+ }
+
+ private static Hashtable<Object, Object> fCache = null;
+
+ private CMDocumentFactoryTLD fCMDocumentBuilder = null;
+
+ /** list of listTaglibTrackers */
+ private List<TaglibTracker> listTaglibTrackers;
+
+ /**
+ * The locally-know list of CMDocuments
+ */
+ private Hashtable<?, ?> fDocuments = null;
+
+ public TLDEditorDocumentManager() {
+
+ }
+
+ public XMLSourceParser getSourceParser() {
+ return sourceParser;
+ }
+
+ public void setSourceParser(XMLSourceParser sourceParser) {
+ if (sourceParser != null) {
+ sourceParser
+ .removeStructuredDocumentRegionHandler(getStructuredDocumentRegionHandler());
+ }
+
+ this.sourceParser = sourceParser;
+
+ if (this.sourceParser != null) {
+ this.sourceParser
+ .addStructuredDocumentRegionHandler(getStructuredDocumentRegionHandler());
+ }
+
+ }
+
+ public DirectiveStructuredDocumentRegionHandler getStructuredDocumentRegionHandler() {
+ if (structuredDocumentRegionHandler == null) {
+ structuredDocumentRegionHandler = new DirectiveStructuredDocumentRegionHandler();
+ }
+
+ return structuredDocumentRegionHandler;
+ }
+
+ public IStructuredDocument getDocument() {
+ return document;
+ }
+
+ public void setDocument(IStructuredDocument document) {
+ this.document = document;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jst.jsp.core.taglib.ITaglibIndexListener#indexChanged(org.eclipse.jst.jsp.core.taglib.ITaglibIndexDelta)
+ */
+ public void indexChanged(ITaglibIndexDelta delta) {
+ }
+
+ public void documentAboutToBeChanged(DocumentEvent event) {
+ }
+
+ public void documentChanged(DocumentEvent event) {
+ Object document = event.fDocument;
+ if (document instanceof BasicStructuredDocument) {
+ BasicStructuredDocument bsDocument = (BasicStructuredDocument) document;
+ IStructuredDocumentRegionList o = bsDocument.getRegionList();
+ int countElements = o.getLength();
+
+ for (int i = 0; i < countElements; i++) {
+ IStructuredDocumentRegion element = o.item(i);
+ if (element.containsOffset(event.fOffset)) {
+ parseXmlns2(element);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("restriction")
+ public void parseXmlns(IStructuredDocumentRegion structuredDocumentRegion) {
+
+ ITextRegion name = structuredDocumentRegion.getRegions().get(1);
+ int startOffset = structuredDocumentRegion.getStartOffset(name);
+ String sName = getSourceParser().getText(startOffset,
+ name.getTextLength());
+
+ ITextRegionList regionList = structuredDocumentRegion.getRegions();
+
+ String attrName = null;
+ String attrValue = null;
+ String sTemp;
+ for (Iterator<?> iterator = regionList.iterator(); iterator.hasNext();) {
+ ITextRegion region = (ITextRegion) iterator.next();
+
+ startOffset = structuredDocumentRegion.getStartOffset(region);
+ sTemp = getSourceParser().getText(startOffset,
+ region.getTextLength());
+
+ if (region instanceof AttributeNameRegion) {
+ attrName = sTemp;
+ } else if (region instanceof AttributeValueRegion) {
+ attrValue = sTemp;
+ processXmlns(attrName, attrValue, structuredDocumentRegion);
+ }
+ }
+ }
+
+ @SuppressWarnings("restriction")
+ public void parseXmlns2(IStructuredDocumentRegion structuredDocumentRegion) {
+ ITextRegionList regionList = structuredDocumentRegion.getRegions();
+
+ String attrName = null;
+ String attrValue = null;
+ int startOffset = 0;
+ String sTemp;
+
+ for (Iterator<?> iterator = regionList.iterator(); iterator.hasNext();) {
+ ITextRegion region = (ITextRegion) iterator.next();
+
+ startOffset = structuredDocumentRegion.getStartOffset(region);
+ sTemp = structuredDocumentRegion.getText(region);
+
+ if (region instanceof AttributeNameRegion) {
+ attrName = sTemp;
+ } else if (region instanceof AttributeValueRegion) {
+ attrValue = sTemp;
+ processXmlns(attrName, attrValue, structuredDocumentRegion);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param prefix
+ * @param uri
+ * @param structuredDocumentRegion
+ */
+ private void processXmlns(String prefix, String uri, IStructuredDocumentRegion structuredDocumentRegion) {
+ if (prefix.startsWith("xmlns")) {
+ String tmpPrefix = "";
+
+ if (prefix.length() > 6) {
+ tmpPrefix = prefix.substring(6);
+ }
+ String tmpUri = StringUtils.strip(uri);
+ JspEditorPlugin.getPluginLog().logInfo("prefix " + tmpPrefix + " uri " + tmpUri);
+ enableTaglibFromURI(tmpPrefix, tmpUri, structuredDocumentRegion);
+ }
+ }
+
+ /**
+ *
+ * @param prefix
+ * @param uri
+ * @param anchorStructuredDocumentRegion
+ */
+ private void enableTags(String prefix, String uri,
+ IStructuredDocumentRegion anchorStructuredDocumentRegion) {
+ if (prefix == null || uri == null || bannedPrefixes.contains(prefix))
+ return;
+ // Try to load the CMDocument for this URI
+ CMDocument tld = getCMDocument(uri);
+ if (tld == null || !(tld instanceof TLDDocument)) {
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_MANAGER) {
+ JspEditorPlugin.getPluginLog().logInfo("TLDEditorDocumentManager failed to create a CMDocument for " + uri);
+ }
+ return;
+ }
+ registerTaglib(prefix, uri, anchorStructuredDocumentRegion, tld);
+ }
+
+ /**
+ * Derives an unique cache key for the give URI. The URI is "resolved" and a
+ * unique value generated from the result. This ensures that two different
+ * relative references from different files do not have overlapping TLD
+ * records in the shared cache if they don't resolve to the same TLD.
+ *
+ * @param uri
+ * @return
+ */
+ protected Object getCacheKey(String uri) {
+ ITaglibRecord record = TaglibIndex.resolve(getCurrentParserPath()
+ .toString(), uri, false);
+ if (record != null) {
+ return getUniqueIdentifier(record);
+ }
+ String location = URIResolverPlugin.createResolver().resolve( getCurrentBaseLocation().toString(), null, uri);
+ return location;
+ }
+
+ /**
+ * get the CMDocument at the uri (cached)
+ * @param uri
+ * @return the CMDocument at the uri (cached)
+ */
+ protected CMDocument getCMDocument(String uri) {
+ if (uri == null || uri.length() == 0)
+ return null;
+ String reference = uri;
+ Object cacheKey = getCacheKey(reference);
+ long lastModified = getModificationStamp(reference);
+ CMDocument doc = (CMDocument) getDocuments().get(cacheKey);
+ if (doc == null) {
+ /*
+ * If hasn't been moved into the local table, do so and increment
+ * the count. A local URI reference can be different depending on
+ * the file from which it was referenced. Use a computed key to keep
+ * them straight.
+ */
+ Object o = getSharedDocumentCache().get(cacheKey);
+ if (o != null) {
+ if (o instanceof TLDCacheEntry) {
+ TLDCacheEntry entry = (TLDCacheEntry) o;
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_CACHE) {
+ JspEditorPlugin.getPluginLog().logInfo("TLDCMDocument cache hit on " + cacheKey);
+ }
+ if (entry != null
+ && entry.modificationStamp != IResource.NULL_STAMP
+ && entry.modificationStamp >= lastModified) {
+ doc = entry.document;
+ entry.referenceCount++;
+ } else {
+ getSharedDocumentCache().remove(cacheKey);
+ }
+ } else if (o instanceof Reference) {
+ TLDCacheEntry entry = (TLDCacheEntry) ((Reference) o).get();
+ if (entry != null) {
+ if (entry.modificationStamp != IResource.NULL_STAMP
+ && entry.modificationStamp >= lastModified) {
+ doc = entry.document;
+ entry.referenceCount = 1;
+ getSharedDocumentCache().put(cacheKey, entry);
+ }
+ } else {
+ getSharedDocumentCache().remove(cacheKey);
+ }
+ }
+ }
+ /* No document was found cached, create a new one and share it */
+ if (doc == null) {
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_CACHE) {
+ JspEditorPlugin.getPluginLog().logInfo("TLDCMDocument cache miss on " + cacheKey);
+ }
+ TLDCMDocumentDescriptor descriptor = loadTaglib(reference);
+ if (descriptor != null) {
+ TLDCacheEntry entry = new TLDCacheEntry();
+ doc = entry.document = descriptor.document;
+ entry.referenceCount = 1;
+ entry.modificationStamp = getModificationStamp(reference);
+ getSharedDocumentCache().put(cacheKey, entry);
+ }
+ }
+ if (doc != null) {
+ getDocuments().put(cacheKey, doc);
+ }
+ }
+ return doc;
+ }
+
+ /**
+ * Return the filesystem location in the current parser. This method is
+ * called while recursing through included fragments, so it much check the
+ * include stack. The filesystem location is needed for common URI
+ * resolution in case the Taglib Index doesn't know the URI being loaded.
+ *
+ * @return
+ */
+ private IPath getCurrentBaseLocation() {
+ IPath baseLocation = null;
+ IPath path = getCurrentParserPath();
+ baseLocation = ResourcesPlugin.getWorkspace().getRoot().getFile(path)
+ .getLocation();
+ if (baseLocation == null) {
+ baseLocation = path;
+ }
+ return baseLocation;
+ }
+
+ /**
+ * Return the path used in the current parser. This method is called while
+ * recursing through included fragments, so it much check the include stack.
+ *
+ * @return
+ */
+ private IPath getCurrentParserPath() {
+ IPath path = null;
+ if (!getIncludes().isEmpty()) {
+ path = (IPath) getIncludes().peek();
+ } else {
+ path = XHTMLTaglibController.getFileBuffer(this).getLocation();
+ }
+
+ return path;
+ }
+
+ /**
+ * Gets the includes.
+ *
+ * @return Returns a Stack
+ */
+ protected Stack getIncludes() {
+ if (fIncludes == null)
+ fIncludes = new Stack();
+ return fIncludes;
+ }
+
+ public static Object getUniqueIdentifier(ITaglibRecord reference) {
+ if (reference == null)
+ return null;
+ Object identifier = null;
+ switch (reference.getRecordType()) {
+ case (ITaglibRecord.TLD): {
+ ITLDRecord record = (ITLDRecord) reference;
+ identifier = record.getPath();
+ }
+ break;
+ case (ITaglibRecord.JAR): {
+ IJarRecord record = (IJarRecord) reference;
+ identifier = record.getLocation();
+ }
+ break;
+ case (ITaglibRecord.TAGDIR): {
+ ITagDirRecord record = (ITagDirRecord) reference;
+ identifier = record.getPath();
+ }
+ break;
+ case (ITaglibRecord.URL): {
+ IURLRecord record = (IURLRecord) reference;
+ identifier = record.getURL();
+ }
+ break;
+ default:
+ identifier = reference;
+ break;
+ }
+ return identifier;
+ }
+
+ private long getModificationStamp(String reference) {
+ ITaglibRecord record = TaglibIndex.resolve(getCurrentParserPath()
+ .toString(), reference, false);
+ long modificationStamp = IResource.NULL_STAMP;
+ if (record != null) {
+ switch (record.getRecordType()) {
+ case (ITaglibRecord.TLD): {
+ IFile tldfile = ResourcesPlugin.getWorkspace().getRoot()
+ .getFile(((ITLDRecord) record).getPath());
+ if (tldfile.isAccessible()) {
+ modificationStamp = tldfile.getModificationStamp();
+ }
+ }
+ break;
+ case (ITaglibRecord.JAR): {
+ File jarfile = new File(((IJarRecord) record).getLocation()
+ .toOSString());
+ if (jarfile.exists()) {
+ try {
+ modificationStamp = jarfile.lastModified();
+ } catch (SecurityException e) {
+ modificationStamp = IResource.NULL_STAMP;
+ }
+ }
+ }
+ break;
+ case (ITaglibRecord.TAGDIR): {
+ IFolder tagFolder = ResourcesPlugin.getWorkspace().getRoot()
+ .getFolder(((ITagDirRecord) record).getPath());
+ if (tagFolder.isAccessible()) {
+ IResource[] members;
+ try {
+ members = tagFolder.members();
+ for (int i = 0; i < members.length; i++) {
+ modificationStamp = Math.max(modificationStamp,
+ members[i].getModificationStamp());
+ }
+ } catch (CoreException e) {
+ modificationStamp = IResource.NULL_STAMP;
+ }
+ }
+ }
+ break;
+ case (ITaglibRecord.URL): {
+ modificationStamp = IResource.NULL_STAMP;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return modificationStamp;
+ }
+
+ /**
+ * Gets the documents.
+ *
+ * @return Returns a java.util.Hashtable
+ */
+ public Hashtable getDocuments() {
+ if (fDocuments == null)
+ fDocuments = new Hashtable();
+ return fDocuments;
+ }
+
+ /**
+ * Gets all of the known documents.
+ *
+ * @return Returns a Hashtable of either TLDCacheEntrys or WeakReferences to TLDCMDocuments
+ */
+ public static Hashtable<Object, Object> getSharedDocumentCache() {
+ if (fCache == null) {
+ fCache = new Hashtable<Object, Object>();
+ }
+ return fCache;
+ }
+
+ protected TLDCMDocumentDescriptor loadTaglib(String uri) {
+ TLDCMDocumentDescriptor entry = null;
+ IPath currentPath = getCurrentParserPath();
+
+ IFile ifile = ResourcesPlugin.getWorkspace().getRoot().getFile(currentPath);
+ IProject iProject = ifile.getProject();
+ IModelNature nature = EclipseResourceUtil.getModelNature(iProject);
+ XModel model = nature.getModel();
+
+ XModelObject xmo = WebProject.getInstance(model).getTaglibMapping().getTaglibObject(uri);
+
+ TaglibMapping taglibMapping = WebProject.getInstance(model).getTaglibMapping();
+
+
+ if (currentPath != null) {
+ CMDocument document = null;
+ ITaglibRecord record = TaglibIndex.resolve(currentPath.toString(),
+ uri, false);
+ if (record != null) {
+ document = getCMDocumentBuilder().createCMDocument(record);
+ if (document != null) {
+ entry = new TLDCMDocumentDescriptor();
+ entry.document = document;
+ entry.cacheKey = getUniqueIdentifier(record);
+ }
+ } else {
+ /* Not a very-often used code path (we hope) */
+ IPath currentBaseLocation = getCurrentBaseLocation();
+ if (currentBaseLocation != null) {
+ String location = URIResolverPlugin.createResolver()
+ .resolve(currentBaseLocation.toString(), null, uri);
+ if (location != null) {
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_MANAGER) {
+ JspEditorPlugin.getPluginLog().logInfo("Loading tags from " + uri + " at " + location);
+ }
+ document = getCMDocumentBuilder().createCMDocument( location);
+ entry = new TLDCMDocumentDescriptor();
+ entry.document = document;
+ entry.cacheKey = location;
+ }
+ }
+ }
+ }
+ return entry;
+ }
+
+ /**
+ * Gets the cMDocumentBuilder.
+ *
+ * @return Returns a CMDocumentFactoryTLD, since it has more builder methods
+ */
+ protected CMDocumentFactoryTLD getCMDocumentBuilder() {
+ if (fCMDocumentBuilder == null)
+ fCMDocumentBuilder = new CMDocumentFactoryTLD();
+ return fCMDocumentBuilder;
+ }
+
+ /**
+ * Adds a block tagname (fully namespace qualified) into the list of block
+ * tag names for the parser. The marker IStructuredDocumentRegion along with
+ * position cues during reparses allow the JSPSourceParser to enable/ignore
+ * the tags as blocks.
+ */
+ protected void addBlockTag(String tagnameNS,
+ IStructuredDocumentRegion marker) {
+ if (getSourceParser() == null)
+ return;
+ if (getSourceParser().getBlockMarker(tagnameNS) == null) {
+ getSourceParser().addBlockMarker(
+ new BlockMarker(tagnameNS, marker,
+ DOMRegionContext.BLOCK_TEXT, true, false));
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_MANAGER) {
+ JspEditorPlugin.getPluginLog().logInfo("TLDEditorDocumentManager added block marker: " + tagnameNS + "@" + marker.getStartOffset()); //$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ *
+ * @param prefix
+ * @param uri
+ * @param anchorStructuredDocumentRegion
+ * @param tldCMDocument
+ */
+ protected void addTaglibTracker(String prefix, String uri, IStructuredDocumentRegion anchorStructuredDocumentRegion, CMDocument tldCMDocument) {
+ getTaglibTrackers().add( new TaglibTracker(uri, prefix, tldCMDocument, anchorStructuredDocumentRegion));
+ }
+
+ /**
+ * Enables a TLD owning the given prefix loaded from the given URI at the
+ * anchorStructuredDocumentRegion. The list of additionalCMDocuments will
+ * claim to not know any of its tags at positions earlier than that
+ * IStructuredDocumentRegion's position.
+ *
+ * For taglib directives, the taglib is the anchor while taglibs registered
+ * through include directives use the parent document's include directive as
+ * their anchor.
+ *
+ * @param prefix
+ * @param uri
+ * @param anchorStructuredDocumentRegion
+ */
+ protected void enableTaglibFromURI(String prefix, String uri, IStructuredDocumentRegion anchorStructuredDocumentRegion) {
+ enableTags(prefix, uri, anchorStructuredDocumentRegion);
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_MANAGER) {
+ JspEditorPlugin.getPluginLog().logInfo("TLDEditorDocumentManager registered a tracker for " + uri + " with prefix " + prefix); //$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ * @return a list of TaglibTrackers
+ */
+ public List<TaglibTracker> getTaglibTrackers() {
+ if (listTaglibTrackers == null) {
+ listTaglibTrackers = new ArrayList<TaglibTracker>();
+ }
+ return listTaglibTrackers;
+ }
+
+ protected void processTaglib( IStructuredDocumentRegion taglibStructuredDocumentRegion) {
+ processTaglib(taglibStructuredDocumentRegion, taglibStructuredDocumentRegion, getSourceParser());
+ }
+
+ protected void processTaglib( IStructuredDocumentRegion taglibStructuredDocumentRegion, IStructuredDocumentRegion anchorStructuredDocumentRegion, XMLSourceParser textSource) {
+ ITextRegionList regions = taglibStructuredDocumentRegion.getRegions();
+ String uri = null;
+ String prefix = null;
+ String tagdir = null;
+ String attrName = null;
+ try {
+ for (int i = 0; i < regions.size(); i++) {
+ ITextRegion region = regions.get(i);
+ // remember attribute name
+ int startOffset = taglibStructuredDocumentRegion.getStartOffset(region);
+ int textLength = region.getTextLength();
+ if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
+ if (textSource.regionMatches(startOffset, textLength,JSP11TLDNames.PREFIX)) {
+ attrName = JSP11TLDNames.PREFIX;
+ } else if (textSource.regionMatches(startOffset,
+ textLength, JSP12TLDNames.URI)) {
+ attrName = JSP11TLDNames.URI;
+ } else if (textSource.regionMatches(startOffset,
+ textLength, JSP20TLDNames.TAGDIR)) {
+ attrName = JSP20TLDNames.TAGDIR;
+ } else {
+ attrName = null;
+ }
+ }
+ // process value
+ else if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
+ if (JSP11TLDNames.PREFIX.equals(attrName))
+ prefix = StringUtils.strip(textSource.getText(
+ startOffset, textLength));
+ else if (JSP11TLDNames.URI.equals(attrName))
+ uri = StringUtils.strip(textSource.getText(startOffset,
+ textLength));
+ else if (JSP20TLDNames.TAGDIR.equals(attrName))
+ tagdir = StringUtils.strip(textSource.getText(
+ startOffset, textLength));
+ }
+ }
+ } catch (StringIndexOutOfBoundsException sioobExc) {
+ // nothing to be done
+ uri = null;
+ prefix = null;
+ }
+ if (uri != null && prefix != null && uri.length() > 0
+ && prefix.length() > 0) {
+ if (anchorStructuredDocumentRegion == null)
+ enableTaglibFromURI(prefix, StringUtils.strip(uri),
+ taglibStructuredDocumentRegion);
+ else
+ enableTaglibFromURI(prefix, uri, anchorStructuredDocumentRegion);
+ } else if (tagdir != null && prefix != null && tagdir.length() > 0
+ && prefix.length() > 0) {
+ if (anchorStructuredDocumentRegion == null)
+ enableTagsInDir(StringUtils.strip(prefix), StringUtils
+ .strip(tagdir), taglibStructuredDocumentRegion);
+ else
+ enableTagsInDir(StringUtils.strip(prefix), StringUtils
+ .strip(tagdir), anchorStructuredDocumentRegion);
+ }
+ }
+
+ /**
+ * Enables a TLD owning the given prefix loaded from the given URI at the
+ * anchorStructuredDocumentRegion. The list of additionalCMDocuments will
+ * claim to not know any of its tags at positions earlier than that
+ * IStructuredDocumentRegion's position.
+ *
+ * For taglib directives, the taglib is the anchor while taglibs registered
+ * through include directives use the parent document's include directive as
+ * their anchor.
+ *
+ * @param prefix
+ * @param uri
+ * @param taglibStructuredDocumentRegion
+ */
+ protected void enableTagsInDir(String prefix, String tagdir,
+ IStructuredDocumentRegion anchorStructuredDocumentRegion) {
+ enableTags(prefix, tagdir, anchorStructuredDocumentRegion);
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_MANAGER) {
+ JspEditorPlugin.getPluginLog().logInfo("TLDEditorDocumentManager registered a tracker for directory" + tagdir + " with prefix " + prefix); //$NON-NLS-2$//$NON-NLS-1$
+ }
+ }
+
+ /**
+ *
+ * @param prefix
+ * @param uri
+ * @param anchorStructuredDocumentRegion
+ * @param tld
+ */
+ private void registerTaglib(String prefix, String uri,
+ IStructuredDocumentRegion anchorStructuredDocumentRegion,
+ CMDocument tld) {
+ CMNamedNodeMap elements = tld.getElements();
+ /*
+ * Go through the CMDocument for any tags that must be marked as block
+ * tags starting at the anchoring IStructuredDocumentRegion. As the
+ * document is edited and the IStructuredDocumentRegion moved around,
+ * the block tag enablement will automatically follow it.
+ */
+ for (int i = 0; i < elements.getLength(); i++) {
+ TLDElementDeclaration ed = (TLDElementDeclaration) elements.item(i);
+ if (ed.getBodycontent() == JSP12TLDNames.CONTENT_TAGDEPENDENT)
+ addBlockTag(
+ prefix + ":" + ed.getNodeName(), anchorStructuredDocumentRegion); //$NON-NLS-1$
+ }
+ /*
+ * Since modifications to StructuredDocumentRegions adjacent to a taglib
+ * directive can cause that IStructuredDocumentRegion to be reported,
+ * filter out any duplicated URIs. When the taglib is actually modified,
+ * a full rebuild will occur and no duplicates will/should be found.
+ */
+ boolean doTrack = true;
+ List trackers = getTaglibTrackers();
+ for (int i = 0; i < trackers.size(); i++) {
+ TaglibTracker tracker = (TaglibTracker) trackers.get(i);
+ if (tracker.getPrefix().equals(prefix)
+ && tracker.getURI().equals(uri)) {
+ doTrack = false;
+ }
+ }
+ if (doTrack) {
+ addTaglibTracker(prefix, uri, anchorStructuredDocumentRegion, tld);
+ }
+ }
+
+
+ public void clearCache() {
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_CACHE) {
+ System.out.println("TLDCMDocumentManager cleared its private CMDocument cache"); //$NON-NLS-1$
+ }
+ for (Iterator iter = getDocuments().keySet().iterator(); iter.hasNext();) {
+ Object key = iter.next();
+ synchronized (getSharedDocumentCache()) {
+ Object o = getSharedDocumentCache().get(key);
+ if (o instanceof TLDCacheEntry) {
+ TLDCacheEntry entry = (TLDCacheEntry) o;
+ entry.referenceCount--;
+ if (entry.referenceCount <= 0) {
+ getSharedDocumentCache().put(key, new WeakReference(entry));
+ }
+ }
+ }
+ }
+ }
+
+ public List getCMDocumentTrackers(int offset) {
+ List validDocs = new ArrayList();
+ Iterator alldocs = getTaglibTrackers().iterator();
+ while (alldocs.hasNext()) {
+ TaglibTracker aTracker = (TaglibTracker) alldocs.next();
+ if (aTracker.getStructuredDocumentRegion().getStartOffset() < offset || offset < 0) {
+ validDocs.add(aTracker);
+ }
+ }
+ return validDocs;
+ }
+
+ public List getCMDocumentTrackers(String prefix, int offset) {
+ List validDocs = new ArrayList();
+ Iterator alldocs = getTaglibTrackers().iterator();
+ while (alldocs.hasNext()) {
+ TaglibTracker aTracker = (TaglibTracker) alldocs.next();
+ if ((aTracker.getStructuredDocumentRegion().getStartOffset() < offset || offset < 0) && aTracker.getPrefix().equals(prefix)) {
+ validDocs.add(aTracker);
+ }
+ }
+ return validDocs;
+ }
+
+}
Added: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/XHTMLTaglibController.java
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/XHTMLTaglibController.java (rev 0)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/XHTMLTaglibController.java 2007-10-02 15:36:48 UTC (rev 3967)
@@ -0,0 +1,253 @@
+package org.jboss.tools.jst.jsp.jspeditor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
+import org.eclipse.core.filebuffers.IFileBuffer;
+import org.eclipse.core.filebuffers.IFileBufferListener;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jst.jsp.core.internal.parser.JSPSourceParser;
+import org.eclipse.jst.jsp.core.taglib.ITaglibIndexDelta;
+import org.eclipse.jst.jsp.core.taglib.ITaglibIndexListener;
+import org.eclipse.jst.jsp.core.taglib.TaglibIndex;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+
+public class XHTMLTaglibController implements IDocumentSetupParticipant{
+ /** isShutdown */
+ static private boolean isShutdown = false;
+
+ /** */
+ private static XHTMLTaglibController INSTANCE = null;
+
+ /** */
+ private FileBufferListener fileBufferListener;
+
+ /** Map IDocument, ITaglibIndexListener */
+ private Map<IDocument, ITaglibIndexListener> documentMap;
+
+ /** List of IDocument */
+ private List<IDocument> documentList;
+
+ class DocumentInfo implements ITaglibIndexListener {
+ IStructuredDocument document;
+ ITextFileBuffer textFileBuffer;
+ TLDEditorDocumentManager tldDocumentManager;
+
+ public void indexChanged(ITaglibIndexDelta delta) {
+ int type = delta.getKind();
+ if (type == ITaglibIndexDelta.CHANGED || type == ITaglibIndexDelta.REMOVED) {
+ ITaglibIndexDelta[] deltas = delta.getAffectedChildren();
+ boolean affected = false;
+ for (int i = 0; i < deltas.length; i++) {
+ Object key = TLDEditorDocumentManager.getUniqueIdentifier(deltas[i].getTaglibRecord());
+ if (tldDocumentManager.getDocuments().containsKey(key)) {
+ affected = true;
+ }
+ }
+ if (affected) {
+ if (JspEditorPlugin.DEBIG_TLDCMDOCUMENT_CACHE) {
+ JspEditorPlugin.getPluginLog().logInfo("TLDCMDocumentManager cleared its private CMDocument cache");
+ }
+ tldDocumentManager.getDocuments().clear();
+ tldDocumentManager.getSourceParser().resetHandlers();
+
+ if (document instanceof BasicStructuredDocument) {
+ ((BasicStructuredDocument) document).reparse(this);
+ }
+ }
+ }
+ tldDocumentManager.indexChanged(delta);
+ }
+ }
+
+
+ class FileBufferListener implements IFileBufferListener {
+
+ public void bufferContentAboutToBeReplaced(IFileBuffer buffer) {
+ }
+
+ public void bufferContentReplaced(IFileBuffer buffer) {
+ }
+
+ public void bufferCreated(IFileBuffer buffer) {
+ if (buffer instanceof ITextFileBuffer) {
+ IDocument document = ((ITextFileBuffer) buffer).getDocument();
+
+ synchronized (INSTANCE.documentList) {
+ if (!INSTANCE.documentList.contains(document))
+ return;
+ }
+
+ DocumentInfo info = new DocumentInfo();
+ info.document = (IStructuredDocument) document;
+ info.textFileBuffer = (ITextFileBuffer) buffer;
+ info.tldDocumentManager = new TLDEditorDocumentManager();
+ info.tldDocumentManager.setSourceParser((JSPSourceParser) info.document.getParser());
+ synchronized (INSTANCE.documentMap) {
+ INSTANCE.documentMap.put(document, info);
+ }
+ TaglibIndex.addTaglibIndexListener(info);
+ if (document instanceof BasicStructuredDocument) {
+ ((BasicStructuredDocument) document).reparse(this);
+ }
+ }
+ }
+
+ public void bufferDisposed(IFileBuffer buffer) {
+ if (buffer instanceof ITextFileBuffer) {
+ IDocument document = ((ITextFileBuffer) buffer).getDocument();
+ synchronized (INSTANCE.documentList) {
+ if (!INSTANCE.documentList.remove(document))
+ return;
+ }
+ }
+ DocumentInfo info = null;
+ synchronized (INSTANCE.documentMap) {
+ Object[] keys = INSTANCE.documentMap.keySet().toArray();
+ for (int i = 0; i < keys.length; i++) {
+ info = (DocumentInfo) INSTANCE.documentMap.get(keys[i]);
+ if (info != null && info.textFileBuffer.equals(buffer)) {
+ INSTANCE.documentMap.remove(keys[i]);
+ break;
+ }
+ }
+ }
+ if (info != null) {
+ info.tldDocumentManager.clearCache();
+ TaglibIndex.removeTaglibIndexListener(info);
+ }
+ }
+
+ public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
+ }
+
+ public void stateChangeFailed(IFileBuffer buffer) {
+ }
+
+ public void stateChanging(IFileBuffer buffer) {
+ }
+
+ public void stateValidationChanged(IFileBuffer buffer, boolean isStateValidated) {
+ }
+
+ public void underlyingFileDeleted(IFileBuffer buffer) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void underlyingFileMoved(IFileBuffer buffer, IPath path) {
+ }
+ }
+
+
+ public XHTMLTaglibController() {
+ super();
+ fileBufferListener = new FileBufferListener();
+ documentMap = new HashMap<IDocument, ITaglibIndexListener>(1);
+ documentList = new ArrayList<IDocument>(1);
+ }
+
+
+
+
+ public synchronized static void startup() {
+ if (INSTANCE == null) {
+ INSTANCE = new XHTMLTaglibController();
+ FileBuffers.getTextFileBufferManager().addFileBufferListener(INSTANCE.fileBufferListener);
+ }
+ setShutdown(false);
+ }
+
+ public synchronized static void shutdown() {
+ setShutdown(true);
+ FileBuffers.getTextFileBufferManager().removeFileBufferListener(INSTANCE.fileBufferListener);
+ INSTANCE = null;
+ }
+
+
+ /**
+ *
+ * @param document
+ * @return
+ */
+ public static ITextFileBuffer getFileBuffer(IDocument document) {
+ synchronized (INSTANCE.documentMap) {
+ DocumentInfo info = (DocumentInfo) INSTANCE.documentMap.get(document);
+ if (info != null)
+ return info.textFileBuffer;
+ return null;
+ }
+ }
+
+
+ /**
+ * @param manager
+ * @return
+ */
+ public static ITextFileBuffer getFileBuffer(TLDEditorDocumentManager manager) {
+ // if _instance is null, we are already shutting donw
+ if (INSTANCE == null)
+ return null;
+
+ ITextFileBuffer buffer = null;
+ synchronized (INSTANCE.documentMap) {
+ Iterator docInfos = INSTANCE.documentMap.values().iterator();
+ while (docInfos.hasNext() && buffer == null) {
+ DocumentInfo info = (DocumentInfo) docInfos.next();
+ if (info.tldDocumentManager.equals(manager))
+ buffer = info.textFileBuffer;
+ }
+ }
+ return buffer;
+ }
+ /**
+ *
+ */
+ public void setup(IDocument document) {
+ if (isShutdown())
+ return;
+ // reference the shared instance's documents directly
+ synchronized (INSTANCE.documentList) {
+ INSTANCE.documentList.add(document);
+ }
+ }
+
+ public static TLDEditorDocumentManager getTLDCMDocumentManager(IDocument document) {
+ // if _instance is null, we are already shutting donw
+ if (INSTANCE == null)
+ return null;
+ synchronized (INSTANCE.documentMap) {
+ DocumentInfo info = (DocumentInfo) INSTANCE.documentMap.get(document);
+ if (info != null)
+ return info.tldDocumentManager;
+ return null;
+
+ }
+ }
+
+
+ /**
+ *
+ * @return
+ */
+ private static synchronized boolean isShutdown() {
+ return isShutdown;
+ }
+
+ /**
+ *
+ * @param isShutdown
+ */
+ private static synchronized void setShutdown(boolean isShutdown) {
+ isShutdown = isShutdown;
+ }
+}
Added: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/ModelHandlerForXHTML.java
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/ModelHandlerForXHTML.java (rev 0)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/ModelHandlerForXHTML.java 2007-10-02 15:36:48 UTC (rev 3967)
@@ -0,0 +1,46 @@
+ /*******************************************************************************
+ * 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.jst.jsp.modelhandler;
+
+import org.eclipse.jst.jsp.core.internal.modelhandler.ModelHandlerForJSP;
+import org.eclipse.wst.sse.core.internal.provisional.IModelLoader;
+
+/**
+ * @author A. Yukhovich
+ */
+public class ModelHandlerForXHTML extends ModelHandlerForJSP {
+
+ /**
+ * Needs to match what's in plugin registry. In fact, can be overwritten
+ * at run time with what's in registry! (so should never be 'final')
+ */
+ static String AssociatedContentTypeID = "org.eclipse.wst.html.core.htmlsource"; //$NON-NLS-1$
+ /**
+ * Needs to match what's in plugin registry. In fact, can be overwritten
+ * at run time with what's in registry! (so should never be 'final')
+ */
+ private static String ModelHandlerID = "org.jboss.tools.jst.jsp.modelhandler.xhtml";
+
+
+ public ModelHandlerForXHTML() {
+ super();
+ setId(ModelHandlerID);
+ setAssociatedContentTypeId(AssociatedContentTypeID);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler#getModelLoader()
+ */
+ public IModelLoader getModelLoader() {
+ return new XHTMLModelLoader();
+ }
+
+}
Added: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/XHTMLModelLoader.java
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/XHTMLModelLoader.java (rev 0)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelhandler/XHTMLModelLoader.java 2007-10-02 15:36:48 UTC (rev 3967)
@@ -0,0 +1,46 @@
+ /*******************************************************************************
+ * 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.jst.jsp.modelhandler;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jst.jsp.core.internal.modelhandler.JSPModelLoader;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
+import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
+import org.jboss.tools.jst.jsp.modelquery.ModelQueryAdapterFactoryForXHTML;
+
+/**
+ * @author A. Yukhovich
+ *
+ */
+public class XHTMLModelLoader extends JSPModelLoader {
+
+ public XHTMLModelLoader() {
+ }
+
+ public List getAdapterFactories() {
+ List factories = super.getAdapterFactories();
+ /*
+ * Replace the default JSP model query by using our own factory
+ */
+
+ Iterator i = factories.iterator();
+ while (i.hasNext()) {
+ if (((INodeAdapterFactory) i.next()).isFactoryForType(ModelQueryAdapter.class)) {
+ i.remove();
+ }
+ }
+
+ factories.add(new ModelQueryAdapterFactoryForXHTML());
+ return factories;
+ }
+}
Added: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/ModelQueryAdapterFactoryForXHTML.java
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/ModelQueryAdapterFactoryForXHTML.java (rev 0)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/ModelQueryAdapterFactoryForXHTML.java 2007-10-02 15:36:48 UTC (rev 3967)
@@ -0,0 +1,98 @@
+ /*******************************************************************************
+ * 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.jst.jsp.modelquery;
+
+import java.io.File;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.jsp.core.internal.modelquery.JSPModelQueryAdapterImpl;
+import org.eclipse.jst.jsp.core.internal.modelquery.ModelQueryAdapterFactoryForJSP;
+import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
+import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.ModelQueryImpl;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.SimpleAssociationProvider;
+import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
+import org.eclipse.wst.xml.core.internal.modelquery.XMLCatalogIdResolver;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.jboss.tools.jst.jsp.JspEditorPlugin;
+
+/**
+ * @author A. Yukhovich
+ *
+ */
+public class ModelQueryAdapterFactoryForXHTML extends ModelQueryAdapterFactoryForJSP {
+ public ModelQueryAdapterFactoryForXHTML() {
+ }
+
+ public ModelQueryAdapterFactoryForXHTML(Object key, boolean registerAdapters) {
+ super(key, registerAdapters);
+ }
+
+ @SuppressWarnings("restriction")
+ public INodeAdapterFactory copy() {
+ return new ModelQueryAdapterFactoryForXHTML(getAdapterKey(), isShouldRegisterAdapter());
+ }
+
+ @SuppressWarnings("restriction")
+ ModelQuery createModelQuery(IStructuredModel model, URIResolver resolver) {
+ return new ModelQueryImpl(new SimpleAssociationProvider(new XHTMLModelQueryCMProvider()));
+ }
+
+ /**
+ * createAdapter method comment.
+ */
+ protected INodeAdapter createAdapter(INodeNotifier target) {
+
+ if (JspEditorPlugin.DEBIG_INFO) {
+ System.out.println("-----------------------ModelQueryAdapterFactoryForXHTML.createAdapter" + target); //$NON-NLS-1$
+ }
+
+ if (modelQueryAdapterImpl == null) {
+ if (target instanceof IDOMNode) {
+ IDOMNode xmlNode = (IDOMNode) target;
+ IStructuredModel model = stateNotifier = xmlNode.getModel();
+ String baseLocation = model.getBaseLocation();
+ // continue only if the location is known
+ if (baseLocation != null) {
+ stateNotifier.addModelStateListener(this);
+ File file = new Path(model.getBaseLocation()).toFile();
+ if (file.exists()) {
+ baseLocation = file.getAbsolutePath();
+ }
+ else {
+ IPath basePath = new Path(model.getBaseLocation());
+ IPath derivedPath = null;
+ if (basePath.segmentCount() > 1)
+ derivedPath = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath).getLocation();
+ else
+ derivedPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(basePath);
+ if (derivedPath != null) {
+ baseLocation = derivedPath.toString();
+ }
+ }
+ URIResolver resolver = new XMLCatalogIdResolver(baseLocation, model.getResolver());
+
+ ModelQuery modelQuery = createModelQuery(model, resolver);
+ modelQuery.setEditMode(ModelQuery.EDIT_MODE_UNCONSTRAINED);
+ modelQueryAdapterImpl = new JSPModelQueryAdapterImpl(new CMDocumentCache(), modelQuery, resolver);
+ }
+ }
+ }
+ return modelQueryAdapterImpl;
+ }
+
+}
Added: branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/XHTMLModelQueryCMProvider.java
===================================================================
--- branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/XHTMLModelQueryCMProvider.java (rev 0)
+++ branches/jbosstools_ve_codeassistant/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/modelquery/XHTMLModelQueryCMProvider.java 2007-10-02 15:36:48 UTC (rev 3967)
@@ -0,0 +1,85 @@
+ /*******************************************************************************
+ * 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.jst.jsp.modelquery;
+
+import java.util.List;
+import org.eclipse.jst.jsp.core.internal.contentmodel.JSPCMDocumentFactory;
+import org.eclipse.jst.jsp.core.internal.contenttype.DeploymentDescriptorPropertyCache;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryCMProvider;
+import org.w3c.dom.Node;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+import org.eclipse.core.runtime.Path;
+import org.jboss.tools.jst.jsp.jspeditor.TLDEditorDocumentManager;
+import org.jboss.tools.jst.jsp.jspeditor.XHTMLTaglibController;
+/**
+ * @author A. Yukhovich
+ *
+ */
+public class XHTMLModelQueryCMProvider implements ModelQueryCMProvider {
+
+ protected XHTMLModelQueryCMProvider() {
+ super();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryCMProvider#getCorrespondingCMDocument(org.w3c.dom.Node)
+ */
+ public CMDocument getCorrespondingCMDocument(Node node) {
+ CMDocument jcmdoc = null;
+ if (node instanceof IDOMNode) {
+ IDOMModel model = ((IDOMNode) node).getModel();
+ String modelPath = model.getBaseLocation();
+ if (modelPath != null && !IModelManager.UNMANAGED_MODEL.equals(modelPath)) {
+ float version = DeploymentDescriptorPropertyCache.getInstance().getJSPVersion(new Path(modelPath));
+ jcmdoc = JSPCMDocumentFactory.getCMDocument(version);
+ }
+ }
+ if (jcmdoc == null) {
+ jcmdoc = JSPCMDocumentFactory.getCMDocument();
+ }
+
+ CMDocument result = null;
+ try {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ String elementName = node.getNodeName();
+
+ // test to see if this node belongs to JSP's CMDocument (case
+ // sensitive)
+ CMElementDeclaration dec = (CMElementDeclaration) jcmdoc.getElements().getNamedItem(elementName);
+ if (dec != null) {
+ result = jcmdoc;
+ }
+ }
+
+ String prefix = node.getPrefix();
+
+ if (result == null && prefix != null && prefix.length() > 0 && node instanceof IDOMNode) {
+ // check position dependent
+ IDOMNode xmlNode = (IDOMNode) node;
+ TLDEditorDocumentManager tldmgr = XHTMLTaglibController.getTLDCMDocumentManager(xmlNode.getStructuredDocument());
+ if (tldmgr != null) {
+ List documents = tldmgr.getCMDocumentTrackers(node.getPrefix(), xmlNode.getStartOffset());
+ // there shouldn't be more than one cmdocument returned
+ if (documents != null && documents.size() > 0)
+ result = (CMDocument) documents.get(0);
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+}
17 years, 3 months
JBoss Tools SVN: r3966 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2007-10-02 11:34:02 -0400 (Tue, 02 Oct 2007)
New Revision: 3966
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
Log:
NPE
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2007-10-02 15:25:47 UTC (rev 3965)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/DeployableServerBehavior.java 2007-10-02 15:34:02 UTC (rev 3966)
@@ -217,11 +217,13 @@
if( recurse ) {
ArrayList tmp = new ArrayList();
IModule[] children = getServer().getChildModules(module, new NullProgressMonitor());
- for( int i = 0; i < children.length; i++ ) {
- tmp = new ArrayList();
- tmp.addAll(Arrays.asList(module));
- tmp.add(children[i]);
- fillPublishOneModuleLists((IModule[]) tmp.toArray(new IModule[tmp.size()]), moduleList, deltaKindList, deltaKind, recurse);
+ if( children != null ) {
+ for( int i = 0; i < children.length; i++ ) {
+ tmp = new ArrayList();
+ tmp.addAll(Arrays.asList(module));
+ tmp.add(children[i]);
+ fillPublishOneModuleLists((IModule[]) tmp.toArray(new IModule[tmp.size()]), moduleList, deltaKindList, deltaKind, recurse);
+ }
}
}
17 years, 3 months
JBoss Tools SVN: r3965 - in trunk/documentation/qa: findbugs and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-10-02 11:25:47 -0400 (Tue, 02 Oct 2007)
New Revision: 3965
Added:
trunk/documentation/qa/findbugs/
trunk/documentation/qa/findbugs/build.xml
Log:
FindBugs build.xml example
Added: trunk/documentation/qa/findbugs/build.xml
===================================================================
--- trunk/documentation/qa/findbugs/build.xml (rev 0)
+++ trunk/documentation/qa/findbugs/build.xml 2007-10-02 15:25:47 UTC (rev 3965)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project basedir="." default="build" name="org.jboss.tools.vpe">
+ <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
+ <property name="findbugs.home" value="C:/Development/Tools/findbugs-1.2.1" />
+
+ <target name="findbugs">
+ <findbugs home="${findbugs.home}"
+ output="xml"
+ outputFile="vpe.xml" >
+ <!-- auxClasspath path="${basedir}/lib/Regex.jar" /-->
+ <sourcePath path="${basedir}/src" />
+ <class location="${basedir}/bin" />
+ </findbugs>
+ </target>
+</project>
17 years, 3 months
JBoss Tools SVN: r3964 - in trunk/documentation/qa: pmd and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-10-02 10:59:52 -0400 (Tue, 02 Oct 2007)
New Revision: 3964
Added:
trunk/documentation/qa/pmd/
trunk/documentation/qa/pmd/build.properties
trunk/documentation/qa/pmd/build.xml
Log:
Ant build for generating PMD reports
Added: trunk/documentation/qa/pmd/build.properties
===================================================================
--- trunk/documentation/qa/pmd/build.properties (rev 0)
+++ trunk/documentation/qa/pmd/build.properties 2007-10-02 14:59:52 UTC (rev 3964)
@@ -0,0 +1,5 @@
+#Tue Oct 02 16:34:22 MSD 2007
+check.plugins.home=E\:/eclipse-3.3/workspace/designtime/rhds
+pmd.home=E\:/pmd-4.0
+build.dir=build
+rulesets.filenames=rulesets/basic.xml,rulesets/braces.xml,rulesets/clone.xml,rulesets/codesize.xml,rulesets/controversial.xml,rulesets/coupling.xml,rulesets/design.xml,rulesets/finalizers.xml,rulesets/imports.xml,rulesets/j2ee.xml,rulesets/javabeans.xml,rulesets/junit.xml,rulesets/logging-jakarta-commons.xml,rulesets/logging-java.xml,rulesets/migrating.xml,rulesets/naming.xml,rulesets/optimizations.xml,rulesets/strictexception.xml,rulesets/strings.xml,rulesets/sunsecure.xml,rulesets/unusedcode.xml
\ No newline at end of file
Added: trunk/documentation/qa/pmd/build.xml
===================================================================
--- trunk/documentation/qa/pmd/build.xml (rev 0)
+++ trunk/documentation/qa/pmd/build.xml 2007-10-02 14:59:52 UTC (rev 3964)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="PMD checking" default="create-report" basedir=".">
+
+ <property file ="${basedir}/build.properties"/>
+
+ <path id="pmd.classpath">
+ <pathelement location="${build}"/>
+ <fileset dir="${pmd.home}/lib">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
+
+ <target name="create-report">
+ <mkdir dir="${basedir}/${build.dir}"/>
+ <pmd rulesetfiles="${rulesets.filenames}">
+ <formatter type="html" toFile="${basedir}/${build.dir}/pmd_report.html" toConsole="true"/>
+ <formatter type="xml" toFile="${basedir}/${build.dir}/pmd_report.xml" toConsole="true"/>
+ <formatter type="summaryhtml" toFile="${basedir}/${build.dir}/pmd_summary_report.html" toConsole="true"/>
+ <formatter type="text" toFile="${basedir}/${build.dir}/pmd_report.txt" toConsole="true"/>
+ <fileset dir="${check.plugins.home}">
+ <include name="org.jboss.*/**/*.java"/>
+ <include name="org.hibernate.*/**/*.java"/>
+ </fileset>
+ </pmd>
+ </target>
+</project>
\ No newline at end of file
17 years, 3 months
JBoss Tools SVN: r3963 - in trunk/seam/plugins/org.jboss.tools.seam.core: src/org/jboss/tools/seam/internal/core/project/facet and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2007-10-02 10:48:15 -0400 (Tue, 02 Oct 2007)
New Revision: 3963
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
trunk/seam/plugins/org.jboss.tools.seam.core/templates/test/.classpath
Log:
http://jira.jboss.org/jira/browse/JBIDE-978
fixed for seam web project and test project
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-10-02 14:08:35 UTC (rev 3962)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-10-02 14:48:15 UTC (rev 3963)
@@ -117,6 +117,10 @@
return getSeamGenDir()+"/view";
}
+ public String getResourceTemplatesDir() {
+ return getHomeDir()+"/seam-gen/resources";
+ }
+
public String getTemplatesDir() {
return getSeamGenDir();
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-10-02 14:08:35 UTC (rev 3962)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-10-02 14:48:15 UTC (rev 3963)
@@ -219,10 +219,10 @@
final IDataModel model = (IDataModel)config;
// get WebContents folder path from DWP model
- IVirtualComponent com = ComponentCore.createComponent(project);
- IVirtualFolder webRootFolder = com.getRootFolder().getFolder(new Path("/"));
- final IVirtualFolder srcRootFolder = com.getRootFolder().getFolder(new Path("/WEB-INF/classes"));
- IContainer folder = webRootFolder.getUnderlyingFolder();
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new Path("/"));
+ final IVirtualFolder srcRootFolder = component.getRootFolder().getFolder(new Path("/WEB-INF/classes"));
+ IContainer webRootFolder = webRootVirtFolder.getUnderlyingFolder();
model.setProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME, project.getName());
model.setProperty(ISeamFacetDataModelProperties.SEAM_TEST_PROJECT, project.getName()+"-test");
@@ -237,7 +237,7 @@
model.setProperty(ISeamFacetDataModelProperties.HIBERNATE_HBM2DDL_AUTO,"create-drop");
}
- final File webContentFolder = folder.getLocation().toFile();
+ final File webContentFolder = webRootFolder.getLocation().toFile();
final File webInfFolder = new File(webContentFolder,"WEB-INF");
final File webInfClasses = new File(webInfFolder,"classes");
final File webInfClassesMetaInf = new File(webInfClasses, "META-INF");
@@ -339,13 +339,11 @@
IPath modelSrcPath = new Path(source.getFullPath().lastSegment()+"/model");
srcRootFolder.delete(IVirtualFolder.FORCE, monitor);
- WtpUtils.createSourceFolder(project, actionSrcPath, new Path(source.getFullPath().lastSegment()), new Path("WebContent/WEB-INF/dev"));
+ WtpUtils.createSourceFolder(project, actionSrcPath, new Path(source.getFullPath().lastSegment()), new Path(webRootFolder.getLocation().lastSegment()+"/WEB-INF/dev"));
WtpUtils.createSourceFolder(project, modelSrcPath, new Path(source.getFullPath().lastSegment()), null);
- IVirtualComponent c = ComponentCore.createComponent(project);
- IVirtualFolder src = c.getRootFolder().getFolder("/WEB-INF/classes");
- src.createLink(actionSrcPath, 0, null);
- src.createLink(modelSrcPath, 0, null);
+ srcRootFolder.createLink(actionSrcPath, 0, null);
+ srcRootFolder.createLink(modelSrcPath, 0, null);
AntCopyUtils.copyFileToFile(
new File(seamGenHomeFolder,"src/Authenticator.java"),
@@ -608,16 +606,20 @@
String projectName = model.getProperty(ISeamFacetDataModelProperties.SEAM_PROJECT_NAME).toString();
File testProjectDir = new File(seamWebProject.getLocation().removeLastSegments(1).toFile(),projectName+"-test");
testProjectDir.mkdir();
+
+ IVirtualComponent component = ComponentCore.createComponent(seamWebProject);
+ IVirtualFolder webRootVirtFolder = component.getRootFolder().getFolder(new Path("/"));
+
File testLibDir = new File(testProjectDir,"lib");
File embededEjbDir = new File(testProjectDir,"embedded-ejb");
File testSrcDir = new File(testProjectDir,"test-src");
- String seamGenResFolder = seamRuntime.getHomeDir()+"/seam-gen/resources";
+ String seamGenResFolder = seamRuntime.getResourceTemplatesDir();
File persistenceFile = new File(seamGenResFolder ,"META-INF/persistence-" + (isWarConfiguration(model)?TEST_WAR_PROFILE:TEST_EAR_PROFILE) + ".xml");
File jbossBeansFile = new File(seamGenResFolder ,"META-INF/jboss-beans.xml");
FilterSet filterSet = new FilterSet();
filterSet.addFilter("projectName", projectName);
filterSet.addFilter("runtimeName", WtpUtils.getServerRuntimeName(seamWebProject));
-
+ filterSet.addFilter("webRootFolder",webRootVirtFolder.getUnderlyingFolder().getLocation().lastSegment());
final SeamRuntime selectedRuntime = SeamRuntimeManager.getInstance().findRuntimeByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_RUNTIME_NAME).toString());
final String seamHomePath = selectedRuntime.getHomeDir();
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/templates/test/.classpath
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/templates/test/.classpath 2007-10-02 14:08:35 UTC (rev 3962)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/templates/test/.classpath 2007-10-02 14:48:15 UTC (rev 3963)
@@ -3,7 +3,7 @@
<classpathentry kind="src" path="test-src"/>
<classpathentry kind="src" path="embedded-ejb"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-@testLibraries@<classpathentry kind="lib" path="/@projectName@/WebContent"/>
+@testLibraries@<classpathentry kind="lib" path="/@projectName@/@webRootFolder@"/>
@requiredProjects@
<classpathentry kind="output" path="bin"/>
</classpath>
17 years, 3 months
JBoss Tools SVN: r3962 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-10-02 10:08:35 -0400 (Tue, 02 Oct 2007)
New Revision: 3962
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java
Log:
JBIDE-975
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java 2007-10-02 14:06:06 UTC (rev 3961)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/extensions/archives/WarArchiveType.java 2007-10-02 14:08:35 UTC (rev 3962)
@@ -22,13 +22,11 @@
package org.jboss.ide.eclipse.as.core.extensions.archives;
import org.apache.tools.ant.DirectoryScanner;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
@@ -38,9 +36,9 @@
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.util.ProjectModule;
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
+import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
@@ -100,7 +98,9 @@
IPath path = new Path(files[0]);
path = path.removeLastSegments(2); // remove the file name
path = new Path(project.getName()).append(path); // pre-pend project name to make workspace-relative
- addFileset(project, packageRoot, path.toOSString(), "**/*");
+ IArchiveFileSet fs = addFileset(project, packageRoot, path.toOSString(), "**/*");
+ //If we have separate file set for libraries, we do not need to duplicate jars.
+ fs.setExcludesPattern("**/WEB-INF/lib/*.jar");
}
}
protected void addClassesFileset(IProject project, IArchiveFolder folder) {
@@ -130,7 +130,25 @@
// Lib support
protected void addLibFileset(IProject project, IArchiveFolder folder, boolean includeTopLevelJars) {
- addFileset(project, folder, project.getName(), "**/*.jar"); // add default jars
+ // Let us find /WEB-INF/lib directory and set it as source for the file set.
+ String sourcePath = null;
+
+ IPath projectPath = project.getLocation();
+ DirectoryScanner scanner =
+ DirectoryScannerFactory.createDirectoryScanner(projectPath, "**/WEB-INF/web.xml", null, true);
+ String[] files = scanner.getIncludedFiles();
+
+ if(files != null && files.length > 0) {
+ IPath path = new Path(files[0]);
+ path = path.removeLastSegments(1).append("lib");
+ sourcePath = project.getFullPath().append(path).toString();
+ }
+
+ if(sourcePath == null) {
+ //having failed to find 'lib' directory, let us make source of the project itself
+ sourcePath = project.getName();
+ }
+ addFileset(project, folder, sourcePath, "**/*.jar"); // add default jars
}
protected void addReferencedProjectsAsLibs(IProject project, IArchiveFolder folder) {
IJavaProject jp = JavaCore.create(project);
17 years, 3 months
JBoss Tools SVN: r3961 - in trunk/documentation/GettingStartedGuide/docs/userguide/en: modules and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: sabrashevich
Date: 2007-10-02 10:06:06 -0400 (Tue, 02 Oct 2007)
New Revision: 3961
Added:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj22.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj23.png
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj04.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj044.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj045.png
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GetStartSeamGen.xml
Log:
updated context
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj04.png
===================================================================
(Binary files differ)
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj044.png
===================================================================
(Binary files differ)
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/SeamNewProj045.png
===================================================================
(Binary files differ)
Added: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj22.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj22.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj23.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/GettingStartedGuide/docs/userguide/en/images/newseamproj23.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GetStartSeamGen.xml
===================================================================
--- trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GetStartSeamGen.xml 2007-10-02 13:55:52 UTC (rev 3960)
+++ trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GetStartSeamGen.xml 2007-10-02 14:06:06 UTC (rev 3961)
@@ -13,7 +13,7 @@
<para>The Red Hat Developer Studio provides sophisticated tools for enterprise applications. With the Red Hat Developer Studio, you can get started very quickly with a web prototype, and then scale up your application to include enterprise features (e.g., business processes, web services, etc.) using the same developer tools. It is a "scalable" RAD (Rapid Application Development) tool.</para>
- <para>A core element that makes the Red Hat Developer Studio "scalable" is the JBoss <property>Seam</property> framework. <property>Seam</property> is a fully featured application framework on top of Java EE 5. It is also one of the most popular enterprise Java framework today. <property>Seam</property> deeply integrates many other standard-based or open source frameworks (e.g., JSF, EJB3, JMS, Web Services, jBPM, JBoss Rules, Ajax4jsf, RichFaces, Facelets, Spring, iText, Quartz, TestNG etc.), and provides a single programming model for developers to "drive" those underlying frameworks via simple annotated POJOs (Plain Old Java Objects). It makes life easier for developers to tackle complex enterprise applications with many component frameworks.</para>
+ <para>A core element that makes the Red Hat Developer Studio "scalable" is the JBoss <property>Seam</property> framework. <property>Seam</property> is a fully featured application framework on top of Java EE 5. It is also one of the most popular enterprise Java framework today. <property>Seam</property> deeply integrates many other standard-based or open source frameworks (e.g., JSF, EJB3, JMS, Web Services, jBPM, JBoss Rules, Ajax4jsf, RichFaces, Facelets, Spring, iText, Quartz, TestNG, etc.), and provides a single programming model for developers to "drive" those underlying frameworks via simple annotated POJOs (Plain Old Java Objects). It makes life easier for developers to tackle complex enterprise applications with many component frameworks.</para>
<para>In this chapter, we will cover how to build a simple <property>Seam</property> web application in minutes with the Red Hat Developer Studio.</para>
@@ -55,7 +55,7 @@
- <para>Now you need to define a connection profile and choose a database. If you have no connections yet you should create the one.</para>
+ <para>We will use a default connection provided by RHDS.</para>
<orderedlist>
<listitem><para>Click Next in the dialog "JPA Facet"</para></listitem>
</orderedlist>
@@ -81,60 +81,15 @@
</mediaobject>
</figure>
- <orderedlist continuation="continues">
- <listitem><para>Click New button to create a new connection profile.</para></listitem>
- </orderedlist>
-
- <figure>
- <title>Create New Connection Profile</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/SeamNewProj045.png"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <orderedlist continuation="continues">
- <listitem><para>Give a name to your connection and some description. Click Next.</para></listitem>
- </orderedlist>
- <figure>
- <title>Give a name to connection profile</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/connectionprofile.png"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>Now you need to specify driver and connection details.</para>
- <orderedlist continuation="continues">
- <listitem><para>Select Generic JDBC driver from the drop down list Click Next.</para></listitem>
- </orderedlist>
- <figure>
- <title>Select Driver</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/connectionprofile2.png"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>A summary diallog will be prompted. Click Finish.</para>
-
- <figure>
- <title>Summary window</title>
- <mediaobject>
- <imageobject>
- <imagedata fileref="images/connectionprofile7.png"/>
- </imageobject>
- </mediaobject>
- </figure>
+ <para>We will also use a default Hibernate Dialect - <emphasis>org.hibernate.dialect.HSQLDialect</emphasis> and deploy as a <emphasis>war</emphasis> archive.</para>
+
<para>The project setup wizard also asks you to configure how <property>Seam</property> generates code for the project. The <property>Seam</property> Home Folder should point to a valid <property>Seam</property> distribution. By default, it is set to the <property>Seam</property> distribution bundled in your Red Hat Developer Studio tool. For the deployment format, choose WAR deployment if you want to use POJOs for UI event handling and business logic; choose EAR deployment if you want to EJB3 beans for added features. In most web applications, the WAR deployment option would suffice. You should also enter Java packages for the entity beans (for database mapping) and session beans (for action handlers). All generated code will be placed in those packages. </para>
<figure>
<title>Enter Java packages for generated code</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/SeamNewProj06.png"/>
+ <imagedata fileref="images/SeamNewProj045.png"/>
</imageobject>
</mediaobject>
</figure>
@@ -194,12 +149,12 @@
<title>New form for the application</title>
<mediaobject>
<imageobject>
- <imagedata fileref="images/xxxx.png"/>
+ <imagedata fileref="images/newseamproj22.png"/>
</imageobject>
</mediaobject>
</figure>
- <para>The wizard generate a web page with a single text input field and an action button. Notice that the generated page uses layout/template.xhtml as a template. The template page provides the page header, footer, side menu, and CSS styles (see the template.xhtml for more details). The Simplepage.xhtml is assembled into the template when the Simplepage.seam URL is loaded.</para>
+ <para>The wizard generate a web page with a single text input field and an action button. Notice that the generated page uses <emphasis>layout/template.xhtml</emphasis> as a template. The template page provides the page header, footer, side menu, and CSS styles (see the template.xhtml for more details). The Simplepage.xhtml is assembled into the template when the Simplepage.seam URL is loaded.</para>
<programlisting role="XML"><![CDATA[
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -242,9 +197,16 @@
</ui:composition>
]]></programlisting>
+ <figure>
+ <title>Generated form</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/newseamproj23.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
+ <para>The <emphasis>#{simpleAction.value}</emphasis> notation on the web page maps to the "value" property in the backend component named "simpleAction", and the <emphasis>#{simpleAction.hello}</emphasis> notation indicates that the <emphasis><property>hello()</property></emphasis> method is called when the button is clicked on. Here is the "simpleAction" named backend <property>Seam</property> component generated by the wizard.</para>
- <para>The #{simpleAction.value} notation on the web page maps to the "value" property in the backend component named "simpleAction", and the #{simpleAction.hello} notation indicates that the hello() method is called when the button is clicked on. Here is the "simpleAction" named backend <property>Seam</property> component generated by the wizard.</para>
-
<programlisting role="JAVA"><![CDATA[
@Name("simpleAction")
public class SimpleAction {
@@ -281,14 +243,14 @@
}
]]></programlisting>
- <para>Load the Simplepage.seam in the web browser. Type something in the text field and click on the "hello" button. A JSF message containing the input string is created by the SimpleAction.hello() method. The message is displayed on the page via the h:messages tag.</para>
+ <para>Load the Simplepage.seam in the web browser. Type something in the text field and click on the "hello" button. A JSF message containing the input string is created by the <emphasis><property>SimpleAction.hello()</property></emphasis> method. The message is displayed on the page via the <emphasis role="bold"><property><h:messages></property></emphasis> tag.</para>
</section>
<section>
<title>Input Validation</title>
- <para>Notice that in the generated SimpleAction class, there is a @Length annotation to validate the input when the input string is bound to #{simpleAction.value}. To see how this works, enter a text string longer than 10 chars and click on the button. This is what you should see.</para>
+ <para>Notice that in the generated SimpleAction class, there is a <emphasis>@Length</emphasis> annotation to validate the input when the input string is bound to <emphasis>#{simpleAction.value}</emphasis>. To see how this works, enter a text string longer than 10 chars and click on the button. This is what you should see.</para>
<figure>
<title>The input validation in action</title>
@@ -299,7 +261,7 @@
</mediaobject>
</figure>
- <para><property>Seam</property> supports many different input validation annotations. To see an example, you can replace the @Length(max=10) annotation with the following. It would require the input string to have a first name and last name separated by a space. If the validation fails, the web page would print the customized error message.</para>
+ <para><property>Seam</property> supports many different input validation annotations. To see an example, you can replace the <emphasis>@Length(max=10)</emphasis> annotation with the following. It would require the input string to have a first name and last name separated by a space. If the validation fails, the web page would print the customized error message.</para>
<programlisting role="JAVA"><![CDATA[
@NotNull
@@ -329,8 +291,7 @@
<para>Now, let's add a little more logic to the application. We will add a new boolean property to the action component. If it is set to true, the action would capitalize the input string and display it on the web page. The following code in the SimpleAction class implements the logic.</para>
- <programlisting role="JAVA"><![CDATA[
-@Name("simpleAction")
+ <programlisting role="JAVA"><![CDATA[@Name("simpleAction")
public class SimpleAction {
private boolean convertToCap;
@@ -351,14 +312,12 @@
<para>Next, on the web page, add the following line to display the value property on the simpleAction component. Notice that code completion is supported for the JSF EL expression.</para>
- <programlisting role="XML"><![CDATA[
-<p><b>Hello, #{simpleAction.value}</b></p>
+ <programlisting role="XML"><![CDATA[<p><b>Hello, #{simpleAction.value}</b></p>
]]></programlisting>
<para>Finally, on the web page, we add a boolean selection box component. It is bound to the <emphasis><property>convertToCap</property></emphasis> property on the backend component.</para>
- <programlisting role="XML"><![CDATA[
-<h:selectBooleanCheckbox title="convertToCap"
+ <programlisting role="XML"><![CDATA[<h:selectBooleanCheckbox title="convertToCap"
value="#{simpleAction.convertToCap}" />
Capitalize the input?
]]></programlisting>
@@ -379,17 +338,32 @@
<section>
<title>Add Security to the Application</title>
- <para>You have probably noticed that the web page template has a login link at the top of the page. You can use the <property>Seam</property> security framework to secure access to any web page or web action. You can implement the login logic in the XXXX method. In the following example, we just use hardcoded username and password. But you can easily change it to use database, LDAP or any other means.</para>
+ <para>You have probably noticed that the web page template has a login link at the top of the page. You can use the <property>Seam</property> security framework to secure access to any web page or web action. You can implement the login logic in the <emphasis>checkLoggedIn</emphasis> method. In the following example, we just use hardcoded username and password. But you can easily change it to use database, LDAP or any other means.</para>
<programlisting role="JAVA"><![CDATA[
]]></programlisting>
- <para>Then, on the action method, you can use the XXXX annotation to specify that it is only invoked by authenticated users.</para>
+ <para>Then, on the action method, you can use the <emphasis>@AroundInvoke</emphasis> annotation to specify that it is only invoked by authenticated users.</para>
- <programlisting role="JAVA"><![CDATA[
+ <programlisting role="JAVA"><![CDATA[public class LoggedInInterceptor
+ {
+ @AroundInvoke
+ public Object checkLoggedIn(InvocationContext invocation) throws Exception
+ {
+ boolean isLoggedIn = Contexts.getSessionContext().get("loggedIn")!=null;
+ if (isLoggedIn) {
+ //the user is already logged in
+ return invocation.proceed();
+ }
+ else {
+ //the user is not logged in, fwd to login page
+ return "login";
+ }
+ }
+}
]]></programlisting>
- <para>Now, re-deploy the application and try the XXXX button. The application redirects to the XXXX page asking for login credentials. The method is invoked after you successfully logged in.</para>
+ <para>Now, re-deploy the application and try the action button. The application redirects to the <emphasis>login</emphasis> page asking for login credentials. The method is invoked after you successfully logged in.</para>
<figure>
<title>Access control for action methods</title>
@@ -400,12 +374,34 @@
</mediaobject>
</figure>
- <para>We can also secure web pages. You can edit the XXXX file to put an access constraint on the XXXXX page.</para>
+ <para>We can also secure web pages. You can edit the <emphasis>Authenticator.java</emphasis> file to put an access constraint on the login page.</para>
- <programlisting role="XML"><![CDATA[
+ <programlisting role="JAVA"><![CDATA[package.org.domain.MySeamProj.session;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.security.identity;
+
+ @Name ("authenticator")
+ public class Authenticator
+ {
+ @Logger Log log;
+ @In Identity identity;
+
+ public boolean authenticate()
+ {
+ log.info("authenticating #0", identity.getUserName());
+ //write your authentication logic here,
+ //return true if the authentication was
+ //successful, false otherwise
+ identity.addRole("admin");
+ return true;
+ }
+ }
]]></programlisting>
- <para>You can try to load the XXXX URL in the browser and it will redirect to ask for login.</para>
+ <para>You can try to load the http://localhost:8080/MySeamProj/ URL in the browser and it will redirect to ask for login.</para>
</section>
17 years, 3 months
JBoss Tools SVN: r3960 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-10-02 09:55:52 -0400 (Tue, 02 Oct 2007)
New Revision: 3960
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key/KeyLoader.java
Log:
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key/KeyLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key/KeyLoader.java 2007-10-02 13:12:18 UTC (rev 3959)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/meta/key/KeyLoader.java 2007-10-02 13:55:52 UTC (rev 3960)
@@ -20,9 +20,9 @@
public static Properties load(String locale) {
Properties keys = new Properties();
- Set set = getKeyResources(locale);
+ Set<URL> set = getKeyResources(locale);
- Iterator it = set.iterator();
+ Iterator<URL> it = set.iterator();
if(!it.hasNext()) return keys;
while(it.hasNext()) {
URL url = (URL)it.next();
@@ -41,7 +41,7 @@
return keys;
}
- private static Set getKeyResources(String locale) {
+ private static Set<URL> getKeyResources(String locale) {
Set<URL> resources = new HashSet<URL>();
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint("org.jboss.tools.common.model.keys");
IExtension[] es = point.getExtensions();
17 years, 3 months
JBoss Tools SVN: r3959 - trunk/documentation/GettingStartedGuide/docs/userguide/en/modules.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2007-10-02 09:12:18 -0400 (Tue, 02 Oct 2007)
New Revision: 3959
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedWithRHDS.xml
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/RADdevelopmentOfSimpleJSFapplication.xml
Log:
http://jira.jboss.com/jira/browse/RHDS-163
have checked language and content of half of the chapter. the errors were found, language is corrected. content will be corrected.
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedWithRHDS.xml
===================================================================
--- trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedWithRHDS.xml 2007-10-02 09:56:31 UTC (rev 3958)
+++ trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedWithRHDS.xml 2007-10-02 13:12:18 UTC (rev 3959)
@@ -13,7 +13,7 @@
<section id="ConfigJavaEnvironment">
<?dbhtml filename="ConfigJavaEnvironment.html"?>
<title>Configuring Your Java Environment</title>
- <para>You must have a working installation of JDK 1.5 before you install Red Hat Developer Studio. Currently it will only fully work with a 32-bit JVM, not a 64-bit JVM. On a 64-bit JVM the visual editor will fail to launch. Thus in this guide we will show you how to install a 32-bit Sun JDK 5.0 on a Linux Platform and Microsoft Windows Platform.</para>
+ <para>You must have a working installation of JDK 1.5 before you install Red Hat Developer Studio. Currently it will only fully work with a 32-bit JVM, not a 64-bit JVM. On a 64-bit JVM the visual editor fails to launch. Thus in this guide we will show you how to install a 32-bit Sun JDK 5.0 on a Linux Platform and Microsoft Windows Platform.</para>
<section id="InstallJDK50onLinux">
<title>Installing and Configuring 32-bit Sun JDK 5.0 on Linux</title>
<itemizedlist>
@@ -22,10 +22,10 @@
<listitem><para>If you don't want to use SysV service scripts you can install the "self-extracting file" for Linux instead of choosing the "RPM in self-extracting" file.
In that case you can skip the next step mentioned here. But it is recommended to use the SysV service scripts for production servers.</para></listitem>
<listitem><para>Download and install the appropriate -compat RPM from JPackage <ulink url="ftp://jpackage.hmdc.harvard.edu/JPackage/1.7/generic/RPMS.non-free/">here</ulink>.
- Please ensure you choose a matching version of the -compat package to the JDK you installed.</para></listitem>
+ Please ensure you choose a matching version of the -compat package to the JDK you've installed.</para></listitem>
<listitem><para>Create an environment variable that points to the JDK installation directory and call it JAVA_HOME. Add <emphasis><property>$JAVA_HOME/bin</property></emphasis> to the system path to be able to run java from the
command line. You can do this by adding the following lines to the .bashrc file in your home directory.</para>
- <programlisting role="JAVA"><![CDATA[#In this example /usr/java/jdk1.5.0_11 is the JDK installation directory.
+ <programlisting><![CDATA[#In this example /usr/java/jdk1.5.0_11 is the JDK installation directory.
export JAVA_HOME=/usr/java/jdk1.5.0_11
export PATH=$PATH:$JAVA_HOME/bin]]></programlisting>
</listitem>
@@ -36,18 +36,18 @@
You only need to run "alternative" as a safe guard for the right JVM.</para>
</note>
- <para>Set this variable for the your account doing the installation and also for the user account that will run the server.</para>
+ <para>Set this variable for your account doing the installation and also for the user account that will run the server.</para>
<itemizedlist>
- <listitem><para>If you have more than one version of JVM installed in your machine, make sure you are using the JDK 1.5 installation as the default java and javac.
- You can do this using the alternatives system. The alternatives system allows different versions of Java, from different sources to co-exist on your system.</para></listitem>
+ <listitem><para>If you have more than one version of JVM installed on your machine, make sure you are using the JDK 1.5 installation as the default java and javac.
+ You can do this using the alternatives system. The alternatives system allows different versions of Java from different sources to co-exist on your system.</para></listitem>
</itemizedlist>
<section id="SelectAlternativesforJava">
<title>Select alternatives for java, javac and java_sdk_1.5.0</title>
<itemizedlist>
- <listitem><para>As root, type the following command at the shell prompt and you should see something like this:</para></listitem>
+ <listitem><para>As a root user, type the following command at the shell prompt and you should see something like this:</para></listitem>
</itemizedlist>
- <programlisting role="JAVA"><![CDATA[[root@vsr ~]$ /usr/sbin/alternatives --config java
-There are 2 programs which provide 'java'.
+ <programlisting ><![CDATA[[root@vsr ~]$ /usr/sbin/alternatives --config java
+There are 2 programs that provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
@@ -57,15 +57,15 @@
<itemizedlist>
<listitem><para>Repeat the same for javac and java_sdk_1.5.0.</para></listitem>
</itemizedlist>
- <programlisting role="JAVA"><![CDATA[[root@vsr ~]$ /usr/sbin/alternatives --config javac
-There are 1 programs which provide 'javac'.
+ <programlisting ><![CDATA[[root@vsr ~]$ /usr/sbin/alternatives --config javac
+There is 1 program that provides 'javac'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/java-1.5.0-sun/bin/javac
Enter to keep the current selection[+], or type selection number:
[root@vsr ~]$ /usr/sbin/alternatives --config java_sdk_1.5.0
-There are 1 programs which provide 'java_sdk_1.5.0'.
+There is 1 program that provide 'java_sdk_1.5.0'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/java-1.5.0-sun
@@ -84,10 +84,8 @@
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)]]></programlisting>
</section>
-
- </section>
-
- <section id="InstallJDK50onWindows">
+ </section>
+ <section id="InstallJDK50onWindows">
<title>Installing and Configuring 32-bit Sun JDK 5.0 on Microsoft Windows</title>
<itemizedlist>
<listitem><para>Download the <ulink url="http://java.sun.com/javase/downloads/index_jdk5.jsp">Sun JDK 5.0 (Java 2 Development Kit)</ulink> from Sun's website.
@@ -95,18 +93,17 @@
<listitem><para>Create an environment variable called JAVA_HOME that points to the JDK installation directory, for example:</para></listitem>
</itemizedlist>
<para><emphasis>C:\Program Files\Java\jdk1.5.0_11\</emphasis></para>
- <para>In order to run java from the command line add the <emphasis>jre\bin</emphasis> directory to your path, for example:</para>
+ <para>In order to run java from the command line, add the <emphasis>jre\bin</emphasis> directory to your path, for example:</para>
<para><emphasis>C:\Program Files\Java\jdk1.5.0_11\jre\bin</emphasis></para>
- <para>To do this, open the Control Panel from the Start Menu, switch to Classic View if necessary, open the System Control Panel applet, select the Advanced Tab, and click on the Environment Variables button.</para>
-
- </section>
+ <para>To do this, open the Control Panel from the Start Menu, switch to Classic View if necessary, open the System Control Panel applet (System), select the Advanced Tab, and click on the Environment Variables button.</para>
+ </section>
</section>
<section id="InstallingRHDS">
<?dbhtml filename="InstallingRHDS.html"?>
<title>Red Hat Developer Studio Installation</title>
<section id="Instfromdownver">
<title>Installing from the downloaded version</title>
- <para>RHDS comes with simple installer, bundled with tested/pre-configured versions of Eclipse, Webtools, JBossEAP, and SpringIDE.</para>
+ <para>RHDS comes with a simple installer, bundled with tested/pre-configured versions of Eclipse, Webtools, JBossEAP, Seam, and SpringIDE.</para>
<itemizedlist>
<listitem>
<para>Download the appropriate installation file for your platform from <ulink url="http://www.redhat.com/developers/rhds/index.html">Red Hat website</ulink>.</para>
@@ -145,7 +142,7 @@
</figure>
<note>
<title>Note:</title>
- <para>The installer will install JBoss J2EE Application Server for running your applications if you select this option during the installation process.
+ <para>The installer installs JBoss J2EE Application Server for running your applications if you select this option during the installation process.
If you want to use a different server than ours, you can change the setting in Red Hat Developer Studio.</para>
</note>
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/RADdevelopmentOfSimpleJSFapplication.xml
===================================================================
--- trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/RADdevelopmentOfSimpleJSFapplication.xml 2007-10-02 09:56:31 UTC (rev 3958)
+++ trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/RADdevelopmentOfSimpleJSFapplication.xml 2007-10-02 13:12:18 UTC (rev 3959)
@@ -117,17 +117,17 @@
<section id="CreatingResourceFile">
<?dbhtml filename="CreatingResourceFile.html"?>
<title>Creating Resource File</title>
-<para>Red Hat Developer Studio allows to quickly create a resource file. Using this feature you can collect text messages in one central place. A resource file is just a file with a <emphasis>.properties</emphasis> extension. The messages stored in resource file can be displayed to you on a Web page during application execution. </para>
+<para>Red Hat Developer Studio allows to create quickly a resource file. Using this feature you can collect text messages in one central place. A resource file is just a file with a <emphasis>.properties</emphasis> extension. The messages stored in resource file can be displayed to you on a Web page during application execution. </para>
<para>With resource file first, you don't hard code anything into the JSP pages. And second, it makes it easier to translate your application to other languages. All you have to do is to translate all your messages to the other language and save them in a new properties file with a name that ends with the appropriate ISO-639 language code.</para>
<para>It is a good idea to keep your resources inside the <emphasis>JavaSource</emphasis> folder, where you keep your .java files. Every time you build the project, all <emphasis>.properties</emphasis> files will then be copied to the <emphasis>classes</emphasis> folder by default.</para>
<itemizedlist>
<listitem><para>Right click <emphasis>JavaSource</emphasis> folder and select <emphasis>New > Folder</emphasis></para></listitem>
-<listitem><para>Type "game" for Folder name and click Finish</para></listitem>
+<listitem><para>Type "game" for Folder name and click <emphasis><property>Finish</property></emphasis></para></listitem>
</itemizedlist>
<para>We will store in this folder our resource file and java bean.</para>
<itemizedlist>
<listitem><para>Right click game folder and select <emphasis>New > Properties File</emphasis></para></listitem>
-<listitem><para>Type <emphasis>messages</emphasis> as the value for <emphasis>name</emphasis> attribute and click Finish</para></listitem>
+<listitem><para>Type <emphasis>messages</emphasis> as the value for <emphasis>name</emphasis> attribute and click <emphasis><property>Finish</property></emphasis></para></listitem>
</itemizedlist>
<para>Red Hat Developer Studio will automatically open messages.properties file for editing.</para>
<figure>
@@ -141,7 +141,7 @@
<itemizedlist>
<listitem><para>Click <emphasis>Add</emphasis> button</para></listitem>
<listitem><para>Type <emphasis role="italic"><property>how_to_play</property></emphasis> for "name" and <emphasis role="italic"><property>Please pick a number between 0 and 100.</property></emphasis> for value</para></listitem>
-<listitem><para>Click Finish</para></listitem>
+<listitem><para>Click <emphasis><property>Finish</property></emphasis></para></listitem>
<listitem><para>In such a way add the next properties:</para></listitem>
</itemizedlist>
<programlisting role="JAVA"><![CDATA[makeguess_button=Make Guess
@@ -183,7 +183,7 @@
<itemizedlist>
<listitem><para>Right click NumberBean.java in Package Explorer</para></listitem>
<listitem><para>Select <emphasis>Source > Generate Getters and Setters...</emphasis></para></listitem>
-<listitem><para>Check <emphasis>userNumber</emphasis> box and click OK
+<listitem><para>Check <emphasis>userNumber</emphasis> box and click <emphasis><property>OK</property></emphasis>
<figure>
<title>Generate Getters and Setters</title>
<mediaobject>
@@ -316,9 +316,9 @@
<section id="EditingFacesConfig">
<?dbhtml filename="EditingFacesConfig.html"?>
<title>Editing faces-config.xml File</title>
-<para>This file holds our two navigation rules and defines the backing bean used.</para>
+<para>This file holds two navigation rules and defines the backing bean used.</para>
<itemizedlist>
-<listitem><para>Open faces-config.xml file in source mode</para></listitem>
+<listitem><para>Open faces-config.xml file in a source mode</para></listitem>
<listitem><para>Add here one more navigation rule and a managed bean declarations that the content of the file looks like this:</para></listitem>
</itemizedlist>
<programlisting role="XML"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
@@ -420,7 +420,7 @@
</mediaobject>
</figure>
<itemizedlist>
-<listitem><para>Switch to Visual tab, so we can work with the editor completely in its WYSIWYG mode</para></listitem>
+<listitem><para>Switch to Visual tab, so it could be possible to work with the editor completely in its WYSIWYG mode</para></listitem>
<listitem><para>Click on <emphasis>outputText</emphasis>, drag the cursor over to the editor, and drop it inside the blue box in the editor</para></listitem>
<listitem><para>Select <emphasis>value</emphasis> and click on this line below "value" header</para></listitem>
@@ -437,7 +437,7 @@
</figure>
<itemizedlist>
<listitem><para>Expand <emphasis>Resource Bundles > msg</emphasis></para></listitem>
-<listitem><para>Select "how_to_play" value and click Ok. Then click <emphasis><property>Finish</property></emphasis>
+<listitem><para>Select "how_to_play" value and click <emphasis><property>Ok</property></emphasis>. Then click <emphasis><property>Finish</property></emphasis>
<figure>
<title>Selecting Value</title>
<mediaobject>
@@ -460,10 +460,10 @@
<itemizedlist>
<listitem><para>Switch to Source mode and insert <emphasis role="bold"><property><br/></property></emphasis> tag after <emphasis role="bold"><property><h:outputText></property></emphasis> component to make a new line.</para></listitem>
<listitem><para>Click <emphasis><property>Save</property></emphasis> button.</para></listitem>
-<listitem><para>On the Palette Click on <emphasis>inputText</emphasis>, drag the cursor over to the editor, and drop it inside the editor after the text.</para></listitem>
-<listitem><para>Switch to Source mode and insert <emphasis role="bold"><property><br/></property></emphasis> tag after <emphasis role="bold"><property><h:outputText></property></emphasis> component to make a new line</para></listitem>
-<listitem><para>Click Save button</para></listitem>
-<listitem><para>On the Palette Click on <emphasis>inputText</emphasis>, drag the cursor over to the editor, and drop it inside the editor after the text</para></listitem>
+<listitem><para>On the Palette click on <emphasis>inputText</emphasis>, drag the cursor over to the editor, and drop it inside the editor after the text.</para></listitem>
+<listitem><para>Switch to a Source mode and insert <emphasis role="bold"><property><br/></property></emphasis> tag after <emphasis role="bold"><property><h:outputText></property></emphasis> component to make a new line</para></listitem>
+<listitem><para>Click <emphasis><property>Save</property></emphasis> button</para></listitem>
+<listitem><para>On the Palette click on <emphasis>inputText</emphasis>, drag the cursor over to the editor, and drop it inside the editor after the text</para></listitem>
<listitem><para>Select <emphasis>value</emphasis> and click on this line below "value" header</para></listitem>
<listitem><para>Click <emphasis>...</emphasis> button next to the value field</para></listitem>
<listitem><para>Expand <emphasis>Managed Beans > NumberBean</emphasis></para></listitem>
@@ -495,14 +495,14 @@
<listitem><para>Click <emphasis><property>Save</property></emphasis> button</para></listitem>
<listitem><para>Again select Visual mode</para></listitem>
<listitem><para>On the Palette, click on <emphasis>commandButton</emphasis>, drag the cursor over to the editor, and drop it inside the editor after the inputText component.</para></listitem>
-<listitem><para>On the Palette Click on <emphasis>commandButton</emphasis>, drag the cursor over to the editor, and drop it inside the editor after the inputText component</para></listitem>
+<listitem><para>On the Palette click on <emphasis>commandButton</emphasis>, drag the cursor over to the editor, and drop it inside the editor after the inputText component</para></listitem>
<listitem><para>In the editing dialog select <emphasis>value</emphasis> and click on this line below "value" header</para></listitem>
<listitem><para>Click <emphasis>...</emphasis> button next to the value field</para></listitem>
<listitem><para>Expand <emphasis>Resource Bundles > msg</emphasis> and select <emphasis>makeguess_button</emphasis> as a value</para></listitem>
<listitem><para>Click Ok</para></listitem>
<listitem><para>Select <emphasis>action</emphasis> and click on this line below "value" header</para></listitem>
<listitem><para>Type "NumberBean.checkGuess" in text field</para></listitem>
-<listitem><para>Click Finish</para></listitem>
+<listitem><para>Click <emphasis><property>Finish</property></emphasis></para></listitem>
<listitem><para>In Source mode add <emphasis role="bold"><property><br/></property></emphasis> tags between <emphasis role="bold"><property><outputText></property></emphasis>, <emphasis role="bold"><property><inputText></property></emphasis> and <emphasis role="bold"><property><commandButton></property></emphasis> components to place them on different lines</para></listitem>
</itemizedlist>
<para>inputnumber.jsp page should look like this:</para>
17 years, 3 months
JBoss Tools SVN: r3958 - trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-10-02 05:56:31 -0400 (Tue, 02 Oct 2007)
New Revision: 3958
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server/ChangeTimeStampActionDelegate.java
Log:
JBIDE-929 actually call timestamp on file
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server/ChangeTimeStampActionDelegate.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server/ChangeTimeStampActionDelegate.java 2007-10-02 09:54:38 UTC (rev 3957)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/action/server/ChangeTimeStampActionDelegate.java 2007-10-02 09:56:31 UTC (rev 3958)
@@ -125,7 +125,8 @@
List<IFile> fs = getFilesToTouch(project);
for (int i = 0; i < fs.size(); i++) {
IFile f = (IFile)fs.get(i);
- f.touch(new NullProgressMonitor());
+ f.setLocalTimeStamp(System.currentTimeMillis());
+ f.touch(new NullProgressMonitor()); // done so deployers/listeners can detect the actual change.
}
}
17 years, 3 months