JBoss Tools SVN: r7148 - in trunk/seam/tests/org.jboss.tools.seam.core.test/projects: Test1 and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2008-03-27 11:51:57 -0400 (Thu, 27 Mar 2008)
New Revision: 7148
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/.project
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1-ear/.project
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1-ejb/.project
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/.project
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/.project
Log:
http://jira.jboss.com/jira/browse/JBIDE-1733
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/.project
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/.project 2008-03-27 15:16:00 UTC (rev 7147)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/.project 2008-03-27 15:51:57 UTC (rev 7148)
@@ -21,11 +21,6 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.jboss.tools.common.verification.verifybuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.jboss.tools.seam.core.seambuilder</name>
<arguments>
</arguments>
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/.project
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/.project 2008-03-27 15:16:00 UTC (rev 7147)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1/.project 2008-03-27 15:51:57 UTC (rev 7148)
@@ -16,16 +16,6 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.jboss.tools.common.verification.verifybuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.jboss.tools.seam.core.seambuilder</name>
<arguments>
</arguments>
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1-ear/.project
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1-ear/.project 2008-03-27 15:16:00 UTC (rev 7147)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1-ear/.project 2008-03-27 15:51:57 UTC (rev 7148)
@@ -13,11 +13,6 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.jboss.ide.eclipse.archives.core.archivesBuilder</name>
<arguments>
</arguments>
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1-ejb/.project
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1-ejb/.project 2008-03-27 15:16:00 UTC (rev 7147)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/Test1-ejb/.project 2008-03-27 15:51:57 UTC (rev 7148)
@@ -16,11 +16,6 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.jboss.ide.eclipse.archives.core.archivesBuilder</name>
<arguments>
</arguments>
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/.project
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/.project 2008-03-27 15:16:00 UTC (rev 7147)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/TestScanner/.project 2008-03-27 15:51:57 UTC (rev 7148)
@@ -16,16 +16,6 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.wst.validation.validationbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.jboss.tools.common.verification.verifybuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.jboss.tools.seam.core.seambuilder</name>
<arguments>
</arguments>
16 years, 1 month
JBoss Tools SVN: r7147 - trunk/documentation/guides/GettingStartedGuide/en/modules.
by jbosstools-commits@lists.jboss.org
Author: afedosik
Date: 2008-03-27 11:16:00 -0400 (Thu, 27 Mar 2008)
New Revision: 7147
Modified:
trunk/documentation/guides/GettingStartedGuide/en/modules/getting_started.xml
Log:
http://jira.jboss.com/jira/browse/JBDS-268 A mention about Dependencies between standalone plug-ins is added in JBoss Tools Installation section.
Modified: trunk/documentation/guides/GettingStartedGuide/en/modules/getting_started.xml
===================================================================
--- trunk/documentation/guides/GettingStartedGuide/en/modules/getting_started.xml 2008-03-27 13:13:43 UTC (rev 7146)
+++ trunk/documentation/guides/GettingStartedGuide/en/modules/getting_started.xml 2008-03-27 15:16:00 UTC (rev 7147)
@@ -355,6 +355,9 @@
<property>plugins/features</property>
</emphasis> directory and it will be readily available. It might be necessary to start Eclipse
with eclipse -clean to make sure it starts clean and rereads the new list of plugins.</para>
+
+ <para>If you need to install any standalone plug-in from JBoss Tools visit a
+ <ulink url="http://labs.jboss.com/wiki/InstallingJBossTools">JBoss Tools Wiki</ulink> page to read about dependencies between standalone plug-ins.</para>
</section>
</section>
16 years, 1 month
JBoss Tools SVN: r7146 - in trunk: common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-03-27 09:13:43 -0400 (Thu, 27 Mar 2008)
New Revision: 7146
Removed:
trunk/common/plugins/org.jboss.tools.common.kb/resources/icons/
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/DtdDeclarationException.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/JspKbConnector.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdConvertor.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdResource.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdStore.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlMap.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbIcon.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbJspDirectiveStore.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPreferencesConstants.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/XmlKbConnector.java
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbConnectorType.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlStore.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/TagDescriptor.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/configuration/KbConfiguration.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/configuration/KbPluginConfiguration.java
trunk/common/tests/org.jboss.tools.common.kb.test/src/org/jboss/tools/common/kb/test/resources/TestDynamicResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbImageFileResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdActionResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundleNameResource.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdTaglibResource.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1495
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/DtdDeclarationException.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/DtdDeclarationException.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/DtdDeclarationException.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-/**
- * @author eskimo
- */
-public class DtdDeclarationException extends Exception {
-
- private static final long serialVersionUID = 7273236131209833023L;
-}
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/JspKbConnector.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/JspKbConnector.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/JspKbConnector.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,446 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-
-/**
- * @author eskimo
- */
-public class JspKbConnector implements KbConnector {
-
- private ArrayList<KbResource> registretedResources;
- private ArrayList<KbDinamicResource> registretedDinamicResources;
-// private static KbResource jsfVariables = JsfValuesResource.getInstance();
-
- /**
- *
- *
- */
- public JspKbConnector() {
- registretedResources = new ArrayList<KbResource>();
- registretedDinamicResources = new ArrayList<KbDinamicResource>();
- KbResource jspResource = KbTldStore.getInstance().getJspResource();
- if(jspResource!=null) {
- registretedResources.add(jspResource);
- }
-// registerResource(jsfVariables);
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbConnector#queryTagInformation(org.jboss.tools.common.kb.KbQuery)
- */
- public TagDescriptor getTagInformation(String query) throws KbException {
- KbPlugin.getPluginLog().logInfo("Query=" + query);
- String lastTag = getLastCompleteTag(query);
- KbPlugin.getPluginLog().logInfo("lastTag=" + lastTag);
- if(lastTag==null) {
- return null;
- }
- if(lastTag.indexOf(KbQuery.PREFIX_SEPARATOR)<0) {
- return KbHtmlStore.getInstance().queryTagInformation(new KbQuery(query, registretedResources));
- }
-// StringBuffer tldQuery = new StringBuffer();
-// tldQuery.append(KbQuery.TAG_SEPARATOR).append(lastTag).append(KbQuery.TAG_SEPARATOR);
-// return KbTldStore.getInstance().queryTagInformation(new KbQuery(tldQuery.toString(), registretedResources));
- return KbTldStore.getInstance().queryTagInformation(new KbQuery(query, registretedResources));
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbConnector#getProposals()
- **/
- public Collection getProposals(String query) throws KbException {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> JspKbConnector.getProposals(String query)");
- KbPlugin.getPluginLog().logInfo("Query=" + query);
- }
-
- int tagSeparator = query.indexOf(KbQuery.TAG_SEPARATOR);
- boolean jspDirectiveQuery = query.startsWith(KbQuery.JSP_DIRECTIVE_QUERY);
- if((tagSeparator<0)&&(!jspDirectiveQuery)) {
- // Bad query
- String errorMessage = "ERROR: Bad query: " + query + ". Query must starts with \"" + KbQuery.TAG_SEPARATOR + "\" or \"" + KbQuery.JSP_DIRECTIVE_QUERY + "\"";
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(errorMessage);
- }
- throw new IllegalArgumentException(errorMessage);
- }
-
- boolean autocompleteRequiredAttributes = KbConfigurationFactory.getInstance().getDefaultConfiguration().isAutocompleteRequiredAttributes();
-
- Collection<KbProposal> jspDirectiveProposals = new ArrayList<KbProposal>();
- if(query.startsWith(KbQuery.JSP_DIRECTIVE_QUERY)) {
- jspDirectiveProposals = KbJspDirectiveStore.getInstance().queryProposal(new KbQuery(query));
- if(!autocompleteRequiredAttributes) {
- removeAutocompleteRequiredAttributes(jspDirectiveProposals);
- }
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- JspKbConnector.getProposals(String query)");
- KbPlugin.getPluginLog().logInfo(" proposals size=" + jspDirectiveProposals.size());
- }
-
- return jspDirectiveProposals;
- } else if(query.lastIndexOf(KbQuery.TAG_SEPARATOR) + KbQuery.TAG_SEPARATOR.length() == query.length()) {
- jspDirectiveProposals = KbJspDirectiveStore.getInstance().queryProposal(new KbQuery(KbQuery.JSP_DIRECTIVE_QUERY));
- }
-
- JspQuery jspQuery = parseQuery(query);
-
- String tldQuery = jspQuery.getTldQuery();
- String htmlQuery = jspQuery.getHtmlQuery();
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("tld query - " + tldQuery);
- KbPlugin.getPluginLog().logInfo("html query - " + htmlQuery);
- }
-
- Collection<KbProposal> tldProposals = new ArrayList<KbProposal>();
- Collection<KbProposal> htmlProposals = new ArrayList<KbProposal>();
-
- if(tldQuery!=null) {
- KbQuery kbQuery = new KbQuery(tldQuery, registretedResources, registretedDinamicResources);
- tldProposals = KbTldStore.getInstance().queryProposal(kbQuery);
- }
-
- if(jspQuery.getLastTldTag()!=null) {
- String mask = "";
- int lastSeparator = query.lastIndexOf(KbQuery.TAG_SEPARATOR);
- if((lastSeparator!=-1)&&(lastSeparator + KbQuery.TAG_SEPARATOR.length()<query.length())) {
- mask = query.substring(lastSeparator + KbQuery.TAG_SEPARATOR.length());
- }
-
- if(((mask.indexOf(KbQuery.DONT_FILTER_END_TAG_CHAR)!=-1)&&(KbQuery.DONT_FILTER_END_TAG_CHAR + jspQuery.getLastTldTag()).startsWith(mask))||(mask.equals(""))) {
- KbProposal proposal = new KbProposal();
- String label = "/" + jspQuery.getLastTldTag();
- proposal.setLabel(label);
- proposal.setReplacementString(label);
- proposal.setIcon(KbIcon.TLD_TAG);
- if(tldProposals instanceof List) {
- ((List<KbProposal>)tldProposals).add(0, proposal);
- } else {
- tldProposals.add(proposal);
- }
- }
- }
-
- if(htmlQuery!=null) {
- boolean lowerCase = KbConfigurationFactory.getInstance().getDefaultConfiguration().isLowerCase();
- KbQuery kbQuery = new KbQuery(htmlQuery);
- htmlProposals = KbHtmlStore.getInstance().queryProposal(kbQuery);
- changeCase(htmlProposals, lowerCase);
- }
-
- ArrayList<KbProposal> proposals = mergeCollection(tldProposals, htmlProposals);
- proposals = mergeCollection(proposals, jspDirectiveProposals);
- proposals = sortProposals(proposals, query);
-
- if(!autocompleteRequiredAttributes) {
- removeAutocompleteRequiredAttributes(proposals);
- }
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- JspKbConnector.getProposals(String query)");
- KbPlugin.getPluginLog().logInfo(" proposals size=" + proposals.size());
- }
-
- return proposals;
- }
-
- private ArrayList<KbProposal> mergeCollection(Collection<KbProposal> col1, Collection<KbProposal> col2) {
- ArrayList<KbProposal> arrayList = new ArrayList<KbProposal>();
- Iterator<KbProposal> iterator = col1.iterator();
- while(iterator.hasNext()) {
- arrayList.add(iterator.next());
- }
- iterator = col2.iterator();
- while(iterator.hasNext()) {
- arrayList.add(iterator.next());
- }
- return arrayList;
- }
-
- private ArrayList<KbProposal> sortProposals(Collection<KbProposal> proposals, String query) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> JspKbConnector.sortProposals(Collection proposals)");
-// KbPlugin.getPluginLog().logInfo("Proposals = " + proposals);
- }
-
- ArrayList<KbProposal> closeTags = new ArrayList<KbProposal>();
- ArrayList<KbProposal> openTags = new ArrayList<KbProposal>(proposals.size());
-
- for(Iterator<KbProposal> iter = proposals.iterator(); iter.hasNext();) {
- KbProposal proposal = iter.next();
- if(proposal.isCloseTag()) {
- closeTags.add(proposal);
- } else {
- openTags.add(proposal);
- }
- }
-
- String lastTag = getLastCompleteTag(query);
- if((lastTag!=null)&&(closeTags.size()>0)) {
- for(Iterator iter = closeTags.iterator(); iter.hasNext();) {
- KbProposal proposal = (KbProposal)iter.next();
- if(proposal.getLabel().equals("/" + lastTag)) {
- closeTags.remove(proposal);
- closeTags.add(0, proposal);
- break;
- }
- }
- }
-
- ArrayList<KbProposal> collection = mergeCollection(closeTags, openTags);
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- JspKbConnector.sortProposals()");
-// KbPlugin.getPluginLog().logInfo("return Collection = [" + collection +"]");
- }
-
- return collection;
- }
-
- private JspQuery parseQuery(String query) {
- JspQuery jspQuery = new JspQuery();
-
- jspQuery.setLastTldTag(getLastTldTag(query));
-
- String lastTag = getLastTagMask(query);
- if(lastTag.indexOf(KbQuery.ATTRIBUTE_SEPARATOR)!=-1) {
- if(lastTag.indexOf(KbQuery.PREFIX_SEPARATOR)!=-1) {
- jspQuery.setTldQuery(KbQuery.TAG_SEPARATOR + lastTag);
- return jspQuery;
- }
- jspQuery.setHtmlQuery(KbQuery.TAG_SEPARATOR + lastTag);
- return jspQuery;
- }
- jspQuery.setTldQuery(KbQuery.TAG_SEPARATOR + lastTag);
-
- if(lastTag.indexOf(KbQuery.PREFIX_SEPARATOR)!=-1) {
- return jspQuery;
- }
-
- StringTokenizer tags = new StringTokenizer(query, KbQuery.TAG_SEPARATOR, true);
-
- StringBuffer htmlQuery = new StringBuffer();
- while(tags.hasMoreTokens()) {
- String tag = tags.nextToken();
- if(!htmlQuery.toString().endsWith(KbQuery.TAG_SEPARATOR)) {
- htmlQuery.append(KbQuery.TAG_SEPARATOR);
- }
- if(tag.equals(KbQuery.TAG_SEPARATOR)) {
- continue;
- }
- if(tag.indexOf(KbQuery.PREFIX_SEPARATOR) < 0) {
- htmlQuery.append(tag);
- }
- }
-
- jspQuery.setHtmlQuery(htmlQuery.toString());
-
- return jspQuery;
- }
-
- private String getLastTldTag(String query) {
- StringTokenizer tags = new StringTokenizer(query, KbQuery.TAG_SEPARATOR, true);
-
- String lastTag = null;
- while(tags.hasMoreTokens()) {
- String tag = tags.nextToken();
- if(tag.equals(KbQuery.TAG_SEPARATOR)) {
- continue;
- }
- if((tag.indexOf(KbQuery.PREFIX_SEPARATOR) != -1)&&(tags.hasMoreTokens())) {
-// KbPlugin.log("tag - " + tag);
- lastTag = tag;
- }
- }
- return lastTag;
- }
-
- private String getLastTagMask(String query) {
- int lastTagSeparator = query.lastIndexOf(KbQuery.TAG_SEPARATOR);
- if(lastTagSeparator < 0) {
- return null;
- }
- int endLastTagSeparator = lastTagSeparator + KbQuery.TAG_SEPARATOR.length();
- if(endLastTagSeparator < query.length()) {
- return query.substring(endLastTagSeparator);
- }
- return "";
- }
-
- private String getLastCompleteTag(String query) {
- int lastTagSeparator = query.lastIndexOf(KbQuery.TAG_SEPARATOR);
- if(lastTagSeparator < 0) {
- return null;
- }
-
- String shortQuery = query.substring(0, lastTagSeparator);
- int nextToLastTagSeparator = shortQuery.lastIndexOf(KbQuery.TAG_SEPARATOR);
- if(nextToLastTagSeparator < 0) {
- return null;
- }
-
- int endNextToLastTagSeparator = nextToLastTagSeparator + KbQuery.TAG_SEPARATOR.length();
- return query.substring(endNextToLastTagSeparator, lastTagSeparator);
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbConnector#RegisterResource(org.jboss.tools.common.kb.KbResource)
- */
- public boolean registerResource(KbResource resource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> JspKbConnector.registerResource(KbResource resource)");
- KbPlugin.getPluginLog().logInfo(" resource=" + resource);
- }
- if(resource instanceof KbTldResource) {
-// KbTldResource tldResource =(KbTldResource)resource;
- registretedResources.add(resource);
-
- KbTldStore.getInstance().registerResource(resource);
- } else if(resource instanceof KbDinamicResource) {
- registretedDinamicResources.add((KbDinamicResource)resource);
- KbTldStore.getInstance().registerResource(resource);
- } else {
- throw new IllegalArgumentException("JspKbConnector.registerResource(KbResource resource): resource must be instance of KbTldResource or KbDinamicResource");
- }
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" registretedResources=" + registretedResources);
- KbPlugin.getPluginLog().logInfo("<-- JspKbConnector.registerResource(KbResource resource)");
- }
- return true;
- }
-/*
- private KbTldResource findEqualTldResource(KbTldResource resource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.log("--> JspKbConnector.findEqualTldResource(KbTldResource resource)");
- KbPlugin.log(" reg size = " + registretedResources.size());
- }
- for(int i=0; i<registretedResources.size(); i++) {
-// KbPlugin.log(i + " = " + registretedResources.get(i));
- if(registretedResources.get(i).equals(resource)) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.log("<-- JspKbConnector.findEqualTldResource(KbTldResource resource)");
- KbPlugin.log(" return: " + registretedResources.get(i));
- }
- return (KbTldResource)registretedResources.get(i);
- }
- }
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.log("<-- JspKbConnector.findEqualTldResource(KbTldResource resource)");
- KbPlugin.log(" return: null");
- }
- return null;
- }
-*/
- /**
- * @see org.jboss.tools.common.kb.KbConnector#RegisterResource(org.jboss.tools.common.kb.KbResource)
- */
- public void unregisterResource(KbResource resource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> JspKbConnector.unregisterResource(KbResource resource)");
- KbPlugin.getPluginLog().logInfo(" resource: " + resource.toString());
- }
-
- if(resource instanceof KbTldResource) {
- KbTldResource tldResource =(KbTldResource)resource;
-
- KbTldStore.getInstance().unregisterResourcePrefix(tldResource);
- registretedResources.remove(resource);
- } else if(resource instanceof KbDinamicResource) {
- KbTldStore.getInstance().unregisterResource(resource);
- registretedDinamicResources.remove(resource);
- } else {
- throw new IllegalArgumentException("JspKbConnector.unregisterResource(KbResource resource): resource must be instance of KbTldResource or KbDinamicResource");
- }
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- JspKbConnector.unregisterResource(KbResource resource)");
- }
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return "Resources size = " + registretedResources.size();
- }
-
- private void changeCase(Collection proposals, boolean lowerCase) {
- for(Iterator iter = proposals.iterator(); iter.hasNext();) {
- ((KbProposal)iter.next()).changeCase(lowerCase);
- }
- }
-
- private void removeAutocompleteRequiredAttributes(Collection proposals) {
- for(Iterator iter = proposals.iterator(); iter.hasNext();) {
- ((KbProposal)iter.next()).removeAutocompleteRequiredAttributes();
- }
- }
-
- private class JspQuery {
- private String htmlQuery;
- private String tldQuery;
- private String lastTldTag;
-
- /**
- * @return
- */
- public String getHtmlQuery() {
- return htmlQuery;
- }
-
- /**
- * @return
- */
- public String getTldQuery() {
- return tldQuery;
- }
-
- /**
- * @param string
- */
- public void setHtmlQuery(String string) {
- htmlQuery = string;
- }
-
- /**
- * @param string
- */
- public void setTldQuery(String string) {
- if(string.indexOf(KbQuery.PREFIX_SEPARATOR + KbQuery.ATTRIBUTE_SEPARATOR) < 0) {
- tldQuery = string;
- }
- }
-
- /**
- * @return
- */
- public String getLastTldTag() {
- return lastTldTag;
- }
-
- /**
- * @param string
- */
- public void setLastTldTag(String string) {
- lastTldTag = string;
- }
- }
-}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbConnectorType.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbConnectorType.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbConnectorType.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -41,29 +41,9 @@
return getConnectorClass().getName();
}
- /**
- *
- */
- public static KbConnectorType XML_KB_CONNECTOR =
- new KbConnectorType() {
- public Class getConnectorClass() {
- return XmlKbConnector.class;
- }
- };
-
/**
*
*/
- public static KbConnectorType JSP_KB_CONNECTOR =
- new KbConnectorType() {
- public Class getConnectorClass() {
- return JspKbConnector.class;
- }
- };
-
- /**
- *
- */
public static KbConnectorType JSP_WTP_KB_CONNECTOR =
new KbConnectorType() {
public Class getConnectorClass() {
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdConvertor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdConvertor.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdConvertor.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Vector;
-
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-import com.wutka.dtd.DTD;
-import com.wutka.dtd.DTDAttribute;
-import com.wutka.dtd.DTDComment;
-import com.wutka.dtd.DTDContainer;
-import com.wutka.dtd.DTDDecl;
-import com.wutka.dtd.DTDElement;
-import com.wutka.dtd.DTDEnumeration;
-import com.wutka.dtd.DTDItem;
-import com.wutka.dtd.DTDName;
-import com.wutka.dtd.DTDParser;
-
-/**
- * @author igels
- */
-public class KbDtdConvertor implements KbSchemaConvertor {
-
-
- private static final KbDtdConvertor INSTANCE = new KbDtdConvertor();
-
- private KbDtdConvertor() {
- super();
- }
-
- /**
- *
- * @return
- */
- public static KbDtdConvertor getInstance() {
- return INSTANCE;
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbSchemaConvertor#convertToSchema(java.io.InputStream)
- */
- public Document convertToSchema(InputStream inputStream) {
- return convertToSchema(new InputStreamReader(inputStream), new Properties());
- }
-
- /**
- *
- * @param reader
- * @param attributes
- * @return
- */
- public Document convertToSchema(Reader reader, Properties attributes) {
- DTD dtdRoot;
- Document document=null;
- try {
- DTDParser parser = new DTDParser(reader);
- dtdRoot = parser.parse();
-
- document = prepareDocument(dtdRoot, attributes);
-// Object[] objs = dtdRoot.getItems();
-
- // first add Attributes and Elements definitions
- List elements = Arrays.asList(dtdRoot.getItems());
-
- if(elements.size() > 0){
-// set root element
- if(elements.size()!=0) {
- int i=0;
- // find first dtd element
- while(! (elements.get(i) instanceof DTDElement))i++;
- DTDElement element = (DTDElement)elements.get(i);
- document.getDocumentElement().setAttribute(SchemaNodeFactory.ROOT_ELEMENT_ATTRIBUTE, element.getName());
- }
- }
-
- for(int i=0;i<elements.size();i++) {
- if (elements.get(i) instanceof DTDElement) {
- DTDComment previousComment = null;
- if(i!=0 && (elements.get(i-1) instanceof DTDComment)) previousComment = (DTDComment)elements.get(i-1);
- prepareElementTypeNode(document.getDocumentElement(),(DTDElement)elements.get(i),previousComment);
- }
-
- }
-
- } catch (IOException e) {
- KbPlugin.getPluginLog().logError(e);
- }
-
- return document;
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbSchemaConvertor#convertToSchema(org.jboss.tools.common.kb.KbDtdResource)
- */
- public Document convertToSchema(KbResource resource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdConvertor.convertToSchema(KbResource resource)");
- KbPlugin.getPluginLog().logInfo(" resource = " + resource);
- }
-
- // KbPlugin.log("convert resource - " + resource);
- KbDtdResource dtdResource = null;
- if(resource instanceof KbDtdResource) {
- dtdResource = (KbDtdResource)resource;
- } else {
- throw new IllegalArgumentException("KbDtdConvertor.convertToSchema(KbResource resource): resource must be instance of KbDtdResource");
- }
- Properties attributes = new Properties();
- attributes.put(SchemaNodeFactory.URI_ATTRIBUTE, dtdResource.getUri());
- attributes.put(SchemaNodeFactory.URL_ATTRIBUTE, dtdResource.getId());
-
- InputStream is = dtdResource.getInputStream();
- if(is==null) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Can't get Input Stream from resource.");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdConvertor.convertToSchema(KbResource resource)");
- KbPlugin.getPluginLog().logInfo(" return = null");
- }
- return null;
- }
- return convertToSchema(new InputStreamReader(is), attributes);
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbSchemaConvertor#convertToSchema(java.io.File)
- */
- public Document convertToSchema(File dtdFile) {
- try {
- return convertToSchema(new FileReader(dtdFile), new Properties());
- } catch (FileNotFoundException e) {
- KbPlugin.getPluginLog().logError(e);
- return null;
- }
- }
-
- private Document prepareDocument(DTD dtd, Properties attributes) {
-// Vector notations = dtd.getItemsByType(DTDNotation.class);
-// KbPlugin.log("Notation URI = " + notations.size());
- Document document = SchemaNodeFactory.getInstance().createSchemaDocument(attributes);
- return document;
- }
-
- public static final String EMPTY = "EMPTY";
- public static final String ANY = "ANY";
- public static final String PCDATA = "PCDATA";
-
- private void prepareElementTypeNode(Element parent,DTDElement dtdElement, DTDComment comment) {
- Properties attributes = new Properties();
- prepareElementTypeAttributes(dtdElement,attributes);
-
- DTDItem item = dtdElement.getContent();
- Collection<String> content = new ArrayList<String>();
- getElementContent(item,content);
-
- if(content.size()==1) {
- Object element = content.iterator().next();
- if(EMPTY.equalsIgnoreCase(element.toString()))
- attributes.put(SchemaNodeFactory.BODY_CONTENT_ATTRIBUTE,SchemaNodeFactory.REFUSED_BODY_CONTENT_TYPE);
- } else {
- attributes.put(SchemaNodeFactory.BODY_CONTENT_ATTRIBUTE,SchemaNodeFactory.ALLOWED_BODY_CONTENT_TYPE);
- }
-
- Element child = SchemaNodeFactory.getInstance().createElementType(parent,attributes);
- if(comment!=null && KbConfigurationFactory.getInstance().getDefaultConfiguration().isUtilizeComments()) {
- SchemaNodeFactory.getInstance().createDescription(child,comment.getText());
- }
-
- Collection values = dtdElement.attributes.values();
-
- for (Iterator iter = values.iterator(); iter.hasNext();) {
- DTDAttribute element = (DTDAttribute) iter.next();
- prepareAttributeTypeNode(child,element);
- prepareAttributeNode(child,element);
- }
-
- for(Iterator i=content.iterator();i.hasNext();) {
- String contentItem = i.next().toString();
- if(ANY.equalsIgnoreCase(contentItem) || EMPTY.equalsIgnoreCase(contentItem) || PCDATA.equalsIgnoreCase(contentItem)) continue;
- prepareElementNode(child,contentItem.toString());
- }
- }
-
- private void getElementContent(DTDItem item, Collection<String> content) {
- if(item instanceof DTDContainer) {
- DTDContainer container = (DTDContainer)item;
- for(int i=0;i<container.getItems().length;i++) {
- getElementContent(container.getItem(i),content);
- }
- }if(item instanceof DTDName) {
- String name = ((DTDName)item).getValue();
- if(!content.contains(name)) content.add(name);
- return;
- }
- }
-
- private void prepareAttributeTypeNode(Element element,DTDAttribute dtdElement) {
- Properties attributes = new Properties();
- prepareAttributeTypeAttributes(dtdElement,attributes);
- SchemaNodeFactory.getInstance().createAttributeType(element,attributes);
-
- }
-
- private void prepareAttributeNode(Element element,DTDAttribute dtdAttribute) {
- Properties attributes = new Properties();
- prepareAttributeAttributes(dtdAttribute,attributes);
- SchemaNodeFactory.getInstance().createAttribute(element,attributes);
- }
-
- private void prepareElementNode(Element element,String name) {
- Properties attributes = new Properties();
- attributes.put(SchemaNodeFactory.TYPE_ATTRIBUTE,name);
- SchemaNodeFactory.getInstance().createElement(element,attributes);
- }
-
- private void prepareElementTypeAttributes(DTDElement element,Properties attributes) {
-// DTDItem item = element.getContent();
- attributes.put(SchemaNodeFactory.NAME_ATTRIBUTE,element.getName());
- attributes.put(SchemaNodeFactory.START_TAG_ATTRIBUTE,SchemaNodeFactory.REQUIRED_TAG_TYPE);
- attributes.put(SchemaNodeFactory.END_TAG_ATTRIBUTE,SchemaNodeFactory.REQUIRED_TAG_TYPE);
- }
-
- private void prepareAttributeTypeAttributes(DTDAttribute element,Properties attributes) {
- attributes.put(SchemaNodeFactory.NAME_ATTRIBUTE,element.getName());
- attributes.put(SchemaNodeFactory.DEFAULT_ATTRIBUTE,element.getDefaultValue()==null?"":element.getDefaultValue());
- String enumList = getEnumValues(element);
- if(!"".equals(enumList)) {
- attributes.put(SchemaNodeFactory.TYPE_ATTRIBUTE,SchemaNodeFactory.ENUMERATION_TYPE);
- attributes.put(SchemaNodeFactory.VALUES_ATTRIBUTE,getEnumValues(element));
- }
- attributes.put(SchemaNodeFactory.REQUIRED_ATTRIBUTE,(element.getDecl() == DTDDecl.REQUIRED)+"");
- }
-
- private void prepareAttributeAttributes(DTDAttribute attribute,Properties attributes) {
- attributes.put(SchemaNodeFactory.DEFAULT_ATTRIBUTE,attribute.getDefaultValue()==null?"":attribute.getDefaultValue());
- attributes.put(SchemaNodeFactory.TYPE_ATTRIBUTE,attribute.getName());
- attributes.put(SchemaNodeFactory.REQUIRED_ATTRIBUTE,(attribute.getDecl() == DTDDecl.REQUIRED)+"");
-
- }
-
- public void prepareCommentNode(Element element, DTDComment comment) {
- SchemaNodeFactory.getInstance().createDescription(element,comment.getText());
- }
-
- private String getEnumValues(DTDAttribute attribute) {
- if(attribute.getType() instanceof DTDEnumeration) {
- DTDEnumeration enumeration = (DTDEnumeration)attribute.getType();
- Vector items = enumeration.getItemsVec();
- String enumList = "";
- for(int i=0;i<items.size();i++) {
- enumList+=items.get(i).toString()+",";
- }
- return enumList.substring(0,enumList.length()-1);
- }
- return "";
- }
-
- /**
- *
- * @param element
- * @return
- */
- public String serialize(Element element) {
- StringWriter sw = new StringWriter();
- XMLSerializer ser = new XMLSerializer(sw, createOutputFormat());
-
- try {
- ser.asDOMSerializer();
- ser.serialize(element);
- sw.close();
- } catch (IOException e) {
- KbPlugin.getPluginLog().logError(e);
- }
- return sw.toString();
-
- }
-
- /**
- *
- * @return
- */
- public OutputFormat createOutputFormat() {
- OutputFormat format = new OutputFormat("xml", "UTF-8", true);
- format.setLineSeparator("\n");
- format.setIndent(2);
- return format;
- }
-}
\ No newline at end of file
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdResource.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdResource.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdResource.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,311 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.xml.sax.InputSource;
-
-import org.jboss.tools.common.util.HttpUtil;
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-
-/**
- * @author igels
- */
-public class KbDtdResource implements KbResource {
-
- private String uri;
- private URL url;
- private File dtdLocation;
- private File schemaLocation;
- private String rootElement;
- private InputSource inputSource;
-
- /**
- *
- * @param uri
- * @param inputSource
- * @param rootElement
- */
- public KbDtdResource(String uri, InputSource inputSource, String rootElement) {
- this.uri = uri;
- this.rootElement = rootElement;
- this.inputSource = inputSource;
- }
-
- /**
- *
- * @param uri
- * @param url
- * @param rootElement
- */
- public KbDtdResource(String uri, URL url, String rootElement) {
- this.uri = uri;
- this.url = url;
- this.rootElement = rootElement;
- }
-
- /**
- *
- * @param uri
- * @param dtdLocation
- * @param rootElement
- */
- public KbDtdResource(String uri, File dtdLocation, String rootElement) {
- this.uri = uri;
- this.dtdLocation = dtdLocation;
- this.rootElement = rootElement;
- }
-
- /**
- *
- */
- public InputStream getInputStream() {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdResource.getInputStream()");
- KbPlugin.getPluginLog().logInfo(" this resource = " + this);
- }
-
- InputStream is = null;
-
- try {
- if(dtdLocation != null) {
- is = new BufferedInputStream(new FileInputStream(dtdLocation));
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" dtd location is not null and is will getting from dtd location");
- }
- } else if((url != null)) {
- if("jar".equals(url.getProtocol())) {
- is = url.openStream();
- } else if(KbConfigurationFactory.getInstance().getDefaultConfiguration().isAllowDownload()) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" the dtd is will getting from url because url is not null and downloading from internet is alowed");
- }
- is = HttpUtil.getInputStreamFromUrlByGetMethod(url.toString());
- }
- } else if(inputSource != null) {
- String systemId = inputSource.getSystemId();
- String publicId = inputSource.getPublicId();
- String id;
- if(systemId!=null) {
- id = systemId;
- } else if(publicId!=null) {
- id = publicId;
- } else {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" system id and public id from input sourec are null and so can't to get url from input source");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdResource.getInputStream()");
- KbPlugin.getPluginLog().logInfo(" return is = null");
- }
- return null;
- }
-
- is = HttpUtil.getInputStreamFromUrlByGetMethod(id);
- }
- } catch (Exception e) {
- KbPlugin.getPluginLog().logError(e);
- }
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- KbDtdResource.getInputStream()");
- KbPlugin.getPluginLog().logInfo(" return is = " + is);
- }
- return is;
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object ob) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdResource.equals(Object ob)");
- KbPlugin.getPluginLog().logInfo(" this = " + this);
- KbPlugin.getPluginLog().logInfo(" ob = " + ob);
- }
-
- if(ob == this) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- KbDtdResource.equals(Object ob)");
- KbPlugin.getPluginLog().logInfo(" return = true");
- }
- return true;
- }
- if((!(ob instanceof KbDtdResource)) || (ob == null)) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- KbDtdResource.equals(Object ob)");
- KbPlugin.getPluginLog().logInfo(" return = false");
- }
- return false;
- }
- KbDtdResource resource = (KbDtdResource)ob;
-
- boolean eqUri = false;
-// boolean eqUrl = false;
-// boolean eqLocation = false;
-// boolean eqInputSource = false;
- boolean eqId = false;
- if(this.uri!=null) {
- eqUri = this.uri.equals(resource.getUri());
- } else if(resource.getUri()==null) {
- eqUri = true;
- }
- if(this.getId()!=null) {
- eqId = this.getId().equals(resource.getId());
- } else if(resource.getId()==null) {
- eqId = true;
- }
-/* if(this.url!=null) {
- eqUrl = this.url.equals(resource.getUrl());
- } else if(resource.getUrl()==null) {
- eqUrl = true;
- }
- if(this.dtdLocation!=null) {
- eqLocation = this.dtdLocation.equals(resource.getDtdLocation());
- } else if(resource.getDtdLocation()==null) {
- eqLocation = true;
- }
- if(this.inputSource!=null) {
- eqInputSource = this.inputSource.equals(resource.getInputSource());
- } else if(resource.getInputSource()==null) {
- eqInputSource = true;
- }
-*/
- boolean result = eqUri||eqId;
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- KbDtdResource.equals(Object ob)");
- KbPlugin.getPluginLog().logInfo(" return = " + result);
- }
-
- return result;
- }
-
- /**
- * @return
- */
- public File getDtdLocation() {
- return dtdLocation;
- }
-
- /**
- * @return
- */
- public String getUri() {
- return uri;
- }
-
- /**
- * @return
- */
- public URL getUrl() {
- return url;
- }
-
- /**
- *
- * @return
- */
- public String getId() {
- if(url!=null) {
- return url.toString();
- } else if((inputSource!=null)&&(inputSource.getPublicId()!=null)) {
- return inputSource.getPublicId();
- } else if((inputSource!=null)&&(inputSource.getSystemId()!=null)) {
- return inputSource.getSystemId();
- }
- return dtdLocation.toString();
- }
-
- /**
- * @return
- */
- public File getSchemaLocation() {
- return schemaLocation;
- }
-
- /**
- * @param file
- */
- public void setSchemaLocation(File file) {
- schemaLocation = file;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append("URI=\"");
- buffer.append(uri);
- buffer.append("\" URL=\"");
- buffer.append(url);
- buffer.append("\" ID=\"");
- buffer.append(getId());
- buffer.append("\" DTDlocation=\"");
- buffer.append(dtdLocation);
- buffer.append("\" InputSource=\"");
- buffer.append(inputSource);
- buffer.append("\" SchemaLocation=\"");
- buffer.append(schemaLocation);
- buffer.append("\" RootElement=\"");
- buffer.append(rootElement);
- buffer.append("\"");
-
- return buffer.toString();
- }
-
- /**
- *
- * @return
- */
- public boolean isModified() {
-// KbPlugin.log("--> KbDtdResource.isModified()");
-
- if(dtdLocation==null) {
- return false;
- }
-
- if(dtdLocation.exists()&&(schemaLocation!=null)&&(schemaLocation.exists())) {
- long lastModifiedDtd = dtdLocation.lastModified();
- long lastModifiedSchema = schemaLocation.lastModified();
-// KbPlugin.log("<-- KbTldResource.isModified()");
-// KbPlugin.log(" return: " + (lastModifiedSchema < lastModifiedDtd));
- return lastModifiedSchema < lastModifiedDtd;
- }
-
-// KbPlugin.log("<-- KbDtdResource.isModified()");
- return true;
- }
-
- /**
- * @return
- */
- public String getRootElement() {
- return rootElement;
- }
-
- /**
- * @param string
- */
- public void setRootElement(String name) {
- rootElement = name;
- }
-
- /**
- * @return
- */
- public InputSource getInputSource() {
- return inputSource;
- }
-}
\ No newline at end of file
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdStore.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdStore.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDtdStore.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,1003 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileOutputStream;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author eskimo
- */
-public class KbDtdStore implements KbStore {
-
- public static final String XML_DECLARATION = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
-
- private String schemaLocation;
- private List<Document> activeDocuments;
- private List<KbDtdResource> registratedResources;
- private List<KbDtdResource> downloadingResources;
-
- private static final KbDtdStore INSTANCE = new KbDtdStore();
-
- private KbDtdStore() {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdStore()");
- }
- schemaLocation = KbConfigurationFactory.getInstance().getDefaultConfiguration().getDtdSchemaPath();
-
- activeDocuments = new Vector<Document>();
- registratedResources = new Vector<KbDtdResource>();
- downloadingResources = new Vector<KbDtdResource>();
-
- loadRegistratedResources();
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore()");
- }
- }
-
- /**
- *
- * @return
- */
- public static KbDtdStore getInstance() {
- return INSTANCE;
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbStore#queryTagInformation(org.jboss.tools.common.kb.KbQuery)
- */
- public TagDescriptor queryTagInformation(KbQuery query) {
-// String strQuery = query.getQuery();
- String lastTag = query.getLastTag();
- String queryForLastTag = query.getFullQueryForLastTag();
- if(queryForLastTag==null) {
- return null;
- }
-
- InerDtdQuery inerDtdQuery = getInerDtdQery(new KbQuery(queryForLastTag, query.getResources()));
- List elementTypes = inerDtdQuery.getElementTypes();
-
- return KbSchemaUtil.getTagInformationFromElementTypes(elementTypes, lastTag, new HashSet());
- }
-
- public AttributeDescriptor queryAttributeInformation(KbQuery query) {
- // TODO
- throw new IllegalStateException("This method is not implemented yet.");
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbStore#queryProposal(org.jboss.tools.common.kb.KbQuery)
- */
- public Collection<KbProposal> queryProposal(KbQuery query) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdStore.queryProposal(KbQuery query)");
- KbPlugin.getPluginLog().logInfo(" query = " + query);
- KbPlugin.getPluginLog().logInfo(" registratedResources = " + registratedResources);
- }
-
- String strQuery = query.getQuery();
-
- if((strQuery.equals(KbQuery.XML_DECLARATION_QUERY))) {
- KbProposal proposal = new KbProposal();
- proposal.setLabel(XML_DECLARATION);
- proposal.setReplacementString(XML_DECLARATION);
- proposal.setContextInfo(null);
- ArrayList<KbProposal> proposals = new ArrayList<KbProposal>();
- proposals.add(proposal);
- return proposals;
- }
-
- List<KbProposal> proposals = queryTagProposal(getInerDtdQery(query));
- KbProposal endTag = getEndTagProposal(query);
- if(endTag != null) {
- proposals.add(endTag);
- }
-
- Collections.sort(proposals);
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("proposals size = " + proposals.size());
- }
- return proposals;
- }
-
- private InerDtdQuery getInerDtdQery(KbQuery query) {
- String strQuery = query.getQuery();
-
- Collection needResources = query.getResources();
- activateResources(needResources);
-
- int firstTagSeparator = strQuery.indexOf(KbQuery.TAG_SEPARATOR);
- if(firstTagSeparator == -1) {
-// KbPlugin.log("ERROR: Bad query: " + strQuery + ". Query must starts with \"" + KbQuery.TAG_SEPARATOR + "\" or \"" + KbQuery.XML_DECLARATION_QUERY + "\"");
- throw new IllegalArgumentException("Bad query: " + strQuery + ". Query must starts with \"" + KbQuery.TAG_SEPARATOR + "\" or \"" + KbQuery.XML_DECLARATION_QUERY + "\"");
- }
-
- List<Element> elementTypes = new ArrayList<Element>();
- String tagQuery = null;
- int lastTagSeparator = strQuery.lastIndexOf(KbQuery.TAG_SEPARATOR);
- if(lastTagSeparator > firstTagSeparator) {
- String axis = strQuery.substring(firstTagSeparator + KbQuery.TAG_SEPARATOR.length(), lastTagSeparator);
- StringTokenizer tags = new StringTokenizer(axis, KbQuery.TAG_SEPARATOR);
- if(!tags.hasMoreTokens()) {
- String errorMessage = "ERROR: Bad query: " + strQuery + "\n" +
- " Possible query formats: \"" + KbQuery.TAG_SEPARATOR +"rootTagName" + KbQuery.TAG_SEPARATOR + "childTagName1" + KbQuery.TAG_SEPARATOR + "..." + KbQuery.TAG_SEPARATOR + "childTagNameN" + KbQuery.ATTRIBUTE_SEPARATOR + "attributeName" + KbQuery.ENUMERATION_SEPARATOR + "attributeValue\"\n" +
- " or \"" + KbQuery.XML_DECLARATION_QUERY + "\"";
-// KbPlugin.log(errorMessage);
- throw new IllegalArgumentException(errorMessage);
- }
- elementTypes = getChildElementTypes(needResources, tags);
- if(lastTagSeparator + KbQuery.TAG_SEPARATOR.length() < strQuery.length()) {
- tagQuery = strQuery.substring(lastTagSeparator);
- } else {
- tagQuery = KbQuery.TAG_SEPARATOR;
- }
- } else {
- Iterator iterator = needResources.iterator();
- while(iterator.hasNext()) {
- KbDtdResource resource = (KbDtdResource)iterator.next();
- Element rootElementType = getRootElementType(resource);
- if(rootElementType!=null) {
- elementTypes.add(rootElementType);
- }
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Root Element: " + rootElementType);
- }
-// KbPlugin.log("RESOURCE: " + resource);
-/*
- Document document = getActiveDocument(resource);
- if(document != null) {
- elementTypes.add(getRootElementType(document));
- }
-*/
- }
- tagQuery = strQuery;
- }
-
- InerDtdQuery inerDtdQuery = new InerDtdQuery(elementTypes, tagQuery);
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Iner DTD Query = " + inerDtdQuery);
- }
-
- return inerDtdQuery;
- }
-
- private KbProposal getEndTagProposal(KbQuery kbQuery) {
- String query = kbQuery.getQuery();
- String mask = "";
- int lastSeparator = query.lastIndexOf(KbQuery.TAG_SEPARATOR);
- if((lastSeparator!=-1)&&(lastSeparator + KbQuery.TAG_SEPARATOR.length()<query.length())) {
- mask = query.substring(lastSeparator + KbQuery.TAG_SEPARATOR.length());
- }
-
- String lastTag = kbQuery.getLastTag();
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("last tag - " + lastTag);
- KbPlugin.getPluginLog().logInfo("mask - " + mask);
- }
- if((lastTag != null)&&(((mask.indexOf(KbQuery.DONT_FILTER_END_TAG_CHAR)!=-1)&&(KbQuery.DONT_FILTER_END_TAG_CHAR + lastTag).startsWith(mask))||(mask.equals("")))) {
- KbProposal proposal = new KbProposal();
- proposal.setLabel("/" + lastTag);
- proposal.setReplacementString("/" + lastTag);
- proposal.setIcon(KbIcon.XML_TAG);
- return proposal;
- }
-
- return null;
- }
-/*
- private ArrayList getEndTagProposal(ArrayList elementTypes) {
- ArrayList proposals = new ArrayList();
- for(Iterator iter = elementTypes.iterator(); iter.hasNext();) {
- Element elementType = (Element)iter.next();
- KbProposal proposal = new KbProposal();
- String name = elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
- proposal.setLabel("/" + name);
- proposal.setReplacementString("/" + name);
- proposal.setIcon(KbIcon.XML_TAG);
-
- proposals.add(proposal);
- }
- return proposals;
- }
-*/
-
- public void registerResource(KbResource resource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdStore.registerResource(KbResource resource)");
- KbPlugin.getPluginLog().logInfo(" resource = " + resource);
- }
-
- KbDtdResource dtdResource = null;
- if(resource instanceof KbDtdResource) {
- dtdResource = (KbDtdResource)resource;
- } else {
- throw new IllegalArgumentException("KbDtdStore.registerResource(KbResource resource): resource must be instance of KbDtdResource");
- }
-
- if(checkActiveDocument(dtdResource)) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" resource already is activated");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.registerResource()");
- }
- return;
- } else if(checkDownloadingResource(dtdResource)) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" resource is downloading");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.registerResource()");
- }
- return;
- } else if(checkRegistratedResource(dtdResource)) {
- activateResource(dtdResource);
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" resource already is registred");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.registerResource()");
- }
- return;
- }
-
- if((dtdResource.getDtdLocation()==null)&&(!KbConfigurationFactory.getInstance().getDefaultConfiguration().isAllowDownload())) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Unknown resource but is not allow download.");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.registerResource()");
- }
- return;
- }
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Unknown resource. Start downloading resource...");
- }
-
- new ResourceDownloader(dtdResource).start();
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.registerResource()");
- }
- }
-
- /**
- *
- * @param resource
- */
- public synchronized void reregisterModifiededResource(KbDtdResource resource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdStore.reregisterModifiededResource(KbDtdResource resource)");
- KbPlugin.getPluginLog().logInfo(" resource = " + resource);
- }
- KbDtdResource regResource = getRegistratedResource(resource);
- if((regResource!=null)&®Resource.isModified()) {
- unregisterResource(resource);
- registerResource(resource);
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" resource hase been reregistrated");
- }
- }
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.reregisterModifiededResource(KbDtdResource resource)");
- }
- }
-
- /*
- * @see org.jboss.tools.common.kb.KbStore#unregisterResource(org.jboss.tools.common.kb.KbResource)
- */
- public void unregisterResource(KbResource resource) {
- KbDtdResource dtdResource = (KbDtdResource)resource;
- KbDtdResource regResource = getRegistratedResource(dtdResource);
- if(regResource!=null) {
- registratedResources.remove(regResource);
- Document document = getActiveDocument(dtdResource);
- if(document!=null) {
- activeDocuments.remove(document);
- }
- File schema = regResource.getSchemaLocation();
- if(schema!=null) {
- schema.delete();
- }
- } else if(checkDownloadingResource(dtdResource)) {
-// TODO Stop downloading and registration resource
- }
- }
-
- private List<Element> getChildElementTypes(Collection resources, StringTokenizer tagNames) {
-// KbPlugin.log("--> getChildElementTypes(Collection resources, StringTokenizer tagNames)");
-// KbPlugin.log(" resources size = " + resources.size());
-// KbPlugin.log(" tagNames = " + tagNames);
-
- String tagName = tagNames.nextToken();
-// KbPlugin.log(" tagName = " + tagName);
-
- List<Element> childElements = getChildElements(resources, tagName, true);
-
-// KbPlugin.log(" childElements size = " + childElements.size());
-
- while(tagNames.hasMoreElements()&&childElements.size()>0) {
- tagName = tagNames.nextToken();
-// KbPlugin.log(" tagName = " + tagName);
- Iterator iterator = childElements.iterator();
- childElements = new ArrayList<Element>();
- while(iterator.hasNext()) {
- Element element = (Element)iterator.next();
- if(element.getAttribute(SchemaNodeFactory.TYPE_ATTRIBUTE).equals(tagName)) {
-// KbPlugin.log(" add childElements size = " + childElements.size());
- childElements = addCollection(childElements, getChildElements(resources, tagName, false));
- }
- }
- }
-
-// KbPlugin.log(" childElements size = " + childElements.size());
-
- ArrayList<Element> childElementTypes = new ArrayList<Element>();
- for(int i=0; i<childElements.size(); i++) {
- Element elementType = KbSchemaUtil.getElementTypeByElement((Element)childElements.get(i));
- if(elementType!=null) {
- childElementTypes.add(elementType);
- }
- }
-
-// KbPlugin.log("<-- getChildElementTypes(Collection resources, StringTokenizer tagNames)");
-// KbPlugin.log(" childElementTypes size = " + childElementTypes.size());
- return childElementTypes;
- }
-
-/*
- private Element getRootElementType(Document document) {
- String rootElementName = document.getDocumentElement().getAttribute(SchemaNodeFactory.ROOT_ELEMENT_ATTRIBUTE);
-
-// KbPlugin.log("rootElementName = " + rootElementName);
-
- NodeList nodeList = document.getElementsByTagName(SchemaNodeFactory.ELEMENT_TYPE_NODE);
- for(int j=0; j<nodeList.getLength(); j++) {
- Node child = nodeList.item(j);
- if(child instanceof Element) {
- Element element = (Element)child;
- if(rootElementName.equals(element.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE))) {
-// KbPlugin.log("rootElementName = " + element.getAttribute("name"));
- return element;
- }
- }
- }
-
-// KbPlugin.log("ERROR: Can't find ElementType for tagName (name=\"" + rootElementName + "\").");
- return null;
- }
-*/
-
- private Element getRootElementType(KbDtdResource resource) {
- Document document = getActiveDocument(resource);
- if(document != null) {
- String rootElementName = resource.getRootElement();
- if(rootElementName == null) {
- rootElementName = document.getDocumentElement().getAttribute(SchemaNodeFactory.ROOT_ELEMENT_ATTRIBUTE);
- }
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Root element name: " + rootElementName);
- }
- return KbSchemaUtil.getElementTypeByName(document, rootElementName, false);
- }
-// KbPlugin.log("DOCUMENT IS null!");
- return null;
- }
-
- private List<Element> addCollection(Collection<Element> col1, Collection<Element> col2) {
- ArrayList<Element> arrayList = new ArrayList<Element>();
- Iterator<Element> iterator = col1.iterator();
- while(iterator.hasNext()) {
- arrayList.add(iterator.next());
- }
- iterator = col2.iterator();
- while(iterator.hasNext()) {
- arrayList.add(iterator.next());
- }
- return arrayList;
- }
-
- private List<Element> getChildElements(Collection resources, String elementTypeName, boolean rootTag) {
-// KbPlugin.log("--> getChildElements(Collection resources, String elementTypeName, boolean rootTag)");
-// KbPlugin.log(" resources size = " + resources.size());
-// KbPlugin.log(" elementTypeName = " + elementTypeName);
-
- ArrayList<Element> elements = new ArrayList<Element>();
-
- ArrayList<Document> documents = new ArrayList<Document>();
- Iterator iterator = resources.iterator();
- while(iterator.hasNext()) {
- KbDtdResource resource = (KbDtdResource)iterator.next();
- Document document = getActiveDocument(resource);
-/*
- if((document != null)&&(!rootTag || KbSchemaUtil.checkRootElement(document, elementTypeName))) {
- documents.add(document);
- }
-*/
-
- String rootElementName = resource.getRootElement();
- if(rootElementName == null) {
- rootElementName = document.getDocumentElement().getAttribute(SchemaNodeFactory.ROOT_ELEMENT_ATTRIBUTE);
- }
-
- if((document != null)&&(!rootTag || rootElementName.equals(elementTypeName))) {
- documents.add(document);
- }
- }
-
- for(int i=0; i< documents.size(); i++) {
- Document document = (Document)documents.get(i);
- NodeList elementTypes = document.getElementsByTagName(SchemaNodeFactory.ELEMENT_TYPE_NODE);
- for(int j=0; j<elementTypes.getLength(); j++) {
- Node child = elementTypes.item(j);
- if(child instanceof Element) {
- Element elementType = (Element)child;
-// KbPlugin.log("Element type: " + elementType);
- if(elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE).equals(elementTypeName)) {
- NodeList childElements = elementType.getElementsByTagName(SchemaNodeFactory.ELEMENT_NODE);
- for(int g=0; g<childElements.getLength(); g++) {
- Node childElement = childElements.item(g);
- if(childElement instanceof Element) {
-// KbPlugin.log("Add Element: " + ((Element)childElement).getAttribute("type"));
- elements.add((Element)childElement);
- }
- }
- }
- }
- }
- }
-
-// KbPlugin.log("<-- getChildElements(Collection resources, String elementTypeName, boolean rootTag)");
-// KbPlugin.log(" element size = " + elements.size());
- return elements;
- }
-
- private List<KbProposal> queryTagProposal(InerDtdQuery query) {
- return queryTagProposal(query.getElementTypes(), query.getTagQuery());
- }
-
- private List<KbProposal> queryTagProposal(List elementTypes, String query) {
-// KbPlugin.log("--> queryTagProposal(ArrayList elementTypes, String query)");
-// KbPlugin.log(" Query = " + query);
-// KbPlugin.log(" elementTypes size = " + elementTypes.size());
-
- if((!query.startsWith(KbQuery.TAG_SEPARATOR))||
- (query.startsWith(KbQuery.TAG_SEPARATOR + KbQuery.ATTRIBUTE_SEPARATOR))) {
- return new ArrayList<KbProposal>();
- } else if(query.length() == KbQuery.TAG_SEPARATOR.length()) {
- return getTags(elementTypes, "");
- }
-
- int startAttributeName = query.indexOf(KbQuery.ATTRIBUTE_SEPARATOR);
- if(startAttributeName < 0){
- return getTags(elementTypes, query.substring(KbQuery.TAG_SEPARATOR.length()));
- }
-
- String tagName = query.substring(KbQuery.TAG_SEPARATOR.length(), startAttributeName);
- startAttributeName+=KbQuery.ATTRIBUTE_SEPARATOR.length();
- if(startAttributeName == query.length()) {
- return getAttributes(elementTypes, tagName, "");
- }
-
- int startAttributeValue = query.indexOf(KbQuery.ENUMERATION_SEPARATOR);
- if(startAttributeValue < 0) {
- return getAttributes(elementTypes, tagName, query.substring(startAttributeName));
- }
-
- String attributeName = query.substring(startAttributeName, startAttributeValue);
- startAttributeValue+=KbQuery.ENUMERATION_SEPARATOR.length();
- if(startAttributeValue == query.length()) {
- return getEnumeration(elementTypes, tagName, attributeName, "");
- }
-
- return getEnumeration(elementTypes, tagName, attributeName, KbQuery.decode(query.substring(startAttributeValue)));
- }
-
- private synchronized boolean checkActiveDocument(KbDtdResource resource) {
- return getActiveDocument(resource) != null;
- }
-
- private synchronized boolean checkDownloadingResource(KbDtdResource resource) {
- synchronized (downloadingResources) {
- for(int i=0; i<downloadingResources.size(); i++) {
- if(((KbDtdResource)downloadingResources.get(i)).equals(resource)) {
- return true;
- }
-/* String downloadingUri = ((KbDtdResource)downloadingResources.get(i)).getUri();
- URL downloadingUrl = ((KbDtdResource)downloadingResources.get(i)).getUrl();
- if(downloadingUri.equals(resource.getUri())) {
- // Is downloading this resource.
- return true;
- } else if(downloadingUrl.equals(resource.getUrl())) {
- // Is downloading this resource.
- return true;
- }
-*/
- }
- }
- // Isn't downloading this resource.
- return false;
- }
-
- private synchronized boolean checkRegistratedResource(KbDtdResource resource) {
- return getRegistratedResource(resource) != null;
- }
-
- private synchronized KbDtdResource getRegistratedResource(KbDtdResource dtdResource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdStore.getRegistratedResource(KbDtdResource dtdResource)");
- KbPlugin.getPluginLog().logInfo(" dtdResource = " + dtdResource);
- }
-
- synchronized (registratedResources) {
- for(int i=0; i<registratedResources.size(); i++){
- KbDtdResource resource = (KbDtdResource)registratedResources.get(i);
- if(resource.equals(dtdResource)) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Found resource");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.getRegistratedResource(KbDtdResource dtdResource)");
- KbPlugin.getPluginLog().logInfo(" return resource = " + resource);
- }
- return resource;
- }
-/* String registratedUri = resource.getUri();
- URL registratedUrl = resource.getUrl();
- // KbPlugin.log("reg-d uri=" + registratedUri);
- // KbPlugin.log("reg uri=" + uri);
- if(registratedUri.equals(dtdResource.getUri())) {
- // Registrated resource.
- return resource;
- } else if(registratedUrl.equals(dtdResource.getUrl())) {
- // Registrated resource.
- return resource;
- }
-*/
- }
- }
- // Non-registrated resource.
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Did not find resource");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.getRegistratedResource(KbDtdResource dtdResource)");
- KbPlugin.getPluginLog().logInfo(" return resource = null");
- }
- return null;
- }
-
- private synchronized Document getActiveDocument(KbDtdResource resource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdStore.getActiveDocument(KbDtdResource resource)");
- KbPlugin.getPluginLog().logInfo(" resource = " + resource);
- }
-
- synchronized (activeDocuments) {
- for(int i=0; i<activeDocuments.size(); i++){
- Document activeDocument = (Document)activeDocuments.get(i);
- String activeDocumentsUri = activeDocument.getDocumentElement().getAttribute(SchemaNodeFactory.URI_ATTRIBUTE);
- String activeDocumentsUrl = activeDocument.getDocumentElement().getAttribute(SchemaNodeFactory.URL_ATTRIBUTE);
- if((activeDocumentsUri.equals(resource.getUri()))||(activeDocumentsUrl.equals(resource.getId()))) {
- // Active resource.
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Found document");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.getActiveDocument(KbDtdResource resource)");
- KbPlugin.getPluginLog().logInfo(" return document = " + activeDocument);
- }
- return activeDocument;
- }
- }
- }
- // Non-active resource.
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Did not find document");
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.getActiveDocument(KbDtdResource resource)");
- KbPlugin.getPluginLog().logInfo(" return document = null");
- }
- return null;
- }
-
- private synchronized void activateResource(KbDtdResource resource) {
- if(checkActiveDocument(resource)) {
- return;
- }
-
- KbDtdResource regResource = getRegistratedResource(resource);
- if(regResource == null) {
- return;
- }
-
- File schemaLocation = regResource.getSchemaLocation();
- if((schemaLocation == null)||(!schemaLocation.exists())) {
-// KbPlugin.log("ERROR: Schema (location: " + schemaLocation + ") for resource (" + regResource +") does not exist!");
- return;
- }
-
- Document document = null;
- try {
- document = KbDocumentBuilderFactory.createDocumentBuilder(false).parse(schemaLocation);
- } catch (Exception e) {
- String message = "ERROR: Can't parse Schema (location: " + schemaLocation + ")";
- KbPlugin.getPluginLog().logError(message, e);
- return;
- }
- activeDocuments.add(document);
- }
-
- private synchronized void activateResources(Collection resources) {
- Iterator iterator = resources.iterator();
- while(iterator.hasNext()) {
- KbDtdResource resource = (KbDtdResource)iterator.next();
- activateResource(resource);
- }
- }
-
- public synchronized void activateAllResources() {
- synchronized (registratedResources) {
- for(int i=0; i<registratedResources.size(); i++) {
- KbDtdResource resource = (KbDtdResource)registratedResources.get(i);
- activateResource(resource);
- }
- }
- }
-/*
- private synchronized void deactivateResource(KbDtdResource resource) {
- Document document = getActiveDocument(resource);
- if(document!=null) {
- activeDocuments.remove(document);
- }
- }
-*/
- public synchronized void deactivateAllResources() {
- for(int i=0; i<activeDocuments.size(); i++) {
- activeDocuments.clear();
- }
- }
-
- private void loadRegistratedResources() {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> KbDtdStore.loadRegistratedResources()");
- }
-
- File schemaFolder = new File(schemaLocation);
- if(!schemaFolder.exists()) {
- return;
- }
- File[] schemas = schemaFolder.listFiles(new FileFilter(){
- public boolean accept(File file) {
- if(file.isFile()) {
- return true;
- }
- return false;
- }
- });
-
- for(int i=0; i<schemas.length; i++) {
- Document document = null;
- try {
- document = KbDocumentBuilderFactory.createDocumentBuilder(false).parse(schemas[i]);
- } catch (Exception e) {
- if(KbPlugin.isDebugEnabled()) {
- String message = "WARNING: Can't parse Schema (location: " + schemas[i] + ")";
- KbPlugin.getPluginLog().logError(message, e);
- }
- continue;
- }
- String uri = document.getDocumentElement().getAttribute(SchemaNodeFactory.URI_ATTRIBUTE);
- String url = document.getDocumentElement().getAttribute(SchemaNodeFactory.URL_ATTRIBUTE);
- KbDtdResource resource = null;
- try {
- resource = new KbDtdResource(uri, new URL(url), null);
- } catch (Exception e) {
- if(KbPlugin.isDebugEnabled()) {
- String message = "ERROR: can't create java.net.URL for url=\"" + url + "\" from schema (location=" + schemas[i] + ")";
- KbPlugin.getPluginLog().logError(message);
- }
- continue;
- }
- resource.setSchemaLocation(schemas[i]);
- registratedResources.add(resource);
- }
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- KbDtdStore.loadRegistratedResources()");
- }
- }
-
- private List<KbProposal> getTags(Collection elementTypes, String tagMask) {
-// KbPlugin.log("--> getTags(Collection elementTypes, String tagMask)");
-// KbPlugin.log(" elementTypes size = " + elementTypes.size());
-// KbPlugin.log(" tagMask = " + tagMask);
-// KbPlugin.log("<-- getTags()");
- return getTagProposal(getElementTypesByName(elementTypes, tagMask, true));
- }
-
- private List<Element> getElementTypesByName(Collection elementTypes, String name, boolean mask) {
-// KbPlugin.log("--> getElementTypesByName(Collection elementTypes, String name, boolean mask)");
-// KbPlugin.log(" elementTypes size = " + elementTypes.size());
-// KbPlugin.log(" name = " + name);
-// KbPlugin.log(" mask = " + mask);
-
- ArrayList<Element> elements = new ArrayList<Element>();
-
- Iterator iterator = elementTypes.iterator();
- while(iterator.hasNext()) {
- Element elementType = (Element)iterator.next();
- String schemaTagName = elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
- boolean match = mask?schemaTagName.startsWith(name):schemaTagName.equals(name);
- if(match) {
-// KbPlugin.log(" add element: " + elementType);
- elements.add(elementType);
- }
- }
-
-// KbPlugin.log("<-- getElementTypesByName()");
-// KbPlugin.log(" elements Size = " + elements.size());
-
- return elements;
- }
-
- private List<KbProposal> getAttributes(Collection elementTypes, String tagName, String attributeMask) {
-// KbPlugin.log("--> getAttributes(String prefix, String tagName, String attributeMask)");
-// KbPlugin.log(" prefix = " + prefix);
-// KbPlugin.log(" tagName = " + tagName);
-// KbPlugin.log(" attributeMask = " + attributeMask);
-// KbPlugin.log("<-- getAttributes()");
- return getAttributeProposal(getAttributeTypesByName(elementTypes, tagName, attributeMask, true));
- }
-
- private List<Element> getAttributeTypesByName(Collection elementTypes, String tagName, String attributeName, boolean mask) {
- List<Element> attributes = new ArrayList<Element>();
-
- List elements = getElementTypesByName(elementTypes, tagName, false);
- if(!elements.isEmpty()) {
- Element element = (Element)elements.get(0);
-
- ArrayList attributeTypes = KbSchemaUtil.getAttributeTypes(element);
- for(int i=0; i<attributeTypes.size(); i++) {
- Element attributeType = (Element)attributeTypes.get(i);
-
- String attributeTypeName = attributeType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
- boolean match = mask?attributeTypeName.startsWith(attributeName):attributeTypeName.equals(attributeName);
- if(match) {
- attributes.add(attributeType);
- }
- }
- }
- return attributes;
- }
-
- private List<KbProposal> getEnumeration(Collection elementTypes, String tagName, String attributeName, String valueMask) {
- List<KbProposal> enumeration = new ArrayList<KbProposal>();
-
- List attributeTypes = new ArrayList();
- attributeTypes = getAttributeTypesByName(elementTypes, tagName, attributeName, false);
- if(!attributeTypes.isEmpty()) {
- Element attributeType = (Element)attributeTypes.get(0);
- String type = attributeType.getAttribute(SchemaNodeFactory.TYPE_ATTRIBUTE);
- if(type.equals(SchemaNodeFactory.ENUMERATION_TYPE)) {
- String values = attributeType.getAttribute(SchemaNodeFactory.VALUES_ATTRIBUTE);
- StringTokenizer st = new StringTokenizer(values, SchemaNodeFactory.ENUMERATION_SEPARATOR);
- while(st.hasMoreElements()) {
- String value = (String)st.nextElement();
- if(value.startsWith(valueMask)) {
- KbProposal proposal = new KbProposal();
- proposal.setLabel(value);
- proposal.setReplacementString(value);
- proposal.setContextInfo(null);
- proposal.setIcon(KbIcon.ENUM_ITEM);
-
- enumeration.add(proposal);
- }
- }
- }
- }
-
- return enumeration;
- }
-
- private List<KbProposal> getTagProposal(List<Element> elements) {
- return getProposal(elements, true);
- }
-
- private List<KbProposal> getAttributeProposal(List elements) {
- return getProposal(elements, false);
- }
-
- private List<KbProposal> getProposal(List elements, boolean tag) {
-// KbPlugin.log("--> getProposal(ArrayList elements, boolean tag)");
-// KbPlugin.log(" elemnets size = " + elements.size());
-// KbPlugin.log(" tag = " + tag);
-
- ArrayList<KbProposal> kbProposals = new ArrayList<KbProposal>();
-
- for(int i=0; i<elements.size(); i++) {
- Element element = (Element)elements.get(i);
- String tagName = element.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
-
- KbProposal proposal = new KbProposal();
-
- if(tag) {
- String endTag = SchemaNodeFactory.REFUSED_BODY_CONTENT_TYPE.equals(element.getAttribute(SchemaNodeFactory.BODY_CONTENT_ATTRIBUTE))?" /":"";
-
- String attributes = KbSchemaUtil.getRequaredAttributesAsString(element);
- proposal.setReplacementString(tagName + attributes + endTag);
- int position = proposal.getReplacementString().indexOf('"');
- if(position!=-1) {
- position ++;
- } else {
- position = proposal.getReplacementString().length();
- }
- proposal.setPosition(position);
- proposal.setLabel(tagName);
- proposal.setIcon(KbIcon.XML_TAG);
- } else {
- proposal.setReplacementString(tagName);
- if(KbSchemaUtil.checkRequaredAttribute(element)) {
- proposal.setIcon(KbIcon.XML_ATTRIBUTE);
- } else {
- proposal.setIcon(KbIcon.XML_ATTRIBUTE_OPTIONAL);
- }
- proposal.setLabel(tagName);
- }
-
- proposal.setContextInfo(KbSchemaUtil.getDescription(element));
-
-// KbPlugin.log(" add kbProposals:\n" + proposal.toString());
-// KbPlugin.log(" for element: " + element);
-// proposal.setContextInfo(proposal.getIcon().toString());
-
- kbProposals.add(proposal);
- }
-
-// KbPlugin.log("<-- getProposal()");
-// KbPlugin.log(" kbProposals size = " + kbProposals.size());
-
- return kbProposals;
- }
-
- private class ResourceDownloader implements Runnable {
-
- private KbDtdResource resource;
- private Thread thread;
-
- public ResourceDownloader(KbDtdResource resource) {
- this.resource = resource;
- }
-
- public void start() {
- thread = new Thread(this);
- thread.setDaemon(false);
- thread.start();
- }
-
- public void run() {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("downloading resource - " + resource);
- }
- downloadingResources.add(resource);
- String uniqFileName = "schema.xml";
- try {
- File tempFile = File.createTempFile("schema", ".xml");
- uniqFileName = tempFile.getName();
- tempFile.deleteOnExit();
- } catch(Exception e) {
- String message = "WARNING: Can't create temp file.";
- KbPlugin.getPluginLog().logError(message, e);
- }
- File schemaFolder = new File(schemaLocation);
-
- schemaFolder.mkdirs();
- File schemaFile = new File(schemaLocation + "/" + uniqFileName);
- int i=0;
- while(schemaFile.exists()) {
- schemaFile = new File(schemaLocation + "/" + i++ + uniqFileName);
- }
-
- Document document = KbDtdConvertor.getInstance().convertToSchema(resource);
- if(document == null) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" Can't get document from resource.");
- KbPlugin.getPluginLog().logInfo(" cancel downloading.");
- }
- downloadingResources.remove(resource);
- return;
- }
- try {
- Element element = document.getDocumentElement();
- StringWriter sw = new StringWriter();
- XMLSerializer ser = new XMLSerializer(sw, createOutputFormat());
-
- ser.asDOMSerializer();
- ser.serialize(element);
- sw.close();
-
- BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(schemaFile));
- os.write(sw.toString().getBytes());
- os.flush();
- os.close();
-
-// TransformerFactory.newInstance().newTransformer().transform(new DOMSource(document), new StreamResult(schemaFile));
- } catch (Exception e) {
- String message = "ERROR: Can't serialize DTD schema (" + schemaFile + ").";
- KbPlugin.getPluginLog().logError(message, e);
- schemaFile.deleteOnExit();
- downloadingResources.remove(resource);
- return;
- }
- resource.setSchemaLocation(schemaFile);
- registratedResources.add(resource);
- activeDocuments.add(document);
- downloadingResources.remove(resource);
- }
-
- public OutputFormat createOutputFormat() {
- OutputFormat format = new OutputFormat("xml", "UTF-8", true);
- format.setLineSeparator("\n");
- format.setIndent(2);
- return format;
- }
- }
-
- private class InerDtdQuery {
-
- private List elementTypes;
- private String tagQuery;
-
- public InerDtdQuery(List elementTypes, String tagQuery) {
- this.elementTypes = elementTypes;
- this.tagQuery = tagQuery;
- }
-
- /**
- * @return
- */
- public List getElementTypes() {
- return elementTypes;
- }
-
- /**
- * @return
- */
- public String getTagQuery() {
- return tagQuery;
- }
-
- /**
- * @param list
- */
- public void setElementTypes(ArrayList list) {
- elementTypes = list;
- }
-
- /**
- * @param string
- */
- public void setTagQuery(String string) {
- tagQuery = string;
- }
-
- public String toString() {
- return new StringBuffer().append("Element types: ").append(elementTypes).append("; Element types size: ").append(elementTypes==null?"null":""+elementTypes.size()).append("; tagQuery: ").append(tagQuery).toString();
- }
- }
-
-}
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlMap.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlMap.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlMap.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-
-/**
- * @author igels
- */
-public class KbHtmlMap {
- private final static String ROOT_ELEMENT_ATTRIBUTE_VALUE = "HTML";
-
- private Map htmlMap;
- private static File hashMapLocation = new File(KbConfigurationFactory.getInstance().getDefaultConfiguration().getHtmlMapFilePath());
-
- /**
- *
- */
- private KbHtmlMap(Map proposals) {
- htmlMap = proposals;
- }
-
- public static KbHtmlMap parseSchema(Document schema) {
- HashMap<String,KbProposal[]> map = new HashMap<String,KbProposal[]>();
- NodeList nodeList = schema.getElementsByTagName(SchemaNodeFactory.ELEMENT_TYPE_NODE);
- for(int i=0; i<nodeList.getLength(); i++) {
- HashMap<String,Element> children = new HashMap<String,Element>();
- Element elementType = (Element)nodeList.item(i);
- String tagName = elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
- List childrenElementTypes = getChildElementTypes(schema, tagName);
- addOptionalTags(children, elementType);
- for(int j=0; j<childrenElementTypes.size(); j++) {
- Element childrenElementType = (Element)childrenElementTypes.get(j);
- addOptionalTags(children, childrenElementType);
- }
- ArrayList<KbProposal> proposalList = getTagProposal(children);
- KbProposal[] proposals = (KbProposal[])proposalList.toArray(new KbProposal[proposalList.size()]);
- map.put(tagName, proposals);
- }
- return new KbHtmlMap(map);
- }
-
- public static Document convertSchema(Document schema) {
- Properties attributes = new Properties();
- attributes.put(SchemaNodeFactory.ROOT_ELEMENT_ATTRIBUTE, ROOT_ELEMENT_ATTRIBUTE_VALUE);
- Document document = SchemaNodeFactory.getInstance().createSchemaDocument(attributes);
- Element schemaElement = document.getDocumentElement();
-
- NodeList nodeList = schema.getElementsByTagName(SchemaNodeFactory.ELEMENT_TYPE_NODE);
- for(int i=0; i<nodeList.getLength(); i++) {
- HashMap<String,Element> children = new HashMap<String,Element>();
- Element elementType = (Element)nodeList.item(i);
- String tagName = elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
- List childrenElementTypes = getChildElementTypes(schema, tagName);
- addOptionalTags(children, elementType);
- for(int j=0; j<childrenElementTypes.size(); j++) {
- Element childrenElementType = (Element)childrenElementTypes.get(j);
- addOptionalTags(children, childrenElementType);
- }
-
- attributes = KbSchemaUtil.getAttributes(elementType);
- Element newElementType = SchemaNodeFactory.getInstance().createElementType(schemaElement, attributes);
-
- NodeList attributeTypes = elementType.getElementsByTagName(SchemaNodeFactory.ATTRIBUTE_TYPE_NODE);
- for(int j=0; j<attributeTypes.getLength(); j++) {
- Element attribute = (Element)attributeTypes.item(j);
- attributes = KbSchemaUtil.getAttributes(attribute);
- SchemaNodeFactory.getInstance().createAttributeType(newElementType, attributes);
- }
-
- NodeList attributeElements = elementType.getElementsByTagName(SchemaNodeFactory.ATTRIBUTE_NODE);
- for(int j=0; j<attributeElements.getLength(); j++) {
- Element attribute = (Element)attributeElements.item(j);
- attributes = KbSchemaUtil.getAttributes(attribute);
- SchemaNodeFactory.getInstance().createAttribute(newElementType, attributes);
- }
-
- for(Iterator iter = children.values().iterator();iter.hasNext();) {
- Element element = (Element)iter.next();
- attributes = new Properties();
- attributes.put(SchemaNodeFactory.TYPE_ATTRIBUTE, element.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE));
- SchemaNodeFactory.getInstance().createElement(newElementType, attributes);
- }
- }
-
- return document;
- }
-
- public static boolean convertSchemaToFile(Document schema, File schemaFile) {
- Document convertedSchema = convertSchema(schema);
- try {
- Element element = convertedSchema.getDocumentElement();
- StringWriter sw = new StringWriter();
- XMLSerializer ser = new XMLSerializer(sw, createOutputFormat());
-
- ser.asDOMSerializer();
- ser.serialize(element);
- sw.close();
-
- BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(schemaFile));
- os.write(sw.toString().getBytes());
- os.flush();
- os.close();
-
-// TransformerFactory.newInstance().newTransformer().transform(new DOMSource(document), new StreamResult(schemaFile));
- } catch (Exception e) {
- String message = "ERROR: Can't serialize HTML schema to file :" + schemaFile;
- KbPlugin.getPluginLog().logError(message, e);
- schemaFile.deleteOnExit();
- return false;
- }
- return true;
- }
-
- private static OutputFormat createOutputFormat() {
- OutputFormat format = new OutputFormat("xml", "UTF-8", true);
- format.setLineSeparator("\n");
- format.setIndent(2);
- return format;
- }
-
- private static void addOptionalTags(HashMap<String,Element> map, Element elementType) {
-// KbPlugin.log("--> KbHtmlMap.addRefuseTag(HashMap map, Element elementType, String tagName, boolean mask)");
- String elementTypeName = elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
-// KbPlugin.log(" map size=" + map.size());
-// KbPlugin.log(" elementType=" + elementTypeName);
- if(!map.containsKey(elementTypeName)) {
- map.put(elementTypeName, elementType);
- String startTagType = elementType.getAttribute(SchemaNodeFactory.START_TAG_ATTRIBUTE);
- if(SchemaNodeFactory.OPTIONAL_TAG_TYPE.equals(startTagType)) {
-// KbPlugin.log(" Tag have optional start tag");
- List childElementTypes = getChildElementTypes(elementType.getOwnerDocument(), elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE));
- for(Iterator iter = childElementTypes.iterator(); iter.hasNext();) {
- Element childElementType = (Element)iter.next();
- addOptionalTags(map, childElementType);
- }
- }
- }
-// KbPlugin.log("<-- KbHtmlMap.addRefuseTag(HashMap map, Element elementType, String tagName, boolean mask)");
-// KbPlugin.log(" map size=" + map.size());
- }
-
- private static List<Element> getChildElementTypes(Document schema, String tagName) {
- List<Element> childElementTypes = new ArrayList<Element>();
-
- List childElements = getChildElements(schema, tagName);
-
- for(Iterator iter = childElements.iterator(); iter.hasNext();) {
- Element element = (Element)iter.next();
- Element elementType = KbSchemaUtil.getElementTypeByElement(element);
- if(elementType!=null) {
- childElementTypes.add(elementType);
- }
- }
-
- return childElementTypes;
- }
-
- private static ArrayList<Element> getChildElements(Document schema, String elementTypeName) {
-// KbPlugin.log("--> getChildElements(Collection resources, String elementTypeName, boolean rootTag)");
-// KbPlugin.log(" resources size = " + resources.size());
-// KbPlugin.log(" elementTypeName = " + elementTypeName);
-
- ArrayList<Element> elements = new ArrayList<Element>();
-
-// ArrayList documents = new ArrayList();
-
- NodeList elementTypes = schema.getElementsByTagName(SchemaNodeFactory.ELEMENT_TYPE_NODE);
- for(int j=0; j<elementTypes.getLength(); j++) {
- Node child = elementTypes.item(j);
- if(child instanceof Element) {
- Element elementType = (Element)child;
- if(elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE).equalsIgnoreCase(elementTypeName)) {
- NodeList childElements = elementType.getElementsByTagName(SchemaNodeFactory.ELEMENT_NODE);
- for(int g=0; g<childElements.getLength(); g++) {
- Node childElement = childElements.item(g);
- if(childElement instanceof Element) {
- elements.add((Element)childElement);
- }
- }
- }
- }
- }
-
-// KbPlugin.log("<-- getChildElements(Collection resources, String elementTypeName, boolean rootTag)");
-// KbPlugin.log(" element size = " + elements.size());
- return elements;
- }
-
- private static ArrayList<KbProposal> getTagProposal(HashMap elements) {
- return getProposal(elements.values(), true);
- }
-
- private static ArrayList<KbProposal> getProposal(Collection elements, boolean tag) {
-// KbPlugin.log("--> getProposal(ArrayList elements, boolean tag)");
-// KbPlugin.log(" elemnets size = " + elements.size());
-// KbPlugin.log(" tag = " + tag);
-
- ArrayList<KbProposal> kbProposals = new ArrayList<KbProposal>();
-
- for(Iterator iter = elements.iterator();iter.hasNext();) {
- Element element = (Element)iter.next();
- String label = element.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
-
- KbProposal proposal = new KbProposal();
- proposal.setLabel(label);
- proposal.setContextInfo(KbSchemaUtil.getDescription(element));
-
- if(tag) {
- String attributes = KbSchemaUtil.getRequaredAttributesAsString(element);
- proposal.setReplacementString(label + attributes);
- int position = proposal.getReplacementString().indexOf('"');
- if(position!=-1) {
- position ++;
- }
- proposal.setPosition(position);
- proposal.setIcon(KbIcon.HTML_TAG);
- } else {
- proposal.setReplacementString(label);
- proposal.setIcon(KbIcon.HTML_ATTRIBUTE);
- }
-
-// KbPlugin.log(" add kbProposals:\n" + proposal.toString());
-// KbPlugin.log(" for element: " + element);
-
- kbProposals.add(proposal);
- }
-
-// KbPlugin.log("<-- getProposal()");
-// KbPlugin.log(" kbProposals size = " + kbProposals.size());
-
- return kbProposals;
- }
-
- public KbProposal[] getChildren(String tagName) {
- return (KbProposal[])htmlMap.get(tagName);
- }
-
- public boolean serialize() {
- boolean res = true;
- try {
- FileOutputStream fos = new FileOutputStream(hashMapLocation);
- ObjectOutputStream oos = new ObjectOutputStream(fos);
- oos.writeObject(htmlMap);
- oos.flush();
- oos.close();
- } catch (Exception e) {
- res = false;
- String message = "ERROR: Can't serialize html map to file: " + hashMapLocation;
- KbPlugin.getPluginLog().logError(message, e);
- }
-
- return res;
- }
-
- public static KbHtmlMap loadMap() throws IOException, ClassNotFoundException {
- HashMap map = null;
- FileInputStream fis = new FileInputStream(hashMapLocation);
- ObjectInputStream ois = new ObjectInputStream(fis);
- map = (HashMap)ois.readObject();
- ois.close();
- return new KbHtmlMap(map);
- }
-}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlStore.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlStore.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlStore.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -15,17 +15,15 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
+import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-
/**
* @author eskimo
*/
@@ -246,7 +244,6 @@
KbProposal proposal = new KbProposal();
proposal.setLabel("/" + lastTag);
proposal.setReplacementString("/" + lastTag);
- proposal.setIcon(KbIcon.HTML_TAG);
return proposal;
}
}
@@ -323,7 +320,6 @@
position = proposal.getReplacementString().length();
}
proposal.setPosition(position);
- proposal.setIcon(KbIcon.HTML_TAG);
kbProposals.add(proposal);
}
@@ -381,16 +377,7 @@
private synchronized boolean htmlSchemaIsActivating() {
return activatingHtmlSchema;
}
-/*
- private synchronized void enableHtmlSchemaActivating(boolean status) {
- activatingHtmlSchema = status;
- }
- private synchronized void deactivateHtmlSchema() {
- htmlSchema = null;
-// htmlMap = null;
- }
-*/
private ArrayList<KbProposal> getAttributes(String tagName, String attributeMask) {
return getAttributeProposal(getAttributeTypesByName(tagName, attributeMask, true));
}
@@ -433,7 +420,6 @@
proposal.setLabel(value);
proposal.setReplacementString(value);
proposal.setContextInfo(null);
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposal.setPosition(value.length());
enumeration.add(proposal);
@@ -475,7 +461,6 @@
proposal.setLabel(value);
proposal.setReplacementString(value);
proposal.setContextInfo(null);
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposal.setPosition(value.length());
enumeration.add(proposal);
@@ -510,14 +495,8 @@
position = proposal.getReplacementString().length();
}
proposal.setPosition(position);
- proposal.setIcon(KbIcon.HTML_TAG);
} else {
proposal.setReplacementString(label);
- if(KbSchemaUtil.checkRequaredAttribute(element)) {
- proposal.setIcon(KbIcon.HTML_ATTRIBUTE);
- } else {
- proposal.setIcon(KbIcon.HTML_ATTRIBUTE_OPTIONAL);
- }
}
kbProposals.add(proposal);
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbIcon.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbIcon.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbIcon.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-import java.io.ObjectStreamException;
-import java.io.Serializable;
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * @author igels
- */
-public class KbIcon implements Serializable {
-
- private static final long serialVersionUID = 3762136564046244137L;
-
- private static Map<String,KbIcon> allObjects = new Hashtable<String,KbIcon>();
-
- private final String imageType;
- private String imagePath;
- private transient Image image = null;
-
- /**
- *
- */
- private KbIcon(String imageType, String imagePath) {
- this.imageType = imageType;
- this.imagePath = imagePath;
-
- allObjects.put(imageType, this);
- }
-
- public static final KbIcon ENUM_ITEM = new KbIcon("Enumeration item icon", "/icons/proposals/enum_item.gif");
-
- public static final KbIcon HTML_ATTRIBUTE = new KbIcon("HTML requared attribute icon", "/icons/proposals/html_attribute.gif");
- public static final KbIcon HTML_ATTRIBUTE_OPTIONAL = new KbIcon("HTML optional attribute icon", "/icons/proposals/html_attribute_optional.gif");
- public static final KbIcon HTML_TAG = new KbIcon("HTML tag icon","/icons/proposals/html_tag.gif");
-
- public static final KbIcon TLD_ATTRIBUTE = new KbIcon("TLD requared attribute icon", "/icons/proposals/tld_attribute.gif");
- public static final KbIcon TLD_ATTRIBUTE_OPTIONAL = new KbIcon("TLD optional attribute icon", "/icons/proposals/tld_attribute_optional.gif");
- public static final KbIcon TLD_TAG = new KbIcon("TLD tag icon", "/icons/proposals/tld_tag.gif");
-
- public static final KbIcon XML_ATTRIBUTE = new KbIcon("XML requared attribute icon", "/icons/proposals/xml_attribute.gif");
- public static final KbIcon XML_ATTRIBUTE_OPTIONAL = new KbIcon("XML optional attribute icon", "/icons/proposals/xml_attribute_optional.gif");
- public static final KbIcon XML_TAG = new KbIcon("XML tag icon","/icons/proposals/xml_tag.gif");
-
- public static final KbIcon JSP_DIRECTIVE_ATTRIBUTE = new KbIcon("JSP directive requared attribute icon", "/icons/proposals/jsp_directive_attr.gif");
- public static final KbIcon JSP_DIRECTIVE_ATTRIBUTE_OPTIONAL = new KbIcon("JSP directive optional attribute icon","/icons/proposals/jsp_directive_attr_optional.gif");
- public static final KbIcon JSP_DIRECTIVE = new KbIcon("JSP directive icon", "/icons/proposals/jsp_directive.gif");
-
- public Image getImage() {
- if (image == null)
- image = new Image(Display.getCurrent(), KbProposal.class.getResourceAsStream(imagePath));
-
- return image;
- }
-
- public String toString() {
- return imageType;
- }
-
- private Object readResolve() throws ObjectStreamException {
- return allObjects.get(imageType);
- }
-}
\ No newline at end of file
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbJspDirectiveStore.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbJspDirectiveStore.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbJspDirectiveStore.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,286 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.StringTokenizer;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-
-/**
- * @author igels
- */
-public class KbJspDirectiveStore implements KbStore {
-
- private final static TagDescriptor DEFAULT_TAG_INFO;
- static {
- DEFAULT_TAG_INFO = new TagDescriptor();
- DEFAULT_TAG_INFO.setBody(false);
- DEFAULT_TAG_INFO.setClosingTag(false);
- }
-
- private String jspDirectiveSchemaLocation;
- private Document jspDirectiveSchema;
-
- private static final KbJspDirectiveStore INSTANCE = new KbJspDirectiveStore();
-
- private KbJspDirectiveStore() {
- jspDirectiveSchemaLocation = KbConfigurationFactory.getInstance().getDefaultConfiguration().getJspDirectiveSchemaFilePath();
- }
-
- public static KbJspDirectiveStore getInstance() {
- return INSTANCE;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbStore#queryTagInformation(org.jboss.tools.common.kb.KbQuery)
- */
- public TagDescriptor queryTagInformation(KbQuery query) {
- return DEFAULT_TAG_INFO;
- }
-
- public AttributeDescriptor queryAttributeInformation(KbQuery query) {
- // TODO
- throw new IllegalStateException("This method is not implemented yet.");
- }
-
- public Collection<KbProposal> queryProposal(KbQuery query) {
- if(!activateJspDirectiveSchema()) {
- return new ArrayList<KbProposal>();
- }
-
- ArrayList<KbProposal> proposals = queryTagProposal(query);
- Collections.sort(proposals);
-
- return proposals;
- }
-
- private ArrayList<KbProposal> queryTagProposal(KbQuery query) {
-// KbPlugin.log("--> KbJspDirectiveStore.queryProposal(KbQuery query)");
- String strQuery = query.getQuery();
-// KbPlugin.log(" query=\"" + query + "\"");
-
- if((!strQuery.startsWith(KbQuery.JSP_DIRECTIVE_QUERY))||
- (strQuery.startsWith(KbQuery.JSP_DIRECTIVE_QUERY + KbQuery.ATTRIBUTE_SEPARATOR))||
- (strQuery.indexOf(KbQuery.ATTRIBUTE_SEPARATOR + KbQuery.ENUMERATION_SEPARATOR)!=-1)) {
-
- String errorMessage = "ERROR: Bad query: " + strQuery + "\n" +
- " Possible query format: \"" + KbQuery.JSP_DIRECTIVE_QUERY + "directiveName" + KbQuery.ATTRIBUTE_SEPARATOR + "attributeName" + KbQuery.ENUMERATION_SEPARATOR + "attributeValue\"";
-// KbPlugin.log(errorMessage);
- throw new IllegalArgumentException(errorMessage);
-// return new ArrayList();
- } else if(strQuery.length() == KbQuery.JSP_DIRECTIVE_QUERY.length()) {
- return getDirectives("");
- }
-
- int startAttributeName = strQuery.lastIndexOf(KbQuery.ATTRIBUTE_SEPARATOR);
- if((startAttributeName == 0)||(startAttributeName < 0)){
- return getDirectives(strQuery.substring(KbQuery.JSP_DIRECTIVE_QUERY.length()));
- }
-
- String directiveName = strQuery.substring(KbQuery.JSP_DIRECTIVE_QUERY.length(), startAttributeName);
- startAttributeName+=KbQuery.ATTRIBUTE_SEPARATOR.length();
- if(startAttributeName == strQuery.length()) {
- return getAttributes(directiveName, "");
- }
-
- int startAttributeValue = strQuery.indexOf(KbQuery.ENUMERATION_SEPARATOR);
- if(startAttributeValue < 0) {
- return getAttributes(directiveName, strQuery.substring(startAttributeName));
- }
-
- String attributeName = strQuery.substring(startAttributeName, startAttributeValue);
- startAttributeValue+=KbQuery.ENUMERATION_SEPARATOR.length();
- if(startAttributeValue == strQuery.length()) {
- return getEnumeration(directiveName, attributeName, "");
- }
-
-// KbPlugin.log("<-- queryProposal()");
- return getEnumeration(directiveName, attributeName, KbQuery.decode(strQuery.substring(startAttributeValue)));
- }
-
- public void registerResource(KbResource resource) {
- }
-
- public void unregisterResource(KbResource resource) {
- }
-
- private synchronized boolean activateJspDirectiveSchema() {
- if(jspDirectiveSchema != null) {
- return true;
- }
-
- File schemaLocation = new File(jspDirectiveSchemaLocation);
- if((schemaLocation == null)||(!schemaLocation.exists())) {
-// String errorMessage = "ERROR: Html schema (location: " + schemaLocation + ") does not exist!";
-// KbPlugin.log(errorMessage);
-// throw new RuntimeException(errorMessage);
- return false;
- }
-
- try {
- jspDirectiveSchema = KbDocumentBuilderFactory.createDocumentBuilder(false).parse(schemaLocation);
- } catch (Exception e) {
- String message = "ERROR: Can't parse JSP Directive Schema (location: " + schemaLocation + ")";
- KbPlugin.getPluginLog().logError(message, e);
- return false;
- }
- return true;
- }
-
- private ArrayList<KbProposal> getDirectives(String directiveMask) {
- return getDirectiveProposal(getElementTypesByName(directiveMask, true));
- }
-
- private ArrayList<KbProposal> getAttributes(String directiveName, String attributeMask) {
- return getAttributeProposal(getAttributeTypesByName(directiveName, attributeMask, true));
- }
-
- private ArrayList<Element> getElementTypesByName(String name, boolean mask) {
-// KbPlugin.log("--> getElementTypesByName(String name, boolean mask)");
-// KbPlugin.log(" name = " + name);
-// KbPlugin.log(" mask = " + mask);
-
- ArrayList<Element> elements = new ArrayList<Element>();
-
- NodeList elementTypes = jspDirectiveSchema.getElementsByTagName(SchemaNodeFactory.ELEMENT_TYPE_NODE);
- for(int i=0; i<elementTypes.getLength(); i++) {
- Element elementType = (Element)elementTypes.item(i);
- String schemaDirectiveName = elementType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
- boolean match = mask?schemaDirectiveName.startsWith(name):schemaDirectiveName.equals(name);
- if(match) {
-// KbPlugin.log(" add element: " + elementType);
- elements.add(elementType);
- }
- }
-
-// KbPlugin.log("<-- getElementTypesByName()");
-// KbPlugin.log(" elements Size = " + elementType.size());
-
- return elements;
- }
-
- private ArrayList<Element> getAttributeTypesByName(String directiveName, String attributeName, boolean mask) {
- ArrayList<Element> attributes = new ArrayList<Element>();
-
- ArrayList elements = getElementTypesByName(directiveName, false);
- if(!elements.isEmpty()) {
- Element element = (Element)elements.get(0);
-
- ArrayList attributeTypes = KbSchemaUtil.getAttributeTypes(element);
- for(int i=0; i<attributeTypes.size(); i++) {
- Element attributeType = (Element)attributeTypes.get(i);
-
- String attributeTypeName = attributeType.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
- boolean match = mask?attributeTypeName.startsWith(attributeName):attributeTypeName.equals(attributeName);
- if(match) {
- attributes.add(attributeType);
- }
- }
- }
- return attributes;
- }
-
- private ArrayList<KbProposal> getEnumeration(String directiveName, String attributeName, String valueMask) {
- ArrayList<KbProposal> enumeration = new ArrayList<KbProposal>();
-
- ArrayList attributeTypes = new ArrayList();
- attributeTypes = getAttributeTypesByName(directiveName, attributeName, false);
- if(!attributeTypes.isEmpty()) {
- Element attributeType = (Element)attributeTypes.get(0);
- String type = attributeType.getAttribute(SchemaNodeFactory.TYPE_ATTRIBUTE);
- if(type.equals(SchemaNodeFactory.ENUMERATION_TYPE)) {
- String values = attributeType.getAttribute(SchemaNodeFactory.VALUES_ATTRIBUTE);
- StringTokenizer st = new StringTokenizer(values, SchemaNodeFactory.ENUMERATION_SEPARATOR);
- while(st.hasMoreElements()) {
- String value = (String)st.nextElement();
- if(value.startsWith(valueMask)) {
- KbProposal proposal = new KbProposal();
- proposal.setLabel(value);
- proposal.setReplacementString(value);
- proposal.setContextInfo(null);
- proposal.setIcon(KbIcon.ENUM_ITEM);
-
- enumeration.add(proposal);
- }
- }
- }
- }
-
- return enumeration;
- }
-
- private ArrayList<KbProposal> getDirectiveProposal(ArrayList elements) {
- return getProposal(elements, true);
- }
-
- private ArrayList<KbProposal> getAttributeProposal(ArrayList elements) {
- return getProposal(elements, false);
- }
-
- private ArrayList<KbProposal> getProposal(ArrayList elements, boolean directive) {
-// KbPlugin.log("--> getProposal(ArrayList elements, boolean directive)");
-// KbPlugin.log(" elemnets size = " + elements.size());
-// KbPlugin.log(" directive = " + directive);
-
- ArrayList<KbProposal> kbProposals = new ArrayList<KbProposal>();
-
- for(int i=0; i<elements.size(); i++) {
- Element element = (Element)elements.get(i);
- String label = element.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
-
- KbProposal proposal = new KbProposal();
-
- if(directive) {
- label = "%@ " + label;
- proposal.setLabel(label);
-
- String attributes = KbSchemaUtil.getRequaredAttributesAsString(element);
-
- proposal.setReplacementString(label + attributes);
- int position = proposal.getReplacementString().indexOf('"');
- if(position!=-1) {
- position ++;
- } else {
- position = proposal.getReplacementString().length();
- }
- proposal.setPosition(position);
- proposal.setIcon(KbIcon.JSP_DIRECTIVE);
- } else {
- proposal.setReplacementString(label);
- proposal.setLabel(label);
- if(KbSchemaUtil.checkRequaredAttribute(element)) {
- proposal.setIcon(KbIcon.JSP_DIRECTIVE_ATTRIBUTE);
- } else {
- proposal.setIcon(KbIcon.JSP_DIRECTIVE_ATTRIBUTE_OPTIONAL);
- }
- }
- proposal.setContextInfo(KbSchemaUtil.getDescription(element));
-
-// KbPlugin.log(" add kbProposals:\n" + proposal.toString());
-// KbPlugin.log(" for element: " + element);
-
- kbProposals.add(proposal);
- }
-
-// KbPlugin.log("<-- getProposal()");
-// KbPlugin.log(" kbProposals size = " + kbProposals.size());
-
- return kbProposals;
- }
-}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPlugin.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -31,24 +31,6 @@
// The shared instance
private static KbPlugin plugin;
-
- protected void initializeDefaultPluginPreferences() {
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_USE_LOWER_CASE, true);
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_USE_AUTOCOMPLETE_FOR_MANDATORY, true);
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_UTILIZE_COMMENTS, false);
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_USE_AUTOCOMPLETE_FOR_TAGS, true);
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_ALLOW_DOWNLOAD, true);
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_USE_PROXY, false);
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_HOST, "");
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_PORT, "");
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_USER, "");
- getPreferenceStore().setDefault(KbPreferencesConstants.PROMPTING_PASSWORD, "");
- }
-
- /**
- *
- *
- */
public KbPlugin() {
}
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPreferencesConstants.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPreferencesConstants.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbPreferencesConstants.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-public interface KbPreferencesConstants {
- public static final String PROMPTING_USE_LOWER_CASE = "PROMPTING_USE_LOWER_CASE";
- public static final String PROMPTING_USE_AUTOCOMPLETE_FOR_MANDATORY = "PROMPTING_USE_AUTOCOMPLETE_FOR_MANDATORY";
- public static final String PROMPTING_UTILIZE_COMMENTS = "PROMPTING_UTILIZE_COMMENTS";
- public static final String PROMPTING_USE_AUTOCOMPLETE_FOR_TAGS = "PROMPTING_USE_AUTOCOMPLETE_FOR_TAGS";
- public static final String PROMPTING_ALLOW_DOWNLOAD = "PROMPTING_ALLOW_DOWNLOAD";
- public static final String PROMPTING_USE_PROXY = "PROMPTING_USE_PROXY";
- public static final String PROMPTING_HOST = "PROMPTING_HOST";
- public static final String PROMPTING_PORT = "PROMPTING_PORT";
- public static final String PROMPTING_USER = "PROMPTING_USER";
- public static final String PROMPTING_PASSWORD = "PROMPTING_PASSWORD";
-}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbProposal.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -12,8 +12,6 @@
import java.io.Serializable;
-import org.eclipse.swt.graphics.Image;
-
/**
* Describes a proposal for content assistants
* @author igels
@@ -36,7 +34,6 @@
private String contextInfo;
private String replacementString;
private boolean emptyContextInfo = true;
- private KbIcon icon;
private int relevance = R_NONE;
private int position = -1;
private boolean autoActivationContentAssistantAfterApplication = false;
@@ -117,20 +114,6 @@
/**
* @return
*/
- public Image getIcon() {
- return icon.getImage();
- }
-
- /**
- * @param image
- */
- public void setIcon(KbIcon icon) {
- this.icon = icon;
- }
-
- /**
- * @return
- */
public int getPosition() {
if(position==-1 && getReplacementString()!=null) {
return getReplacementString().length();
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -30,8 +30,6 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-
/**
* Class helps to convert TLD to Schema
* @author igels
@@ -170,8 +168,7 @@
Element elementType = SchemaNodeFactory.getInstance().createElementType(schemaElement, attributes);
String description = getDescription(tldTag);
- if( KbConfigurationFactory.getInstance().getDefaultConfiguration().isUtilizeComments())
- SchemaNodeFactory.getInstance().createDescription(elementType, description);
+ SchemaNodeFactory.getInstance().createDescription(elementType, description);
addAttributes(tldTag, elementType, jsfTld);
}
@@ -206,9 +203,7 @@
attributes.put(SchemaNodeFactory.NAME_ATTRIBUTE, name);
attributes.put(SchemaNodeFactory.REQUIRED_ATTRIBUTE, required);
Element attributeType = SchemaNodeFactory.getInstance().createAttributeType(schemaElement, attributes);
- if(description != null && KbConfigurationFactory.getInstance().getDefaultConfiguration().isUtilizeComments()) {
- SchemaNodeFactory.getInstance().createDescription(attributeType, description);
- }
+ SchemaNodeFactory.getInstance().createDescription(attributeType, description);
if(jsfTld || tldAttribute.getElementsByTagName("deferred-value").getLength()>0) {
// Add default proposals
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -778,7 +778,6 @@
proposal.setLabel(value);
proposal.setReplacementString(value);
proposal.setContextInfo(null);
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposal.setPosition(value.length());
enumeration.add(proposal);
@@ -847,7 +846,6 @@
proposal.setLabel(lb);
proposal.setReplacementString(lb);
- proposal.setIcon(KbIcon.TLD_TAG);
} else if(tldElement.isTag()) {
String prefix = tldElement.getPrefix();
String label = element.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
@@ -873,17 +871,11 @@
position = proposal.getReplacementString().length();
}
proposal.setPosition(position);
- proposal.setIcon(KbIcon.TLD_TAG);
} else {
String label = element.getAttribute(SchemaNodeFactory.NAME_ATTRIBUTE);
proposal.setReplacementString(label);
proposal.setLabel(label);
- if(KbSchemaUtil.checkRequaredAttribute(element)) {
- proposal.setIcon(KbIcon.TLD_ATTRIBUTE);
- } else {
- proposal.setIcon(KbIcon.TLD_ATTRIBUTE_OPTIONAL);
- }
}
proposal.setContextInfo(KbSchemaUtil.getDescription(element));
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/TagDescriptor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/TagDescriptor.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/TagDescriptor.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -185,7 +185,6 @@
position = proposal.getReplacementString().length();
}
proposal.setPosition(position);
- proposal.setIcon(KbIcon.TLD_TAG);
return proposal;
}
Deleted: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/XmlKbConnector.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/XmlKbConnector.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/XmlKbConnector.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.common.kb;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
-
-/**
- * @author eskimo
- */
-public class XmlKbConnector implements KbConnector {
-
- private ArrayList<KbResource> registretedResources;
-
- public XmlKbConnector() {
- registretedResources = new ArrayList<KbResource>();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbConnector#queryTagInformation(org.jboss.tools.common.kb.KbQuery)
- */
- public TagDescriptor getTagInformation(String query) throws KbException {
- KbQuery kbQuery = new KbQuery(query, registretedResources);
- return KbDtdStore.getInstance().queryTagInformation(kbQuery);
- }
-
- /**
- * @see org.jboss.tools.common.kb.KbConnector#getProposals()
- **/
- public Collection getProposals(String query) throws KbException {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> XmlKbConnector.getProposals(String query)");
- KbPlugin.getPluginLog().logInfo(" query = " + query);
- }
-/*
- try {
- KbPlugin.log("Query: " + query);
- KbPlugin.log("TagInfo: " + queryTagInformation(query));
- } catch(Exception e) {
- KbPlugin.log(e);
- }
-*/
- KbQuery kbQuery = new KbQuery(query, registretedResources);
- Collection proposals = KbDtdStore.getInstance().queryProposal(kbQuery);
-
- boolean autocompleteRequiredAttributes = KbConfigurationFactory.getInstance().getDefaultConfiguration().isAutocompleteRequiredAttributes();
- if(!autocompleteRequiredAttributes) {
- removeAutocompleteRequiredAttributes(proposals);
- }
-
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- XmlKbConnector.getProposals(String query)");
- KbPlugin.getPluginLog().logInfo(" proposals size=" + proposals.size());
- }
- return proposals;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbConnector#RegisterResource(org.jboss.tools.common.kb.KbResource)
- */
- public boolean registerResource(KbResource resource) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("--> XmlKbConnector.registerResource(KbResource resource)");
- KbPlugin.getPluginLog().logInfo(" resource = " + resource);
- }
-
- if(!(resource instanceof KbDtdResource)) {
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- XmlKbConnector.registerResource(KbResource resource)");
- KbPlugin.getPluginLog().logInfo(" resource don't instanse of KbDtdResource.");
- }
- return false;
- }
- KbDtdResource dtdResource =(KbDtdResource)resource;
-
- if(findEqualResource(resource)==null) {
- registretedResources.add(resource);
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo(" resource has been registered.");
- }
- KbDtdStore.getInstance().registerResource(resource);
- }
-
- KbDtdStore.getInstance().reregisterModifiededResource(dtdResource);
- if(KbPlugin.isDebugEnabled()) {
- KbPlugin.getPluginLog().logInfo("<-- XmlKbConnector.registerResource(KbResource resource)");
- }
- return true;
- }
-
- private KbResource findEqualResource(KbResource resource) {
- for(int i=0; i<registretedResources.size(); i++) {
- if(registretedResources.get(i).equals(resource)) {
- return (KbResource)registretedResources.get(i);
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.tools.common.kb.KbConnector#RegisterResource(org.jboss.tools.common.kb.KbResource)
- */
- public void unregisterResource(KbResource resource) {
- KbResource er = findEqualResource(resource);
-
- if(er!=null) {
- registretedResources.remove(er);
- }
- }
-
- private void removeAutocompleteRequiredAttributes(Collection proposals) {
- for(Iterator iter = proposals.iterator(); iter.hasNext();) {
- ((KbProposal)iter.next()).removeAutocompleteRequiredAttributes();
- }
- }
-
- public String toString() {
- return "Resources size = " + registretedResources.size();
- }
-}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/configuration/KbConfiguration.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/configuration/KbConfiguration.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/configuration/KbConfiguration.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -60,28 +60,4 @@
* @return
*/
public String getHtmlMapFilePath();
-
- /**
- *
- * @return
- */
- public boolean isAllowDownload();
-
- /**
- *
- * @return
- */
- public boolean isLowerCase();
-
- /**
- *
- * @return
- */
- public boolean isAutocompleteRequiredAttributes();
-
- /**
- *
- * @return
- */
- public boolean isUtilizeComments();
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/configuration/KbPluginConfiguration.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/configuration/KbPluginConfiguration.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/configuration/KbPluginConfiguration.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -14,10 +14,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.preference.IPreferenceStore;
-
import org.jboss.tools.common.kb.KbPlugin;
-import org.jboss.tools.common.kb.KbPreferencesConstants;
/**
* @author igels
@@ -89,42 +86,10 @@
}
/**
- * @see org.jboss.tools.common.kb.configuration.KbConfiguration#isAllowDownload()
- */
- public boolean isAllowDownload() {
- IPreferenceStore store = KbPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(KbPreferencesConstants.PROMPTING_ALLOW_DOWNLOAD);
- }
-
- /**
- * @see org.jboss.tools.common.kb.configuration.KbConfiguration#isLowerCase()
- */
- public boolean isLowerCase() {
- IPreferenceStore store = KbPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(KbPreferencesConstants.PROMPTING_USE_LOWER_CASE);
- }
-
- /**
- * @see org.jboss.tools.common.kb.configuration.KbConfiguration#isAutocompleteRequiredAttributes()
- */
- public boolean isAutocompleteRequiredAttributes() {
- IPreferenceStore store = KbPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(KbPreferencesConstants.PROMPTING_USE_AUTOCOMPLETE_FOR_MANDATORY);
- }
-
- /**
*
* @return
*/
public static KbPluginConfiguration getInstance() {
return INSTANCE;
}
-
- /**
- * @see org.jboss.tools.common.kb.configuration.KbConfiguration#isUtilizeComments()
- */
- public boolean isUtilizeComments() {
- IPreferenceStore store = KbPlugin.getDefault().getPreferenceStore();
- return store.getBoolean(KbPreferencesConstants.PROMPTING_UTILIZE_COMMENTS);
- }
}
\ No newline at end of file
Modified: trunk/common/tests/org.jboss.tools.common.kb.test/src/org/jboss/tools/common/kb/test/resources/TestDynamicResource.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.kb.test/src/org/jboss/tools/common/kb/test/resources/TestDynamicResource.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/common/tests/org.jboss.tools.common.kb.test/src/org/jboss/tools/common/kb/test/resources/TestDynamicResource.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -15,7 +15,6 @@
import java.util.Collection;
import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbIcon;
import org.jboss.tools.common.kb.KbProposal;
abstract public class TestDynamicResource implements KbDinamicResource {
@@ -34,7 +33,6 @@
KbProposal proposal = new KbProposal();
proposal.setLabel(bundle);
proposal.setReplacementString(bundle);
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposal.setPosition(bundle.length());
proposals.add(proposal);
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbImageFileResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbImageFileResource.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbImageFileResource.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -11,7 +11,14 @@
package org.jboss.tools.jst.jsp.support.kb;
import java.io.InputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -20,14 +27,11 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-
+import org.jboss.tools.common.kb.KbDinamicResource;
+import org.jboss.tools.common.kb.KbProposal;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbIcon;
-import org.jboss.tools.common.kb.KbProposal;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.outline.ValueHelper;
import org.jboss.tools.jst.web.tld.FilePathEncoderFactory;
@@ -121,7 +125,6 @@
}
proposal.setReplacementString(replacementString);
proposal.setPosition(replacementString.length());
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposals.add(proposal);
}
return proposals;
@@ -285,4 +288,4 @@
}
return false;
}
-}
+}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdActionResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdActionResource.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdActionResource.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -21,7 +21,6 @@
import org.eclipse.ui.IEditorInput;
import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbIcon;
import org.jboss.tools.common.kb.KbProposal;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
@@ -68,7 +67,6 @@
KbProposal proposal = new KbProposal();
proposal.setLabel(text);
proposal.setReplacementString(text);
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposal.setPosition(text.length());
proposals.add(proposal);
}
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBeanPropertyResource.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -20,13 +20,11 @@
import java.util.TreeSet;
import org.eclipse.ui.IEditorInput;
-
-import org.jboss.tools.common.model.XModel;
-import org.jboss.tools.common.model.util.ELParser;
import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbIcon;
import org.jboss.tools.common.kb.KbProposal;
import org.jboss.tools.common.kb.KbProposal.PostProcessing;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.util.ELParser;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
@@ -145,7 +143,6 @@
KbProposal proposal = new KbProposal();
proposal.setLabel(prefix + text + suffix);
proposal.setReplacementString(text);
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposals.add(proposal);
proposal.setPosition(cursor);
proposal.setPostProcessing(postProcessing);
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundleNameResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundleNameResource.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdBundleNameResource.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -19,11 +19,9 @@
import java.util.TreeSet;
import org.eclipse.ui.IEditorInput;
-
-import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbIcon;
import org.jboss.tools.common.kb.KbProposal;
+import org.jboss.tools.common.model.XModel;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
/**
@@ -60,7 +58,6 @@
KbProposal proposal = new KbProposal();
proposal.setLabel(text);
proposal.setReplacementString(text);
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposal.setPosition(text.length());
proposals.add(proposal);
}
@@ -102,4 +99,4 @@
*/
public void clearConstraints() {
}
-}
+}
\ No newline at end of file
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdTaglibResource.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdTaglibResource.java 2008-03-27 12:01:03 UTC (rev 7145)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/support/kb/WTPKbdTaglibResource.java 2008-03-27 13:13:43 UTC (rev 7146)
@@ -19,11 +19,9 @@
import java.util.TreeSet;
import org.eclipse.ui.IEditorInput;
-
-import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.kb.KbDinamicResource;
-import org.jboss.tools.common.kb.KbIcon;
import org.jboss.tools.common.kb.KbProposal;
+import org.jboss.tools.common.model.XModel;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
@@ -56,7 +54,6 @@
KbProposal proposal = new KbProposal();
proposal.setLabel(text);
proposal.setReplacementString(text);
- proposal.setIcon(KbIcon.ENUM_ITEM);
proposals.add(proposal);
proposal.setPosition(proposal.getReplacementString().length());
}
@@ -94,5 +91,4 @@
public void clearConstraints() {
}
-
-}
+}
\ No newline at end of file
16 years, 1 month
JBoss Tools SVN: r7145 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2008-03-27 08:01:03 -0400 (Thu, 27 Mar 2008)
New Revision: 7145
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE1479Test.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1734
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE1479Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE1479Test.java 2008-03-27 11:05:47 UTC (rev 7144)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE1479Test.java 2008-03-27 12:01:03 UTC (rev 7145)
@@ -11,6 +11,7 @@
package org.jboss.tools.jsf.vpe.jsf.test.jbide;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -19,7 +20,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.progress.UIJob;
+import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.vpe.ui.test.TestUtil;
import org.jboss.tools.vpe.ui.test.VpeTest;
@@ -32,10 +33,12 @@
*/
public class JBIDE1479Test extends VpeTest {
- public static final String IMPORT_PROJECT_NAME = "jsfTest";
+ public static final String IMPORT_PROJECT_NAME = "jsfTest"; //$NON-NLS-1$
- public static final String TEST_PAGE_NAME = "JBIDE/1479/employee.xhtml";
+ public static final String TEST_PAGE_NAME = "JBIDE/1479/employee.xhtml"; //$NON-NLS-1$
+ private boolean finished;
+
public JBIDE1479Test(String name) {
super(name);
}
@@ -49,44 +52,56 @@
TEST_PAGE_NAME, IMPORT_PROJECT_NAME);
- assertNotNull("Could not open specified file " + TEST_PAGE_NAME,
+ assertNotNull("Could not open specified file " + TEST_PAGE_NAME, //$NON-NLS-1$
file);
IEditorInput input = new FileEditorInput(file);
- assertNotNull("Editor input is null", input);
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
TestUtil.waitForJobs();
JSPMultiPageEditor part = openEditor(input);
- TestUtil.delay(20000L);
+ TestUtil.delay(10000L);
assertNotNull(part);
final StyledTextContent content= part.getSourceEditor().getTextViewer().getTextWidget().getContent();
-
- Job job = new UIJob("Test"){
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- for(int i=1000;i<content.getCharCount();i+=10) {
- if(content.getTextRange(i, 1).charAt(0) ==' ') {
- content.replaceTextRange(i, 2, content.getTextRange(i, 1)+" ");
- }
- }
- return Status.OK_STATUS;
- }
-
+
+ finished = false;
+
+ Job job = new WorkspaceJob("Test JBIDE-1479"){ //$NON-NLS-1$
+
+ public IStatus runInWorkspace(IProgressMonitor monitor) {
+ try {
+ new FormatProcessorXML().formatFile(file);
+ }catch (Throwable exception){
+ /*
+ * Here we test JBIDE-1479, if eclipse crashed we won't get any
+ * exception, so we just ignore it's.
+ */
+ }
+ finished = true;
+ return Status.OK_STATUS;
+ }
};
job.setPriority(Job.SHORT);
job.schedule(0L);
TestUtil.delay(15000L);
TestUtil.waitForJobs();
-
+
+ while (!finished) {
+ TestUtil.delay(1000L);
+ }
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
.closeAllEditors(false);
-
- if(getException()!=null) {
- throw getException();
- }
+/*
+ * we ignore this code, because we are testint JBIDE-1479,
+ * it's test fot crash of eclipse.And if we modifying content from non-ui thread, we almost
+ * always will get SWTException 'access violation'.
+ */
+// if(getException()!=null) {
+// throw getException();
+// }
}
}
16 years, 1 month
JBoss Tools SVN: r7144 - in trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces: src/org/jboss/tools/jsf/vpe/richfaces/template and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2008-03-27 07:05:47 -0400 (Thu, 27 Mar 2008)
New Revision: 7144
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tabPanel/activeBackground.gif
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tabPanel/tabPanel.css
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1697, css style updated, labelWidth added.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tabPanel/activeBackground.gif
===================================================================
(Binary files differ)
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tabPanel/tabPanel.css
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tabPanel/tabPanel.css 2008-03-27 10:38:30 UTC (rev 7143)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/resources/tabPanel/tabPanel.css 2008-03-27 11:05:47 UTC (rev 7144)
@@ -1,28 +1,62 @@
-.dr-tbpnl-cntnt {
+
+.rich-tabpanel{
+
+}
+
+.rich-tabpanel-content {
border-width: 1px;
border-style: solid;
font-size: 11px;
font-family: verdana;
color: #000000;
vertical-align: top;
+ background-color: #FFFFFF;
+ border-color: #C4C0B9;
}
-.dr-tbpnl-tbtopbrdr {
+.rich-tabpanel-content-position {
+ top: -1px;
+ height: 100%;
+}
+
+.rich-tabhdr-side-border {
border-top-width: 1px;
border-top-style: solid;
}
-.dr-tbpnl-tb {
+.rich-tabhdr-side-cell {
+ border-top-color: #C4C0B9;
+ background-repeat: no-repeat;
+ background-position: top;
+}
+
+.rich-tabhdr-cell-active {
+
+}
+
+.rich-tabhdr-cell-inactive {
+ padding-top: 2px;
+ padding-bottom: 1px;
+}
+
+.rich-tabhdr-cell-disabled {
+ padding-top: 2px;
+ padding-bottom: 1px;
+}
+
+.rich-tab-header {
padding: 2px 10px 2px 10px;
text-align: center;
+ color: #000000;
+ font-size: 11px;
+ font-family: Arial, Verdana, sans-serif;
}
-.dr-tbpnl-tbbrdr {
- background-repeat: no-repeat;
- background-position: top;
+rich-tab-label {
+
}
-.dr-tbpnl-tb-act {
+.rich-tab-active {
border-width: 1px;
border-style: solid;
padding: 3px 10px 4px 10px;
@@ -30,79 +64,29 @@
background-repeat: repeat-x;
background-position: top;
cursor: default;
+ color:#000000;
+ border-color: #FFFFFF;
+ background-color:#FFFFFF;
}
-.dr-tbpnl-tb-inact {
+.rich-tab-inactive {
border-width: 1px;
border-style: solid;
border-bottom: 0px;
background-repeat: repeat-x;
background-position: top;
cursor: default;
+ border-color: #ffffff;
}
-.dr-tbpnl-tb-dsbld {
+.rich-tab-disabled {
border-width: 1px;
border-style: solid;
border-bottom: 0px;
background-repeat: repeat-x;
background-position: top;
cursor: default;
-}
-
-.dr-tbpnl-tbcell-dsbl, .dr-tbpnl-tbcell-inact {
- padding-top: 2px;
- padding-bottom: 1px;
-}
-
-.dr-tbpnl-tb {
- color: #000000;
- font-size: 11px;
- font-family: Arial, Verdana, sans-serif;
-}
-
-.dr-tbpnl-tb-act {
- color:#000000;
border-color: #ffffff;
-}
-
-.dr-tbpnl-tb-inact {
- border-color: #ffffff;
-}
-
-.dr-tbpnl-tb-dsbl {
- border-color: #ffffff;
color: #848079;
}
-.dr-tbpnl-tb-sel {
- border-width: 1px;
- border-style: solid;
- border-bottom: 0px;
- color: #000000;
- background-repeat: repeat-x;
- background-position: top;
- cursor: default;
-}
-
-.dr-tbpnl-cntnt-pstn {
- top: -1px;
- height: 100%;
-}
-
-.dr-tbpnl-tb-sel {
- border-color: #E79A00;
-}
-
-.dr-tbpnl-tbtopbrdr {
- border-top-color: #C4C0B9;
-}
-
-.dr-tbpnl-cntnt {
- background-color: #FFFFFF;
- border-color: #C4C0B9;
-}
-
-.dr-tbpnl-tb-act {
- background-color:#FFFFFF;
-}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-27 10:38:30 UTC (rev 7143)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-27 11:05:47 UTC (rev 7144)
@@ -105,8 +105,6 @@
inerTable.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
inerTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
inerTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
- inerTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
- CSS_CONTENT + SPACE + CSS_CONTENT_POSITION);
// Encode header
nsIDOMElement inerTr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
@@ -145,13 +143,19 @@
(Element) child,
visualDocument, inerTr, active,
ComponentUtil.getAttribute(sourceElement,
- HEADER_CLASS),
+ HEADER_CLASS)
+ + SPACE
+ + ComponentUtil.getAttribute(sourceElement,
+ TAB_CLASS),
ComponentUtil.getAttribute(sourceElement,
- ACTIVE_TAB_CLASS),
+ ACTIVE_TAB_CLASS)
+ + SPACE + CSS_CELL_ACTIVE,
ComponentUtil.getAttribute(sourceElement,
- INACTIVE_TAB_CLASS),
+ INACTIVE_TAB_CLASS)
+ + SPACE + CSS_CELL_INACTIVE,
ComponentUtil.getAttribute(sourceElement,
- DISABLED_TAB_CLASS),
+ DISABLED_TAB_CLASS)
+ + SPACE + CSS_CELL_DISABLED,
String.valueOf(i));
i++;
addSpacer(visualDocument, inerTr, headerSpacing);
@@ -180,20 +184,7 @@
if (active) {
RichFacesTabTemplate.encodeBody(creationData,
(Element) child, visualDocument, inerTr, true,
- ComponentUtil.getAttribute(sourceElement,
- TAB_CLASS)
- + SPACE + CSS_SIDE_CELL
- + SPACE + CSS_SIDE_BORDER,
- ComponentUtil.getAttribute(sourceElement,
- ACTIVE_TAB_CLASS)
- + SPACE + CSS_CELL_ACTIVE,
ComponentUtil.getAttribute(sourceElement,
- INACTIVE_TAB_CLASS)
- + SPACE + CSS_CELL_INACTIVE,
- ComponentUtil.getAttribute(sourceElement,
- DISABLED_TAB_CLASS)
- + SPACE + CSS_CELL_DISABLED,
- ComponentUtil.getAttribute(sourceElement,
CONTENT_CLASS)
+ SPACE + CSS_PANEL
+ SPACE + CSS_CONTENT
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2008-03-27 10:38:30 UTC (rev 7143)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2008-03-27 11:05:47 UTC (rev 7144)
@@ -49,6 +49,7 @@
private static final String ZERO = "0"; //$NON-NLS-1$
private static final String ONE = "1"; //$NON-NLS-1$
+ private static final String TEN = "10"; //$NON-NLS-1$
private static final String SPACE = " "; //$NON-NLS-1$
private static final String EMPTY = ""; //$NON-NLS-1$
@@ -56,7 +57,12 @@
private static final String HEIGHT_STYLE_NAME = "height: "; //$NON-NLS-1$
private static final String WIDTH_STYLE_NAME = "width: "; //$NON-NLS-1$
private static final String STYLE_SEMICOLUMN = "; "; //$NON-NLS-1$
+ private static final String PX = "px"; //$NON-NLS-1$
+ private static final String BODY_TABLE_STYLE = "position: relative; z-index: 1;"; //$NON-NLS-1$
+ private static final String HEADER_TABLE_STYLE = "height : 100%; position : relative; z-index : 2;"; //$NON-NLS-1$
+ private static final String HEADER_TD_STYLE = "height: 100%; vertical-align: bottom;"; //$NON-NLS-1$
+ private static final String TRUE = "true"; //$NON-NLS-1$
/**
* Encode body of tab
@@ -65,23 +71,15 @@
* @param visualDocument
* @param parentTr
* @param active
- * @param tabClass
- * @param activeTabClass
- * @param inactiveTabClass
- * @param disabledTabClass
* @param contentClass
* @param contentStyle
- * @return
+ * @return the tab body
*/
public static VpeCreationData encodeBody(VpeCreationData creationData,
Element sourceElement,
nsIDOMDocument visualDocument,
nsIDOMElement parentTr,
boolean active,
- String tabClass,
- String activeTabClass,
- String inactiveTabClass,
- String disabledTabClass,
String contentClass,
String contentStyle) {
@@ -101,11 +99,11 @@
nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
td.appendChild(table);
table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
- table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "10"); //$NON-NLS-1$
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, TEN);
table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, HUNDRED_PERCENTS);
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-cntnt-pstn" + SPACE + RichFacesTabPanelTemplate.CSS_CONTENT_POSITION); //$NON-NLS-1$
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "position: relative; z-index: 1;"); //$NON-NLS-1$
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,RichFacesTabPanelTemplate.CSS_CONTENT_POSITION);
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, BODY_TABLE_STYLE);
nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
table.appendChild(tr);
@@ -113,7 +111,6 @@
tr.appendChild(td);
td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR)
- + SPACE + "dr-tbpnl-cntnt" //$NON-NLS-1$
+ SPACE + contentClass);
td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLE_ATTR)
@@ -150,7 +147,7 @@
//bodyTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, HtmlComponentUtil.CSS_DISPLAY+" : "+DISABLED_ELEMENT_STYLE+";"); //$NON-NLS-1$ //$NON-NLS-2$
table.appendChild(headerTable);
table.appendChild(bodyTable);
- encodeBody(creationData, (Element)sourceNode, visualDocument, bodyTable, true, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY);
+ encodeBody(creationData, (Element)sourceNode, visualDocument, bodyTable, true, EMPTY, EMPTY);
return creationData;
}
@@ -178,18 +175,16 @@
nsIDOMElement headerTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
parentTr.appendChild(headerTd);
- headerTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height: 100%; vertical-align: bottom;"); //$NON-NLS-1$
- String styleClass = "dr-tbpnl-tbcell-dsbl rich-tabhdr-cell-dsbl"; //$NON-NLS-1$
- if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) { //$NON-NLS-1$
+ headerTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, HEADER_TD_STYLE);
+ String styleClass = RichFacesTabPanelTemplate.CSS_CELL_DISABLED
+ + SPACE + CSS_DISABLED;
+ if(!TRUE.equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
if(active) {
- styleClass = "dr-tbpnl-tbcell-act" //$NON-NLS-1$
- + SPACE + RichFacesTabPanelTemplate.CSS_CELL_ACTIVE;
+ styleClass = RichFacesTabPanelTemplate.CSS_CELL_ACTIVE;
} else {
- styleClass = "dr-tbpnl-tbcell-inact" //$NON-NLS-1$
- + SPACE + RichFacesTabPanelTemplate.CSS_CELL_INACTIVE;
+ styleClass = RichFacesTabPanelTemplate.CSS_CELL_INACTIVE;
}
}
- styleClass += SPACE + headerClass;
headerTd.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
headerTd.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
@@ -198,7 +193,7 @@
table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height : 100%; position : relative; z-index : 2;"); //$NON-NLS-1$
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, HEADER_TABLE_STYLE);
table.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
nsIDOMElement mainTr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
@@ -224,7 +219,7 @@
*/
}
if (val > 0) {
- labelWidth = val + "px"; //$NON-NLS-1$
+ labelWidth = val + PX;
}
} else {
labelWidth = HUNDRED_PERCENTS;
@@ -241,32 +236,28 @@
mainTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
tr.appendChild(mainTd);
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-dsbl" //$NON-NLS-1$
- + SPACE + CSS_HEADER
+ styleClass = CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_DISABLED
+ SPACE + disabledTabClass;
String bgImgPath = ComponentUtil.getAbsoluteResourcePath(INACTIVE_BKG_FILE_PATH);
- if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) { //$NON-NLS-1$
+ if(!TRUE.equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
if(active) {
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-act" //$NON-NLS-1$
- + SPACE + CSS_HEADER
+ styleClass = CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_ACTIVE
+ SPACE + activeTabClass;
bgImgPath = ComponentUtil.getAbsoluteResourcePath(ACTIVE_BKG_FILE_PATH);
} else {
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-inact" //$NON-NLS-1$
- + SPACE + CSS_HEADER
+ styleClass = CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_INACTIVE
+ SPACE + inactiveTabClass;
}
}
- styleClass += SPACE + "dr-tbpnl-tbtopbrdr" + SPACE //$NON-NLS-1$
- + RichFacesTabPanelTemplate.CSS_SIDE_CELL;
+ styleClass += SPACE + headerClass;
mainTd.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
String style = "background-image: url(file:///" //$NON-NLS-1$
+ bgImgPath.replace('\\', '/') + ");"; //$NON-NLS-1$
@@ -297,8 +288,10 @@
private static void encodeSpacer(nsIDOMElement parentTr, nsIDOMDocument visualDocument) {
nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
parentTr.appendChild(td);
- td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-tbbrdr" //$NON-NLS-1$
- + SPACE + RichFacesTabPanelTemplate.CSS_SIDE_BORDER);
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
+ RichFacesTabPanelTemplate.CSS_SIDE_CELL
+ + SPACE +
+ RichFacesTabPanelTemplate.CSS_SIDE_BORDER);
String borderImgPath = ComponentUtil.getAbsoluteResourcePath(BORDER_FILE_PATH);
String style = "background-image: url(file:///" + borderImgPath.replace('\\', '/') + ");"; //$NON-NLS-1$ //$NON-NLS-2$
td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
16 years, 1 month
JBoss Tools SVN: r7143 - trunk/jsf/docs/jsf_tools_ref_guide/en/modules.
by jbosstools-commits@lists.jboss.org
Author: ochikvina
Date: 2008-03-27 06:38:30 -0400 (Thu, 27 Mar 2008)
New Revision: 7143
Removed:
trunk/jsf/docs/jsf_tools_ref_guide/en/modules/jsf_tools.xml
Log:
http://jira.jboss.com/jira/browse/JBDS-261 - the chapter was split into several chapters that's why is deleted
Deleted: trunk/jsf/docs/jsf_tools_ref_guide/en/modules/jsf_tools.xml
===================================================================
--- trunk/jsf/docs/jsf_tools_ref_guide/en/modules/jsf_tools.xml 2008-03-27 09:27:47 UTC (rev 7142)
+++ trunk/jsf/docs/jsf_tools_ref_guide/en/modules/jsf_tools.xml 2008-03-27 10:38:30 UTC (rev 7143)
@@ -1,1673 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<chapter id="jsf_tools">
- <?dbhtml filename="jsf_tools.html"?>
- <chapterinfo>
- <keywordset>
- <keyword>JBoss Developer Studio</keyword>
- <keyword>Eclipse</keyword>
- <keyword>JSF Tools</keyword>
- <keyword>Java</keyword>
- <keyword>JBoss</keyword>
- </keywordset>
- </chapterinfo>
-
- <title>JavaServer Faces Support</title>
-
- <para>JBoss Developer Studio is especially designed for supporting JSF and
- JSF-related technologies. JBDS provides extensible and exemplary tools for
- building JSF-based applications as well as adding JSF capabilities to
- existing web projects, importing JSF projects (created outside JBDS) and
- choosing any JSF implementation while developing JSF application.</para>
-
- <section id="SupportForJSFEnvironmentsJSF_RIMyFacesFaceletsShaleOrAnyCustom442">
- <title>Support for JSF Environments: JSF-RI, MyFaces, Facelets or any Custom</title>
- <para>With Developer Studio, we don't lock you into any one
- <property>JavaServer Faces</property> implementation. Select
- the one you want to use for your project.</para>
- <para>When you:</para>
- <itemizedlist>
- <listitem>
- <para>Create a new <property>JSF project</property></para>
- </listitem>
- <listitem>
- <para>Add <property>JSF capability</property> to any
- existing Eclipse project</para>
- </listitem>
- <listitem>
- <para>Add <property>JSF capability</property> to any
- existing project (created outside JBDS)</para>
- </listitem>
- </itemizedlist>
- <para>You can always select which JSF implementation to use.</para>
-
- <para>You can also create your own custom JSF environments.</para>
- <figure>
- <title>Choosing JSF Environment</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_11.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>JBoss Developer Studio will add all the required libraries for the
- selected version to your project.</para>
- </section>
-
- <!--
-<section id="AddingSupportForTheOracleADFComponentsLibraryOrAnyOtherSupport64">
-<?dbhtml filename="AddingSupportForTheOracleADFComponentsLibraryOrAnyOtherSupport.html"?>
-<title>Adding Support for the Oracle ADF Components Library or Any Other Support</title>
-
-<para>JBoss Developer Studio is set up to work with the <property>ADF Faces Component Library</property>, but still requires a few extra
- steps to complete the support. First, you will need to download the 2 jar files for the library from the
- Oracle site down to your system. Then, you just need to follow these steps to add ADF Faces support to your projects:</para>
-
-<itemizedlist>
- <listitem><para>Select <emphasis><property>Window > Preferences > Red Hat > Library Sets</property></emphasis> from the menu bar.</para></listitem>
- <listitem><para>Select <emphasis><property>OracleADF</property></emphasis> in the upper pane.</para></listitem>
- <listitem>Then, click <emphasis><property>Add</property></emphasis> in the lower pane and browse to the location where you have both ADF jar files:
-<itemizedlist>
- <listitem><para>adf-faces-api-eaXX.jar</para></listitem>
- <listitem><para>adf-faces-impl-eaXX.jar</para></listitem>
- </itemizedlist></listitem>
- <listitem>In Preferences, select <emphasis><property>Custom Capability</property></emphasis>. Notice that Custom Capability ADF has the OracleADF
- library set to which we just added the required Jar libraries. We don't need to do anything here.</listitem>
- <listitem><para>Click <emphasis><property>OK</property></emphasis> and then click <emphasis><property>OK</property></emphasis> again.</para></listitem>
-<listitem>After this is done, you can always add in the library files to a project by just right-clicking
- your project and selecting <emphasis><property>JBoss Developer Studio > Add Custom Capability...</property></emphasis> from the context menu and select a needed capability.</listitem>
-</itemizedlist>
-
-<para>You can add any custom capability (support) to your project using Library Sets in the same fashion. </para>
-</section>
--->
-
- <section id="FaceletsSupport865">
-
- <title>Facelets Support</title>
- <para>This section will perform you all concepts that JBDS involves to use
- the Facelets.</para>
-
- <para>The Facelets extends JavaServer Faces by providing a lightweight
- framework that radically simplifies the design of presentation pages
- for JSF. JBoss Developer Studio provides support for Facelets in a
- variety of ways:</para>
-
- <itemizedlist>
- <listitem>
- <para>The New JSF Project wizard contains templates for
- creating Facelets projects based on version 1.2 of
- the JSF Reference Implementation. Select the <emphasis>
- <property>JSF 1.2 with Facelets</property>
- </emphasis> in JSF Environment section.</para>
- </listitem>
- </itemizedlist>
-
-
- <figure>
- <title>Choosing Facelets Environment</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_2.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>Once you select the environment, you can specify the one of three
- available templates:</para>
-
- <figure>
- <title>Choosing Facelets Template</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_3.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>The following table lists possible Facelets templates for any JSF
- project and gives a proper description for each one.</para>
- <table>
- <title>Facelets Templates</title>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="2*"/>
- <colspec colnum="2" colwidth="3*"/>
-
-
- <thead>
- <row>
- <entry align="center">
- <para>Template</para>
- </entry>
-
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
-
- <tbody>
-
- <row>
- <entry>
- <para>
- <emphasis>
- <property>FaceletsBlankWithoutLibs</property>
- </emphasis>
- </para>
- </entry>
-
- <entry>
- <para>Some servers already provide
- jsf libs and you take risk
- of getting conflicting
- libraries while deploying
- your project. To avoid such
- conflicts, use a template
- without libs if you have a
- server with its own jsf
- libraries</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>
- <emphasis>
- <property>FaceletsKickStartWithRILibs</property>
- </emphasis>
- </para>
- </entry>
-
- <entry>
- <para>a sample application with
- Facelets that is ready to
- run</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>
- <emphasis>
- <property>FaceletsKickStartWithoutLibs</property>
- </emphasis>
- </para>
- </entry>
-
- <entry>
- <para>a sample application without
- libraries</para>
- </entry>
- </row>
-
- </tbody>
- </tgroup>
- </table>
-
-
-
- <itemizedlist>
- <listitem>
- <para>The <link linkend="palette">JBoss Tools Palette</link>
- comes with the Facelets components ready to use. A
- useful tip appears when you hover the mouse cursor
- over the tag, the tip includes a detailed
- description of the tag component, the syntax and
- available attributes.</para>
- </listitem>
- </itemizedlist>
-
-
-
- <!-- JBoss Developer Studio does not provide templates for MyFaces right out of the box, but you can easily do it
- yourself with the "Save As Template" feature (available on the File submenu). Just create a small project
- with MyFaces and Facelets and then save it as a template for future use.
-
- How can I add Facelets support to an existing project?</para>
- <para>A: Right-click on the folder of existing project and select <emphasis>JBoss Tools > Add Custom Capabilities.. > Facelets</emphasis>. </para>
- -->
- <figure>
- <title>Facelets Components</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_4.png"
- scale="85"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <itemizedlist>
- <listitem>
- <para>Code assist (Ctrl + Space) for <property>Facelets
- tags</property> is available when editing <emphasis>
- <property>.xhtml</property>
- </emphasis> files.</para>
- </listitem>
- </itemizedlist>
-
- <figure>
- <title>XHTML File Code Assist</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_5.png"
- scale="70"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>What's more, code assist is also available for <emphasis
- role="italic">
- <property>"jsfc"</property>
- </emphasis> attribute in any HTML tag.</para>
-
- <figure>
- <title>Code Assist for Jsfc Attribute</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_6.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>After selecting <emphasis role="italic">
- <property>"jsfc"</property>
- </emphasis> you get the code assist for JSF components available on
- a page.</para>
-
- <figure>
- <title>Code Assist for JSF Components</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_7.png"
- scale="80"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>When a component is chosen you will see all available attributes for
- it.</para>
-
- <figure>
- <title>Available Attributes for the Component</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_8.png"
- scale="80"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <itemizedlist>
- <listitem>
- <para>JBDS provides Eclipse's <emphasis>
- <property>OpenOn</property>
- </emphasis> feature for editing Facelets files.
- Using this feature, you can easily navigate between
- the <property>Facelets templates</property> and
- other parts of your projects. Just by holding down
- the Control key while hovering the mouse cursor over
- a reference to a template, the reference becomes a
- hyperlink to open that template.</para>
- </listitem>
- </itemizedlist>
-
- <figure>
- <title>Template Hyperlink</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_9.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <!-- <para>Additionally, when hovering the mouse cursor over <emphasis role="italic"><property>"Facelets tag"</property></emphasis> attributes, JBoss Developer Studio provides a pop-up help tip:</para>
- <figure>
-<title>Pop-up Help Tip for Facelets Tag Attributes</title>
-<mediaobject>
- <imageobject>
- <imagedata fileref="images/jsf_support/defaultImage.png"/>
- </imageobject>
-</mediaobject>
- </figure>
-
- -->
- <!-- <para>See <link linkend="faq_facelets">FAQ</link> concerning Facelets
- support.</para>
- -->
- <section>
- <title>Relevant Resources Links</title>
- <para>Necessary information and support for Facelets find out <ulink
- url="https://facelets.dev.java.net/"
- >here</ulink>.</para>
- </section>
- </section>
- <section id="WorkingWithProjects7844">
-
- <title>Working with Projects</title>
- <para>To take an advantage of JSF support in <property>JBoss Developer
- Studio</property> firstly you should perform one of the next
- steps:</para>
-
- <itemizedlist>
- <listitem>
- <para>Create new JSF projects</para>
- </listitem>
- <listitem>
- <para>Import (open) existing JSF projects</para>
- </listitem>
- <listitem>
- <para>Add JSF capability to any existing Eclipse
- project</para>
- </listitem>
- <listitem>
- <para>Import and add JSF capability to any existing project
- created outside Eclipse.</para>
- </listitem>
- </itemizedlist>
- <para>In this section we're going to stop on each of them in
- detail.</para>
- <section id="CreatingANewJSFProject96">
-
- <title>Creating a New JSF Project</title>
-
- <para>If you want your project has already contained all JSF
- libraries, tag libraries and JSF configuration file, just
- organize a new brand JSF project. <property>JBoss Developer
- Studio</property> allows to do this easily with the
- help of the special wizard. To get it, select<emphasis>
- <property> File > New > Project
- > JBoos Tools Web > JSF
- > JSF Project</property>
- </emphasis> and click <emphasis>
- <property>Next</property>.</emphasis></para>
-
- <figure>
- <title>Choosing a JSF Project</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_10.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>On the next form you'll be prompted to enter
- <property>Project Name</property> and select a
- location for the project or just leave a default path.</para>
- <para>Here, JSF Version also allows you to select which JSF
- implementation to use.</para>
- <figure>
- <title>Creating a New JSF Project</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_11.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para><property>JBoss Developer Studio</property> comes with a
- number of predefined project templates that are flexible and
- easily customizable. Thus you can pick a different template
- on which the project should be based to. Almost all
- templates come in two variations: with jsf libraries and
- without ones.</para>
- <figure>
- <title>Choosing JSF Templates</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_12.png "
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>The table below provides description for each possible JSF
- template.</para>
- <table>
- <title>JSF Project Templates</title>
- <tgroup cols="2">
- <colspec colnum="1" colwidth="1*"/>
- <colspec colnum="2" colwidth="3*"/>
-
-
- <thead>
- <row>
- <entry align="center">
- <para>Template</para>
- </entry>
-
- <entry align="center">
- <para>Description</para>
- </entry>
- </row>
- </thead>
-
- <tbody>
-
- <row>
- <entry>
- <para>
- <emphasis>
- <property>JSFBlankWithLibs</property>
- </emphasis>
- </para>
- </entry>
-
- <entry>
- <para>This template will
- create a standard
- Web project
- structure with all
- JSF
- capabilities</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>
- <emphasis>
- <property>JSFKickStartWithLibs</property>
- </emphasis>
- </para>
- </entry>
-
- <entry>
- <para>This template will
- create a standard
- Web project
- structure but will
- also include a
- sample application
- that is ready to
- run</para>
- </entry>
- </row>
-
- <row>
- <entry>
- <para>
- <emphasis>
- <property>JSFKickStartWithoutLibs</property>
- </emphasis>
- </para>
- </entry>
-
- <entry>
- <para>Some servers already
- provide jsf libs and
- you take risk of
- getting conflicting
- libraries while
- deploying your
- project. To avoid
- such conflicts, use
- a template without
- libs if you have a
- server with its own
- jsf libraries</para>
- </entry>
- </row>
-
- </tbody>
- </tgroup>
- </table>
-
-
- <!-- <para>You can of course create your own custom templates. More information
- on templates creation could be found in <link
- linkend="CreatingCustomJSPTemplates">Chapter 5</link>.</para>
- -->
-
- <para>On the next screen select what <emphasis>
- <property>Servlet version</property>
- </emphasis> to use and whether to register this application
- with JBoss AS (or other server) for running and testing of
- your application.</para>
-
- <para>The <emphasis>
- <property>Context Path</property>
- </emphasis> is the name under which the application will be
- deployed.</para>
-
- <para>The <emphasis>
- <property>Runtime</property>
- </emphasis> value tells Eclipse where to find Web libraries
- in order to build (compile) the project. It is not possible
- to finish project creation without selecting Runtime. If you
- don't have any values, select <emphasis>
- <property>New...</property>
- </emphasis> to add new Runtime.</para>
-
- <para>The <emphasis>
- <property>Target Server</property>
- </emphasis> allows you specifying whether to deploy the
- application. The Target Server corresponds to the Runtime
- value selected above. If you don't want to deploy
- the application, uncheck this value.</para>
- <figure>
- <title>Registering the Project on Server</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_14.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>When you are all done, you should have the project that has
- been appeared in the Package Explorer view:</para>
- <figure>
- <title>A New Project in the Package Explorer</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_15.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>At this point you can open <emphasis>
- <property>faces-config.xml</property>
- </emphasis> and start working on your application.
- <property>JBDS</property> provides a lot of features
- to develop JSF applications. We will describe the features
- further.</para>
- </section>
-
- <section id="ImportingExsJSFProjWithAnyStr74447">
-
- <title>Importing Existing JSF Projects with Any Structure</title>
-
- <para>For detailed information on migration projects to JBoss
- Developer Studio see <ulink
- url="../../../Exadel-migration/en/html_single/index.html"
- >Migration Guide</ulink>. </para>
-
- </section>
- <section id="AddingJSFCapabilityToAnyExistingEclipseProject">
-
- <title>Adding JSF Capability to Any Existing Eclipse Project</title>
-
- <para>With <property>JBoss Developer Studio</property> it's
- also possible to add <property>JSF capability</property>
- (JSF libraries, tag libraries) to any existing Eclipse
- project in your workspace. After that you'll be
- able to make use of such <property>JBoss Developer
- Studio</property> editors as JSF configuration editor, JBoss
- Tools JSP editor and any others.</para>
- <para>Right click the project and select <emphasis>
- <property>JBoss Tools > Add JSF
- Capabilities</property>. </emphasis> This will start
- the process of adding all necessary libraries, files to make
- this a Web JSF project.</para>
- <figure>
- <title>Adding JSF Capabilities</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_16.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <para>The wizard will first ask you to show the <emphasis>
- <property>web.xml</property>
- </emphasis> file location and the project name.</para>
- <figure>
- <title>Project Location</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_17.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <para>On the last form you can set the different folders for your
- project as well as register this application with a servlet
- container.</para>
-
- <para>Make sure to select <emphasis>
- <property>Add Libraries</property>
- </emphasis> for <property>JBoss Developer Studio</property>
- to add all required JSF related libraries to this project.</para>
-
- <para>The <emphasis>
- <property>Context Path</property>
- </emphasis> is the name under which the application will be
- deployed.</para>
-
- <para>The <emphasis>
- <property>Runtime</property>
- </emphasis> value tells Eclipse where to find Web libraries
- in order to build (compile) the project. It is not possible
- to finish project import without selecting Runtime. If you
- don't have any values, select <emphasis>
- <property>New...</property>
- </emphasis> to add new Runtime.</para>
-
- <para>The <emphasis>
- <property>Target Server</property>
- </emphasis> allows you to specify whether to deploy the
- application. The Target Server corresponds to the Runtime
- value selected above. If you don't want to deploy
- the application, uncheck this value.</para>
- <figure>
- <title>Project Folders</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_18.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <para>Once your project is imported you can see that JSF related
- libraries have been added to your project: <emphasis>
- <property>jsf-api.jar</property>
- </emphasis> and <emphasis>
- <property>jsf-impl.jar</property>
- </emphasis>.</para>
- <note>
- <title>Note:</title>
- <para>Some application servers provide their own jsf
- implementation libraries. So, to avoid conflicts you
- should not add jsf libraries while adding jsf
- capabilities.</para>
- </note>
- <para>You are now ready to work with JSF by creating a new JSF
- configuration file:</para>
-
-
- <figure>
- <title>Creating a New JSF Configuration File</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_19.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>Once the file have been created, it should be open in a
- special <link
- linkend="GraphicalEditorAndViewingForJSFConfigurationFiles76331"
- >Faces Config Editor</link>.</para>
- </section>
- <section id="AddingYourOwnProjectTemplates853">
-
- <title>Adding Your Own Project Templates</title>
- <para>Template is a set of files that serve as a basis to facilitate
- the creation of a new project. Project templates provide
- content and structure for a project.</para>
- <para><property>JBoss Developer Studio</property> has a powerful
- templating capability for creating new and importing
- existing Struts and JSF projects. This templating facility
- has a variety of aspects to consider. But, let's
- start with the most straightforward case and consider the
- process of creating a template from your existing JSF
- project.</para>
-
- <para>Let's say you have a project that you want to use as
- the basis for a new <property>template</property>. Follow
- these steps to make a template out of it:</para>
- <itemizedlist>
- <listitem>
- <para>In the Web Projects view, right-click the
- project and select <emphasis>
- <property>JBoss Tools JSF > Save As
- Template</property>
- </emphasis></para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Saving Your Project as Template</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_20.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>In the first dialog box, you can choose a name
- for the template (defaults to the project
- name) and confirm what run-time
- implementation of the project's
- technology will be used</para>
- </listitem>
-
- </itemizedlist>
- <figure>
- <title>Define Template Properties</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_20_1.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
-
- <itemizedlist>
- <listitem>
- <para>Select <emphasis>
- <property>Next</property>
- </emphasis> and you will be sent to a dialog
- box with your project structure displayed
- with check boxes. Here you can check only
- those parts and files in your project
- directory that should be part of the
- template</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Define Template Properties</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_20_2.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>At this point, unless you want to designate
- some extra files as having Velocity template
- coding inside them, you should click <emphasis>
- <property>Finish</property>
- </emphasis>.</para>
- </listitem>
- </itemizedlist>
- <para>That's it. Now, you can use this template with any
- new or imported project that uses the same run-time
- implementation as the project you turned into a
- template.</para>
- </section>
-
- <para>At this point, you have a fully configured project and now you can
- bring some new logic to it starting from JSF configuration
- file.</para>
- </section>
- <section id="GraphicalEditorAndViewingForJSFConfigurationFiles76331">
-
- <title>Graphical Editor and Viewing for JSF Configuration Files</title>
-
- <para>First, we should mention that JSF configuration file (<emphasis>
- <property>faces-config.xml</property>
- </emphasis>) is intended for registering JSF application resources
- such as Converters, Validators, Managed Beans and page-to-page
- navigation rules.</para>
- <para>Now, let's look at how you can easily configure this file by
- means of a special graphical editor. The editor has three main
- viewers (modes):</para>
-
- <itemizedlist>
- <listitem>
- <para>Diagram</para>
- </listitem>
- <listitem>
- <para>Tree</para>
- </listitem>
- <listitem>
- <para>Source</para>
- </listitem>
- </itemizedlist>
-
- <para>The modes can be selected via the tabs at the bottom of the editor.</para>
-
- <para>The JSF configuration editor also comes with a very useful <link
- linkend="OpenOnSelection4Hyperlinknavigation">OpenOn</link>
- selection feature.</para>
-
- <section id="Diagram9553">
-
- <title>Diagram</title>
- <para>The Diagram view displays the navigation rules in the JSF
- configuration file:</para>
- <figure>
- <title>Diagram View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_21.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="CreatingNewViewPage85">
-
- <title>Creating New View (Page)</title>
-
- <para>To create a new page (view), you can click the page icon on
- this toolbar and then click anywhere on the diagram. A New
- Page Wizard will appear.</para>
-
- <para>To create a transition (rule) connecting pages:</para>
-
-
- <itemizedlist>
- <listitem>
- <para>Select the transition icon from the toolbar
- (2nd from the bottom).</para>
- </listitem>
- <listitem>
- <para>Click the source page.</para>
- </listitem>
- <listitem>
- <para>Click the target page.</para>
- </listitem>
- </itemizedlist>
-
- <para>A transition will appear between the two pages:</para>
- <figure>
- <title>Transition Between JSP Pages</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_22.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>It is also possible to create a new page with context menu by
- right-clicking anywhere on the diagram and selecting <emphasis>
- <property>New View</property>. </emphasis></para>
- <figure>
- <title>Creating a New View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_23.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>To edit an existing transition, first select the transition
- line. Then, place the mouse cursor over the last black dot
- (on the target page). The mouse cursor will change to a big
- +. At this point, drag the line to a new target page:</para>
- <figure>
- <title>Editing Transition Between Views</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_24.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="TreeView11123">
-
- <title>Tree View</title>
-
- <para>The Tree mode for the editor displays all JSF application
- artifacts referenced in the configuration file in a tree
- format. By selecting any node you can see and edit its
- properties which will appear in the right-hand area. For
- example, a Managed Bean:</para>
- <figure>
- <title>Tree View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_25.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>To edit some artifact, right-click any node and select one of
- the available actions in the context menu. You can also edit
- in the properties window to the right:</para>
- <figure>
- <title>Editing in Tree View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_26.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <para>The same way you can create a new artifact:</para>
- <figure>
- <title>Creating a New Artifact in Tree View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_59.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="SourceView4643">
-
- <title>Source View</title>
-
- <para>The Source mode for the editor displays a text view of the JSF
- configuration file. All three viewers are always
- synchronized, so any changes made in one of the viewers will
- immediately appear in the others:</para>
- <figure>
- <title>Source View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_27.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="ContentAssist976">
-
- <title>Code Assist</title>
- <para>Code Assist provides pop-up tip to help you complete your code
- statements. It allows you to write your code faster and with
- more accuracy.</para>
- <para>Code assist is always available in the Source mode:</para>
- <figure>
- <title>Code Assist in Source View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_28.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- <section id="ErrorReporting3324">
-
- <title>Error Reporting</title>
- <para>When you are developing your project, JBoss Developer Studio
- constantly provides error checking. This greatly reduces
- your development time as it allows you to catch many of the
- errors during development.</para>
- <para>Errors will be reported by JBoss Developer Studio's
- <link linkend="verif_valid"> verification</link>
- facility:</para>
- <figure>
- <title>Error Reporting in Source View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_29.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>Other errors are also reported.</para>
- <figure>
- <title>Other Errors Reporting</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_30.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>You can also work in the Source editor with the help of the <emphasis>
- <property>Outline view</property>.</emphasis> The
- Outline views show a tree structure of the JSF configuration
- file. Simply select any element in the Outline view, and it
- will jump to the same place in the Source editor, so you can
- navigate through the source code with Outline view.</para>
- <figure>
- <title>Outline View</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_31.png"
- scale="60"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>If your diagram is large, within Outline view you can switch
- to a <emphasis>
- <property>Diagram Navigator</property>
- </emphasis> mode by selecting the middle icon at the top of
- the view window. It allows you to easily move around the
- diagram. Just move the blue area in any direction, and the
- diagram on the left will also move:</para>
- <figure>
- <title>Outline View for Diagram</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_32.png"
- scale="60"/>
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>You can also edit the properties of the selected element in
- the <property>Tree</property> mode with the help of the
- Properties view as shown below:</para>
- <figure>
- <title>Properties View </title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_33.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
- </section>
- </section>
- <section id="ManagedBeans96453">
-
- <title>Managed Beans</title>
-
- <para>JBoss Developer Studio gives you lots of power to work with
- <property>managed beans</property>.</para>
- <itemizedlist>
- <listitem>
- <para>Add and generate code for new managed beans</para>
- <itemizedlist>
- <listitem>
- <para>Generate code for attributes and
- getter/setter methods</para>
- </listitem>
- </itemizedlist>
- </listitem>
- <listitem>
- <para>Add existing managed beans to JSF configuration
- file</para>
- </listitem>
- </itemizedlist>
-
- <para>Thus, in this section we will guides you through all this possibilities.</para>
-
- <section id="CodeGenerationForManagedBeans421">
-
- <title>Code Generation for Managed Beans</title>
-
- <para>To start, create a new managed bean in JSF configuration file
- editor, in the Tree view.</para>
- <figure>
- <title>Creation of New Managed Bean</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_34.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <note>
- <title>Note:</title>
- <para>When you define a new managed bean, make sure that <emphasis>
- <property>Generate Source Code</property>
- </emphasis> is checked as shown in the figure
- below.</para>
- </note>
- <figure>
- <title>New Managed Bean</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_35.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>After the <emphasis role="italic">
- <property>"Java"</property>
- </emphasis> class has been generated you can open it for
- additional editing. There are two ways to open the <emphasis
- role="italic">
- <property>"Java"</property>
- </emphasis> class:</para>
-
- <itemizedlist>
- <listitem>
- <para>click on <emphasis>
- <property>Managed-Bean-Class</property>
- </emphasis> link in the editor</para>
- </listitem>
- </itemizedlist>
- <para>or</para>
- <itemizedlist>
- <listitem>
- <para>right click the <emphasis>
- <property>managed bean</property>
- </emphasis> and select <emphasis>
- <property>Open Source</property>
- </emphasis></para>
- </listitem>
- </itemizedlist>
-
- <figure>
- <title>Opening of Created Managed Bean</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_36.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>The generated Java source:</para>
-
- <figure>
- <title>Java Source Code</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_37.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <para>You can also generate source code for properties, also
- includes <emphasis role="italic">
- <property>"getter"</property>
- </emphasis> and <emphasis role="italic">
- <property>"setter"</property>
- </emphasis> methods. Right click on the bean and select <emphasis>
- <property>New > Property</property>
- </emphasis>. You will see <property>Add Property</property>
- dialog.</para>
- <figure>
- <title>Generation of Source Code for Properties</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_38.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <para>When the form is open make sure that all the check boxes are
- selected:</para>
- <itemizedlist>
- <listitem>Add Java property</listitem>
- <listitem>Generate Getter</listitem>
- <listitem>Generate Setter</listitem>
- </itemizedlist>
- <para/>
- <figure>
- <title>"Add Property" Form</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_39.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <para>Once the generation is complete, you can open the file and see
- the added property with <emphasis role="italic">
- <property>"getter"</property>
- </emphasis> and <emphasis role="italic">
- <property>"setter"</property>
- </emphasis> methods:</para>
- <figure>
- <title>Generated Java Source Code for Property</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_40.png"
- scale="75"/>
- </imageobject>
- </mediaobject>
- </figure>
- <para>Thus, we've discussed everything which comes to
- creating a new Managed Bean. Further we will show you how to
- add an existing Bean into a JSF configuration file.</para>
- </section>
- <section id="AddExistingJavaBeansToAJSFConfigurationFile74332">
-
- <title>Add Existing Java Beans to a JSF Configuration File</title>
- <para>If you already have a Java bean you can easily add it to a
- <property>JSF configuration file</property>.</para>
- <para>You should start the same way you create a new managed bean.
- Use the <emphasis>
- <property>Browse...</property>
- </emphasis> button to add your existing Java class.</para>
- <figure>
- <title>New Managed Bean Form</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_42.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <para>Once the class is set, it's <emphasis>
- <property>Name</property>
- </emphasis> will be set as well. But you can easily
- substitute it for the other one. Notice that <emphasis>
- <property>Generate Source Code</property>
- </emphasis> option is not available as the <emphasis
- role="italic">
- <property>"Java"</property>
- </emphasis> class already exists. </para>
- <para>After adding your class <emphasis>
- <property>Next</property>
- </emphasis> button will be activated. Pressing it
- you'll get <emphasis>
- <property>Managed Properties</property>
- </emphasis> dialog where all corresponding properties are
- displayed. Check the necessary ones to add them into your
- <property>JSF Configuration File</property>.</para>
-
- <figure>
- <title>Selection of Bean's Properties.</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_43.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>If you don't want to add any, just click <emphasis>
- <property>Finish</property>. </emphasis></para>
- </section>
- <para>Above-listed steps have demonstrated specifying an existing Bean in
- the JSF configuration file, i.e. <emphasis>
- <property>faces-config.xml</property>. </emphasis> In the
- next section you'll know how to organize and register a
- custom Converter to specify your own converting rules.</para>
- </section>
-
- <section id="CreateAndRegisterACustomConverter94230">
-
- <title>Create and Register a Custom Converter</title>
-
- <para>To create and register a custom converter it's necessary to
- go through the following steps:</para>
-
- <itemizedlist>
- <listitem>
- <para>In the Project Explorer view open <emphasis>
- <property>faces-config.xml</property>
- </emphasis> and select <emphasis>
- <property>Tree</property>
- </emphasis> tab.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Converters</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_44.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>Select <emphasis>
- <property>Converters</property>
- </emphasis> and click on<emphasis>
- <property> Add</property>
- </emphasis> button.</para>
- </listitem>
- <listitem>
- <para>On the form type the name of your converter in the <emphasis>
- <property>Converter-id</property>
- </emphasis> field and name of the class for
- converters. After clicking <emphasis>
- <property>Finish</property>
- </emphasis> button your custom converter is
- registered under the entered name.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Add Converter Form</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_45.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>Now you can create <emphasis role="italic">
- <property>"converter"</property>
- </emphasis> class. In the Converter section you
- should see your <emphasis>
- <property>Converter-id</property>
- </emphasis> and
- <emphasis><property>Converter-class</property>.</emphasis>
- Click on <emphasis>
- <property>Converter-class</property>
- </emphasis> to generate the source code.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Generation of Source Code for Converter Class</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_46.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <itemizedlist>
- <listitem>
- <para>A usual wizard for creating a Java class will appear.
- All needed fields here will be adjusted
- automatically. Just leave everything without changes
- and click <emphasis>
- <property>Finish</property>.
- </emphasis></para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>New Java Class Form</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_47.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>To open a converter class click again on <emphasis>
- <property>Converter-class</property>
- </emphasis> link in the Converter section. Now you
- are able to add a business logic of converter in the
- Java editor.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Converter Class</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_48.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- </section>
-
- <section id="CreateAndRegisterACustomValidator5632">
-
- <title>Create and Register a Custom Validator</title>
-
- <para>With the help of JBDS it's also quite easy to develop your
- own custom Validators. You should perform the actions similar to
- previous. Go through the following steps:</para>
- <itemizedlist>
- <listitem>
- <para>In the Project Explorer view open<emphasis>
- <property> faces-config.xml</property>
- </emphasis> and select <emphasis>
- <property>Tree </property>
- </emphasis>tab.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Validator in Faces Config Editor</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_49.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>Select <emphasis>
- <property>Validators</property>
- </emphasis> and click on <emphasis>
- <property>Add </property>
- </emphasis>button.</para>
- </listitem>
- <listitem>
- <para>Type the name of your validator in the <emphasis>
- <property>Validator-id</property>
- </emphasis> field and name of the class for
- validators. After clicking <emphasis>
- <property>Finish</property>
- </emphasis> button your custom validator is
- registered under the entered name.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Adding Validator</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_50.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
-
- <para>Now you can create the "validator" class. </para>
- <itemizedlist>
- <listitem>
- <para>In the Validator section you can see your <emphasis>
- <property>Validator-id</property>
- </emphasis> and <emphasis>
- <property>Validator-class</property>
- </emphasis>. To generate the source code click on <emphasis>
- <property>Validator-class</property>.
- </emphasis></para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Creating Validator Class</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_51.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>Java class will be created automatically. Leave
- everything without changes and click <emphasis>
- <property>Finish</property>.
- </emphasis></para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>New Java Class Form</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_52.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>To open validator class click again on <emphasis>
- <property>Validator-Class</property>
- </emphasis> link in the Validator section. Now you
- are able to write a business logic of validator in
- the Java editor.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Converter Class Editing</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_53.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- </section>
-
- <section id="CreateAndRegisterReferencedBeans64322">
-
- <title>Create and Register Referenced Beans</title>
-
- <para>Creation of Referenced Beans is similar to creation of Custom
- Validator.</para>
-
- <itemizedlist>
- <listitem>
- <para>In the Project Explorer view open<emphasis>
- <property> faces-config.xml</property>
- </emphasis> and select <emphasis>
- <property>Tree </property>
- </emphasis>tab.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Referenced Beans in Faces Config Editor</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_54.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>Select <emphasis>
- <property>Referenced Beans</property>
- </emphasis> and click on <emphasis>
- <property>Add</property>
- </emphasis> button.</para>
- </listitem>
- <listitem>
- <para>Type in the name of your Referenced Bean and type in
- or select <emphasis>
- <property>Referenced-Bean-Class</property>
- </emphasis> by using <emphasis>
- <property>Browse</property>
- </emphasis> button.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Add Referenced Bean</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_55.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>In the Referenced Bean section you should see your <emphasis>
- <property>Referenced-Bean-Name</property>
- </emphasis> and
- <emphasis><property>Referenced-Bean-Class</property>.</emphasis>
- Click on the link to open the Java creation
- wizard.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Create Referenced Bean Class</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_56.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>Java class will be created automatically. Leave
- everything without changes and click <emphasis>
- <property>Finish</property>.
- </emphasis></para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>New Java Class Form</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_57.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- <itemizedlist>
- <listitem>
- <para>To open Referenced Bean class click again on <emphasis>
- <property>Referenced-Bean-Class</property>
- </emphasis> in the Referenced Bean section. Now you
- are able to write business logic of Referenced Bean
- in the Java editor.</para>
- </listitem>
- </itemizedlist>
- <figure>
- <title>Referenced Bean Class Editing</title>
- <mediaobject>
- <imageobject>
- <imagedata
- fileref="images/jsf_support/jsf_support_58.png"
- />
- </imageobject>
- </mediaobject>
- </figure>
- </section>
-
- <section>
- <title>Relevant Resources Links</title>
- <para>If you don't familiar with <ulink
- url="http://java.sun.com/javaee/javaserverfaces/">JSF
- technology</ulink>, we suggest that you walk through the
- information on the topic.</para>
- </section>
- </chapter>
\ No newline at end of file
16 years, 1 month
JBoss Tools SVN: r7142 - in trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces: template and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2008-03-27 05:27:47 -0400 (Thu, 27 Mar 2008)
New Revision: 7142
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
Log:
http://jira.jboss.org/jira/browse/JBIDE-1398
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-03-26 23:40:06 UTC (rev 7141)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2008-03-27 09:27:47 UTC (rev 7142)
@@ -33,496 +33,548 @@
public class ComponentUtil {
- /**
- * Gets child of Facet element by name. If facet has a few children the
- * method will return first one.
- *
- * @param sourceElement
- * @param facetName
- * @param returnTextNode
- * return child text node if facet doesn't have any child
- * elements;
- * @return
- */
- public static Node getFacet(Element sourceElement, String facetName,
- boolean returnTextNode) {
- NodeList children = sourceElement.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node node = children.item(i);
- if (node instanceof Element && node.getNodeName() != null
- && node.getNodeName().indexOf(":facet") > 0) {
- Element element = (Element) node;
- String name = element.getAttribute("name");
- if (facetName.equals(name)) {
- NodeList childNodes = element.getChildNodes();
- Text textNode = null;
- for (int j = 0; j < childNodes.getLength(); j++) {
- Node child = childNodes.item(j);
- if (child instanceof Element) {
- return child;
- } else if (child instanceof Text) {
- textNode = (Text) child;
+ /**
+ * Gets child of Facet element by name. If facet has a few children the
+ * method will return first one.
+ *
+ * @param sourceElement
+ * @param facetName
+ * @param returnTextNode
+ * return child text node if facet doesn't have any child
+ * elements;
+ * @return
+ */
+ public static Node getFacet(Element sourceElement, String facetName,
+ boolean returnTextNode) {
+ NodeList children = sourceElement.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if (node instanceof Element && node.getNodeName() != null
+ && node.getNodeName().indexOf(":facet") > 0) { //$NON-NLS-1$
+ Element element = (Element) node;
+ String name = element.getAttribute("name"); //$NON-NLS-1$
+ if (facetName.equals(name)) {
+ NodeList childNodes = element.getChildNodes();
+ Text textNode = null;
+ for (int j = 0; j < childNodes.getLength(); j++) {
+ Node child = childNodes.item(j);
+ if (child instanceof Element) {
+ return child;
+ } else if (child instanceof Text) {
+ textNode = (Text) child;
+ }
+ }
+ if (returnTextNode) {
+ return textNode;
+ }
+ }
}
- }
- if (returnTextNode) {
- return textNode;
- }
}
- }
+ return null;
}
- return null;
- }
- /**
- * Gets all facets of sourceElement. If facet has a few children the method
- * will return first one.
- *
- * @param sourceElement
- * @param facetName
- * @param returnTextNode
- * return child text node if facet doesn't have any child
- * elements;
- * @return
- */
- public static ArrayList<Node> getFacets(Element sourceElement,
- boolean returnTextNode) {
- ArrayList<Node> facets = new ArrayList<Node>();
- NodeList children = sourceElement.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- Node node = children.item(i);
- if (node instanceof Element && "f:facet".equals(node.getNodeName())) {
- Element element = (Element) node;
- NodeList childNodes = element.getChildNodes();
- Text textNode = null;
- for (int j = 0; j < childNodes.getLength(); j++) {
- Node child = childNodes.item(j);
- if (child instanceof Element) {
- facets.add(child);
- break;
- } else if (child instanceof Text) {
- textNode = (Text) child;
- }
+ /**
+ * Gets all facets of sourceElement. If facet has a few children the method
+ * will return first one.
+ *
+ * @param sourceElement
+ * @param facetName
+ * @param returnTextNode
+ * return child text node if facet doesn't have any child
+ * elements;
+ * @return
+ */
+ public static ArrayList<Node> getFacets(Element sourceElement,
+ boolean returnTextNode) {
+ ArrayList<Node> facets = new ArrayList<Node>();
+ NodeList children = sourceElement.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if (node instanceof Element && "f:facet".equals(node.getNodeName())) { //$NON-NLS-1$
+ Element element = (Element) node;
+ NodeList childNodes = element.getChildNodes();
+ Text textNode = null;
+ for (int j = 0; j < childNodes.getLength(); j++) {
+ Node child = childNodes.item(j);
+ if (child instanceof Element) {
+ facets.add(child);
+ break;
+ } else if (child instanceof Text) {
+ textNode = (Text) child;
+ }
+ }
+ if (returnTextNode && facets.isEmpty()) {
+ facets.add(textNode);
+ }
+ }
}
- if (returnTextNode && facets.isEmpty()) {
- facets.add(textNode);
- }
- }
+ return facets;
}
- return facets;
- }
- /**
- * Gets child of Facet element by name. If facet has a few children the
- * method will return first one.
- *
- * @param sourceElement
- * @param facetName
- * @return
- */
- public static Element getFacet(Element sourceElement, String facetName) {
- return (Element) getFacet(sourceElement, facetName, false);
- }
+ /**
+ * Gets child of Facet element by name. If facet has a few children the
+ * method will return first one.
+ *
+ * @param sourceElement
+ * @param facetName
+ * @return
+ */
+ public static Element getFacet(Element sourceElement, String facetName) {
+ return (Element) getFacet(sourceElement, facetName, false);
+ }
- /**
- * Returns true if "rendered" attribute of source element does not contain
- * "false" value.
- *
- * @param sourceElement
- * @return
- */
- public static boolean isRendered(Element sourceElement) {
- return !"false"
- .equalsIgnoreCase(sourceElement.getAttribute("rendered"));
- }
+ /**
+ * Returns true if "rendered" attribute of source element does not contain
+ * "false" value.
+ *
+ * @param sourceElement
+ * @return
+ */
+ public static boolean isRendered(Element sourceElement) {
+ return !"false" //$NON-NLS-1$
+ .equalsIgnoreCase(sourceElement.getAttribute("rendered")); //$NON-NLS-1$
+ }
- /**
- * Sets CSS link in visual html document.
- *
- * @param pageContext
- * @param cssHref
- */
- public static void setCSSLink(VpePageContext pageContext, String cssHref,
- String ext) {
- String pluginPath = RichFacesTemplatesActivator.getPluginResourcePath();
- IPath pluginFile = new Path(pluginPath);
- File cssFile = pluginFile.append(cssHref).toFile();
- if (cssFile.exists()) {
- String cssPath = "file:///" + cssFile.getPath();
- pageContext.getVisualBuilder().replaceLinkNodeToHead(cssPath, ext);
+ /**
+ * Sets CSS link in visual html document.
+ *
+ * @param pageContext
+ * @param cssHref
+ */
+ public static void setCSSLink(VpePageContext pageContext, String cssHref,
+ String ext) {
+ String pluginPath = RichFacesTemplatesActivator.getPluginResourcePath();
+ IPath pluginFile = new Path(pluginPath);
+ File cssFile = pluginFile.append(cssHref).toFile();
+ if (cssFile.exists()) {
+ String cssPath = "file:///" + cssFile.getPath(); //$NON-NLS-1$
+ pageContext.getVisualBuilder().replaceLinkNodeToHead(cssPath, ext);
+ }
}
- }
- public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
- String pluginPath = RichFacesTemplatesActivator.getPluginResourcePath();
- IPath pluginFile = new Path(pluginPath);
- File file = pluginFile.append(resourcePathInPlugin).toFile();
- if (file.exists()) {
- return file.getAbsolutePath();
- } else {
- throw new RuntimeException("Can't get path for "
- + resourcePathInPlugin);
+ public static String getAbsoluteResourcePath(String resourcePathInPlugin) {
+ String pluginPath = RichFacesTemplatesActivator.getPluginResourcePath();
+ IPath pluginFile = new Path(pluginPath);
+ File file = pluginFile.append(resourcePathInPlugin).toFile();
+ if (file.exists()) {
+ return file.getAbsolutePath();
+ } else {
+ throw new RuntimeException("Can't get path for " //$NON-NLS-1$
+ + resourcePathInPlugin);
+ }
}
- }
- /**
- * Adds image as attribute to IMG tag
- *
- * @param img
- * @param fileImageName
- */
- public static void setImg(nsIDOMElement img, String fileImageName) {
- img.setAttribute("src", "file://"
- + getAbsoluteResourcePath(fileImageName));
- }
+ /**
+ * Adds image as attribute to IMG tag
+ *
+ * @param img
+ * @param fileImageName
+ */
+ public static void setImg(nsIDOMElement img, String fileImageName) {
+ img.setAttribute("src", "file://" //$NON-NLS-1$//$NON-NLS-2$
+ + getAbsoluteResourcePath(fileImageName));
+ }
- /**
- * Returns all child source elements of component but facets.
- *
- * @param sourceElement
- * @param returnTextNodes
- * return child text nodes and elements or elements only;
- * @return
- */
- public static List<Node> getChildren(Element sourceElement,
- boolean returnTextNodes) {
- ArrayList<Node> children = new ArrayList<Node>();
- NodeList nodeList = sourceElement.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node child = nodeList.item(i);
- if ((child instanceof Element || returnTextNodes)
- && (!child.getNodeName().equals("f:facet"))) {
- children.add(child);
- }
+ /**
+ * Returns all child source elements of component but facets.
+ *
+ * @param sourceElement
+ * @param returnTextNodes
+ * return child text nodes and elements or elements only;
+ * @return
+ */
+ public static List<Node> getChildren(Element sourceElement,
+ boolean returnTextNodes) {
+ ArrayList<Node> children = new ArrayList<Node>();
+ NodeList nodeList = sourceElement.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node child = nodeList.item(i);
+ if ((child instanceof Element || returnTextNodes)
+ && (!child.getNodeName().equals("f:facet"))) { //$NON-NLS-1$
+ children.add(child);
+ }
+ }
+ return children;
}
- return children;
- }
- /**
- * Returns all child source elements of component but facets.
- *
- * @param sourceElement
- * @return
- */
- public static List<Node> getChildren(Element sourceElement) {
- return getChildren(sourceElement, false);
- }
+ /**
+ * Returns all child source elements of component but facets.
+ *
+ * @param sourceElement
+ * @return
+ */
+ public static List<Node> getChildren(Element sourceElement) {
+ return getChildren(sourceElement, false);
+ }
- /**
- * Returns all child visual elements of component but facets.
- *
- * @param visualElement
- * @param
- * @return returnTextNodes return child text nodes and elements or elements
- * only;
- */
- public static List<nsIDOMNode> getChildren(nsIDOMElement visualElement,
- boolean returnTextNodes) {
- ArrayList<nsIDOMNode> children = new ArrayList<nsIDOMNode>();
- nsIDOMNodeList nodeList = visualElement.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- nsIDOMNode child = nodeList.item(i);
- if ((child instanceof nsIDOMElement || returnTextNodes)
- && (!child.getNodeName().equals("f:facet"))) {
- children.add(child);
- }
+ /**
+ * Returns all child visual elements of component but facets.
+ *
+ * @param visualElement
+ * @param
+ * @return returnTextNodes return child text nodes and elements or elements
+ * only;
+ */
+ public static List<nsIDOMNode> getChildren(nsIDOMElement visualElement,
+ boolean returnTextNodes) {
+ ArrayList<nsIDOMNode> children = new ArrayList<nsIDOMNode>();
+ nsIDOMNodeList nodeList = visualElement.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ nsIDOMNode child = nodeList.item(i);
+ if ((child instanceof nsIDOMElement || returnTextNodes)
+ && (!child.getNodeName().equals("f:facet"))) { //$NON-NLS-1$
+ children.add(child);
+ }
+ }
+ return children;
}
- return children;
- }
- /**
- * Returns all child visual elements of component but facets.
- *
- * @param visualElement
- * @return
- */
- public static List<nsIDOMNode> getChildren(nsIDOMElement visualElement) {
- return getChildren(visualElement, false);
- }
+ /**
+ * Returns all child visual elements of component but facets.
+ *
+ * @param visualElement
+ * @return
+ */
+ public static List<nsIDOMNode> getChildren(nsIDOMElement visualElement) {
+ return getChildren(visualElement, false);
+ }
- /**
- * Copies all attributes from source node to visual node.
- *
- * @param sourceNode
- * @param visualNode
- */
- public static void copyAttributes(Node sourceNode,
- nsIDOMElement visualElement) {
- NamedNodeMap namedNodeMap = sourceNode.getAttributes();
- for (int i = 0; i < namedNodeMap.getLength(); i++) {
- Node attribute = namedNodeMap.item(i);
- // added by Max Areshkau fix for JBIDE-1568
- try {
+ /**
+ * Copies all attributes from source node to visual node.
+ *
+ * @param sourceNode
+ * @param visualNode
+ */
+ public static void copyAttributes(Node sourceNode,
+ nsIDOMElement visualElement) {
+ NamedNodeMap namedNodeMap = sourceNode.getAttributes();
+ for (int i = 0; i < namedNodeMap.getLength(); i++) {
+ Node attribute = namedNodeMap.item(i);
+ // added by Max Areshkau fix for JBIDE-1568
+ try {
- visualElement.setAttribute(attribute.getNodeName(), attribute
- .getNodeValue());
- } catch (XPCOMException ex) {
- // if error-code not equals error for incorrect name throws
- // exception
- // error code is NS_ERROR_DOM_INVALID_CHARACTER_ERR=0x80530005
- if (ex.errorcode != 2152923141L) {
- throw ex;
+ visualElement.setAttribute(attribute.getNodeName(), attribute
+ .getNodeValue());
+ } catch (XPCOMException ex) {
+ // if error-code not equals error for incorrect name throws
+ // exception
+ // error code is NS_ERROR_DOM_INVALID_CHARACTER_ERR=0x80530005
+ if (ex.errorcode != 2152923141L) {
+ throw ex;
+ }
+ // else we ignore this exception
+ }
}
- // else we ignore this exception
- }
}
- }
- /**
- * Copies attributes from source node to visual node.
- *
- * @param attributes -
- * list names of attributes which will copy
- * @param sourceNode
- * @param visualNode
- */
- public static void copyAttributes(Element sourceElement,
- List<String> attributes, nsIDOMElement visualElement) {
+ /**
+ * Copies attributes from source node to visual node.
+ *
+ * @param attributes -
+ * list names of attributes which will copy
+ * @param sourceNode
+ * @param visualNode
+ */
+ public static void copyAttributes(Element sourceElement,
+ List<String> attributes, nsIDOMElement visualElement) {
- if (attributes == null)
- return;
+ if (attributes == null)
+ return;
- for (String attributeName : attributes) {
+ for (String attributeName : attributes) {
- String attributeValue = sourceElement.getAttribute(attributeName);
- if (attributeValue != null)
- visualElement.setAttribute(attributeName, attributeValue);
+ String attributeValue = sourceElement.getAttribute(attributeName);
+ if (attributeValue != null)
+ visualElement.setAttribute(attributeName, attributeValue);
+ }
+
}
- }
+ /**
+ * Returns true if sourceNode is Facet
+ *
+ * @param sourceNode
+ * @param facetName
+ * @return
+ */
+ public static boolean isFacet(Node sourceNode, String facetName) {
+ if (sourceNode != null && sourceNode instanceof Element
+ && sourceNode.getNodeName().equals("f:facet")) { //$NON-NLS-1$
+ String name = ((Element) sourceNode).getAttribute("name"); //$NON-NLS-1$
+ if (facetName.equals(name)) {
+ return true;
+ }
+ }
+ return false;
+ }
- /**
- * Returns true if sourceNode is Facet
- *
- * @param sourceNode
- * @param facetName
- * @return
- */
- public static boolean isFacet(Node sourceNode, String facetName) {
- if (sourceNode != null && sourceNode instanceof Element
- && sourceNode.getNodeName().equals("f:facet")) {
- String name = ((Element) sourceNode).getAttribute("name");
- if (facetName.equals(name)) {
- return true;
- }
+ /**
+ * Returns Style with default background image for default RichFaces skin.
+ *
+ * @return
+ */
+ public static String getHeaderBackgoundImgStyle() {
+ return getBackgoundImgStyle("common/background.gif"); //$NON-NLS-1$
}
- return false;
- }
- /**
- * Returns Style with default background image for default RichFaces skin.
- *
- * @return
- */
- public static String getHeaderBackgoundImgStyle() {
- return getBackgoundImgStyle("common/background.gif");
- }
+ /**
+ * Returns Style with background image for default RichFaces skin.
+ *
+ * @return
+ */
+ public static String getBackgoundImgStyle(String imagePath) {
+ String imgPath = ComponentUtil.getAbsoluteResourcePath(imagePath);
+ String style = "background-image: url(file:///" //$NON-NLS-1$
+ + imgPath.replace('\\', '/') + ");"; //$NON-NLS-1$
+ return style;
+ }
- /**
- * Returns Style with background image for default RichFaces skin.
- *
- * @return
- */
- public static String getBackgoundImgStyle(String imagePath) {
- String imgPath = ComponentUtil.getAbsoluteResourcePath(imagePath);
- String style = "background-image: url(file:///"
- + imgPath.replace('\\', '/') + ");";
- return style;
- }
+ // public static createStyleClass(String content){
+ //
+ // }
- // public static createStyleClass(String content){
- //
- // }
-
- /**
- * Returns value of attribute.
- *
- * @param sourceElement
- * @param attributeName
- * @return
- */
- public static String getAttribute(Element sourceElement,
- String attributeName) {
- String attribute = sourceElement.getAttribute(attributeName);
- if (attribute == null) {
- attribute = "";
+ /**
+ * Returns value of attribute.
+ *
+ * @param sourceElement
+ * @param attributeName
+ * @return
+ */
+ public static String getAttribute(Element sourceElement,
+ String attributeName) {
+ String attribute = sourceElement.getAttribute(attributeName);
+ if (attribute == null) {
+ attribute = ""; //$NON-NLS-1$
+ }
+ return attribute;
}
- return attribute;
- }
- /**
- * Returns value of attribute.
- *
- * @param sourceElement
- * @param attributeName
- * @return
- */
- public static String getAttribute(nsIDOMElement sourceElement,
- String attributeName) {
- String attribute = sourceElement.getAttribute(attributeName);
- if (attribute == null) {
- attribute = "";
+ /**
+ * Returns value of attribute.
+ *
+ * @param sourceElement
+ * @param attributeName
+ * @return
+ */
+ public static String getAttribute(nsIDOMElement sourceElement,
+ String attributeName) {
+ String attribute = sourceElement.getAttribute(attributeName);
+ if (attribute == null) {
+ attribute = ""; //$NON-NLS-1$
+ }
+ return attribute;
}
- return attribute;
- }
- /**
- * @param style
- * @param name
- * @return
- */
- public static boolean parameterPresent(String style, String name) {
- if (style != null && style.length() > 0) {
- String[] styles = style.split(";");
- for (int i = 0; i < styles.length; i++) {
- String[] pair = styles[i].split(":");
- if (pair[0].trim().equals(name)) {
- return true;
+ /**
+ * @param style
+ * @param name
+ * @return
+ */
+ public static boolean parameterPresent(String style, String name) {
+ if (style != null && style.length() > 0) {
+ String[] styles = style.split(";"); //$NON-NLS-1$
+ for (int i = 0; i < styles.length; i++) {
+ String[] pair = styles[i].split(":"); //$NON-NLS-1$
+ if (pair[0].trim().equals(name)) {
+ return true;
+ }
+ }
}
- }
+ return false;
}
- return false;
- }
- /**
- * @param style
- * @param name
- * @return
- */
- public static String getStyleParametr(String style, String name) {
- if (style != null && style.length() > 0) {
- String[] styles = style.split(";");
- for (int i = 0; i < styles.length; i++) {
- String[] pair = styles[i].split(":");
- if (pair[0].trim().equals(name)) {
- return pair[1].trim();
+ /**
+ * @param style
+ * @param name
+ * @return
+ */
+ public static String getStyleParametr(String style, String name) {
+ if (style != null && style.length() > 0) {
+ String[] styles = style.split(";"); //$NON-NLS-1$
+ for (int i = 0; i < styles.length; i++) {
+ String[] pair = styles[i].split(":"); //$NON-NLS-1$
+ if (pair[0].trim().equals(name)) {
+ return pair[1].trim();
+ }
+ }
}
- }
+ return null;
}
- return null;
- }
- /**
- *
- * @param style
- * @param element
- * @return
- */
- public static String addParameter(String style, String element) {
- String s = style.trim();
- return style + (s.length() == 0 || s.endsWith(";") ? "" : ";")
- + element;
- }
+ /**
+ *
+ * @param style
+ * @param element
+ * @return
+ */
+ public static String addParameter(String style, String element) {
+ String s = style.trim();
+ return style + (s.length() == 0 || s.endsWith(";") ? "" : ";") //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ + element;
+ }
- /**
- * Adds image as attribute to IMG tag from users worcpace
- *
- * @param pageContext
- * Page Context
- * @param img
- * img element to which set picture
- * @param fileImageName
- * image name
- * @param undefinedImgName
- * default image when image is undefined
- */
- public static void setImgFromResources(VpePageContext pageContext,
- nsIDOMElement img, String fileImageName, String undefinedImgName) {
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- IPath inputPath = getInputParentPath(input);
- File file = new File(inputPath.toOSString() + File.separator
- + fileImageName);
- if (file.exists()) {
- img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC,
- HtmlComponentUtil.FILE_PROTOCOL + inputPath.toOSString()
- + File.separator + fileImageName);
- } else {
- img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, undefinedImgName);
+ /**
+ * Adds image as attribute to IMG tag from users worcpace
+ *
+ * @param pageContext
+ * Page Context
+ * @param img
+ * img element to which set picture
+ * @param fileImageName
+ * image name
+ * @param undefinedImgName
+ * default image when image is undefined
+ */
+ public static void setImgFromResources(VpePageContext pageContext,
+ nsIDOMElement img, String fileImageName, String undefinedImgName) {
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ IPath inputPath = getInputParentPath(input);
+ File file = new File(inputPath.toOSString() + File.separator
+ + fileImageName);
+ if (file.exists()) {
+ img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC,
+ HtmlComponentUtil.FILE_PROTOCOL + inputPath.toOSString()
+ + File.separator + fileImageName);
+ } else {
+ img.setAttribute(HtmlComponentUtil.HTML_ATR_SRC, undefinedImgName);
+ }
}
- }
- /**
- * Open file
- *
- * @param pageContext
- * Page Context
- * @param fileName
- * file name
- * @return file
- */
- public static File openFile(VpePageContext pageContext, String fileName) {
- IEditorInput input = pageContext.getEditPart().getEditorInput();
- IPath inputPath = getInputParentPath(input);
- File file = new File(inputPath.toOSString() + File.separator + fileName);
- return file;
- }
+ /**
+ * Open file
+ *
+ * @param pageContext
+ * Page Context
+ * @param fileName
+ * file name
+ * @return file
+ */
+ public static File openFile(VpePageContext pageContext, String fileName) {
+ IEditorInput input = pageContext.getEditPart().getEditorInput();
+ IPath inputPath = getInputParentPath(input);
+ File file = new File(inputPath.toOSString() + File.separator + fileName);
+ return file;
+ }
- /**
- * Returns locale of user input
- *
- * @param input
- * @return
- */
- public static IPath getInputParentPath(IEditorInput input) {
- IPath inputPath = null;
- if (input instanceof ILocationProvider) {
- inputPath = ((ILocationProvider) input).getPath(input);
- } else if (input instanceof IFileEditorInput) {
- IFile inputFile = ((IFileEditorInput) input).getFile();
- if (inputFile != null) {
- inputPath = inputFile.getLocation();
- }
+ /**
+ * Returns locale of user input
+ *
+ * @param input
+ * @return
+ */
+ public static IPath getInputParentPath(IEditorInput input) {
+ IPath inputPath = null;
+ if (input instanceof ILocationProvider) {
+ inputPath = ((ILocationProvider) input).getPath(input);
+ } else if (input instanceof IFileEditorInput) {
+ IFile inputFile = ((IFileEditorInput) input).getFile();
+ if (inputFile != null) {
+ inputPath = inputFile.getLocation();
+ }
+ }
+ if (inputPath != null && !inputPath.isEmpty()) {
+ inputPath = inputPath.removeLastSegments(1);
+ }
+ return inputPath;
}
- if (inputPath != null && !inputPath.isEmpty()) {
- inputPath = inputPath.removeLastSegments(1);
+
+ /**
+ * Move attributes from sourceNode to html
+ *
+ * @param sourceNode
+ * @param visualNode
+ * @param attrName
+ * @param htmlAttrName
+ * @param prefValue
+ * @param defValue
+ */
+ public static void correctAttribute(Element sourceNode,
+ nsIDOMElement visualNode, String attrName, String htmlAttrName,
+ String prefValue, String defValue) {
+ String attrValue = ((Element) sourceNode).getAttribute(attrName);
+ if (prefValue != null && prefValue.trim().length() > 0
+ && attrValue != null) {
+ attrValue = prefValue.trim() + " " + attrValue; //$NON-NLS-1$
+ }
+ if (attrValue != null) {
+ visualNode.setAttribute(htmlAttrName, attrValue);
+ } else if (defValue != null) {
+ visualNode.setAttribute(htmlAttrName, defValue);
+ } else
+ visualNode.removeAttribute(attrName);
}
- return inputPath;
- }
- /**
- * Move attributes from sourceNode to html
- *
- * @param sourceNode
- * @param visualNode
- * @param attrName
- * @param htmlAttrName
- * @param prefValue
- * @param defValue
- */
- public static void correctAttribute(Element sourceNode,
- nsIDOMElement visualNode, String attrName, String htmlAttrName,
- String prefValue, String defValue) {
- String attrValue = ((Element) sourceNode).getAttribute(attrName);
- if (prefValue != null && prefValue.trim().length() > 0
- && attrValue != null) {
- attrValue = prefValue.trim() + " " + attrValue;
+ /**
+ * Parses string value retrieved from sourceElement.getAttribure(..) method
+ * to its boolean value.
+ * <p>
+ * <code>false</code> is returned only if it specified explicitly,
+ * otherwise <code>true</code> is returned.
+ *
+ * @param str
+ * the string to parse
+ * @return boolean value from string
+ */
+ public static boolean string2boolean(String str) {
+ if ((str == null) || ("".equals(str))) { //$NON-NLS-1$
+ return true;
+ } else if (("true".equalsIgnoreCase(str)) //$NON-NLS-1$
+ || ("false".equalsIgnoreCase(str))) { //$NON-NLS-1$
+ return new Boolean(str).booleanValue();
+ }
+ return true;
}
- if (attrValue != null) {
- visualNode.setAttribute(htmlAttrName, attrValue);
- } else if (defValue != null) {
- visualNode.setAttribute(htmlAttrName, defValue);
- } else
- visualNode.removeAttribute(attrName);
- }
- /**
- * Parses string value retrieved from sourceElement.getAttribure(..) method
- * to its boolean value.
- * <p>
- * <code>false</code> is returned only if it specified explicitly,
- * otherwise <code>true</code> is returned.
- *
- * @param str
- * the string to parse
- * @return boolean value from string
- */
- public static boolean string2boolean(String str) {
- if ((str == null) || ("".equals(str))) {
- return true;
- } else if (("true".equalsIgnoreCase(str))
- || ("false".equalsIgnoreCase(str))) {
- return new Boolean(str).booleanValue();
+ /**
+ * find elements by name
+ *
+ * @param node -
+ * current node
+ * @param elements -
+ * list of found elements
+ * @param name -
+ * name element
+ */
+ static public void findElementsByName(Node node, List<Node> elements,
+ String name) {
+ // get children
+ NodeList children = node.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ // if current child is required then add his to list
+ if (name.equalsIgnoreCase((child.getNodeName()))) {
+ elements.add(child);
+ } else {
+ findElementsByName(child, elements, name);
+ }
+ }
}
- return true;
- }
+ /**
+ * find all elements by name
+ *
+ * @param node -
+ * current node
+ * @param elements -
+ * list of found elements
+ * @param name -
+ * name element
+ */
+ static public void findAllElementsByName(nsIDOMNode node,
+ List<nsIDOMNode> elements, String name) {
+
+ try {
+ nsIDOMNodeList list = node.getChildNodes();
+ if (node.getNodeName().equalsIgnoreCase(name)) {
+ elements.add(node);
+ }
+ for (int i = 0; i < list.getLength(); i++) {
+ findAllElementsByName(list.item(i), elements, name);
+ }
+ } catch (XPCOMException e) {
+ // Ignore
+ return;
+ }
+ }
+
}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2008-03-26 23:40:06 UTC (rev 7141)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/HtmlComponentUtil.java 2008-03-27 09:27:47 UTC (rev 7142)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces;
/**
@@ -19,158 +19,160 @@
public class HtmlComponentUtil {
/** HTML TAG DL */
- public static final String HTML_TAG_DL = "dl";
-
+ public static final String HTML_TAG_DL = "dl"; //$NON-NLS-1$
+
/** HTML TAG BR */
- public static final String HTML_TAG_BR = "br";
-
+ public static final String HTML_TAG_BR = "br"; //$NON-NLS-1$
+
/** HTML TAG COLGROUP */
- public static final String HTML_TAG_COLGROUP = "colgroup";
-
+ public static final String HTML_TAG_COLGROUP = "colgroup"; //$NON-NLS-1$
+
/** HTML TAG THEAD */
- public static final String HTML_TAG_THEAD = "thead";
-
+ public static final String HTML_TAG_THEAD = "thead"; //$NON-NLS-1$
+
/** HTML TAG TFOOT */
- public static final String HTML_TAG_TFOOT = "tfoot";
-
+ public static final String HTML_TAG_TFOOT = "tfoot"; //$NON-NLS-1$
+
/** HTML TAG CAPTION */
- public static final String HTML_TAG_CAPTION = "caption";
+ public static final String HTML_TAG_CAPTION = "caption"; //$NON-NLS-1$
/** HTML TAG DT */
- public static final String HTML_TAG_DT = "dt";
+ public static final String HTML_TAG_DT = "dt"; //$NON-NLS-1$
/** HTML TAG DD */
- public static final String HTML_TAG_DD = "dd";
+ public static final String HTML_TAG_DD = "dd"; //$NON-NLS-1$
/** HTML_TAG_TABLE * */
- public static final String HTML_TAG_TABLE = "TABLE";
+ public static final String HTML_TAG_TABLE = "TABLE"; //$NON-NLS-1$
/** HTML_TAG_TBODY * */
- public static final String HTML_TAG_TBODY = "TBODY";
-
+ public static final String HTML_TAG_TBODY = "TBODY"; //$NON-NLS-1$
+
/** HTML_TAG_TR * */
- public static final String HTML_TAG_TR = "TR";
+ public static final String HTML_TAG_TR = "TR"; //$NON-NLS-1$
/** HTML_TAG_TD * */
- public static final String HTML_TAG_TD = "TD";
+ public static final String HTML_TAG_TD = "TD"; //$NON-NLS-1$
/** HTML_TAG_TH * */
- public static final String HTML_TAG_TH = "TH";
+ public static final String HTML_TAG_TH = "TH"; //$NON-NLS-1$
/** HTML_TAG_INPUT * */
- public static final String HTML_TAG_INPUT = "INPUT";
+ public static final String HTML_TAG_INPUT = "INPUT"; //$NON-NLS-1$
/** HTML_TAG_IMG * */
- public static final String HTML_TAG_IMG = "IMG";
+ public static final String HTML_TAG_IMG = "IMG"; //$NON-NLS-1$
/** HTML_TAG_DIV */
- public static final String HTML_TAG_DIV = "DIV";
+ public static final String HTML_TAG_DIV = "DIV"; //$NON-NLS-1$
/** HTML_TAG_SPAN */
- public static final String HTML_TAG_SPAN = "SPAN";
+ public static final String HTML_TAG_SPAN = "SPAN"; //$NON-NLS-1$
/** HTML_TAG_A */
- public static final String HTML_TAG_A = "A";
+ public static final String HTML_TAG_A = "A"; //$NON-NLS-1$
/** HTML_TAG_B */
- public static final String HTML_TAG_B = "B";
-
+ public static final String HTML_TAG_B = "B"; //$NON-NLS-1$
+
/** HTML_TAG_LI */
- public static final String HTML_TAG_LI = "LI";
+ public static final String HTML_TAG_LI = "LI"; //$NON-NLS-1$
/** HTML_TABLE_COLSPAN * */
- public static final String HTML_TABLE_COLSPAN = "colspan";
+ public static final String HTML_TABLE_COLSPAN = "colspan"; //$NON-NLS-1$
/** HTML_HEIGHT_ATTR * */
- public static final String HTML_HEIGHT_ATTR = "height";
+ public static final String HTML_HEIGHT_ATTR = "height"; //$NON-NLS-1$
/** HTML_CLASS_ATTR * */
- public static final String HTML_STYLECLASS_ATTR = "styleClass";
+ public static final String HTML_STYLECLASS_ATTR = "styleClass"; //$NON-NLS-1$
/** HTML_CLASS_ATTR * */
- public static final String HTML_CLASS_ATTR = "class";
+ public static final String HTML_CLASS_ATTR = "class"; //$NON-NLS-1$
/** HTML_CELLSPACING_ATTR * */
- public static final String HTML_CELLSPACING_ATTR = "cellspacing";
+ public static final String HTML_CELLSPACING_ATTR = "cellspacing"; //$NON-NLS-1$
/** HTML_CELLPADDING_ATTR * */
- public static final String HTML_CELLPADDING_ATTR = "cellpadding";
+ public static final String HTML_CELLPADDING_ATTR = "cellpadding"; //$NON-NLS-1$
/** HTML_ALIGN_LEFT_VALUE * */
- public static final String HTML_ALIGN_LEFT_VALUE = "left";
-
+ public static final String HTML_ALIGN_LEFT_VALUE = "left"; //$NON-NLS-1$
+
/** HTML_ALIGN_RIGHT_VALUE * */
- public static final String HTML_ALIGN_RIGHT_VALUE = "right";
+ public static final String HTML_ALIGN_RIGHT_VALUE = "right"; //$NON-NLS-1$
/** HTML_ALIGN_CENTER_VALUE * */
- public static final String HTML_ALIGN_CENTER_VALUE = "center";
-
+ public static final String HTML_ALIGN_CENTER_VALUE = "center"; //$NON-NLS-1$
+
/** HTML_ATR_WIDTH */
- public static final String HTML_ATR_WIDTH = "width";
+ public static final String HTML_ATR_WIDTH = "width"; //$NON-NLS-1$
/** HTML_ATR_WIDTH */
- public static final String HTML_ATR_HEIGHT = "height";
+ public static final String HTML_ATR_HEIGHT = "height"; //$NON-NLS-1$
/** HTML_ATR_src */
- public static final String HTML_ATR_SRC = "src";
+ public static final String HTML_ATR_SRC = "src"; //$NON-NLS-1$
/** style */
- public static final String HTML_STYLE_ATTR = "style";
-
+ public static final String HTML_STYLE_ATTR = "style"; //$NON-NLS-1$
+
/** scope */
- public static final String HTML_SCOPE_ATTR = "scope";
+ public static final String HTML_SCOPE_ATTR = "scope"; //$NON-NLS-1$
/** HTML_TABLE_ATR_ */
- public static final String HTML_BORDER_ATTR = "border";
+ public static final String HTML_BORDER_ATTR = "border"; //$NON-NLS-1$
/** HTML_ALIGN_ATR */
- public static final String HTML_ALIGN_ATTR = "align";
+ public static final String HTML_ALIGN_ATTR = "align"; //$NON-NLS-1$
/** HTML_TABLE_ATR_ */
- public static final String FILE_PROTOCOL = "file://";
-
+ public static final String FILE_PROTOCOL = "file://"; //$NON-NLS-1$
+
/** HTML_COLSPAN_ATTR * */
- public static final String HTML_COLSPAN_ATTR = "colspan";
-
+ public static final String HTML_COLSPAN_ATTR = "colspan"; //$NON-NLS-1$
+
/** HTML_ROWSPAN_ATTR * */
- public static final String HTML_ROWSPAN_ATTR = "rowspan";
+ public static final String HTML_ROWSPAN_ATTR = "rowspan"; //$NON-NLS-1$
/** HTML_ROW_ATTR * */
- public static final String HTML_ROW_ATTR = "row";
-
+ public static final String HTML_ROW_ATTR = "row"; //$NON-NLS-1$
+
/** HTML_SIZE_ATTR * */
- public static final String HTML_SIZE_ATTR = "size";
-
+ public static final String HTML_SIZE_ATTR = "size"; //$NON-NLS-1$
+
/** HTML_TYPE_ATTR * */
- public static final String HTML_TYPE_ATTR = "type";
-
+ public static final String HTML_TYPE_ATTR = "type"; //$NON-NLS-1$
+
/** HTML_READONLY_ATTR * */
- public static final String HTML_READONLY_ATTR = "readonly";
-
+ public static final String HTML_READONLY_ATTR = "readonly"; //$NON-NLS-1$
+
/** HTML_TAG_BUTTON * */
- public static final String HTML_TAG_BUTTON = "button";
-
+ public static final String HTML_TAG_BUTTON = "button"; //$NON-NLS-1$
+
/** HTML_VALUE_ATTR * */
- public static final String HTML_VALUE_ATTR = "value";
-
+ public static final String HTML_VALUE_ATTR = "value"; //$NON-NLS-1$
+
/** CSS_BORDER_WIDTH */
- public static final String CSS_BORDER_WIDTH = "border-width";
-
+ public static final String CSS_BORDER_WIDTH = "border-width"; //$NON-NLS-1$
+
/** CSS_BORDER_STYLE */
- public static final String CSS_BORDER_STYLE = "border-style";
-
- /** HTML_WIDTH_ATTR * */
- public static final String HTML_WIDTH_ATTR = "width";
-
- /** HTML_ATTR_VALIGN */
- public static final String HTML_ATTR_VALIGN = "valign";
-
- /** HTML_ATTR_VALIGN_MIDDLE_VALUE */
- public static final String HTML_ATTR_VALIGN_MIDDLE_VALUE = "middle";
+ public static final String CSS_BORDER_STYLE = "border-style"; //$NON-NLS-1$
- /** HTML_ATTR_BACKGROUND */
- public static final String HTML_ATTR_BACKGROUND = "background";
+ public static final String CSS_DISPLAY = "display"; //$NON-NLS-1$
- /** HTML_ATTR_BACKGROUND */
- public static final String HTML_ATTR_DISABLED = "disabled";
+ /** HTML_WIDTH_ATTR * */
+ public static final String HTML_WIDTH_ATTR = "width"; //$NON-NLS-1$
+
+ /** HTML_ATTR_VALIGN */
+ public static final String HTML_ATTR_VALIGN = "valign"; //$NON-NLS-1$
+
+ /** HTML_ATTR_VALIGN_MIDDLE_VALUE */
+ public static final String HTML_ATTR_VALIGN_MIDDLE_VALUE = "middle"; //$NON-NLS-1$
+
+ /** HTML_ATTR_BACKGROUND */
+ public static final String HTML_ATTR_BACKGROUND = "background"; //$NON-NLS-1$
+
+ /** HTML_ATTR_BACKGROUND */
+ public static final String HTML_ATTR_DISABLED = "disabled"; //$NON-NLS-1$
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-26 23:40:06 UTC (rev 7141)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabPanelTemplate.java 2008-03-27 09:27:47 UTC (rev 7142)
@@ -20,6 +20,7 @@
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
import org.mozilla.interfaces.nsIDOMDocument;
@@ -44,6 +45,8 @@
private static final String RICH_FACES_TAB_PANEL = "richFacesTabPanel"; //$NON-NLS-1$
private static final String CSS_FILE_PATH = "tabPanel/tabPanel.css"; //$NON-NLS-1$
private static final String SPACER_FILE_PATH = "common/spacer.gif"; //$NON-NLS-1$
+ private static final String INCLUDE_TAG = ":include"; //$NON-NLS-1$
+ private static final String YES = "yes"; //$NON-NLS-1$
private final String HEADER_ALINGMENT = "headerAlignment"; //$NON-NLS-1$
private final String HEADER_SPACING = "headerSpacing"; //$NON-NLS-1$
@@ -123,8 +126,14 @@
int i = 0;
for (Node child : children) {
boolean active = (i == activeId);
+
+ if (child.getNodeName().endsWith(INCLUDE_TAG)) {
+ VpeChildrenInfo vpeChildrenInfo = new VpeChildrenInfo(inerTr);
+ creationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(child);
+ }
+
if(child.getNodeName().endsWith(TAB)) {
-
/*
* Adds spacer before first tab
*/
@@ -345,6 +354,22 @@
*/
public void validate(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, VpeCreationData data) {
+ List<nsIDOMNode> elements = new ArrayList<nsIDOMNode>();
+ ComponentUtil.findAllElementsByName(data.getNode(), elements, HtmlComponentUtil.HTML_TAG_TABLE);
+ for (nsIDOMNode node : elements) {
+ try {
+ nsIDOMElement element = (nsIDOMElement) node.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ if (ComponentUtil.getAttribute(element, RichFacesTabTemplate.TAB_HEADER_ATTR).equalsIgnoreCase(YES)) {
+ element.removeAttribute(HtmlComponentUtil.HTML_STYLE_ATTR);
+ }
+ if (ComponentUtil.getAttribute(element, RichFacesTabTemplate.TAB_BODY_ATTR).equalsIgnoreCase(YES)) {
+ element.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, HtmlComponentUtil.CSS_DISPLAY+" : "+RichFacesTabTemplate.DISABLED_ELEMENT_STYLE+";"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ } catch (XPCOMException exeption) {
+ // Ignore
+ }
+ }
+
super.validate(pageContext, sourceNode, visualDocument, data);
if ((storedTabHeaders == null) || (storedTabHeaders.size() < 1)){
return;
@@ -353,7 +378,9 @@
for (nsIDOMElement tab : storedTabHeaders) {
String value = tab.getAttribute(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID);
applyAttributeValueOnChildren(VpeVisualDomBuilder.VPE_USER_TOGGLE_ID, value, getChildren(tab));
- applyAttributeValueOnChildren(VpeVisualDomBuilder.VPE_USER_TOGGLE_LOOKUP_PARENT, "true", getChildren(tab));
+ applyAttributeValueOnChildren(
+ VpeVisualDomBuilder.VPE_USER_TOGGLE_LOOKUP_PARENT,
+ "true", getChildren(tab)); //$NON-NLS-1$
}
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2008-03-26 23:40:06 UTC (rev 7141)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2008-03-27 09:27:47 UTC (rev 7142)
@@ -25,6 +25,11 @@
public class RichFacesTabTemplate extends VpeAbstractTemplate {
+ public static final String TAB_HEADER_ATTR = "tabheaderattr"; //$NON-NLS-1$
+ public static final String YES = "yes"; //$NON-NLS-1$
+ public static final String DISABLED_ELEMENT_STYLE = "none"; //$NON-NLS-1$
+ public static final String TAB_BODY_ATTR = "tabbodyattr"; //$NON-NLS-1$
+
private final static String SPACER_FILE_PATH = "common/spacer.gif"; //$NON-NLS-1$
private final static String ACTIVE_BKG_FILE_PATH = "tabPanel/activeBackground.gif"; //$NON-NLS-1$
private final static String INACTIVE_BKG_FILE_PATH = "tabPanel/inactiveBackground.gif"; //$NON-NLS-1$
@@ -52,6 +57,7 @@
private static final String WIDTH_STYLE_NAME = "width: "; //$NON-NLS-1$
private static final String STYLE_SEMICOLUMN = "; "; //$NON-NLS-1$
+
/**
* Encode body of tab
* @param creationData
@@ -95,11 +101,11 @@
nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
td.appendChild(table);
table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
- table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "10");
+ table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, "10"); //$NON-NLS-1$
table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, HUNDRED_PERCENTS);
- table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-cntnt-pstn" + SPACE + RichFacesTabPanelTemplate.CSS_CONTENT_POSITION);
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "position: relative; z-index: 1;");
+ table.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-cntnt-pstn" + SPACE + RichFacesTabPanelTemplate.CSS_CONTENT_POSITION); //$NON-NLS-1$
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "position: relative; z-index: 1;"); //$NON-NLS-1$
nsIDOMElement tr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
table.appendChild(tr);
@@ -107,7 +113,7 @@
tr.appendChild(td);
td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR,
ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLECLASS_ATTR)
- + SPACE + "dr-tbpnl-cntnt"
+ + SPACE + "dr-tbpnl-cntnt" //$NON-NLS-1$
+ SPACE + contentClass);
td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
ComponentUtil.getAttribute(sourceElement, HtmlComponentUtil.HTML_STYLE_ATTR)
@@ -124,7 +130,29 @@
}
public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
- return encodeBody(null, (Element)sourceNode, visualDocument, null, true, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY);
+ nsIDOMElement table = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ //table.setAttribute("include-tab", "");
+ VpeCreationData creationData = new VpeCreationData(table);
+ nsIDOMElement headerTable = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ headerTable.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ headerTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
+ headerTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
+ headerTable.setAttribute(TAB_HEADER_ATTR, YES);
+ headerTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR,
+ HtmlComponentUtil.CSS_DISPLAY
+ + ":" + DISABLED_ELEMENT_STYLE + STYLE_SEMICOLUMN); //$NON-NLS-1$
+ headerTable.appendChild(encodeHeader(creationData, (Element)sourceNode, visualDocument, table, false, EMPTY, EMPTY, EMPTY, EMPTY,EMPTY));
+ nsIDOMElement bodyTable = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ bodyTable.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
+ bodyTable.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
+ bodyTable.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
+ bodyTable.setAttribute(TAB_BODY_ATTR, YES);
+ //bodyTable.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, HtmlComponentUtil.CSS_DISPLAY+" : "+DISABLED_ELEMENT_STYLE+";"); //$NON-NLS-1$ //$NON-NLS-2$
+ table.appendChild(headerTable);
+ table.appendChild(bodyTable);
+ encodeBody(creationData, (Element)sourceNode, visualDocument, bodyTable, true, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY);
+ return creationData;
+
}
/**
@@ -150,14 +178,14 @@
nsIDOMElement headerTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
parentTr.appendChild(headerTd);
- headerTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height: 100%; vertical-align: bottom;");
- String styleClass = "dr-tbpnl-tbcell-dsbl rich-tabhdr-cell-dsbl";
- if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
+ headerTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height: 100%; vertical-align: bottom;"); //$NON-NLS-1$
+ String styleClass = "dr-tbpnl-tbcell-dsbl rich-tabhdr-cell-dsbl"; //$NON-NLS-1$
+ if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) { //$NON-NLS-1$
if(active) {
- styleClass = "dr-tbpnl-tbcell-act"
+ styleClass = "dr-tbpnl-tbcell-act" //$NON-NLS-1$
+ SPACE + RichFacesTabPanelTemplate.CSS_CELL_ACTIVE;
} else {
- styleClass = "dr-tbpnl-tbcell-inact"
+ styleClass = "dr-tbpnl-tbcell-inact" //$NON-NLS-1$
+ SPACE + RichFacesTabPanelTemplate.CSS_CELL_INACTIVE;
}
}
@@ -170,7 +198,7 @@
table.setAttribute(HtmlComponentUtil.HTML_BORDER_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_CELLPADDING_ATTR, ZERO);
table.setAttribute(HtmlComponentUtil.HTML_CELLSPACING_ATTR, ZERO);
- table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height : 100%; position : relative; z-index : 2;");
+ table.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, "height : 100%; position : relative; z-index : 2;"); //$NON-NLS-1$
table.setAttribute(VPE_USER_TOGGLE_ID, toggleId);
nsIDOMElement mainTr = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TR);
@@ -196,7 +224,7 @@
*/
}
if (val > 0) {
- labelWidth = val + "px";
+ labelWidth = val + "px"; //$NON-NLS-1$
}
} else {
labelWidth = HUNDRED_PERCENTS;
@@ -213,23 +241,23 @@
mainTd = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
tr.appendChild(mainTd);
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-dsbl"
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-dsbl" //$NON-NLS-1$
+ SPACE + CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_DISABLED
+ SPACE + disabledTabClass;
String bgImgPath = ComponentUtil.getAbsoluteResourcePath(INACTIVE_BKG_FILE_PATH);
- if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) {
+ if(!"true".equalsIgnoreCase(sourceElement.getAttribute(DISABLED))) { //$NON-NLS-1$
if(active) {
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-act"
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-act" //$NON-NLS-1$
+ SPACE + CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_ACTIVE
+ SPACE + activeTabClass;
bgImgPath = ComponentUtil.getAbsoluteResourcePath(ACTIVE_BKG_FILE_PATH);
} else {
- styleClass = "dr-tbpnl-tb dr-tbpnl-tb-inact"
+ styleClass = "dr-tbpnl-tb dr-tbpnl-tb-inact" //$NON-NLS-1$
+ SPACE + CSS_HEADER
+ SPACE + CSS_LABEL
+ SPACE + CSS_INACTIVE
@@ -237,11 +265,11 @@
}
}
- styleClass += SPACE + "dr-tbpnl-tbtopbrdr" + SPACE
+ styleClass += SPACE + "dr-tbpnl-tbtopbrdr" + SPACE //$NON-NLS-1$
+ RichFacesTabPanelTemplate.CSS_SIDE_CELL;
mainTd.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, styleClass);
- String style = "background-image: url(file:///"
- + bgImgPath.replace('\\', '/') + ");";
+ String style = "background-image: url(file:///" //$NON-NLS-1$
+ + bgImgPath.replace('\\', '/') + ");"; //$NON-NLS-1$
mainTd.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
@@ -269,10 +297,10 @@
private static void encodeSpacer(nsIDOMElement parentTr, nsIDOMDocument visualDocument) {
nsIDOMElement td = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_TD);
parentTr.appendChild(td);
- td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-tbbrdr"
+ td.setAttribute(HtmlComponentUtil.HTML_CLASS_ATTR, "dr-tbpnl-tbbrdr" //$NON-NLS-1$
+ SPACE + RichFacesTabPanelTemplate.CSS_SIDE_BORDER);
String borderImgPath = ComponentUtil.getAbsoluteResourcePath(BORDER_FILE_PATH);
- String style = "background-image: url(file:///" + borderImgPath.replace('\\', '/') + ");";
+ String style = "background-image: url(file:///" + borderImgPath.replace('\\', '/') + ");"; //$NON-NLS-1$ //$NON-NLS-2$
td.setAttribute(HtmlComponentUtil.HTML_STYLE_ATTR, style);
nsIDOMElement img = visualDocument.createElement(HtmlComponentUtil.HTML_TAG_IMG);
td.appendChild(img);
16 years, 1 month
JBoss Tools SVN: r7141 - in trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test: model and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-26 19:40:06 -0400 (Wed, 26 Mar 2008)
New Revision: 7141
Added:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelUtilTest.java
Removed:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ModelUtilTest.java
Modified:
trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java
Log:
moving unit test
Modified: trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java 2008-03-26 23:37:42 UTC (rev 7140)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ArchivesTestSuite.java 2008-03-26 23:40:06 UTC (rev 7141)
@@ -5,6 +5,7 @@
import org.jboss.ide.eclipse.archives.test.core.ArchivesCoreTest;
import org.jboss.ide.eclipse.archives.test.model.ModelCreationTest;
+import org.jboss.ide.eclipse.archives.test.model.ModelUtilTest;
import org.jboss.ide.eclipse.archives.test.model.XBMarshallTest;
import org.jboss.ide.eclipse.archives.test.model.XBUnmarshallTest;
import org.jboss.ide.eclipse.archives.test.util.TruezipUtilTest;
Deleted: trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ModelUtilTest.java
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ModelUtilTest.java 2008-03-26 23:37:42 UTC (rev 7140)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ModelUtilTest.java 2008-03-26 23:40:06 UTC (rev 7141)
@@ -1,146 +0,0 @@
-package org.jboss.ide.eclipse.archives.test;
-
-import java.io.IOException;
-import java.net.URL;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
-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;
-import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl;
-import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
-import org.osgi.framework.Bundle;
-
-public class ModelUtilTest extends TestCase {
- private Bundle bundle;
- private IPath bundlePath;
- private IPath outputs;
- private IPath inputs;
- private IArchive rootArchive;
- protected void setUp() {
- if( bundlePath == null ) {
- try {
- bundle = ArchivesTest.getDefault().getBundle();
- URL bundleURL = FileLocator.toFileURL(bundle.getEntry(""));
- bundlePath = new Path(bundleURL.getFile());
- outputs = bundlePath.append("output");
- inputs = bundlePath.append("inputs");
- } catch( IOException ioe) {}
- }
- try {
- rootArchive = createArchive();
- } catch( ArchivesModelException ame ) {
- fail(ame.getMessage());
- }
- }
-
- public void tearDown() {
- rootArchive = null;
- }
-
-
-
- protected IArchive createArchive() throws ArchivesModelException {
- IPath fileTrees = inputs.append("fileTrees");
-
- IArchive root = ArchiveNodeFactory.createArchive();
- root.setArchiveType("jar");
- root.setDestinationPath(outputs);
- root.setName("output.jar");
- root.setExploded(false);
- root.setInWorkspace(false);
-
- IArchiveFolder topFolder = ArchiveNodeFactory.createFolder();
- topFolder.setName("topFolder");
- root.addChild(topFolder);
-
- IArchiveFolder inner1 = ArchiveNodeFactory.createFolder();
- inner1.setName("inner1");
- topFolder.addChild(inner1);
-
- IArchiveFolder images = ArchiveNodeFactory.createFolder();
- images.setName("images");
- topFolder.addChild(images);
-
- IArchiveFileSet outerFileset = ArchiveNodeFactory.createFileset();
- outerFileset.setInWorkspace(false);
- outerFileset.setSourcePath(fileTrees.append("misc"));
- outerFileset.setExcludesPattern("**/*.gif,**/*.png");
- outerFileset.setIncludesPattern("**/*");
- topFolder.addChild(outerFileset);
-
- IArchiveFileSet imageFileset = ArchiveNodeFactory.createFileset();
- imageFileset.setInWorkspace(false);
- imageFileset.setSourcePath(fileTrees.append("misc"));
- imageFileset.setIncludesPattern("**/*.gif,**/*.png,**/*.xml");
- images.addChild(imageFileset);
-
- ((ArchiveNodeImpl)root).clearDelta();
- return root;
- }
-
- public void testFindAllDescendentFilesets() {
- IArchiveFileSet[] fsets = ModelUtil.findAllDescendentFilesets(rootArchive);
- assertTrue(fsets.length == 2);
- assertTrue(fsets[0].getParent().getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER);
- assertTrue(fsets[1].getParent().getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER);
- assertTrue(ModelUtil.findAllDescendentFilesets(ArchiveNodeFactory.createFileset()).length == 1);
- }
-
- public void testFindAllDescendentFolders() {
- IArchiveFolder[] folders = ModelUtil.findAllDescendentFolders(rootArchive);
- assertTrue(folders.length == 3);
- }
-
- public void testFindAllDescendentsGeneric() {
- assertTrue(ModelUtil.findAllDescendents(rootArchive, IArchiveNode.TYPE_ARCHIVE, false).size() == 0);
- assertTrue(ModelUtil.findAllDescendents(rootArchive, IArchiveNode.TYPE_ARCHIVE, true).size() == 1);
- assertTrue(ModelUtil.findAllDescendents(rootArchive, IArchiveNode.TYPE_ARCHIVE_FOLDER, false).size() == 3);
- assertTrue(ModelUtil.findAllDescendents(rootArchive, IArchiveNode.TYPE_ARCHIVE_FILESET, false).size() == 2);
- }
-
- public void testGetMatchingFileSets() {
- IPath misc = inputs.append("fileTrees").append("misc");
- IPath gif = misc.append("multiple_files.gif");
- IPath xml = misc.append("rug.xml");
- IPath html = misc.append("someHtml.html");
-
- IArchiveFileSet[] gifFS = ModelUtil.getMatchingFilesets(rootArchive, gif);
- IArchiveFileSet[] xmlFS = ModelUtil.getMatchingFilesets(rootArchive, xml);
- IArchiveFileSet[] htmlFS = ModelUtil.getMatchingFilesets(rootArchive, html);
-
- assertEquals(1, gifFS.length);
- assertEquals(2, xmlFS.length);
- assertEquals(1, htmlFS.length);
-
- }
-
- public void testOtherFilesetMatchesPath() throws ArchivesModelException {
- IPath xml = inputs.append("fileTrees").append("misc").append("rug.xml");
- IArchiveFileSet[] xmlFS = ModelUtil.getMatchingFilesets(rootArchive, xml);
- assertTrue(xmlFS.length == 2);
- assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[0], xml, rootArchive));
- assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[1], xml, rootArchive));
-
- IPath html = inputs.append("fileTrees").append("misc").append("someHtml.html");
- IArchiveFileSet[] htmlFS = ModelUtil.getMatchingFilesets(rootArchive, html);
- assertTrue(htmlFS.length == 1);
- assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(htmlFS[0], html, rootArchive));
-
- // add a temporary fileset that will match exactly
- IArchiveFileSet otherFS = ArchiveNodeFactory.createFileset();
- otherFS.setIncludesPattern(xmlFS[0].getIncludesPattern());
- otherFS.setInWorkspace(xmlFS[0].isInWorkspace());
- otherFS.setSourcePath(xmlFS[0].getSourcePath());
- xmlFS[0].getParent().addChild(otherFS);
-
- assertTrue(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[0], xml, rootArchive));
- }
-}
Copied: trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelUtilTest.java (from rev 7025, trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/ModelUtilTest.java)
===================================================================
--- trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelUtilTest.java (rev 0)
+++ trunk/core/tests/org.jboss.ide.eclipse.archives.test/src/org/jboss/ide/eclipse/archives/test/model/ModelUtilTest.java 2008-03-26 23:40:06 UTC (rev 7141)
@@ -0,0 +1,147 @@
+package org.jboss.ide.eclipse.archives.test.model;
+
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.jboss.ide.eclipse.archives.core.model.ArchiveNodeFactory;
+import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
+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;
+import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveNodeImpl;
+import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
+import org.jboss.ide.eclipse.archives.test.ArchivesTest;
+import org.osgi.framework.Bundle;
+
+public class ModelUtilTest extends TestCase {
+ private Bundle bundle;
+ private IPath bundlePath;
+ private IPath outputs;
+ private IPath inputs;
+ private IArchive rootArchive;
+ protected void setUp() {
+ if( bundlePath == null ) {
+ try {
+ bundle = ArchivesTest.getDefault().getBundle();
+ URL bundleURL = FileLocator.toFileURL(bundle.getEntry(""));
+ bundlePath = new Path(bundleURL.getFile());
+ outputs = bundlePath.append("output");
+ inputs = bundlePath.append("inputs");
+ } catch( IOException ioe) {}
+ }
+ try {
+ rootArchive = createArchive();
+ } catch( ArchivesModelException ame ) {
+ fail(ame.getMessage());
+ }
+ }
+
+ public void tearDown() {
+ rootArchive = null;
+ }
+
+
+
+ protected IArchive createArchive() throws ArchivesModelException {
+ IPath fileTrees = inputs.append("fileTrees");
+
+ IArchive root = ArchiveNodeFactory.createArchive();
+ root.setArchiveType("jar");
+ root.setDestinationPath(outputs);
+ root.setName("output.jar");
+ root.setExploded(false);
+ root.setInWorkspace(false);
+
+ IArchiveFolder topFolder = ArchiveNodeFactory.createFolder();
+ topFolder.setName("topFolder");
+ root.addChild(topFolder);
+
+ IArchiveFolder inner1 = ArchiveNodeFactory.createFolder();
+ inner1.setName("inner1");
+ topFolder.addChild(inner1);
+
+ IArchiveFolder images = ArchiveNodeFactory.createFolder();
+ images.setName("images");
+ topFolder.addChild(images);
+
+ IArchiveFileSet outerFileset = ArchiveNodeFactory.createFileset();
+ outerFileset.setInWorkspace(false);
+ outerFileset.setSourcePath(fileTrees.append("misc"));
+ outerFileset.setExcludesPattern("**/*.gif,**/*.png");
+ outerFileset.setIncludesPattern("**/*");
+ topFolder.addChild(outerFileset);
+
+ IArchiveFileSet imageFileset = ArchiveNodeFactory.createFileset();
+ imageFileset.setInWorkspace(false);
+ imageFileset.setSourcePath(fileTrees.append("misc"));
+ imageFileset.setIncludesPattern("**/*.gif,**/*.png,**/*.xml");
+ images.addChild(imageFileset);
+
+ ((ArchiveNodeImpl)root).clearDelta();
+ return root;
+ }
+
+ public void testFindAllDescendentFilesets() {
+ IArchiveFileSet[] fsets = ModelUtil.findAllDescendentFilesets(rootArchive);
+ assertTrue(fsets.length == 2);
+ assertTrue(fsets[0].getParent().getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER);
+ assertTrue(fsets[1].getParent().getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER);
+ assertTrue(ModelUtil.findAllDescendentFilesets(ArchiveNodeFactory.createFileset()).length == 1);
+ }
+
+ public void testFindAllDescendentFolders() {
+ IArchiveFolder[] folders = ModelUtil.findAllDescendentFolders(rootArchive);
+ assertTrue(folders.length == 3);
+ }
+
+ public void testFindAllDescendentsGeneric() {
+ assertTrue(ModelUtil.findAllDescendents(rootArchive, IArchiveNode.TYPE_ARCHIVE, false).size() == 0);
+ assertTrue(ModelUtil.findAllDescendents(rootArchive, IArchiveNode.TYPE_ARCHIVE, true).size() == 1);
+ assertTrue(ModelUtil.findAllDescendents(rootArchive, IArchiveNode.TYPE_ARCHIVE_FOLDER, false).size() == 3);
+ assertTrue(ModelUtil.findAllDescendents(rootArchive, IArchiveNode.TYPE_ARCHIVE_FILESET, false).size() == 2);
+ }
+
+ public void testGetMatchingFileSets() {
+ IPath misc = inputs.append("fileTrees").append("misc");
+ IPath gif = misc.append("multiple_files.gif");
+ IPath xml = misc.append("rug.xml");
+ IPath html = misc.append("someHtml.html");
+
+ IArchiveFileSet[] gifFS = ModelUtil.getMatchingFilesets(rootArchive, gif);
+ IArchiveFileSet[] xmlFS = ModelUtil.getMatchingFilesets(rootArchive, xml);
+ IArchiveFileSet[] htmlFS = ModelUtil.getMatchingFilesets(rootArchive, html);
+
+ assertEquals(1, gifFS.length);
+ assertEquals(2, xmlFS.length);
+ assertEquals(1, htmlFS.length);
+
+ }
+
+ public void testOtherFilesetMatchesPath() throws ArchivesModelException {
+ IPath xml = inputs.append("fileTrees").append("misc").append("rug.xml");
+ IArchiveFileSet[] xmlFS = ModelUtil.getMatchingFilesets(rootArchive, xml);
+ assertTrue(xmlFS.length == 2);
+ assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[0], xml, rootArchive));
+ assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[1], xml, rootArchive));
+
+ IPath html = inputs.append("fileTrees").append("misc").append("someHtml.html");
+ IArchiveFileSet[] htmlFS = ModelUtil.getMatchingFilesets(rootArchive, html);
+ assertTrue(htmlFS.length == 1);
+ assertFalse(ModelUtil.otherFilesetMatchesPathAndOutputLocation(htmlFS[0], html, rootArchive));
+
+ // add a temporary fileset that will match exactly
+ IArchiveFileSet otherFS = ArchiveNodeFactory.createFileset();
+ otherFS.setIncludesPattern(xmlFS[0].getIncludesPattern());
+ otherFS.setInWorkspace(xmlFS[0].isInWorkspace());
+ otherFS.setSourcePath(xmlFS[0].getSourcePath());
+ xmlFS[0].getParent().addChild(otherFS);
+
+ assertTrue(ModelUtil.otherFilesetMatchesPathAndOutputLocation(xmlFS[0], xml, rootArchive));
+ }
+}
16 years, 1 month
JBoss Tools SVN: r7140 - trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-26 19:37:42 -0400 (Wed, 26 Mar 2008)
New Revision: 7140
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java
Log:
Fixing a unit test
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java 2008-03-26 22:57:08 UTC (rev 7139)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveModelNode.java 2008-03-26 23:37:42 UTC (rev 7140)
@@ -173,15 +173,19 @@
ArrayList<IPath> list = new ArrayList<IPath>();
IArchiveNode[] children = getChildren(IArchiveNode.TYPE_ARCHIVE);
IArchive child;
+ IPath p;
for( int i = 0; i < children.length; i++ ) {
child = (IArchive)children[i];
- if( child.getGlobalDestinationPath() != null ) {
- IPath p = child.getGlobalDestinationPath().append(child.getName());
- if( list.contains(p))
- return false;
- else
- list.add(p);
- }
+
+ if( child.getGlobalDestinationPath() != null )
+ p = child.getGlobalDestinationPath().append(child.getName());
+ else
+ p = child.getDestinationPath().append(child.getName());
+
+ if( list.contains(p))
+ return false;
+ else
+ list.add(p);
}
return super.validateModel();
16 years, 1 month
JBoss Tools SVN: r7139 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-03-26 18:57:08 -0400 (Wed, 26 Mar 2008)
New Revision: 7139
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
Log:
Removing warnings
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java 2008-03-26 22:55:15 UTC (rev 7138)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IPollerFailureHandler.java 2008-03-26 22:57:08 UTC (rev 7139)
@@ -28,6 +28,6 @@
*
*/
public interface IPollerFailureHandler {
- public boolean accepts(IServerStatePoller poller, String action, List requiredProperties);
- public void handle(IServerStatePoller poller, String action, List requiredProperties);
+ public boolean accepts(IServerStatePoller poller, String action, List<String> requiredProperties);
+ public void handle(IServerStatePoller poller, String action, List<String> requiredProperties);
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-03-26 22:55:15 UTC (rev 7138)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/IServerStatePoller.java 2008-03-26 22:57:08 UTC (rev 7139)
@@ -51,7 +51,7 @@
public boolean getState() throws PollingException, RequiresInfoException;
public void cleanup(); // clean up any resources / processes. Will ALWAYS be called
- public List getRequiredProperties();
+ public List<String> getRequiredProperties();
public void failureHandled(Properties properties);
/**
@@ -61,10 +61,12 @@
public void cancel(int type);
public class PollingException extends Exception {
+ private static final long serialVersionUID = -7830978018908940551L;
public PollingException(String message) {super(message);}
}
public class RequiresInfoException extends Exception {
+ private static final long serialVersionUID = 5050044329807740335L;
private boolean checked = false;
public RequiresInfoException(String msg) {super(msg);}
public void setChecked() { this.checked = true; }
16 years, 1 month