JBoss Tools SVN: r10753 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2008-10-08 14:37:02 -0400 (Wed, 08 Oct 2008)
New Revision: 10753
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplate.java
Log:
Bug fix https://jira.jboss.org/jira/browse/JBIDE-2856 .
Now attributes style and styleClass are not applied for popup menu, selection items and input.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplate.java 2008-10-08 17:35:10 UTC (rev 10752)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesComboBoxTemplate.java 2008-10-08 18:37:02 UTC (rev 10753)
@@ -183,9 +183,12 @@
final nsIDOMElement rootDiv = visualDocument.createElement(HTML.TAG_DIV);
//Fix https://jira.jboss.org/jira/browse/JBIDE-2430 issue with resizement.
- rootDiv.setAttribute(HTML.ATTR_STYLE, HTML.STYLE_PARAMETER_WIDTH+Constants.COLON+sourceWidth);
+ rootDiv.setAttribute(HTML.ATTR_STYLE, HTML.STYLE_PARAMETER_WIDTH+Constants.COLON+sourceWidth);
+ final nsIDOMElement comboBoxDiv = visualDocument.createElement(HTML.TAG_DIV);
final nsIDOMElement secondDiv = visualDocument.createElement(HTML.TAG_DIV);
- secondDiv.setAttribute(HTML.ATTR_ALIGN, this.sourceAlign);
+ comboBoxDiv.setAttribute(HTML.ATTR_ALIGN, this.sourceAlign); //$NON-NLS-1$
+ secondDiv.setAttribute(HTML.ATTR_ALIGN, this.sourceAlign);
+ //comboBoxDiv.setAttribute(HTML.ATTR_CLASS, styleClasess.get("secondDiv")); //$NON-NLS-1$
secondDiv.setAttribute(HTML.ATTR_CLASS, styleClasess.get("secondDiv")); //$NON-NLS-1$
String secondDivSubStyle = "; position: {0}; z-index: {1} ;"; //$NON-NLS-1$
if (isToggle) {
@@ -194,6 +197,8 @@
secondDivSubStyle = MessageFormat.format(secondDivSubStyle, "static", "0"); //$NON-NLS-1$ //$NON-NLS-2$
}
// TODO add ATTR_STYLE.
+ comboBoxDiv.setAttribute(HTML.ATTR_STYLE, HTML.STYLE_PARAMETER_WIDTH + Constants.COLON + this.sourceListWidth
+ + Constants.SEMICOLON + secondDivSubStyle);
secondDiv.setAttribute(HTML.ATTR_STYLE, HTML.STYLE_PARAMETER_WIDTH + Constants.COLON + this.sourceListWidth
+ Constants.SEMICOLON + secondDivSubStyle + sourceStyle);
final nsIDOMElement thirdDiv = visualDocument.createElement(HTML.TAG_DIV);
@@ -248,11 +253,12 @@
+ calculateWithForDiv(this.sourceWidth, 10));
forthEmptyDiv.appendChild(visualDocument.createTextNode("Struts")); //$NON-NLS-1$
- rootDiv.appendChild(secondDiv);
+ rootDiv.appendChild(comboBoxDiv);
+ comboBoxDiv.appendChild(secondDiv);
secondDiv.appendChild(thirdDiv);
if (isToggle) {
- secondDiv.appendChild(createToogleDiv(pageContext, source, visualDocument));
+ comboBoxDiv.appendChild(createToogleDiv(pageContext, source, visualDocument));
}
thirdDiv.appendChild(firstInput);
thirdDiv.appendChild(secondInput);
16 years, 3 months
JBoss Tools SVN: r10752 - in trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test: src/org/jboss/tools/jsf/text/ext and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-10-08 13:35:10 -0400 (Wed, 08 Oct 2008)
New Revision: 10752
Added:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/
Removed:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/tests/
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/ELExprPartitionerTest.java
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java
Log:
Package name changed for jst.text.ext tests to exclude from coverage report
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF 2008-10-08 15:40:46 UTC (rev 10751)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/META-INF/MANIFEST.MF 2008-10-08 17:35:10 UTC (rev 10752)
@@ -19,5 +19,5 @@
org.jboss.tools.tests
Eclipse-LazyStart: true
Bundle-Vendor: Red Hat, Inc.
-Export-Package: org.jboss.tools.jsf.text.ext.tests
+Export-Package: org.jboss.tools.jsf.text.ext.test
Bundle-ClassPath: jsf-text-ext-tests.jar
Copied: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test (from rev 8499, trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/tests)
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/ELExprPartitionerTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/tests/ELExprPartitionerTest.java 2008-06-02 14:43:15 UTC (rev 8499)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/ELExprPartitionerTest.java 2008-10-08 17:35:10 UTC (rev 10752)
@@ -8,7 +8,7 @@
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
******************************************************************************/
-package org.jboss.tools.jsf.text.ext.tests;
+package org.jboss.tools.jsf.text.ext.test;
import java.util.ArrayList;
import java.util.HashMap;
Modified: trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/tests/JsfTextExtAllTests.java 2008-06-02 14:43:15 UTC (rev 8499)
+++ trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java 2008-10-08 17:35:10 UTC (rev 10752)
@@ -8,7 +8,7 @@
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
******************************************************************************/
-package org.jboss.tools.jsf.text.ext.tests;
+package org.jboss.tools.jsf.text.ext.test;
import junit.framework.Test;
import junit.framework.TestSuite;
16 years, 3 months
JBoss Tools SVN: r10751 - trunk/examples/features/org.jboss.tools.project.examples.feature.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-10-08 11:40:46 -0400 (Wed, 08 Oct 2008)
New Revision: 10751
Added:
trunk/examples/features/org.jboss.tools.project.examples.feature/.project
trunk/examples/features/org.jboss.tools.project.examples.feature/build.properties
trunk/examples/features/org.jboss.tools.project.examples.feature/feature.properties
trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml
Log:
Initial import.
Added: trunk/examples/features/org.jboss.tools.project.examples.feature/.project
===================================================================
--- trunk/examples/features/org.jboss.tools.project.examples.feature/.project (rev 0)
+++ trunk/examples/features/org.jboss.tools.project.examples.feature/.project 2008-10-08 15:40:46 UTC (rev 10751)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.project.examples.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
Added: trunk/examples/features/org.jboss.tools.project.examples.feature/build.properties
===================================================================
--- trunk/examples/features/org.jboss.tools.project.examples.feature/build.properties (rev 0)
+++ trunk/examples/features/org.jboss.tools.project.examples.feature/build.properties 2008-10-08 15:40:46 UTC (rev 10751)
@@ -0,0 +1,2 @@
+bin.includes = feature.xml,\
+ feature.properties
Added: trunk/examples/features/org.jboss.tools.project.examples.feature/feature.properties
===================================================================
Added: trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml
===================================================================
--- trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml (rev 0)
+++ trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml 2008-10-08 15:40:46 UTC (rev 10751)
@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.jboss.tools.project.examples.feature"
+ label="Project Examples"
+ version="1.0.0"
+ provider-name="Red Hat, Inc."
+ plugin="org.jboss.tools.project.examples">
+
+ <description url="http://www.example.com/description">
+ Project Examples
+ </description>
+
+ <copyright>
+ Copyright (c) 2008 Red Hat, Inc.
+Distributed under license by Red Hat, Inc. All rights reserved.
+This program is made available under the terms of the
+Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+Contributors:
+Red Hat, Inc. - initial API and implementation
+ </copyright>
+
+ <license url="http://www.eclipse.org/legal/epl-v10.html">
+ Eclipse Public License - v 1.0
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS
+ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+OF THIS AGREEMENT.
+1. DEFINITIONS
+"Contribution" means:
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+i) changes to the Program, and
+ii) additions to the Program;
+where such changes and/or additions to the Program originate
+from and are distributed by that particular Contributor. A Contribution
+'originates' from a Contributor if it was added to the Program
+by such Contributor itself or anyone acting on such Contributor's
+behalf. Contributions do not include additions to the Program
+which: (i) are separate modules of software distributed in conjunction
+with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.
+"Contributor" means any person or entity that distributes the
+Program.
+"Licensed Patents " mean patent claims licensable by a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+"Program" means the Contributions distributed in accordance with
+this Agreement.
+"Recipient" means anyone who receives the Program under this
+Agreement, including all Contributors.
+2. GRANT OF RIGHTS
+a) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free copyright
+license to reproduce, prepare derivative works of, publicly display,
+publicly perform, distribute and sublicense the Contribution
+of such Contributor, if any, and such derivative works, in source
+code and object code form.
+b) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free patent
+license under Licensed Patents to make, use, sell, offer to sell,
+import and otherwise transfer the Contribution of such Contributor,
+if any, in source code and object code form. This patent license
+shall apply to the combination of the Contribution and the Program
+if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to
+be covered by the Licensed Patents. The patent license shall
+not apply to any other combinations which include the Contribution.
+No hardware per se is licensed hereunder.
+c) Recipient understands that although each Contributor grants
+the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe
+the patent or other intellectual property rights of any other
+entity. Each Contributor disclaims any liability to Recipient
+for claims brought by any other entity based on infringement
+of intellectual property rights or otherwise. As a condition
+to exercising the rights and licenses granted hereunder, each
+Recipient hereby assumes sole responsibility to secure any other
+intellectual property rights needed, if any. For example, if
+a third party patent license is required to allow Recipient to
+distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright
+license set forth in this Agreement.
+3. REQUIREMENTS
+A Contributor may choose to distribute the Program in object
+code form under its own license agreement, provided that:
+a) it complies with the terms and conditions of this Agreement;
+and
+b) its license agreement:
+i) effectively disclaims on behalf of all Contributors all warranties
+and conditions, express and implied, including warranties or
+conditions of title and non-infringement, and implied warranties
+or conditions of merchantability and fitness for a particular
+purpose;
+ii) effectively excludes on behalf of all Contributors all liability
+for damages, including direct, indirect, special, incidental
+and consequential damages, such as lost profits;
+iii) states that any provisions which differ from this Agreement
+are offered by that Contributor alone and not by any other party;
+and
+iv) states that source code for the Program is available from
+such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for
+software exchange.
+When the Program is made available in source code form:
+a) it must be made available under this Agreement; and
+b) a copy of this Agreement must be included with each copy of
+the Program.
+Contributors may not remove or alter any copyright notices contained
+within the Program.
+Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.
+4. COMMERCIAL DISTRIBUTION
+Commercial distributors of software may accept certain responsibilities
+with respect to end users, business partners and the like. While
+this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any
+losses, damages and costs (collectively "Losses") arising from
+claims, lawsuits and other legal actions brought by a third party
+against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection
+with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any
+claims or Losses relating to any actual or alleged intellectual
+property infringement. In order to qualify, an Indemnified Contributor
+must: a) promptly notify the Commercial Contributor in writing
+of such claim, and b) allow the Commercial Contributor to control,
+and cooperate with the Commercial Contributor in, the defense
+and any related settlement negotiations. The Indemnified Contributor
+may participate in any such claim at its own expense.
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have
+to defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any
+other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+5. NO WARRANTY
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM
+IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with
+its exercise of rights under this Agreement , including but not
+limited to the risks and costs of program errors, compliance
+with applicable laws, damage to or loss of data, programs or
+equipment, and unavailability or interruption of operations.
+6. DISCLAIMER OF LIABILITY
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE
+OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGES.
+7. GENERAL
+If any provision of this Agreement is invalid or unenforceable
+under applicable law, it shall not affect the validity or enforceability
+of the remainder of the terms of this Agreement, and without
+further action by the parties hereto, such provision shall be
+reformed to the minimum extent necessary to make such provision
+valid and enforceable.
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging
+that the Program itself (excluding combinations of the Program
+with other software or hardware) infringes such Recipient's patent(s),
+then such Recipient's rights granted under Section 2(b) shall
+terminate as of the date such litigation is filed.
+All Recipient's rights under this Agreement shall terminate if
+it fails to comply with any of the material terms or conditions
+of this Agreement and does not cure such failure in a reasonable
+period of time after becoming aware of such noncompliance. If
+all Recipient's rights under this Agreement terminate, Recipient
+agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under
+this Agreement and any licenses granted by Recipient relating
+to the Program shall continue and survive.
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted
+and may only be modified in the following manner. The Agreement
+Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other
+than the Agreement Steward has the right to modify this Agreement.
+The Eclipse Foundation is the initial Agreement Steward. The
+Eclipse Foundation may assign the responsibility to serve as
+the Agreement Steward to a suitable separate entity. Each new
+version of the Agreement will be given a distinguishing version
+number. The Program (including Contributions) may always be distributed
+subject to the version of the Agreement under which it was received.
+In addition, after a new version of the Agreement is published,
+Contributor may elect to distribute the Program (including its
+Contributions) under the new version. Except as expressly stated
+in Sections 2(a) and 2(b) above, Recipient receives no rights
+or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under
+this Agreement are reserved.
+This Agreement is governed by the laws of the State of New York
+and the intellectual property laws of the United States of America.
+No party to this Agreement will bring a legal action under this
+Agreement more than one year after the cause of action arose.
+Each party waives its rights to a jury trial in any resulting
+litigation.
+ </license>
+
+ <url>
+ <update label="JBossTools Update Site" url="http://download.jboss.org/jbosstools/updates/stable"/>
+ </url>
+
+
+
+ <plugin
+ id="org.jboss.tools.project.examples"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
16 years, 3 months
JBoss Tools SVN: r10750 - trunk/examples/features.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-10-08 11:40:28 -0400 (Wed, 08 Oct 2008)
New Revision: 10750
Added:
trunk/examples/features/org.jboss.tools.project.examples.feature/
Log:
Initial import.
16 years, 3 months
JBoss Tools SVN: r10749 - in trunk/examples/plugins/org.jboss.tools.project.examples: META-INF and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-10-08 11:39:37 -0400 (Wed, 08 Oct 2008)
New Revision: 10749
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/.classpath
trunk/examples/plugins/org.jboss.tools.project.examples/.project
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.project.examples/about.html
trunk/examples/plugins/org.jboss.tools.project.examples/about.ini
trunk/examples/plugins/org.jboss.tools.project.examples/about.mappings
trunk/examples/plugins/org.jboss.tools.project.examples/about.properties
trunk/examples/plugins/org.jboss.tools.project.examples/build.properties
trunk/examples/plugins/org.jboss.tools.project.examples/icons/
trunk/examples/plugins/org.jboss.tools.project.examples/icons/examples_wiz.gif
trunk/examples/plugins/org.jboss.tools.project.examples/icons/new_wiz.gif
trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
trunk/examples/plugins/org.jboss.tools.project.examples/projectExamples.xml
trunk/examples/plugins/org.jboss.tools.project.examples/rhds_wiz.png
trunk/examples/plugins/org.jboss.tools.project.examples/src/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Category.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
Log:
Initial import.
Added: trunk/examples/plugins/org.jboss.tools.project.examples/.classpath
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/.classpath (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/.classpath 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/examples/plugins/org.jboss.tools.project.examples/.project
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/.project (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/.project 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.project.examples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Project Examples
+Bundle-SymbolicName: org.jboss.tools.project.examples;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.project.examples.ProjectExamplesActivator
+Bundle-Vendor: Red Hat, inc
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.jface,
+ org.eclipse.osgi,
+ org.eclipse.ecf,
+ org.eclipse.ecf.filetransfer,
+ org.eclipse.equinox.common,
+ org.eclipse.ecf.provider.filetransfer,
+ org.eclipse.equinox.security,
+ org.eclipse.equinox.p2.engine,
+ org.eclipse.equinox.p2.core,
+ org.eclipse.ui.ide
+Bundle-ActivationPolicy: lazy
Added: trunk/examples/plugins/org.jboss.tools.project.examples/about.html
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/about.html (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/about.html 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Project Examples</title>
+<style type="text/css" media="screen">
+<!--
+ body {
+ font-family: Sans-serif, Arial, Helvetica;
+ }
+
+-->
+</style>
+</head>
+<body>
+<h1>JBoss Portlet</h1>
+
+<p>
+This plugin is part of the JBoss Tools developed by the <a href="http://www.jboss.com">JBoss Inc.</a>
+</p>
+
+<p>Information about this plugin is available at <a href="http://www.jboss.org/tools">JBoss Tools project page</a></p>
+
+<p>
+This software is distributed under the terms of the Eclipse Public License - v 1.0
+(see <a href="www.eclipse.org/legal/epl-v10.html">Eclipse Public License - Version 1.0</a>).
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/examples/plugins/org.jboss.tools.project.examples/about.ini
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/about.ini (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/about.ini 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=rhds_wiz.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which the
+# welcome page is to be opened.
+# optional
+
+
+
Added: trunk/examples/plugins/org.jboss.tools.project.examples/about.mappings
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/about.mappings (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/about.mappings 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added: trunk/examples/plugins/org.jboss.tools.project.examples/about.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/about.properties (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/about.properties 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,2 @@
+blurb=JBoss Project Examples\n\nVersion\: {featureVersion}\n\n(c) Copyright JBoss Inc. contributors and others 2004 - 2008. All rights reserved.\nVisit http\://jboss.org/tools
+
Added: trunk/examples/plugins/org.jboss.tools.project.examples/build.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/build.properties (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/build.properties 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ projectExamples.xml
Added: trunk/examples/plugins/org.jboss.tools.project.examples/icons/examples_wiz.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/plugins/org.jboss.tools.project.examples/icons/examples_wiz.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/plugins/org.jboss.tools.project.examples/icons/new_wiz.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/plugins/org.jboss.tools.project.examples/icons/new_wiz.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/plugin.xml 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension point="org.eclipse.ui.newWizards">
+ <category
+ name="JBoss Tools"
+ id="org.jboss.ide.eclipse.ui.wizards">
+ </category>
+ <wizard
+ id="org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard"
+ name="Project Examples"
+ class="org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard"
+ category="org.jboss.ide.eclipse.ui.wizards"
+ icon="icons/examples_wiz.gif">
+ </wizard>
+ </extension>
+</plugin>
Added: trunk/examples/plugins/org.jboss.tools.project.examples/projectExamples.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/projectExamples.xml (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/projectExamples.xml 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,46 @@
+<projects>
+ <project>
+ <category>Seam</category>
+ <name>dvdstore</name>
+ <shortDescription>Seam DVD Store Example</shortDescription>
+ <description>This example demonstrates the use of Seam with jBPM pageflow and business process management. It runs on JBoss AS and Tomcat.</description>
+ <size>10000000</size>
+ <url>
+ http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/seam-examples/...
+ </url>
+ </project>
+
+ <project>
+ <category>Portlet</category>
+ <name>TestJavaPortlet</name>
+ <shortDescription>JBoss Java Portlet Example</shortDescription>
+ <description>This example demonstrates the use of JBoss Java Portlet. It runs on JBoss Portal 2.7.0.</description>
+ <size>10000</size>
+ <url>
+ http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/portlet-exampl...
+ </url>
+ </project>
+
+ <project>
+ <category>Portlet</category>
+ <name>TestJSFPortlet</name>
+ <shortDescription>JBoss JSF Portlet Example</shortDescription>
+ <description>This example demonstrates the use of JBoss JSF Portlet. It runs on JBoss Portal 2.7.0.</description>
+ <size>4000000</size>
+ <url>
+ http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/portlet-exampl...
+ </url>
+ </project>
+
+ <project>
+ <category>Portlet</category>
+ <name>TestSeamPortlet</name>
+ <shortDescription>JBoss Seam Portlet Example</shortDescription>
+ <description>This example demonstrates the use of JBoss Seam Portlet. It runs on JBoss Portal 2.7.0.</description>
+ <size>10000000</size>
+ <url>
+ http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/portlet-exampl...
+ </url>
+ </project>
+
+</projects>
\ No newline at end of file
Added: trunk/examples/plugins/org.jboss.tools.project.examples/rhds_wiz.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/plugins/org.jboss.tools.project.examples/rhds_wiz.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/ProjectExamplesActivator.java 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,72 @@
+package org.jboss.tools.project.examples;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ProjectExamplesActivator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.project.examples";
+
+ // The shared instance
+ private static ProjectExamplesActivator plugin;
+
+ private static BundleContext context;
+
+ /**
+ * The constructor
+ */
+ public ProjectExamplesActivator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ this.context = context;
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ context = null;
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ProjectExamplesActivator getDefault() {
+ return plugin;
+ }
+
+ public static void log(Throwable e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e
+ .getLocalizedMessage(), e);
+ ProjectExamplesActivator.getDefault().getLog().log(status);
+ }
+
+ public static BundleContext getBundleContext() {
+ return context;
+ }
+
+}
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,435 @@
+package org.jboss.tools.project.examples.filetransfer;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLEncoder;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.security.ConnectContextFactory;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.filetransfer.IFileTransferListener;
+import org.eclipse.ecf.filetransfer.IIncomingFileTransfer;
+import org.eclipse.ecf.filetransfer.IRemoteFile;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemBrowserContainerAdapter;
+import org.eclipse.ecf.filetransfer.IRemoteFileSystemListener;
+import org.eclipse.ecf.filetransfer.IRetrieveFileTransferContainerAdapter;
+import org.eclipse.ecf.filetransfer.IncomingFileTransferException;
+import org.eclipse.ecf.filetransfer.RemoteFileSystemException;
+import org.eclipse.ecf.filetransfer.UserCancelledException;
+import org.eclipse.ecf.filetransfer.events.IFileTransferEvent;
+import org.eclipse.ecf.filetransfer.events.IIncomingFileTransferReceiveDataEvent;
+import org.eclipse.ecf.filetransfer.events.IIncomingFileTransferReceiveDoneEvent;
+import org.eclipse.ecf.filetransfer.events.IIncomingFileTransferReceiveStartEvent;
+import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemBrowseEvent;
+import org.eclipse.ecf.filetransfer.events.IRemoteFileSystemEvent;
+import org.eclipse.ecf.filetransfer.identity.FileCreateException;
+import org.eclipse.ecf.filetransfer.identity.FileIDFactory;
+import org.eclipse.ecf.filetransfer.service.IRetrieveFileTransferFactory;
+import org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer;
+import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI.AuthenticationInfo;
+import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.equinox.security.storage.StorageException;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author snjeza
+ * based on org.eclipse.equinox.internal.p2.updatesite.ECFTransport
+ *
+ */
+public class ECFExamplesTransport {
+
+ /**
+ * The number of password retry attempts allowed before failing.
+ */
+ private static final int LOGIN_RETRIES = 3;
+ private static final ProtocolException ERROR_401 = new ProtocolException();
+ private static final String SERVER_REDIRECT = "Server redirected too many times";
+
+ private static ECFExamplesTransport INSTANCE;
+ private ServiceTracker retrievalFactoryTracker;
+
+ /**
+ * A job that waits on a barrier.
+ */
+ static class WaitJob extends Job {
+ private final Object[] barrier;
+
+ /**
+ * Creates a wait job.
+ * @param location A location string that is used in the job name
+ * @param barrier The job will wait until the first entry in the barrier is non-null
+ */
+ WaitJob(String location, Object[] barrier) {
+ super("Loading");
+ this.barrier = barrier;
+ setSystem(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ synchronized (barrier) {
+ while (barrier[0] == null) {
+ try {
+ barrier.wait();
+ } catch (InterruptedException e) {
+ //ignore
+ }
+ }
+ }
+ return Status.OK_STATUS;
+ }
+ }
+
+ /**
+ * Private to avoid client instantiation.
+ */
+ private ECFExamplesTransport() {
+ retrievalFactoryTracker = new ServiceTracker(ProjectExamplesActivator.getBundleContext(), IRetrieveFileTransferFactory.class.getName(), null);
+ retrievalFactoryTracker.open();
+ }
+
+ /**
+ * Returns an initialized instance of ECFExamplesTransport
+ */
+ public static synchronized ECFExamplesTransport getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new ECFExamplesTransport();
+ }
+ return INSTANCE;
+ }
+
+ /**
+ * Gets the last modified date for the specified file.
+ * @param location - The URL location of the file.
+ * @return A <code>long</code> representing the date. Returns <code>0</code> if the file is not found or an error occurred.
+ * @exception OperationCanceledException if the request was canceled.
+ */
+ public long getLastModified(URL location) throws CoreException {
+ String locationString = location.toExternalForm();
+ try {
+ IConnectContext context = getConnectionContext(locationString, false);
+ for (int i = 0; i < LOGIN_RETRIES; i++) {
+ try {
+ return doGetLastModified(locationString, context);
+ } catch (ProtocolException e) {
+ if (ERROR_401 == e)
+ context = getConnectionContext(locationString, true);
+ } catch (Exception e) {
+ e.getMessage();
+ }
+ }
+ } catch (UserCancelledException e) {
+ throw new OperationCanceledException();
+ }
+ //too many retries, so report as failure
+ throw new CoreException(new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, "IO error", null));
+ }
+
+ /**
+ * Perform the ECF call to get the last modified time, failing if there is any
+ * protocol failure such as an authentication failure.
+ */
+ private long doGetLastModified(String location, IConnectContext context) throws ProtocolException {
+ IContainer container;
+ try {
+ container = ContainerFactory.getDefault().createContainer();
+ } catch (ContainerCreateException e) {
+ return 0;
+ }
+ IRemoteFileSystemBrowserContainerAdapter adapter = (IRemoteFileSystemBrowserContainerAdapter) container.getAdapter(IRemoteFileSystemBrowserContainerAdapter.class);
+ if (adapter == null) {
+ return 0;
+ }
+ IRemoteFile remoteFile = checkFile(adapter, location, context);
+ if (remoteFile == null) {
+ return 0;
+ }
+ return remoteFile.getInfo().getLastModified();
+ }
+
+ /**
+ * Downloads the contents of the given URL to the given output stream. The
+ * destination stream will be closed by this method whether it succeeds
+ * to download or not.
+ */
+ public IStatus download(String name,String url, OutputStream destination, IProgressMonitor monitor) {
+ try {
+ IConnectContext context = getConnectionContext(url, false);
+ for (int i = 0; i < LOGIN_RETRIES; i++) {
+ try {
+ return performDownload(name,url, destination, context, monitor);
+ } catch (ProtocolException e) {
+ if (e == ERROR_401)
+ context = getConnectionContext(url, true);
+ }
+ }
+ } catch (UserCancelledException e) {
+ return Status.CANCEL_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ } finally {
+ try {
+ destination.close();
+ } catch (IOException e) {
+ //ignore secondary failure
+ }
+ }
+ //reached maximum number of retries without success
+ return new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, "IO error", null);
+ }
+
+ public IStatus performDownload(String name,String toDownload, OutputStream target, IConnectContext context, IProgressMonitor monitor) throws ProtocolException {
+ IRetrieveFileTransferFactory factory = (IRetrieveFileTransferFactory) retrievalFactoryTracker.getService();
+ if (factory == null)
+ return new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, "IO error");
+
+ return transfer(name,factory.newInstance(), toDownload, target, context, monitor);
+ }
+
+ private IStatus transfer(final String name,final IRetrieveFileTransferContainerAdapter retrievalContainer, final String toDownload, final OutputStream target, IConnectContext context, final IProgressMonitor monitor) throws ProtocolException {
+ final IStatus[] result = new IStatus[1];
+ IFileTransferListener listener = new IFileTransferListener() {
+ private long transferStartTime;
+ protected int oldWorked;
+
+ public void handleTransferEvent(IFileTransferEvent event) {
+ if (event instanceof IIncomingFileTransferReceiveStartEvent) {
+ IIncomingFileTransferReceiveStartEvent rse = (IIncomingFileTransferReceiveStartEvent) event;
+ try {
+ if (target != null) {
+ rse.receive(target);
+ transferStartTime = System.currentTimeMillis();
+ }
+ if (monitor != null) {
+ long fileLength = rse.getSource().getFileLength();
+ final long totalWork = ((fileLength == -1) ? 100 : fileLength);
+ int work = (totalWork > Integer.MAX_VALUE) ? Integer.MAX_VALUE : (int) totalWork;
+ monitor.beginTask("Downloading " + name,work);
+ oldWorked=0;
+ }
+ } catch (IOException e) {
+ IStatus status = convertToStatus(e);
+ synchronized (result) {
+ result[0] = status;
+ result.notify();
+ }
+ }
+ }
+ if (event instanceof IIncomingFileTransferReceiveDataEvent) {
+ IIncomingFileTransfer source = ((IIncomingFileTransferReceiveDataEvent) event).getSource();
+ if (monitor != null) {
+ if (monitor.isCanceled()) {
+ source.cancel();
+ return;
+ }
+ long fileLength = source.getFileLength();
+ final long totalWork = ((fileLength == -1) ? 100 : fileLength);
+ double factor = (totalWork > Integer.MAX_VALUE) ? (((double) Integer.MAX_VALUE) / ((double) totalWork)) : 1.0;
+ long received = source.getBytesReceived();
+ int worked = (int) Math.round(factor * received);
+ double downloadRateBytesPerSecond = (received / ((System.currentTimeMillis() + 1 - transferStartTime) / 1000.0));
+
+ String rates = String.format(" (at %s/s)", AbstractRetrieveFileTransfer.toHumanReadableBytes(downloadRateBytesPerSecond));
+ String receivedString = AbstractRetrieveFileTransfer.toHumanReadableBytes(received);
+ String fileLengthString = AbstractRetrieveFileTransfer.toHumanReadableBytes(fileLength);
+ monitor.subTask(receivedString + " of " + fileLengthString + rates);
+ monitor.worked(worked-oldWorked);
+ oldWorked=worked;
+ }
+ }
+ if (event instanceof IIncomingFileTransferReceiveDoneEvent) {
+ Exception exception = ((IIncomingFileTransferReceiveDoneEvent) event).getException();
+ IStatus status = convertToStatus(exception);
+ synchronized (result) {
+ result[0] = status;
+ result.notify();
+ }
+ }
+ }
+ };
+
+ try {
+ retrievalContainer.setConnectContextForAuthentication(context);
+ retrievalContainer.sendRetrieveRequest(FileIDFactory.getDefault().createFileID(retrievalContainer.getRetrieveNamespace(), toDownload), listener, null);
+ } catch (IncomingFileTransferException e) {
+ IStatus status = e.getStatus();
+ Throwable exception = status.getException();
+ if (exception instanceof IOException) {
+ if (exception.getMessage() != null && (exception.getMessage().indexOf("401") != -1 || exception.getMessage().indexOf(SERVER_REDIRECT) != -1)) //$NON-NLS-1$
+ throw ERROR_401;
+ }
+ return status;
+ } catch (FileCreateException e) {
+ return e.getStatus();
+ }
+ waitFor(toDownload, result);
+ return result[0];
+ }
+
+ private IRemoteFile checkFile(final IRemoteFileSystemBrowserContainerAdapter retrievalContainer, final String location, IConnectContext context) throws ProtocolException {
+ final Object[] result = new Object[2];
+ final Object FAIL = new Object();
+ IRemoteFileSystemListener listener = new IRemoteFileSystemListener() {
+ public void handleRemoteFileEvent(IRemoteFileSystemEvent event) {
+ Exception exception = event.getException();
+ if (exception != null) {
+ synchronized (result) {
+ result[0] = FAIL;
+ result[1] = exception;
+ result.notify();
+ }
+ } else if (event instanceof IRemoteFileSystemBrowseEvent) {
+ IRemoteFileSystemBrowseEvent fsbe = (IRemoteFileSystemBrowseEvent) event;
+ IRemoteFile[] remoteFiles = fsbe.getRemoteFiles();
+ if (remoteFiles != null && remoteFiles.length > 0 && remoteFiles[0] != null) {
+ synchronized (result) {
+ result[0] = remoteFiles[0];
+ result.notify();
+ }
+ } else {
+ synchronized (result) {
+ result[0] = FAIL;
+ result.notify();
+ }
+ }
+ }
+ }
+ };
+ try {
+ retrievalContainer.setConnectContextForAuthentication(context);
+ retrievalContainer.sendBrowseRequest(FileIDFactory.getDefault().createFileID(retrievalContainer.getBrowseNamespace(), location), listener);
+ } catch (RemoteFileSystemException e) {
+ return null;
+ } catch (FileCreateException e) {
+ return null;
+ }
+ waitFor(location, result);
+ if (result[0] == FAIL && result[1] instanceof IOException) {
+ IOException ioException = (IOException) result[1];
+ //throw a special exception for authentication failure so we know to prompt for username/password
+ String message = ioException.getMessage();
+ if (message != null && (message.indexOf(" 401 ") != -1 || message.indexOf(SERVER_REDIRECT) != -1)) //$NON-NLS-1$
+ throw ERROR_401;
+ }
+ if (result[0] instanceof IRemoteFile)
+ return (IRemoteFile) result[0];
+ return null;
+ }
+
+
+ /**
+ * Returns the connection context for the given URL. This may prompt the
+ * user for user name and password as required.
+ *
+ * @param xmlLocation - the file location requiring login details
+ * @param prompt - use <code>true</code> to prompt the user instead of
+ * looking at the secure preference store for login, use <code>false</code>
+ * to only try the secure preference store
+ * @throws UserCancelledException when the user cancels the login prompt
+ * @throws CoreException if the password cannot be read or saved
+ * @return The connection context
+ */
+ public IConnectContext getConnectionContext(String xmlLocation, boolean prompt) throws UserCancelledException, CoreException {
+ ISecurePreferences securePreferences = SecurePreferencesFactory.getDefault();
+ IPath hostLocation = new Path(xmlLocation).removeLastSegments(1);
+ String nodeKey;
+ try {
+ nodeKey = URLEncoder.encode(hostLocation.toString(), "UTF-8"); //$NON-NLS-1$
+ } catch (UnsupportedEncodingException e2) {
+ //fall back to default platform encoding
+ nodeKey = URLEncoder.encode(hostLocation.toString());
+ }
+ String nodeName = IRepository.PREFERENCE_NODE + '/' + nodeKey;
+ ISecurePreferences prefNode = null;
+ if (securePreferences.nodeExists(nodeName))
+ prefNode = securePreferences.node(nodeName);
+ if (!prompt) {
+ if (prefNode == null)
+ return null;
+ try {
+ String username = prefNode.get(IRepository.PROP_USERNAME, null);
+ String password = prefNode.get(IRepository.PROP_PASSWORD, null);
+ //if we don't have stored connection data just return a null connection context
+ if (username == null || password == null)
+ return null;
+ return ConnectContextFactory.createUsernamePasswordConnectContext(username, password);
+ } catch (StorageException e) {
+ String msg = "Internal Error";
+ throw new CoreException(new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, msg, e));
+ }
+ }
+ //need to prompt user for user name and password
+ ServiceTracker adminUITracker = new ServiceTracker(ProjectExamplesActivator.getBundleContext(), IServiceUI.class.getName(), null);
+ adminUITracker.open();
+ IServiceUI adminUIService = (IServiceUI) adminUITracker.getService();
+ AuthenticationInfo loginDetails = null;
+ if (adminUIService != null)
+ loginDetails = adminUIService.getUsernamePassword(hostLocation.toString());
+ //null result means user canceled password dialog
+ if (loginDetails == null)
+ throw new UserCancelledException();
+ //save user name and password if requested by user
+ if (loginDetails.saveResult()) {
+ if (prefNode == null)
+ prefNode = securePreferences.node(nodeName);
+ try {
+ prefNode.put(IRepository.PROP_USERNAME, loginDetails.getUserName(), true);
+ prefNode.put(IRepository.PROP_PASSWORD, loginDetails.getPassword(), true);
+ prefNode.flush();
+ } catch (StorageException e1) {
+ String msg = "Internal error";
+ throw new CoreException(new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, msg, e1));
+ } catch (IOException e) {
+ String msg = "Internal error";
+ throw new CoreException(new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, msg, e));
+ }
+ }
+ return ConnectContextFactory.createUsernamePasswordConnectContext(loginDetails.getUserName(), loginDetails.getPassword());
+ }
+
+ private IStatus convertToStatus(Exception e) {
+ if (e == null)
+ return Status.OK_STATUS;
+ if (e instanceof UserCancelledException)
+ return new Status(IStatus.CANCEL, ProjectExamplesActivator.PLUGIN_ID, e.getMessage(), e);
+ return new Status(IStatus.ERROR, ProjectExamplesActivator.PLUGIN_ID, e.getMessage(), e);
+ }
+
+ /**
+ * Waits until the first entry in the given array is non-null.
+ */
+ private void waitFor(String location, Object[] barrier) {
+ WaitJob wait = new WaitJob(location, barrier);
+ wait.schedule();
+ while (barrier[0] == null) {
+ boolean logged = false;
+ try {
+ wait.join();
+ } catch (InterruptedException e) {
+ if (!logged)
+ LogHelper.log(new Status(IStatus.WARNING, ProjectExamplesActivator.PLUGIN_ID, "Unexpected interrupt while waiting on ECF transfer", e));
+ }
+ }
+ }
+}
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Category.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Category.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Category.java 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,72 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.project.examples.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author snjeza
+ *
+ */
+public class Category {
+
+ private String name;
+ private List<Project> projects = new ArrayList<Project>();
+ public static Category OTHER = new Category("Other");
+
+ public Category(String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Project> getProjects() {
+ return projects;
+ }
+
+ public void setProjects(List<Project> projects) {
+ this.projects = projects;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Category other = (Category) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/Project.java 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,98 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.project.examples.model;
+
+import java.math.BigDecimal;
+
+/**
+ * @author snjeza
+ *
+ */
+public class Project {
+
+ private String name;
+ private String shortDescription;
+ private String description;
+ private String url;
+ private long size;
+ private Category category;
+
+ public Project() {
+ name="";
+ shortDescription="";
+ description="";
+ url="";
+ setCategory(Category.OTHER);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getShortDescription() {
+ return shortDescription;
+ }
+
+ public void setShortDescription(String shortDescription) {
+ this.shortDescription = shortDescription;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public long getSize() {
+ return size;
+ }
+
+ public void setSize(long size) {
+ this.size = size;
+ }
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public void setCategory(Category category) {
+ this.category = category;
+ }
+
+ public String getSizeAsText() {
+ String sizeString = "";
+ BigDecimal sizeDecimal = new BigDecimal(size);
+ BigDecimal MB = new BigDecimal(1024*1024);
+ BigDecimal KB = new BigDecimal(1024);
+ if (sizeDecimal.compareTo(MB) > 0) {
+ sizeString = String.format("%5.2fM", sizeDecimal.divide(MB));
+ } else if (sizeDecimal.compareTo(KB) > 0) {
+ sizeString = String.format("%5.2fK", sizeDecimal.divide(KB));
+ } else {
+ sizeString = String.format("%d", size);
+ }
+ return sizeString;
+ }
+}
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/model/ProjectUtil.java 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,242 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.project.examples.model;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.filetransfer.ECFExamplesTransport;
+import org.osgi.framework.Bundle;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author snjeza
+ *
+ */
+public class ProjectUtil {
+
+ private final static String PROJECT_EXAMPLES_XML = "http://anonsvn.jboss.org/repos/jbosstools/workspace/examples/projectExamp...";
+ private static final String PROTOCOL_FILE = "file";
+
+ private ProjectUtil() {
+
+ }
+
+ public static List<Category> getTestProjects() {
+ Category seamCategory = new Category("Seam");
+ Project project = new Project();
+ project.setName("dvdstore");
+ project.setShortDescription("Seam DVD Store Example");
+ project
+ .setDescription("This example demonstrates the use of Seam with jBPM pageflow and business process management. It runs on JBoss AS and Tomcat.");
+ project.setSize(10000);
+ project
+ .setUrl("http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/portlet-exampl...");
+ project.setCategory(seamCategory);
+ seamCategory.getProjects().add(project);
+
+ Category portletCategory = new Category("Portlet");
+
+ project = new Project();
+ project.setName("TestJavaPortlet");
+ project.setShortDescription("JBoss Java Portlet Example");
+ project
+ .setDescription("This example demonstrates the use of JBoss Java Portlet. It runs on JBoss Portal 2.7.0");
+ project.setSize(10000);
+ project
+ .setUrl("http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/portlet-exampl...");
+ project.setCategory(portletCategory);
+ portletCategory.getProjects().add(project);
+
+ project = new Project();
+ project.setName("TestJSFPortlet");
+ project.setShortDescription("JBoss JSF Portlet Example");
+ project
+ .setDescription("This example demonstrates the use of JBoss JSF Portlet. It runs on JBoss Portal 2.7.0");
+ project.setSize(4000000);
+ project
+ .setUrl("http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/portlet-exampl...");
+ project.setCategory(portletCategory);
+ portletCategory.getProjects().add(project);
+
+ project = new Project();
+ project.setName("TestSeamPortlet");
+ project.setShortDescription("JBoss Seam Portlet Example");
+ project
+ .setDescription("This example demonstrates the use of JBoss Seam Portlet. It runs on JBoss Portal 2.7.0");
+ project.setSize(10000000);
+ project
+ .setUrl("http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/portlet-exampl...");
+ project.setCategory(portletCategory);
+ portletCategory.getProjects().add(project);
+
+ Category otherCategory = new Category("Other");
+
+ List<Category> list = new ArrayList<Category>();
+ list.add(seamCategory);
+ list.add(portletCategory);
+ list.add(otherCategory);
+
+ return list;
+ }
+
+ public static List<Category> getProjects() {
+ List<Category> list = new ArrayList<Category>();
+ Category other = Category.OTHER;
+ try {
+ // TODO add a progress monitor
+ File file = getProjectExamplesFile(PROJECT_EXAMPLES_XML,"projectExamples", ".xml",null);
+ if (file.exists() && file.isFile()) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(file);
+ NodeList projects = doc.getElementsByTagName("project");
+ int len = projects.getLength();
+ for (int i = 0; i < len; i++) {
+ Node node = projects.item(i);
+ Project project = new Project();
+ Category category = other;
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) node;
+ NodeList children = element.getChildNodes();
+ int cLen = children.getLength();
+ for (int j = 0; j < cLen; j++) {
+ Node cNode = children.item(j);
+ if (cNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element child = (Element) cNode;
+ String nodeName = child.getNodeName();
+ if (nodeName.equals("category")) {
+ String value = getContent(child);
+ boolean found = false;
+ for (Category cat:list) {
+ if (cat.getName().equals(value)) {
+ category=cat;
+ found=true;
+ break;
+ }
+ }
+ if (!found) {
+ category = new Category(value);
+ list.add(category);
+ }
+ project.setCategory(category);
+ }
+ if (nodeName.equals("name")) {
+ project.setName(getContent(child));
+ }
+ if (nodeName.equals("shortDescription")) {
+ project.setShortDescription(getContent(child));
+ }
+ if (nodeName.equals("description")) {
+ project.setDescription(getContent(child));
+ }
+ if (nodeName.equals("url")) {
+ project.setUrl(getContent(child));
+ }
+ if (nodeName.equals("size")) {
+ long size = 0;
+ try {
+ size = new Long(getContent(child));
+ } catch (Exception ignored) {
+ }
+ project.setSize(size);
+ }
+ }
+ }
+ }
+ category.getProjects().add(project);
+ }
+ }
+ } catch (Exception e) {
+ ProjectExamplesActivator.log(e);
+ }
+ list.add(other);
+ return list;
+ }
+
+ private static String getContent(Element child) {
+ String value = child.getTextContent();
+ if (value == null) {
+ value="";
+ }
+ return value.trim();
+ }
+
+ private static File getProjectExamplesXmlTest() throws Exception {
+ Bundle bundle = Platform.getBundle(ProjectExamplesActivator.PLUGIN_ID);
+ URL examplesURL = bundle.getEntry("/projectExamples.xml");
+ URL url = FileLocator.resolve(examplesURL);
+ File file = new File(FileLocator.toFileURL(url).getFile());
+ return file;
+ }
+
+ public static File getProjectExamplesFile(String urlString,String prefix, String suffix, IProgressMonitor monitor) {
+ URL url;
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ ProjectExamplesActivator.log(e);
+ return null;
+ }
+ File file = null;
+ if (PROTOCOL_FILE.equals(url.getProtocol())) {
+ try {
+ //assume all illegal characters have been properly encoded, so use URI class to unencode
+ file = new File(new URI(url.toExternalForm()));
+ } catch (Exception e) {
+ //URL contains unencoded characters
+ file = new File(url.getFile());
+ }
+ if (!file.exists())
+ return null;
+ } else {
+ try {
+ file = File.createTempFile(prefix,suffix);
+ file.deleteOnExit();
+ BufferedOutputStream destination = new BufferedOutputStream(new FileOutputStream(file));
+ IStatus result = getTransport().download(prefix,url.toExternalForm(), destination, monitor);
+ if (!result.isOK())
+ return null;
+ } catch (FileNotFoundException e) {
+ ProjectExamplesActivator.log(e);
+ return null;
+ } catch (IOException e) {
+ ProjectExamplesActivator.log(e);
+ return null;
+ }
+ }
+ return file;
+ }
+
+ private static ECFExamplesTransport getTransport() {
+ return ECFExamplesTransport.getInstance();
+ }
+}
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,173 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.project.examples.wizard;
+
+/**
+ * @author snjeza
+ *
+ */
+import java.io.File;
+import java.util.zip.ZipFile;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.IOverwriteQuery;
+import org.eclipse.ui.wizards.datatransfer.ImportOperation;
+import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.Project;
+import org.jboss.tools.project.examples.model.ProjectUtil;
+
+public class NewProjectExamplesWizard extends Wizard implements INewWizard {
+
+ private static final IOverwriteQuery OVERWRITE_ALL_QUERY = new IOverwriteQuery() {
+ public String queryOverwrite(String pathString) {
+ return IOverwriteQuery.ALL;
+ }
+ };
+
+ /**
+ * The workbench.
+ */
+ private IWorkbench workbench;
+
+ /**
+ * The current selection.
+ */
+ private IStructuredSelection selection;
+
+ private NewProjectExamplesWizardPage page;
+
+ protected boolean overwrite;
+
+ public NewProjectExamplesWizard() {
+ super();
+ setWindowTitle("New Project Example");
+
+ }
+
+ /**
+ * Creates an empty wizard for creating a new resource in the workspace.
+ */
+
+ @Override
+ public boolean performFinish() {
+ final Project project = page.getSelectedProject();
+ if (project == null) {
+ return false;
+ }
+ WorkspaceJob job = new WorkspaceJob("Downloading...") {
+
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor)
+ throws CoreException {
+ String url = project.getUrl();
+ String name = project.getName();
+ final File file = ProjectUtil.getProjectExamplesFile(url, name,
+ ".zip",monitor);
+ if (file == null) {
+ return Status.CANCEL_STATUS;
+ }
+ try {
+ importProject(project, file, monitor);
+ } catch (final Exception e) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ MessageDialogWithToggle.openError(getShell(), "Error", e
+ .getMessage(), "Detail", false,
+ ProjectExamplesActivator.getDefault()
+ .getPreferenceStore(), "errorDialog");
+ }
+
+ });
+ ProjectExamplesActivator.log(e);
+ }
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.setUser(true);
+ job.schedule();
+ //try {
+ // job.join();
+ //} catch (InterruptedException e) {
+ // return false;
+ //}
+ return true;
+ }
+
+ private void importProject(Project projectDescription, File file, IProgressMonitor monitor) throws Exception {
+ final String projectName = projectDescription.getName();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject(projectName);
+ if (project.exists()) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ overwrite = MessageDialog.openQuestion(getShell(), "Question", "Overwrite project '" + projectName + "'");
+ }
+
+ });
+ if (!overwrite) {
+ return;
+ }
+ project.delete(true, true, monitor);
+ }
+ project.create(monitor);
+ project.open(monitor);
+ ZipFile sourceFile = new ZipFile(file);
+ ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(
+ sourceFile);
+
+ ImportOperation operation = new ImportOperation(workspace.getRoot().getFullPath(),
+ structureProvider.getRoot(), structureProvider,
+ OVERWRITE_ALL_QUERY);
+ operation.setContext(getShell());
+ operation.run(monitor);
+
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ initializeDefaultPageImageDescriptor();
+ }
+
+ protected void initializeDefaultPageImageDescriptor() {
+ ImageDescriptor desc = ProjectExamplesActivator
+ .imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID,
+ "icons/new_wiz.gif");
+ setDefaultPageImageDescriptor(desc);
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ page = new NewProjectExamplesWizardPage();
+ addPage(page);
+ }
+
+}
Added: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizardPage.java 2008-10-08 15:39:37 UTC (rev 10749)
@@ -0,0 +1,186 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.project.examples.wizard;
+
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.Category;
+import org.jboss.tools.project.examples.model.Project;
+import org.jboss.tools.project.examples.model.ProjectUtil;
+
+/**
+ * @author snjeza
+ *
+ */
+public class NewProjectExamplesWizardPage extends WizardPage {
+
+ private Project selectedProject;
+
+ public NewProjectExamplesWizardPage() {
+ super("org.jboss.tools.project.examples");
+ setTitle( "Project Example" );
+ setDescription( "Import Project Example" );
+ setImageDescriptor( ProjectExamplesActivator.imageDescriptorFromPlugin(ProjectExamplesActivator.PLUGIN_ID, "icons/new_wiz.gif"));
+
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent,SWT.NULL);
+ composite.setLayout(new GridLayout(1,false));
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint= 225;
+ composite.setLayoutData(gd);
+
+ TreeViewer viewer = new TreeViewer(composite,SWT.SINGLE);
+ Tree tree = viewer.getTree();
+ tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+ tree.setFont(parent.getFont());
+
+ viewer.setLabelProvider(new ProjectLabelProvider());
+ viewer.setContentProvider(new ProjectContentProvider());
+ viewer.setInput(ProjectUtil.getProjects());
+
+ Label descriptionLabel = new Label(composite,SWT.NULL);
+ descriptionLabel.setText("Description:");
+ final Text text = new Text(composite,SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
+ gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
+ gd.heightHint=75;
+ text.setLayoutData(gd);
+
+ Composite internal = new Composite(composite, SWT.NULL);
+ internal.setLayout(new GridLayout(2,false));
+ gd = new GridData(GridData.FILL_BOTH);
+ internal.setLayoutData(gd);
+
+ Label projectNameLabel = new Label(internal,SWT.NULL);
+ projectNameLabel.setText("Project name:");
+ final Text projectName = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
+ projectName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label projectSizeLabel = new Label(internal,SWT.NULL);
+ projectSizeLabel.setText("Project size:");
+ final Text projectSize = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
+ projectSize.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label projectURLLabel = new Label(internal,SWT.NULL);
+ projectURLLabel.setText("URL:");
+ final Text projectURL = new Text(internal,SWT.BORDER | SWT.READ_ONLY);
+ projectURL.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object selected = selection.getFirstElement();
+ if (selected instanceof Project) {
+ selectedProject = (Project) selected;
+ text.setText(selectedProject.getDescription());
+ setPageComplete(true);
+ projectName.setText(selectedProject.getName());
+ projectURL.setText(selectedProject.getUrl());
+ projectSize.setText(selectedProject.getSizeAsText());
+ } else {
+ selectedProject=null;
+ text.setText("");
+ projectName.setText("");
+ projectURL.setText("");
+ projectSize.setText("");
+ setPageComplete(false);
+ }
+ }
+
+ });
+ setPageComplete(false);
+
+ setControl(composite);
+ }
+
+ private class ProjectLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof Category) {
+ Category category = (Category) element;
+ return category.getName();
+ }
+ if (element instanceof Project) {
+ Project project = (Project) element;
+ return project.getShortDescription();
+ }
+ return super.getText(element);
+ }
+ }
+
+ private class ProjectContentProvider implements ITreeContentProvider {
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof List) {
+ List children = (List) parentElement;
+ return children.toArray();
+ }
+ if (parentElement instanceof Category) {
+ Category category = (Category) parentElement;
+ return category.getProjects().toArray();
+ }
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ if (element instanceof Project) {
+ return ((Project)element).getCategory();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return element instanceof Category;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ }
+
+ public Project getSelectedProject() {
+ return selectedProject;
+ }
+}
16 years, 3 months
JBoss Tools SVN: r10748 - trunk/examples/plugins.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-10-08 11:39:00 -0400 (Wed, 08 Oct 2008)
New Revision: 10748
Added:
trunk/examples/plugins/org.jboss.tools.project.examples/
Log:
Initial import.
16 years, 3 months
JBoss Tools SVN: r10745 - trunk.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-10-08 11:33:50 -0400 (Wed, 08 Oct 2008)
New Revision: 10745
Added:
trunk/examples/
Log:
16 years, 3 months
JBoss Tools SVN: r10744 - trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-10-08 10:07:16 -0400 (Wed, 08 Oct 2008)
New Revision: 10744
Added:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
Log:
JBIDE-1497.
Tests added
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2008-10-08 14:06:11 UTC (rev 10743)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/CommonELAllTests.java 2008-10-08 14:07:16 UTC (rev 10744)
@@ -23,6 +23,7 @@
TestSuite suite = new TestSuite();
suite.setName("All tests for " + PLUGIN_ID);
suite.addTestSuite(ELParserTest.class);
+ suite.addTestSuite(ELModelTest.class);
return suite;
}
}
Added: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELModelTest.java 2008-10-08 14:07:16 UTC (rev 10744)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.el.core.test;
+
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELMethodInvocation;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELMultiExpression;
+import org.jboss.tools.common.el.core.model.ELObject;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+import org.jboss.tools.common.el.core.model.ELParameters;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+
+import junit.framework.TestCase;
+
+public class ELModelTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ }
+
+ public void testELModel() {
+ ELParser parser = ELParserUtil.getJbossFactory().createParser();
+ String el = "#{a.b(c.d(),\"ooo\",s['h'])}xx#{(18 + a) * d + 14}";
+ ELModel model = parser.parse(el);
+
+ List<ELInstance> instances = model.getInstances();
+
+ assertEquals(2, instances.size());
+
+ ELInstance instance_1 = instances.get(0);
+ ELExpression expr1 = instance_1.getExpression();
+ assertTrue(expr1 instanceof ELMethodInvocation);
+
+ ELMethodInvocation method1 = (ELMethodInvocation)expr1;
+ ELParameters paramsObject1 = method1.getParameters();
+ List<ELExpression> paramsList1 = paramsObject1.getParameters();
+ assertEquals(3, paramsList1.size());
+
+ ELExpression param_1_1 = paramsList1.get(0);
+ assertEquals(ELObjectType.EL_METHOD_INVOCATION, param_1_1.getType());
+
+ ELExpression param_1_2 = paramsList1.get(1);
+ assertEquals(ELObjectType.EL_VALUE, param_1_2.getType());
+
+ ELExpression param_1_3 = paramsList1.get(2);
+ assertEquals(ELObjectType.EL_ARGUMENT_INVOCATION, param_1_3.getType());
+
+
+ ELInstance instance_2 = instances.get(1);
+ ELExpression expr2 = instance_2.getExpression();
+ assertEquals(ELObjectType.EL_MULTI_EXPRESSION, expr2.getType());
+
+ List<ELExpression> exprList2 = ((ELMultiExpression)expr2).getExpressions();
+ assertEquals(3, exprList2.size());
+ ELExpression expr_2_1 = exprList2.get(0);
+ assertEquals(ELObjectType.EL_COMPLEX_EXPRESSION, expr_2_1.getType());
+ }
+
+}
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2008-10-08 14:06:11 UTC (rev 10743)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2008-10-08 14:07:16 UTC (rev 10744)
@@ -140,6 +140,21 @@
checkCorrectEL(t,"#{true}");
checkCorrectEL(t,"#{false}");
}
+
+ public void testComplexMath() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkCorrectEL(t, "#{(7 * (13 + 7.9)) * (a + b.c / d) / (1.E5) - (1/a.b+8./c.d)}");
+ }
+
+ public void testComplexInvocation() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkCorrectEL(t, "#{a.b[a1.b1(a2.b2,a3.b3(x))][y].c(a4.b4,a5.b5[a6(b6)])}");
+ }
+
+ public void testSeveralELInstances() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkCorrectEL(t, "aaa#{a}bbb#{1}#{c()}");
+ }
private void checkCorrectEL(Tokenizer t, String test) {
LexicalToken token = t.parse(test);
@@ -155,7 +170,7 @@
checkIncorrectEL(t, "#{a.}", 4);
//2. Incorrect use of ')'
checkIncorrectEL(t, "#{a.b + -c.d + g)}", 16);
- //2. Incorrect use of ')' in second EL instance
+ //2. Incorrect use of '.' in second EL instance
checkIncorrectEL(t, "#{a.b + -c.d + g}#{hh.vv..m()}", 25);
}
16 years, 3 months