JBoss Tools SVN: r8984 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-27 10:56:16 -0400 (Fri, 27 Jun 2008)
New Revision: 8984
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
Log:
JBIDE-2451
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-06-27 14:03:26 UTC (rev 8983)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2008-06-27 14:56:16 UTC (rev 8984)
@@ -1022,9 +1022,19 @@
for (SeamComponent c: sc) {
c.removeDeclaration(d);
changes = Change.addChange(changes, new Change(c, null, d, null));
+ Set<ISeamComponentDeclaration> ds = c.getAllDeclarations();
+ if(ds.size() == 1) {
+ ISeamComponentDeclaration d1 = ds.iterator().next();
+ if(d1 instanceof ISeamJavaComponentDeclaration
+ && !c.getName().equals(d1.getName())) {
+ c.removeDeclaration(d1);
+ changes = Change.addChange(changes, new Change(c, null, d1, null));
+ }
+ }
if(isComponentEmpty(c)) {
changes = removeEmptyComponent(c);
}
+
}
}
fireChanges(changes);
15 years, 10 months
JBoss Tools SVN: r8983 - in trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test: resources/jsfTest/WebContent/pages/JBIDE/788 and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2008-06-27 10:03:26 -0400 (Fri, 27 Jun 2008)
New Revision: 8983
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/demo/resources.properties
Removed:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/demo/Messages.properties
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/TestChangeUriInInnerNodes.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAMessageBundlesAndEL.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAPathProposals.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAforHtml.html
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAforJSP.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE788Test.java
Log:
JBIDE-2444
Deleted: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/demo/Messages.properties
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/demo/Messages.properties 2008-06-27 13:40:48 UTC (rev 8982)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/demo/Messages.properties 2008-06-27 14:03:26 UTC (rev 8983)
@@ -1,3 +0,0 @@
-header=Hello Demo Application
-prompt_message=Name:
-hello_message=Hello
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/demo/resources.properties
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/demo/resources.properties (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/JavaSource/demo/resources.properties 2008-06-27 14:03:26 UTC (rev 8983)
@@ -0,0 +1,3 @@
+header=Hello Demo Application
+prompt_message=Name:
+hello_message=Hello
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/TestChangeUriInInnerNodes.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/TestChangeUriInInnerNodes.xhtml 2008-06-27 13:40:48 UTC (rev 8982)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/TestChangeUriInInnerNodes.xhtml 2008-06-27 14:03:26 UTC (rev 8983)
@@ -7,14 +7,15 @@
XHTML TEST Page
</head>
<body>
-<s:button value="Submit#{p"></s:button>
+
+<
<div xmlns:rich="http://jboss.com/products/seam/taglib">
- <rich:button value="#{hSubmit#{sessionScop"></rich:button>
+ <
</div>
<div xmlns:c="http://java.sun.com/jsp/jstl/core">
-
+ <
</div>
</body>
</html>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAMessageBundlesAndEL.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAMessageBundlesAndEL.xhtml 2008-06-27 13:40:48 UTC (rev 8982)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAMessageBundlesAndEL.xhtml 2008-06-27 14:03:26 UTC (rev 8983)
@@ -6,27 +6,22 @@
xmlns:c="http://java.sun.com/jstl/core"
xmlns:s="http://jboss.com/products/seam/taglib">
- <f:loadBundle basename="resources" var="msg" />
-
+ <f:loadBundle basename="demo.resources" var="msg" />
<ui:composition template="./templates/common.xhtml">
-
+ ${msg.
<ui:define name="pageTitle">JSF 1.2 and Facelets under Tomcat. KickStart Application</ui:define>
<ui:define name="pageHeader">JSF 1.2 Hello Application</ui:define>
- <ui:define name="body">
+ <ui:define name="body">
<h:message showSummary="true" showDetail="false" style="color: red; font-weight: bold;" for="name" />
<form jsfc="h:form" id="helloForm">
${msg.prompt}
<input label="Name" jsfc="h:inputText" required="true" id="name" value="#{person.name}" />
<input type="submit" jsfc="h:commandButton" id="submit"
action="greeting" value="Say Hello" />
- <h:outputText value="#{person.name}" />
</form>
-
- <form jsfc="#{p" id="Test Form">
- <h:outputText value="" />
- </form>
+
</ui:define>
</ui:composition>
</html>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAPathProposals.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAPathProposals.xhtml 2008-06-27 13:40:48 UTC (rev 8982)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAPathProposals.xhtml 2008-06-27 14:03:26 UTC (rev 8983)
@@ -8,7 +8,7 @@
<f:loadBundle basename="resources#{g" var="msg" />
- <ui:composition template="./templates/common.xhtml#{msg">
+ <ui:composition template="./temp">
</ui:composition>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAforHtml.html
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAforHtml.html 2008-06-27 13:40:48 UTC (rev 8982)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAforHtml.html 2008-06-27 14:03:26 UTC (rev 8983)
@@ -2,6 +2,6 @@
<head>
</head>
<body>
- Test
+ Test <ta
</body>
</html>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAforJSP.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAforJSP.jsp 2008-06-27 13:40:48 UTC (rev 8982)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/788/testCAforJSP.jsp 2008-06-27 14:03:26 UTC (rev 8983)
@@ -15,11 +15,15 @@
<head>
<title></title>
</head>
- <body>
- <f:view>
+ <body>
+ <f:loadBundle basename="demo.resources" var="msg" />
+
+ <f:view>
+ <h:outputText value="#{msg.}" />
<H1> CA Test Page </H1> Test
- <h:outputText value="Test" />
+ <h:outputText value="#{msg.header}" />
+ <
</f:view>
</body>
</html>
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE788Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE788Test.java 2008-06-27 13:40:48 UTC (rev 8982)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE788Test.java 2008-06-27 14:03:26 UTC (rev 8983)
@@ -20,6 +20,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
+import org.jboss.tools.jst.jsp.contentassist.AutoContentAssistantProposal;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.vpe.ui.test.TestUtil;
@@ -32,9 +33,9 @@
*/
public class JBIDE788Test extends VpeTest {
- private static final String IMPORT_PROJECT_NAME = "jsfTest";
+ private static final String IMPORT_PROJECT_NAME = "jsfTest"; //$NON-NLS-1$
- private static final String CA_NAME = "org.eclipse.wst.html.HTML_DEFAULT";
+ private static final String CA_NAME = "org.eclipse.wst.html.HTML_DEFAULT"; //$NON-NLS-1$
public JBIDE788Test(String name) {
super(name);
@@ -52,9 +53,9 @@
setException(null);
// Tests CA
- checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml","p",382);
- checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml","sessionScop", 504);
- checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml","h",488);
+ checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml","s:validateFormat",359); //$NON-NLS-1$//$NON-NLS-2$
+ checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml","rich:validateA", 427); //$NON-NLS-1$ //$NON-NLS-2$
+ checkOfCAByStartString(CA_NAME, "JBIDE/788/TestChangeUriInInnerNodes.xhtml","c:otherwi",493); //$NON-NLS-1$//$NON-NLS-2$
// check exception
if (getException() != null) {
@@ -73,40 +74,30 @@
setException(null);
// Tests CA
- ICompletionProposal[] rst = checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml","",585,false);
- assertNotNull(rst);
- assertTrue("Length should be greater that 5",rst.length > 5);
- boolean isFound = false;
- for(ICompletionProposal c:rst){
- if(c.getDisplayString().contains("c:")){
- isFound = true;
- }
+ ICompletionProposal[] results = checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml","",545,false); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull(results);
+ assertTrue("The lenft should be more than 0",results.length>0); //$NON-NLS-1$
+ boolean isMatches=true;
+ for (ICompletionProposal completionProposal : results) {
+ String displayString = ((ICompletionProposal) completionProposal).getDisplayString();
+
+ if(!displayString.startsWith("msg.")) { //$NON-NLS-1$
+ isMatches=false;
+ }
+
}
- assertTrue("Should be found ",isFound);
- checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAPathProposals.xhtml","p",589);
- checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAPathProposals.xhtml","msg",534);
- // check exception
- if (getException() != null) {
-
- throw getException();
+ assertTrue("String not matches", isMatches); //$NON-NLS-1$
+
+ results = checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAPathProposals.xhtml","",511,false); //$NON-NLS-1$//$NON-NLS-2$
+ assertNotNull(results);
+ isMatches = false;
+ for(ICompletionProposal completionProposal : results) {
+ String displayString = ((ICompletionProposal) completionProposal).getDisplayString();
+ if(displayString.contains("temp")) { //$NON-NLS-1$
+ isMatches=true;
+ }
}
- }
-
- /**
- * Tests CA for Messages Bundles and EL Values
- *
- * @throws Throwable
- */
- public void testCAforMessageBundlesAndELExpressions() throws Throwable {
- // wait
- TestUtil.waitForJobs();
- // set exception
- setException(null);
- // Tests CA
-
- ICompletionProposal[] rst = checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml","",1245);
- assertNotNull(rst);
-
+ assertTrue("String not matches", isMatches); //$NON-NLS-1$
// check exception
if (getException() != null) {
@@ -125,9 +116,10 @@
// set exception
setException(null);
// Tests CA
- checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml","p",1203);
+// checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAMessageBundlesAndEL.xhtml","p",1203); //$NON-NLS-1$//$NON-NLS-2$
-
+ //TODO Max Areshkau Repair when this functionality will be workd
+ fail("This functionality doesn't works now"); //$NON-NLS-1$
// check exception
if (getException() != null) {
@@ -147,10 +139,20 @@
// set exception
setException(null);
// Tests CA
- baseCheckofCA(CA_NAME, "JBIDE/788/testCAforHtml.html", 39, 79);
+ ICompletionProposal[] results =checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforHtml.html", "", 42,false); //$NON-NLS-1$//$NON-NLS-2$
- // cursor will set after "<" simbol
- checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforHtml.html", "a", 26);
+ assertNotNull(results);
+ assertTrue("The lenft should be more than 0",results.length>0); //$NON-NLS-1$
+ boolean isMatches=true;
+ for (ICompletionProposal completionProposal : results) {
+ String displayString = ((ICompletionProposal) completionProposal).getDisplayString();
+
+ if(!displayString.startsWith("ta")) { //$NON-NLS-1$
+ isMatches=false;
+ }
+
+ }
+ assertTrue("Proposals doesn't match to entered string",isMatches); //$NON-NLS-1$
// check exception
if (getException() != null) {
@@ -170,12 +172,19 @@
// set exception
setException(null);
// Tests CA
- baseCheckofCA(CA_NAME, "JBIDE/788/testCAforJSP.jsp", 1000, 110);
// cursor will set after "outputText" tag
- // checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforJSP.jsp", "s",
- // 1032);
+ ICompletionProposal[] results = checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforJSP.jsp", "h:outp",1139,false); //$NON-NLS-1$ //$NON-NLS-2$
+ for (ICompletionProposal completionProposal : results) {
+
+ String displayString = ((ICompletionProposal) completionProposal).getDisplayString();
+
+ if(completionProposal instanceof AutoContentAssistantProposal) {
+
+ assertTrue(displayString.startsWith("h:outp")) ; //$NON-NLS-1$
+ }
+ }
// check exception
if (getException() != null) {
@@ -193,15 +202,13 @@
TestUtil.waitForJobs();
// set exception
setException(null);
- // Tests CA
- baseCheckofCA(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml", 745, 96);
// cursor will set after "<" simbol
- checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml", "c",
+ checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml", "c", //$NON-NLS-1$ //$NON-NLS-2$
687);
// cursor will set after "outputText" tag
- checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml", "s",
+ checkOfCAByStartString(CA_NAME, "JBIDE/788/testCAforXHTML.xhtml", "s", //$NON-NLS-1$//$NON-NLS-2$
778);
// check exception
@@ -212,64 +219,7 @@
}
/**
- * Perfoms base test of ca, compare number of proposals which what returned
- * by ca with etalon
*
- * @param caName -
- * content assistent name
- * @param testPagePath -
- * test page
- * @param position -
- * position on test page
- * @param numberOfProposals -
- * standard number of proposals
- * @throws CoreException
- */
- private void baseCheckofCA(String caName, String testPagePath,
- int position, int numberOfProposals) throws CoreException {
- // get test page path
- IFile file = (IFile) TestUtil.getComponentPath(testPagePath,
- IMPORT_PROJECT_NAME);
- assertNotNull("Could not open specified file " + file.getFullPath(),
- file);
-
- IEditorInput input = new FileEditorInput(file);
-
- assertNotNull("Editor input is null", input);
-
- // open and get editor
- JSPMultiPageEditor part = openEditor(input);
-
- // sets cursor position
- part.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(
- position);
- TestUtil.waitForJobs();
- TestUtil.delay(2000);
- SourceViewerConfiguration sourceViewerConfiguration = ((JSPTextEditor) part
- .getSourceEditor()).getSourceViewerConfigurationForTest();
- // errase errors which can be on start of editor(for example xuklunner
- // not found)
- setException(null);
- StructuredTextViewerConfiguration stvc = (StructuredTextViewerConfiguration) sourceViewerConfiguration;
- IContentAssistant iContentAssistant = stvc
- .getContentAssistant((ISourceViewer) part.getSourceEditor()
- .getAdapter(ISourceViewer.class));
- assertNotNull(iContentAssistant);
- IContentAssistProcessor iContentAssistProcessor = iContentAssistant
- .getContentAssistProcessor(caName);
- assertNotNull(iContentAssistProcessor);
- ICompletionProposal[] results = iContentAssistProcessor
- .computeCompletionProposals(part.getSourceEditor()
- .getTextViewer(), position);
- assertNotNull(results);
- assertEquals(numberOfProposals, results.length);
-
- closeEditors();
- TestUtil.delay(1000L);
- }
-
- /**
- *
* @param caName
* @param testPagePath
* @param partOfString
@@ -282,19 +232,28 @@
return this.checkOfCAByStartString(caName, testPagePath, partOfString, position,true);
}
+ /**
+ *
+ * @param caName
+ * @param testPagePath
+ * @param partOfString
+ * @param position
+ * @param isCheck
+ * @return
+ * @throws CoreException
+ */
-
private ICompletionProposal[] checkOfCAByStartString(String caName, String testPagePath,
String partOfString, int position,boolean isCheck) throws CoreException {
// get test page path
IFile file = (IFile) TestUtil.getComponentPath(testPagePath,
IMPORT_PROJECT_NAME);
- assertNotNull("Could not open specified file " + file.getFullPath(),
+ assertNotNull("Could not open specified file " + file.getFullPath(), //$NON-NLS-1$
file);
IEditorInput input = new FileEditorInput(file);
- assertNotNull("Editor input is null", input);
+ assertNotNull("Editor input is null", input); //$NON-NLS-1$
// open and get editor
JSPMultiPageEditor part = openEditor(input);
@@ -309,7 +268,7 @@
part.getSourceEditor().getTextViewer().getTextWidget().setCaretOffset(
newPosition);
TestUtil.waitForJobs();
- TestUtil.delay(2000);
+ TestUtil.delay(1000);
SourceViewerConfiguration sourceViewerConfiguration = ((JSPTextEditor) part
.getSourceEditor()).getSourceViewerConfigurationForTest();
// errase errors which can be on start of editor(for example xuklunner
@@ -329,16 +288,15 @@
// remove inserted string
part.getSourceEditor().getTextViewer().getTextWidget()
- .replaceTextRange(position, partOfString.length(), "");
+ .replaceTextRange(position, partOfString.length(), ""); //$NON-NLS-1$
assertNotNull(results);
+ assertTrue("Number of ca proposals shouldn't be a null",results.length>0); //$NON-NLS-1$
if (isCheck) {
for (int i = 0; i < results.length; i++) {
String displayString = ((ICompletionProposal) results[i]).getDisplayString();
assertNotNull(displayString);
-
- System.out.print("\n" + displayString);
assertEquals(true, displayString.startsWith(partOfString));
}
}
15 years, 10 months
JBoss Tools SVN: r8982 - in trunk/seam/tests/org.jboss.tools.seam.core.test: src/org/jboss/tools/seam/core/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-06-27 09:40:48 -0400 (Fri, 27 Jun 2008)
New Revision: 8982
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/components.5
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2451
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/components.5
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/components.5 (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/WEB-INF/components.5 2008-06-27 13:40:48 UTC (rev 8982)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://jboss.com/products/seam/components"
+ xmlns:core="http://jboss.com/products/seam/core"
+ xmlns:drools="http://jboss.com/products/seam/drools"
+ xmlns:security="http://jboss.com/products/seam/security"
+ xmlns:mail="http://jboss.com/products/seam/mail"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation=
+ "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd
+ http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-1.1.xsd
+ http://jboss.com/products/seam/security http://jboss.com/products/seam/security-1.1.xsd
+ http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-1.2.xsd
+ http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
+
+ <core:init debug="true" jndi-pattern="@jndiPattern@"/>
+
+ <core:manager concurrent-request-timeout="500"
+ conversation-timeout="120000"
+ conversation-id-parameter="cid"
+ conversation-is-long-running-parameter="clr"/>
+
+
+ <core:entity-manager-factory name="SeamWebWarTestProjectEntityManagerFactory"
+ persistence-unit-name="SeamWebWarTestProject"/>
+
+ <core:ejb installed="@embeddedEjb@"/>
+
+
+
+ <event type="org.jboss.seam.notLoggedIn">
+ <action expression="#{redirect.captureCurrentView}"/>
+ </event>
+ <event type="org.jboss.seam.postAuthenticate">
+ <action expression="#{redirect.returnToCapturedView}"/>
+ </event>
+
+ <mail:mail-session host="localhost" port="2525" username="test" password="test" />
+
+ <!-- For use with jBPM pageflow or process management -->
+ <!--
+ <core:jbpm>
+ <core:process-definitions></core:process-definitions>
+ <core:pageflow-definitions></core:pageflow-definitions>
+ </core:jbpm>
+ -->
+
+</components>
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-06-27 12:09:50 UTC (rev 8981)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-06-27 13:40:48 UTC (rev 8982)
@@ -367,47 +367,52 @@
// Duplicate @Create method
System.out.println("Test - Duplicate @Create method");
-
+
final String NEW_CONTENT_FILE_NAME7 = "src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.7";
-
+
assertMarkerIsCreated(
TARGET_FILE_NAME,NEW_CONTENT_FILE_NAME7, ".*(a)Create.*\"createMethod\".*", 36);
assertMarkerIsCreated(
TARGET_FILE_NAME, ".*(a)Create.*\"createMethod2\".*", 41);
-
-
-
+
// Duplicate @Unwrap method
System.out.println("Test - Duplicate @Unwrap method");
-
+
final String NEW_CONTENT_FILE_NAME8 = "src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.8";
assertMarkerIsCreated(
TARGET_FILE_NAME,NEW_CONTENT_FILE_NAME8, ".*(a)Unwrap.*\"unwrapMethod\".*", 40);
assertMarkerIsCreated(
TARGET_FILE_NAME, ".*(a)Unwrap.*\"unwrapMethod2\".*", 45);
-
-
+
+ IFile componentsFileWithoutSTComponent = project.getFile("WebContent/WEB-INF/components.5");
+ try {
+ componentsFile.setContents(componentsFileWithoutSTComponent.getContents(), true, false, new NullProgressMonitor());
+ } catch(Exception ex) {
+ JUnitUtils.fail("Error in changing 'components.xml' content to " +
+ "'components.5'", ex);
+ }
+ refreshProject(project);
+
// Only component class can have @Destroy method
System.out.println("Test - Only component class can have @Destroy method");
-
+
final String NEW_CONTENT_FILE_NAME9 = "src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.9";
assertMarkerIsCreated(
TARGET_FILE_NAME,NEW_CONTENT_FILE_NAME9, ".*(a)Destroy.*\"destroyMethod\".*", 25);
-
-
+
// Only component class can have @Create method
System.out.println("Test - Only component class can have @Create method");
-
+
final String NEW_CONTENT_FILE_NAME10 = "src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.10";
-
+
assertMarkerIsCreated(
TARGET_FILE_NAME,NEW_CONTENT_FILE_NAME10, ".*(a)Create.*\"createMethod\".*", 25);
-
+
// Only component class can have @Unwrap method
System.out.println("Test - Only component class can have @Unwrap method");
-
+
final String NEW_CONTENT_FILE_NAME11 = "src/action/org/domain/SeamWebWarTestProject/session/StatefulComponent.11";
-
+
assertMarkerIsCreated(
TARGET_FILE_NAME,NEW_CONTENT_FILE_NAME11, "Only component class can have @Unwrap method \"unwrapMethod\"", 26);
@@ -430,6 +435,13 @@
assertMarkerIsCreated(
TARGET_FILE_NAME,"Duplicate @Remove method \"removeMethod2\"", 22);
+ IFile componentsFileWithSTComponent = project.getFile("WebContent/WEB-INF/components.2");
+ try {
+ componentsFile.setContents(componentsFileWithoutSTComponent.getContents(), true, false, new NullProgressMonitor());
+ }catch(Exception ex){
+ JUnitUtils.fail("Error in changing 'components.xml' content to " +
+ "'components.6'", ex);
+ }
}
/**
15 years, 10 months
JBoss Tools SVN: r8981 - trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2008-06-27 08:09:50 -0400 (Fri, 27 Jun 2008)
New Revision: 8981
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl/PagesModelImpl.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1189
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl/PagesModelImpl.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl/PagesModelImpl.java 2008-06-27 12:00:03 UTC (rev 8980)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/ecore/pages/impl/PagesModelImpl.java 2008-06-27 12:09:50 UTC (rev 8981)
@@ -291,11 +291,27 @@
public void nodeChanged(XModelTreeEvent event) {
if(getData() == null) return;
XModelObject diagramXML = (XModelObject)getData();
- if(!event.getModelObject().getPath().startsWith(diagramXML.getPath())) {
+ String newPath = event.getModelObject().getPath();
+ if(!newPath.startsWith(diagramXML.getPath())) {
return;
}
- PagesElement item = findElement(event.getInfo().toString());
+ String oldPath = event.getInfo().toString();
+
+ PagesElement item = findElement(oldPath);
if(item != null) {
+ if(!oldPath.equals(newPath)){
+ elementsByPath.remove(oldPath);
+ elementsByPath.put(newPath, item);
+ String[] keys = (String[])linksByPath.keySet().toArray(new String[0]);
+ for (int i = 0; i < keys.length; i++) {
+ if(keys[i].startsWith(oldPath + "/")) {
+ Link o = linksByPath.get(keys[i]);
+ if(o == null) continue;
+ String key = newPath + keys[i].substring(oldPath.length());
+ linksByPath.put(key, o);
+ }
+ }
+ }
item.dataChanged();
}
Link link = findLink(event.getInfo().toString());
15 years, 10 months
JBoss Tools SVN: r8980 - in trunk/seam/tests/org.jboss.tools.seam.core.test: src/org/jboss/tools/seam/core/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-06-27 08:00:03 -0400 (Fri, 27 Jun 2008)
New Revision: 8980
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/JBIDE-1631.1
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/JBIDE-1631.xhtml
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2425 Fixed
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/JBIDE-1631.1
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/JBIDE-1631.1 (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/JBIDE-1631.1 2008-06-27 12:00:03 UTC (rev 8980)
@@ -0,0 +1,22 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.ajax4jsf.org/rich"
+ template="layout/template.xhtml">
+
+<ui:define name="body">
+
+ <h:messages globalOnly="true" styleClass="message"/>
+
+ <rich:panel>
+ #{authenticator.foo1} #{authenticator.foo2}
+ <f:facet name="header">Welcome!</f:facet>
+ <p>This empty shell application includes:</p>
+ </rich:panel>
+
+</ui:define>
+</ui:composition>
\ No newline at end of file
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/JBIDE-1631.xhtml
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/JBIDE-1631.xhtml 2008-06-27 08:19:24 UTC (rev 8979)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/WebContent/JBIDE-1631.xhtml 2008-06-27 12:00:03 UTC (rev 8980)
@@ -10,23 +10,5 @@
<ui:define name="body">
- <h:messages globalOnly="true" styleClass="message"/>
-
- <rich:panel>
- #{authenticator.foo1} #{authenticator.foo2}
- <f:facet name="header">Welcome!</f:facet>
- <p>This empty shell application includes:</p>
- <ul>
- <li>Ant build script</li>
- <li>Deployment to JBoss AS</li>
- <li>Integration testing using TestNG and JBoss Embeddable EJB3</li>
- <li>EJB 3.0 Seam components</li>
- <li>Templated Facelets views</li>
- <li>HSQL (or MySQL) Datasource</li>
- <li>Default CSS stylesheet</li>
- <li>Internationalization support</li>
- </ul>
- </rich:panel>
-
</ui:define>
</ui:composition>
\ No newline at end of file
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-06-27 08:19:24 UTC (rev 8979)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-06-27 12:00:03 UTC (rev 8980)
@@ -90,6 +90,7 @@
* @throws CoreException
*/
public void testJBIDE1318() throws CoreException {
+ getSeamProject(project);
IFile testJSP = project.getFile("WebContent/test.jsp");
assertMarkerIsNotCreated(testJSP, null, "actor cannot be resolved");
}
@@ -122,8 +123,16 @@
public void testJiraJbide1631() throws CoreException {
// Test for http://jira.jboss.com/jira/browse/JBIDE-1631
IFile jbide1631XHTMLFile = project.getFile("WebContent/JBIDE-1631.xhtml");
+ IFile jbide1631XHTMLFileWithFoo = project.getFile("WebContent/JBIDE-1631.1");
+ try{
+ jbide1631XHTMLFile.setContents(jbide1631XHTMLFileWithFoo.getContents(), true, false, new NullProgressMonitor());
+ }catch(Exception ex){
+ JUnitUtils.fail("Error in changing 'JBIDE-1631.xhtml' content to " +
+ "'JBIDE-1631.1'", ex);
+ }
+ refreshProject(project);
assertMarkerIsCreated(jbide1631XHTMLFile, null, "\"foo1\" cannot be resolved", 16 );
- assertMarkerIsCreated(jbide1631XHTMLFile, null, "\"foo2\" cannot be resolved", 17 );
+ assertMarkerIsCreated(jbide1631XHTMLFile, null, "\"foo2\" cannot be resolved", 16 );
}
public void testComponentsValidator() {
15 years, 10 months
JBoss Tools SVN: r8979 - in trunk/ws: plugins/org.jboss.tools.ws.core/META-INF and 24 other directories.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2008-06-27 04:19:24 -0400 (Fri, 27 Jun 2008)
New Revision: 8979
Added:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JBossWSCorePlugin.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntime.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeClassPathInitializer.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeListConverter.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeManager.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSUnInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCore.properties
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JBossWSCoreUtils.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossRuntimeListFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSLibraryListFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSRuntimePreferencePage.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JBossWSRuntimeManagerTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSClientCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/JBossWSUIAllTests.java
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JBossWSRuntimePreferencePageTest.java
Removed:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIPlugin.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JbossWSCoreAllTests.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JbossWSRuntimeManagerTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JavaFirstCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/WSClientCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JbossWSRuntimePreferencePageTest.java
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.core/build.properties
trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RemoveClientJarsCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java
trunk/ws/tests/org.jboss.tools.ws.core.test/META-INF/MANIFEST.MF
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSTopDownCommandTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.test/META-INF/MANIFEST.MF
Log:
JBIDE-2047: codes review and make some change for file format
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC (rev 8979)
@@ -4,7 +4,7 @@
Bundle-SymbolicName: org.jboss.tools.ws.core;singleton:=true
Bundle-Version: 1.0.0
Bundle-Localization: plugin
-Bundle-Activator: org.jboss.tools.ws.core.JbossWSCorePlugin
+Bundle-Activator: org.jboss.tools.ws.core.JBossWSCorePlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.wst.common.project.facet.core,
@@ -22,7 +22,7 @@
org.eclipse.jdt.launching,
org.eclipse.jst.j2ee,
org.eclipse.jst.ws.consumption.ui
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Bundle-Vendor: %PLUGIN_PROVIDER
Export-Package: org.jboss.tools.ws.core,
org.jboss.tools.ws.core.classpath,
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/build.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/build.properties 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/build.properties 2008-06-27 08:19:24 UTC (rev 8979)
@@ -2,4 +2,5 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml
+ plugin.xml,\
+ plugin.properties
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/plugin.xml 2008-06-27 08:19:24 UTC (rev 8979)
@@ -20,7 +20,7 @@
facet="jbossws.core"
id="jbossws.core.install"
type="INSTALL">
- <delegate class="org.jboss.tools.ws.core.facet.delegate.JbossWSInstallRuntimeDelegate"/>
+ <delegate class="org.jboss.tools.ws.core.facet.delegate.JBossWSInstallRuntimeDelegate"/>
<config-factory
class="org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider">
</config-factory>
@@ -30,7 +30,7 @@
id="jbossws.core.uninstall"
type="UNINSTALL">
<delegate
- class="org.jboss.tools.ws.core.facet.delegate.JbossWSUnInstallRuntimeDelegate">
+ class="org.jboss.tools.ws.core.facet.delegate.JBossWSUnInstallRuntimeDelegate">
</delegate>
</action>
@@ -49,7 +49,7 @@
<extension
point="org.eclipse.jdt.core.classpathContainerInitializer">
<classpathContainerInitializer
- class="org.jboss.tools.ws.core.classpath.JbossWSRuntimeClassPathInitializer"
+ class="org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer"
id="JBossWS_Runtime">
</classpathContainerInitializer>
</extension>
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JBossWSCorePlugin.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JBossWSCorePlugin.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JBossWSCorePlugin.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+
+package org.jboss.tools.ws.core;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class JBossWSCorePlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.ws.core";
+
+ // The shared instance
+ private static JBossWSCorePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public JBossWSCorePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static JBossWSCorePlugin getDefault() {
+ return plugin;
+ }
+
+}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/JbossWSCorePlugin.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-
-package org.jboss.tools.ws.core;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class JbossWSCorePlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.tools.ws.core";
-
- // The shared instance
- private static JbossWSCorePlugin plugin;
-
- /**
- * The constructor
- */
- public JbossWSCorePlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
-
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static JbossWSCorePlugin getDefault() {
- return plugin;
- }
-
-}
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntime.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntime.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntime.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.classpath;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntime {
+
+ String name = null;
+
+ String homeDir = null;
+
+ String version = null;
+
+ boolean defaultRt = false;
+
+ List<String> libraries;
+
+ private boolean userConfigClasspath;
+
+ /**
+ * Default constructor
+ */
+ public JBossWSRuntime() {
+ libraries = new ArrayList<String>();
+ }
+
+ /**
+ * Get JBossWSRuntime name
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get path to home directory
+ *
+ * @return home directory path as string
+ */
+ public String getHomeDir() {
+ return homeDir;
+ }
+
+ /**
+ * Set JBossWSRuntime name
+ *
+ * @param name
+ * new JBossWSRuntime name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Set home directory
+ *
+ * @param homeDir
+ * new JBossWSRuntime's home directory
+ */
+ public void setHomeDir(String homeDir) {
+ this.homeDir = homeDir;
+ }
+
+ /**
+ * Mark runtime as default
+ *
+ * @param b
+ * new value for default property
+ */
+ public void setDefault(boolean b) {
+ this.defaultRt = b;
+ }
+
+ /**
+ * Get default flag
+ *
+ * @return default property
+ */
+ public boolean isDefault() {
+ return defaultRt;
+ }
+
+ public List<String> getLibraries(){
+
+ return this.libraries;
+ }
+
+ public void setLibraries(List<String> libraries){
+ this.libraries = libraries;
+ }
+
+ public boolean isUserConfigClasspath(){
+ return this.userConfigClasspath;
+ }
+
+ public void setUserConfigClasspath(boolean userConfigClasspath){
+ this.userConfigClasspath = userConfigClasspath;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+}
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeClassPathInitializer.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeClassPathInitializer.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeClassPathInitializer.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.classpath;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimeClassPathInitializer extends
+ ClasspathContainerInitializer {
+
+ public JBossWSRuntimeClassPathInitializer() {
+ }
+
+ private String segment;
+
+ @Override
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException {
+
+ if (containerPath.segment(0).equals(
+ JBossWSCoreMessages.JBossWS_Runtime_Lib)) {
+ JBossWSRuntimeClasspathContainer container = new JBossWSRuntimeClasspathContainer(
+ containerPath);
+ segment = containerPath.segment(1);
+ JavaCore.setClasspathContainer(containerPath,
+ new IJavaProject[] { project },
+ new IClasspathContainer[] { container }, null);
+ }
+ }
+
+ public IClasspathEntry[] getEntries(IPath path) {
+ return new JBossWSRuntimeClasspathContainer(path).getClasspathEntries();
+ }
+
+ public class JBossWSRuntimeClasspathContainer implements
+ IClasspathContainer {
+ private IPath path;
+ private IClasspathEntry[] entries = null;
+
+ public JBossWSRuntimeClasspathContainer(IPath path) {
+ this.path = path;
+ }
+
+ public String getDescription() {
+ return JBossWSCoreMessages.JBossWS_Runtime;
+ }
+
+ public int getKind() {
+ return IClasspathContainer.K_APPLICATION;
+ }
+
+ public IPath getPath() {
+ return path;
+ }
+
+ public IClasspathEntry[] getClasspathEntries() {
+ if (entries == null) {
+ ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance()
+ .findRuntimeByName(segment);
+ if (jbws != null) {
+
+ List<String> jars = JBossWSRuntimeManager.getInstance().getAllRuntimeJars(jbws);
+ for (String jar : jars) {
+ entryList.add(getEntry(new Path(jar)));
+ }
+ entries = entryList.toArray(new IClasspathEntry[entryList.size()]);
+ if (entries == null)
+ return new IClasspathEntry[0];
+ }
+ }
+ return entries;
+ }
+
+ protected IClasspathEntry getEntry(IPath path) {
+ return JavaRuntime.newArchiveRuntimeClasspathEntry(path)
+ .getClasspathEntry();
+ }
+
+ public void removeEntry(String jarName) {
+ if (entries == null) {
+ return;
+ }
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
+ int i = 0;
+ for (IClasspathEntry entry : entries) {
+ if (!entry.toString().contains(jarName)) {
+ newEntries[i++] = entry;
+ }
+ }
+ entries = newEntries;
+ }
+
+ }
+
+ public boolean filterJars(String jarName, ArrayList<IClasspathEntry> list) {
+ for (IClasspathEntry entry : list) {
+ if (entry.getPath().lastSegment().equals(jarName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeListConverter.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeListConverter.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeListConverter.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,141 @@
+package org.jboss.tools.ws.core.classpath;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+
+/**
+ *
+ * @author Grid Qian
+ *
+ */
+public class JBossWSRuntimeListConverter {
+
+ /*
+ * Constants definitions
+ */
+ private static final String REGEXP_ESCAPE = "\\";
+ private static final String COMMA = ",";
+ private static final String LIBRARY_SEPARATOR = ";";
+ private static final String EMPTY_STRING = "";
+ private static final String FIELD_SEPARATOR = "|";
+ private static final String DEFAULT = "default";
+ private static final String HOME_DIR = "homeDir";
+ private static final String VERSION = "version";
+ private static final String NAME = "name";
+ private static final String USER_CONFIG_CLASSPATH = "userConfig";
+ private static final String LIBRARY = "libraries";
+
+ /**
+ * Load String to JBossWSRuntime map from String
+ * @param input
+ * String representation of map
+ * @return
+ * Map<String, JBossWSRuntime> loaded from string
+ * TODO - switch to XML?
+ * TODO - write converter from old serialization format to XML?
+ * TODO - handle errors in string format
+ */
+ public Map<String, JBossWSRuntime> getMap(String input) {
+
+ Map<String, JBossWSRuntime> result = new HashMap<String, JBossWSRuntime>();
+ if (input == null || EMPTY_STRING.equals(input.trim())) {
+ return result;
+ }
+ StringTokenizer runtimes = new StringTokenizer(input, COMMA);
+ while (runtimes.hasMoreTokens()) {
+ String runtime = runtimes.nextToken();
+ String[] map = runtime.split(REGEXP_ESCAPE + FIELD_SEPARATOR);
+ JBossWSRuntime rt = new JBossWSRuntime();
+ final int step = 2;
+ for (int i = 0; i < map.length; i += step) {
+ String name = map[i];
+ String value = i + 1 < map.length ? map[i + 1] : EMPTY_STRING;
+ if (NAME.equals(name)) {
+ rt.setName(value);
+ } else if (HOME_DIR.equals(name)) {
+ rt.setHomeDir(value);
+ } else if (VERSION.equals(name)) {
+ rt.setVersion(value);
+ } else if (DEFAULT.equals(name)) {
+ rt.setDefault(Boolean.parseBoolean(value));
+ }else if(USER_CONFIG_CLASSPATH.equals(name)){
+ rt.setUserConfigClasspath(Boolean.parseBoolean(value));
+ }else if(LIBRARY.equals(name)){
+ if(value != null && !EMPTY_STRING.equals(value)){
+ rt.setLibraries(getLibrariesFromString(value));
+ }
+ }
+
+ }
+ result.put(rt.getName(), rt);
+ }
+
+ return result;
+ }
+
+ private List<String> getLibrariesFromString(String strLibraries){
+ List<String> libraries = new ArrayList<String>();
+ StringTokenizer st = new StringTokenizer(strLibraries, LIBRARY_SEPARATOR);
+ while(st.hasMoreTokens()){
+ String library = st.nextToken();
+ if(!libraries.contains(library)){
+ libraries.add(library);
+ }
+ }
+ return libraries;
+
+ }
+
+ private String convertListToString(List<String> libraries){
+ String strLib = "";
+ for(String library: libraries){
+ if("".equals(strLib)){
+ strLib = library;
+ }else{
+ strLib = strLib + LIBRARY_SEPARATOR + library;
+ }
+ }
+ return strLib;
+ }
+
+ /**
+ * Convert map String to JBossWSRUntime to string representation
+ * @param runtimeMap
+ * Map<String, JBossWSRuntime> - map of String to JBossWS Runtime to convert
+ * in String
+ * @return
+ * String representation of String to JBossWS Runtime map
+ */
+ public String getString(Map<String, JBossWSRuntime> runtimeMap) {
+ StringBuffer buffer = new StringBuffer();
+ JBossWSRuntime[] runtimes = runtimeMap.values().toArray(
+ new JBossWSRuntime[runtimeMap.size()]);
+ for (int i = 0; i < runtimes.length; i++) {
+ buffer.append(NAME).append(FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getName());
+ buffer.append(FIELD_SEPARATOR).append(VERSION).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getVersion());
+ buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getHomeDir());
+ buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isDefault());
+ buffer.append(FIELD_SEPARATOR).append(USER_CONFIG_CLASSPATH).append(FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isUserConfigClasspath());
+ buffer.append(FIELD_SEPARATOR).append(LIBRARY).append(FIELD_SEPARATOR);
+ buffer.append(convertListToString(runtimes[i].getLibraries()));
+ if (i != runtimes.length - 1) {
+ buffer.append(COMMA);
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeManager.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeManager.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JBossWSRuntimeManager.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,359 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.classpath;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.ws.core.JBossWSCorePlugin;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimeManager {
+
+ private static JBossWSRuntimeListConverter converter = new JBossWSRuntimeListConverter();
+
+ private Map<String, JBossWSRuntime> runtimes = new HashMap<String, JBossWSRuntime>();
+
+ /**
+ * Private constructor
+ */
+ private JBossWSRuntimeManager() {
+ load();
+ }
+
+ /**
+ * This class make Java Runtime responsible for solving synchronization
+ * problems during initialization if there is any
+ *
+ */
+ static class JBossWSRuntimeManagerHolder {
+ private static final JBossWSRuntimeManager INSTANCE = new JBossWSRuntimeManager();
+ }
+
+ /**
+ * Return JBossWSRuntimeManaher instance
+ *
+ * @return JBossWSRuntimeManager instance
+ */
+ public static JBossWSRuntimeManager getInstance() {
+ return JBossWSRuntimeManagerHolder.INSTANCE;
+ }
+
+ /**
+ * Return Array of configured JBossWSRuntimes
+ *
+ * @return JBossWSRuntime[]
+ */
+ public JBossWSRuntime[] getRuntimes() {
+ Collection<JBossWSRuntime> c = runtimes.values();
+ return c.toArray(new JBossWSRuntime[runtimes.size()]);
+ }
+
+ /**
+ * Add new JBossWSRuntime
+ *
+ * @param runtime
+ * JBossWSRuntime
+ */
+ public void addRuntime(JBossWSRuntime runtime) {
+ if (runtimes.size() == 0) {
+ runtime.setDefault(true);
+ }
+
+ JBossWSRuntime oldDefaultRuntime = getDefaultRuntime();
+ if (oldDefaultRuntime != null && runtime.isDefault()) {
+ oldDefaultRuntime.setDefault(false);
+ }
+ runtimes.put(runtime.getName(), runtime);
+ save();
+ }
+
+ /**
+ * Add new JBossWSRuntime with given parameters
+ *
+ * @param name
+ * String - runtime name
+ * @param path
+ * String - runtime home folder
+ * @param version
+ * String - string representation of version number
+ * @param defaultRt
+ * boolean - default flag
+ */
+ public void addRuntime(String name, String path, String version,
+ boolean defaultRt) {
+ JBossWSRuntime jbossWSRt = new JBossWSRuntime();
+ jbossWSRt.setHomeDir(path);
+ jbossWSRt.setName(name);
+ jbossWSRt.setVersion(version);
+ jbossWSRt.setDefault(defaultRt);
+ addRuntime(jbossWSRt);
+ }
+
+ /**
+ * Return JBossWSRuntime by given name
+ *
+ * @param name
+ * String - JBossWSRuntime name
+ * @return JBossWSRuntime - found JBossWSRuntime instance or null
+ */
+ public JBossWSRuntime findRuntimeByName(String name) {
+ for (JBossWSRuntime jbossWSRuntime : runtimes.values()) {
+ if (jbossWSRuntime.getName().equals(name)) {
+ return jbossWSRuntime;
+ }
+ }
+ return null;
+ }
+
+ public List<String> getAllRuntimeJars(JBossWSRuntime rt){
+ List<String> jarList = new ArrayList<String>();
+ if (rt != null) {
+ if (rt.isUserConfigClasspath()) {
+ jarList.addAll(rt.getLibraries());
+
+ } else {
+ IPath wsPath = new Path(rt.getHomeDir());
+ if (wsPath != null) {
+ IPath libPath = wsPath
+ .append(JBossWSCoreMessages.Dir_Lib);
+ List<File> libs = getJarsOfFolder(libPath.toFile());
+ libPath = wsPath
+ .append(JBossWSCoreMessages.Dir_Client);
+ List<File> clientJars = getJarsOfFolder(libPath.toFile());
+
+ jarList = mergeTwoList(libs, clientJars);
+ }
+ }
+
+ }
+ return jarList;
+ }
+
+
+
+ private List<File> getJarsOfFolder(File folder){
+ List<File> jars = new ArrayList<File>();
+ if(folder.isDirectory()){
+ for(File file: folder.listFiles()){
+ if(file.isFile() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))){
+ jars.add(file);
+ }else if (folder.isDirectory()){
+ jars.addAll(getJarsOfFolder(file));
+ }
+ }
+ }
+
+ return jars;
+ }
+
+ // if two folders have the same jar file, one of them will be ignored.
+ private List<String> mergeTwoList(List<File> jarList1, List<File> jarList2){
+ List<String> rtList = new ArrayList<String>();
+ List<String> distinctFileNames = new ArrayList<String>();
+
+ for(File jarFile: jarList1){
+ distinctFileNames.add(jarFile.getName());
+ rtList.add(jarFile.getAbsolutePath());
+ }
+ for(File jarFile: jarList2){
+ if(!distinctFileNames.contains(jarFile.getName())){
+ rtList.add(jarFile.getAbsolutePath());
+ }
+ }
+
+ return rtList;
+
+ }
+
+ /**
+ * Remove given JBossWSRuntime from manager
+ *
+ * @param rt
+ * JBossWSRuntime
+ */
+ public void removeRuntime(JBossWSRuntime rt) {
+ runtimes.remove(rt.getName());
+ }
+
+ /**
+ * Save preference value and force save changes to disk
+ */
+ public void save() {
+ JBossWSCorePlugin.getDefault().getPreferenceStore().setValue(
+ JBossWSCoreMessages.WS_Location, converter.getString(runtimes));
+ IPreferenceStore store = JBossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore) store).save();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Marks this runtime as default. Marks other runtimes with the same version
+ * as not default.
+ *
+ * @param runtime
+ */
+ public void setDefaultRuntime(JBossWSRuntime runtime) {
+ JBossWSRuntime[] runtimes = getRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ runtimes[i].setDefault(false);
+ }
+ runtime.setDefault(true);
+ }
+
+ /**
+ * Return first default JBossWSRuntime
+ *
+ * @return JBossWSRuntime
+ */
+ public JBossWSRuntime getDefaultRuntime() {
+ for (JBossWSRuntime rt : runtimes.values()) {
+ if (rt.isDefault()) {
+ return rt;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return list of available JBossWSRuntime names
+ *
+ * @return List<String>
+ */
+ public List<String> getRuntimeNames() {
+ JBossWSRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (JBossWSRuntime jbossWSRuntime : rts) {
+ result.add(jbossWSRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * Return a list of all runtime names
+ *
+ * @return List of all runtime names
+ */
+ public List<String> getAllRuntimeNames() {
+ JBossWSRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (JBossWSRuntime jbossWSRuntime : rts) {
+ result.add(jbossWSRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * TBD
+ *
+ * @param oldName
+ * old runtime name
+ * @param newName
+ * new runtime name
+ */
+ public void changeRuntimeName(String oldName, String newName) {
+ JBossWSRuntime o = findRuntimeByName(oldName);
+ if (o == null) {
+ return;
+ }
+ o.setName(newName);
+ onRuntimeNameChanged(oldName, newName);
+ }
+
+ private void onRuntimeNameChanged(String oldName, String newName) {
+ IProjectFacet facet = ProjectFacetsManager
+ .getProjectFacet("jbossws.core");
+ Set<IFacetedProject> facetedProjects = null;
+ try {
+ facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (IFacetedProject facetedProject : facetedProjects) {
+ QualifiedName qRuntimeName = IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
+ String name = null;
+ try {
+ name = facetedProject.getProject().getPersistentProperty(
+ qRuntimeName);
+ if (name != null && name.equals(oldName)) {
+ facetedProject.getProject().setPersistentProperty(
+ qRuntimeName, newName);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public static boolean isRuntimeUsed(String name) {
+ IProjectFacet facet = ProjectFacetsManager
+ .getProjectFacet("jbossws.core");
+ Set<IFacetedProject> facetedProjects = null;
+ try {
+ facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (IFacetedProject facetedProject : facetedProjects) {
+ QualifiedName qRuntimeName = IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
+ try {
+ if (name.equals(facetedProject.getProject()
+ .getPersistentProperty(qRuntimeName))) {
+ return true;
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ public void load() {
+ IPreferenceStore ps = JBossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+
+ String runtimeListString = ps
+ .getString(JBossWSCoreMessages.WS_Location);
+
+ runtimes = converter.getMap(runtimeListString);
+ }
+
+}
\ No newline at end of file
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntime.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.classpath;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntime {
-
- String name = null;
-
- String homeDir = null;
-
- String version = null;
-
- boolean defaultRt = false;
-
- List<String> libraries;
-
- private boolean userConfigClasspath;
-
- /**
- * Default constructor
- */
- public JbossWSRuntime() {
- libraries = new ArrayList<String>();
- }
-
- /**
- * Get JbossWSRuntime name
- *
- * @return name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get path to home directory
- *
- * @return home directory path as string
- */
- public String getHomeDir() {
- return homeDir;
- }
-
- /**
- * Set JbossWSRuntime name
- *
- * @param name
- * new JbossWSRuntime name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Set home directory
- *
- * @param homeDir
- * new JbossWSRuntime's home directory
- */
- public void setHomeDir(String homeDir) {
- this.homeDir = homeDir;
- }
-
- /**
- * Mark runtime as default
- *
- * @param b
- * new value for default property
- */
- public void setDefault(boolean b) {
- this.defaultRt = b;
- }
-
- /**
- * Get default flag
- *
- * @return default property
- */
- public boolean isDefault() {
- return defaultRt;
- }
-
- public List<String> getLibraries(){
-
- return this.libraries;
- }
-
- public void setLibraries(List<String> libraries){
- this.libraries = libraries;
- }
-
- public boolean isUserConfigClasspath(){
- return this.userConfigClasspath;
- }
-
- public void setUserConfigClasspath(boolean userConfigClasspath){
- this.userConfigClasspath = userConfigClasspath;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.classpath;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.ClasspathContainerInitializer;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimeClassPathInitializer extends
- ClasspathContainerInitializer {
-
- public JbossWSRuntimeClassPathInitializer() {
- }
-
- private String segment;
-
- @Override
- public void initialize(IPath containerPath, IJavaProject project)
- throws CoreException {
-
- if (containerPath.segment(0).equals(
- JbossWSCoreMessages.JBossWS_Runtime_Lib)) {
- JbossWSRuntimeClasspathContainer container = new JbossWSRuntimeClasspathContainer(
- containerPath);
- segment = containerPath.segment(1);
- JavaCore.setClasspathContainer(containerPath,
- new IJavaProject[] { project },
- new IClasspathContainer[] { container }, null);
- }
- }
-
- public IClasspathEntry[] getEntries(IPath path) {
- return new JbossWSRuntimeClasspathContainer(path).getClasspathEntries();
- }
-
- public class JbossWSRuntimeClasspathContainer implements
- IClasspathContainer {
- private IPath path;
- private IClasspathEntry[] entries = null;
-
- public JbossWSRuntimeClasspathContainer(IPath path) {
- this.path = path;
- }
-
- public String getDescription() {
- return JbossWSCoreMessages.JBossWS_Runtime;
- }
-
- public int getKind() {
- return IClasspathContainer.K_APPLICATION;
- }
-
- public IPath getPath() {
- return path;
- }
-
- public IClasspathEntry[] getClasspathEntries() {
- if (entries == null) {
- ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance()
- .findRuntimeByName(segment);
- if (jbws != null) {
- if (jbws.isUserConfigClasspath()) {
- for (String jar : jbws.getLibraries()) {
- entryList.add(getEntry(new Path(jar)));
- }
- entries = entryList
- .toArray(new IClasspathEntry[entryList.size()]);
- } else {
- IPath wsPath = new Path(jbws.getHomeDir());
- if (wsPath != null) {
- IPath libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Lib);
- entryList.addAll(Arrays.asList(getEntries(libPath,
- entryList)));
- libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Client);
- entryList.addAll(Arrays.asList(getEntries(libPath,
- entryList)));
- entries = entryList
- .toArray(new IClasspathEntry[entryList
- .size()]);
- }
- }
- if (entries == null)
- return new IClasspathEntry[0];
- }
- }
- return entries;
- }
-
- protected IClasspathEntry getEntry(IPath path) {
- return JavaRuntime.newArchiveRuntimeClasspathEntry(path)
- .getClasspathEntry();
- }
-
- protected IClasspathEntry[] getEntries(IPath folder,
- ArrayList<IClasspathEntry> entryList) {
- String[] files = folder.toFile().list();
- ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- for (int i = 0; i < files.length; i++) {
- if (files[i].endsWith(".jar")
- && filterJars(files[i], entryList)) {
- list.add(getEntry(folder.append(files[i])));
- } else if (folder.append(files[i]).toFile().isDirectory()) {
- list.addAll(Arrays.asList(getEntries(folder
- .append(files[i]), entryList)));
- }
- }
- return list.toArray(new IClasspathEntry[list.size()]);
- }
-
- public void removeEntry(String jarName) {
- if (entries == null) {
- return;
- }
- IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
- int i = 0;
- for (IClasspathEntry entry : entries) {
- if (!entry.toString().contains(jarName)) {
- newEntries[i++] = entry;
- }
- }
- entries = newEntries;
- }
-
- }
-
- public boolean filterJars(String jarName, ArrayList<IClasspathEntry> list) {
- for (IClasspathEntry entry : list) {
- if (entry.getPath().lastSegment().equals(jarName)) {
- return false;
- }
- }
- return true;
- }
-
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeListConverter.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,141 +0,0 @@
-package org.jboss.tools.ws.core.classpath;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-
-/**
- *
- * @author Grid Qian
- *
- */
-public class JbossWSRuntimeListConverter {
-
- /*
- * Constants definitions
- */
- private static final String REGEXP_ESCAPE = "\\";
- private static final String COMMA = ",";
- private static final String LIBRARY_SEPARATOR = ";";
- private static final String EMPTY_STRING = "";
- private static final String FIELD_SEPARATOR = "|";
- private static final String DEFAULT = "default";
- private static final String HOME_DIR = "homeDir";
- private static final String VERSION = "version";
- private static final String NAME = "name";
- private static final String USER_CONFIG_CLASSPATH = "userConfig";
- private static final String LIBRARY = "libraries";
-
- /**
- * Load String to JbossWSRuntime map from String
- * @param input
- * String representation of map
- * @return
- * Map<String, JbossWSRuntime> loaded from string
- * TODO - switch to XML?
- * TODO - write converter from old serialization format to XML?
- * TODO - handle errors in string format
- */
- public Map<String, JbossWSRuntime> getMap(String input) {
-
- Map<String, JbossWSRuntime> result = new HashMap<String, JbossWSRuntime>();
- if (input == null || EMPTY_STRING.equals(input.trim())) {
- return result;
- }
- StringTokenizer runtimes = new StringTokenizer(input, COMMA);
- while (runtimes.hasMoreTokens()) {
- String runtime = runtimes.nextToken();
- String[] map = runtime.split(REGEXP_ESCAPE + FIELD_SEPARATOR);
- JbossWSRuntime rt = new JbossWSRuntime();
- final int step = 2;
- for (int i = 0; i < map.length; i += step) {
- String name = map[i];
- String value = i + 1 < map.length ? map[i + 1] : EMPTY_STRING;
- if (NAME.equals(name)) {
- rt.setName(value);
- } else if (HOME_DIR.equals(name)) {
- rt.setHomeDir(value);
- } else if (VERSION.equals(name)) {
- rt.setVersion(value);
- } else if (DEFAULT.equals(name)) {
- rt.setDefault(Boolean.parseBoolean(value));
- }else if(USER_CONFIG_CLASSPATH.equals(name)){
- rt.setUserConfigClasspath(Boolean.parseBoolean(value));
- }else if(LIBRARY.equals(name)){
- if(value != null && !EMPTY_STRING.equals(value)){
- rt.setLibraries(getLibrariesFromString(value));
- }
- }
-
- }
- result.put(rt.getName(), rt);
- }
-
- return result;
- }
-
- private List<String> getLibrariesFromString(String strLibraries){
- List<String> libraries = new ArrayList<String>();
- StringTokenizer st = new StringTokenizer(strLibraries, LIBRARY_SEPARATOR);
- while(st.hasMoreTokens()){
- String library = st.nextToken();
- if(!libraries.contains(library)){
- libraries.add(library);
- }
- }
- return libraries;
-
- }
-
- private String convertListToString(List<String> libraries){
- String strLib = "";
- for(String library: libraries){
- if("".equals(strLib)){
- strLib = library;
- }else{
- strLib = strLib + LIBRARY_SEPARATOR + library;
- }
- }
- return strLib;
- }
-
- /**
- * Convert map String to JbossWSRUntime to string representation
- * @param runtimeMap
- * Map<String, JbossWSRuntime> - map of String to JbossWS Runtime to convert
- * in String
- * @return
- * String representation of String to JbossWS Runtime map
- */
- public String getString(Map<String, JbossWSRuntime> runtimeMap) {
- StringBuffer buffer = new StringBuffer();
- JbossWSRuntime[] runtimes = runtimeMap.values().toArray(
- new JbossWSRuntime[runtimeMap.size()]);
- for (int i = 0; i < runtimes.length; i++) {
- buffer.append(NAME).append(FIELD_SEPARATOR);
- buffer.append(runtimes[i].getName());
- buffer.append(FIELD_SEPARATOR).append(VERSION).append(
- FIELD_SEPARATOR);
- buffer.append(runtimes[i].getVersion());
- buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
- FIELD_SEPARATOR);
- buffer.append(runtimes[i].getHomeDir());
- buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
- FIELD_SEPARATOR);
- buffer.append(runtimes[i].isDefault());
- buffer.append(FIELD_SEPARATOR).append(USER_CONFIG_CLASSPATH).append(FIELD_SEPARATOR);
- buffer.append(runtimes[i].isUserConfigClasspath());
- buffer.append(FIELD_SEPARATOR).append(LIBRARY).append(FIELD_SEPARATOR);
- buffer.append(convertListToString(runtimes[i].getLibraries()));
- if (i != runtimes.length - 1) {
- buffer.append(COMMA);
- }
- }
- return buffer.toString();
- }
- }
-
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.classpath;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jface.preference.IPersistentPreferenceStore;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimeManager {
-
- private static JbossWSRuntimeListConverter converter = new JbossWSRuntimeListConverter();
-
- private Map<String, JbossWSRuntime> runtimes = new HashMap<String, JbossWSRuntime>();
-
- /**
- * Private constructor
- */
- private JbossWSRuntimeManager() {
- load();
- }
-
- /**
- * This class make Java Runtime responsible for solving synchronization
- * problems during initialization if there is any
- *
- */
- static class JbossWSRuntimeManagerHolder {
- private static final JbossWSRuntimeManager INSTANCE = new JbossWSRuntimeManager();
- }
-
- /**
- * Return JbossWSRuntimeManaher instance
- *
- * @return JbossWSRuntimeManager instance
- */
- public static JbossWSRuntimeManager getInstance() {
- return JbossWSRuntimeManagerHolder.INSTANCE;
- }
-
- /**
- * Return Array of configured JbossWSRuntimes
- *
- * @return JbossWSRuntime[]
- */
- public JbossWSRuntime[] getRuntimes() {
- Collection<JbossWSRuntime> c = runtimes.values();
- return c.toArray(new JbossWSRuntime[runtimes.size()]);
- }
-
- /**
- * Add new JbossWSRuntime
- *
- * @param runtime
- * JbossWSRuntime
- */
- public void addRuntime(JbossWSRuntime runtime) {
- if (runtimes.size() == 0) {
- runtime.setDefault(true);
- }
-
- JbossWSRuntime oldDefaultRuntime = getDefaultRuntime();
- if (oldDefaultRuntime != null && runtime.isDefault()) {
- oldDefaultRuntime.setDefault(false);
- }
- runtimes.put(runtime.getName(), runtime);
- save();
- }
-
- /**
- * Add new JbossWSRuntime with given parameters
- *
- * @param name
- * String - runtime name
- * @param path
- * String - runtime home folder
- * @param version
- * String - string representation of version number
- * @param defaultRt
- * boolean - default flag
- */
- public void addRuntime(String name, String path, String version,
- boolean defaultRt) {
- JbossWSRuntime jbossWSRt = new JbossWSRuntime();
- jbossWSRt.setHomeDir(path);
- jbossWSRt.setName(name);
- jbossWSRt.setVersion(version);
- jbossWSRt.setDefault(defaultRt);
- addRuntime(jbossWSRt);
- }
-
- /**
- * Return JbossWSRuntime by given name
- *
- * @param name
- * String - JbossWSRuntime name
- * @return JbossWSRuntime - found JbossWSRuntime instance or null
- */
- public JbossWSRuntime findRuntimeByName(String name) {
- for (JbossWSRuntime jbossWSRuntime : runtimes.values()) {
- if (jbossWSRuntime.getName().equals(name)) {
- return jbossWSRuntime;
- }
- }
- return null;
- }
-
- public List<String> getAllRuntimeJars(JbossWSRuntime rt){
- List<String> jarList = new ArrayList<String>();
- if (rt != null) {
- if (rt.isUserConfigClasspath()) {
- jarList.addAll(rt.getLibraries());
-
- } else {
- IPath wsPath = new Path(rt.getHomeDir());
- if (wsPath != null) {
- IPath libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Lib);
- List<File> libs = getJarsOfFolder(libPath.toFile());
- libPath = wsPath
- .append(JbossWSCoreMessages.Dir_Client);
- List<File> clientJars = getJarsOfFolder(libPath.toFile());
-
- jarList = mergeTwoList(libs, clientJars);
- }
- }
-
- }
- return jarList;
- }
-
-
-
- private List<File> getJarsOfFolder(File folder){
- List<File> jars = new ArrayList<File>();
- if(folder.isDirectory()){
- for(File file: folder.listFiles()){
- if(file.isFile() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))){
- jars.add(file);
- }else if (folder.isDirectory()){
- jars.addAll(getJarsOfFolder(file));
- }
- }
- }
-
- return jars;
- }
-
- // if two folders have the same jar file, one of them will be ignored.
- private List<String> mergeTwoList(List<File> jarList1, List<File> jarList2){
- List<String> rtList = new ArrayList<String>();
- List<String> distinctFileNames = new ArrayList<String>();
-
- for(File jarFile: jarList1){
- distinctFileNames.add(jarFile.getName());
- rtList.add(jarFile.getAbsolutePath());
- }
- for(File jarFile: jarList2){
- if(!distinctFileNames.contains(jarFile.getName())){
- rtList.add(jarFile.getAbsolutePath());
- }
- }
-
- return rtList;
-
- }
-
- /**
- * Remove given JbossWSRuntime from manager
- *
- * @param rt
- * JbossWSRuntime
- */
- public void removeRuntime(JbossWSRuntime rt) {
- runtimes.remove(rt.getName());
- }
-
- /**
- * Save preference value and force save changes to disk
- */
- public void save() {
- JbossWSCorePlugin.getDefault().getPreferenceStore().setValue(
- JbossWSCoreMessages.WS_Location, converter.getString(runtimes));
- IPreferenceStore store = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
- if (store instanceof IPersistentPreferenceStore) {
- try {
- ((IPersistentPreferenceStore) store).save();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Marks this runtime as default. Marks other runtimes with the same version
- * as not default.
- *
- * @param runtime
- */
- public void setDefaultRuntime(JbossWSRuntime runtime) {
- JbossWSRuntime[] runtimes = getRuntimes();
- for (int i = 0; i < runtimes.length; i++) {
- runtimes[i].setDefault(false);
- }
- runtime.setDefault(true);
- }
-
- /**
- * Return first default JbossWSRuntime
- *
- * @return JbossWSRuntime
- */
- public JbossWSRuntime getDefaultRuntime() {
- for (JbossWSRuntime rt : runtimes.values()) {
- if (rt.isDefault()) {
- return rt;
- }
- }
- return null;
- }
-
- /**
- * Return list of available JbossWSRuntime names
- *
- * @return List<String>
- */
- public List<String> getRuntimeNames() {
- JbossWSRuntime[] rts = getRuntimes();
- List<String> result = new ArrayList<String>();
- for (JbossWSRuntime jbossWSRuntime : rts) {
- result.add(jbossWSRuntime.getName());
- }
- return result;
- }
-
- /**
- * Return a list of all runtime names
- *
- * @return List of all runtime names
- */
- public List<String> getAllRuntimeNames() {
- JbossWSRuntime[] rts = getRuntimes();
- List<String> result = new ArrayList<String>();
- for (JbossWSRuntime jbossWSRuntime : rts) {
- result.add(jbossWSRuntime.getName());
- }
- return result;
- }
-
- /**
- * TBD
- *
- * @param oldName
- * old runtime name
- * @param newName
- * new runtime name
- */
- public void changeRuntimeName(String oldName, String newName) {
- JbossWSRuntime o = findRuntimeByName(oldName);
- if (o == null) {
- return;
- }
- o.setName(newName);
- onRuntimeNameChanged(oldName, newName);
- }
-
- private void onRuntimeNameChanged(String oldName, String newName) {
- IProjectFacet facet = ProjectFacetsManager
- .getProjectFacet("jbossws.core");
- Set<IFacetedProject> facetedProjects = null;
- try {
- facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (IFacetedProject facetedProject : facetedProjects) {
- QualifiedName qRuntimeName = IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
- String name = null;
- try {
- name = facetedProject.getProject().getPersistentProperty(
- qRuntimeName);
- if (name != null && name.equals(oldName)) {
- facetedProject.getProject().setPersistentProperty(
- qRuntimeName, newName);
- }
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- }
-
- public static boolean isRuntimeUsed(String name) {
- IProjectFacet facet = ProjectFacetsManager
- .getProjectFacet("jbossws.core");
- Set<IFacetedProject> facetedProjects = null;
- try {
- facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- for (IFacetedProject facetedProject : facetedProjects) {
- QualifiedName qRuntimeName = IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
- try {
- if (name.equals(facetedProject.getProject()
- .getPersistentProperty(qRuntimeName))) {
- return true;
- }
- } catch (CoreException e) {
- e.printStackTrace();
- }
- }
- return false;
- }
-
- public void load() {
- IPreferenceStore ps = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
-
- String runtimeListString = ps
- .getString(JbossWSCoreMessages.WS_Location);
-
- runtimes = converter.getMap(runtimeListString);
- }
-
-}
\ No newline at end of file
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.command;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
+import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSClassPathCommand extends AbstractDataModelOperation {
+
+ IProject project;
+ private IDataModel model;
+
+ public JBossWSClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ this.model = model;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ boolean isServerSupplied = model
+ .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED);
+ if (isServerSupplied) {
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME,
+ IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED);
+ } else {
+ // store runtime name and runtime location to the project
+
+ String runtimeName = model
+ .getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID);
+ String runtimeLocation = model
+ .getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME);
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME,
+ runtimeName);
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION,
+ runtimeLocation);
+ boolean isDeployed = model
+ .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY);
+
+ status = addClassPath(project, runtimeName, isDeployed);
+ }
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JBossWSCoreMessages.Error_Add_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus addClassPath(IProject project, String segment,
+ boolean isDeployed) {
+ IStatus status = Status.OK_STATUS;
+ try {
+
+ IClasspathEntry newClasspath;
+ IJavaProject javaProject = JavaCore.create(project);
+
+ if (isDeployed) {
+ IClasspathAttribute depAttrib = JavaCore
+ .newClasspathAttribute(
+ IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY,
+ ClasspathDependencyUtil.getDefaultRuntimePath(
+ true).toString());
+ newClasspath = JavaCore.newContainerEntry(new Path(
+ JBossWSCoreMessages.JBossWS_Runtime_Lib)
+ .append(segment), null,
+ new IClasspathAttribute[] { depAttrib }, true);
+ } else {
+ newClasspath = JavaCore.newContainerEntry(new Path(
+ JBossWSCoreMessages.JBossWS_Runtime_Lib)
+ .append(segment));
+ }
+
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (oldClasspathEntries[i].getPath().equals(
+ newClasspath.getPath())) {
+ isFolderInClassPathAlready = true;
+ break;
+ }
+ }
+
+ if (!isFolderInClassPathAlready) {
+
+ IClasspathEntry[] newClasspathEntries = new IClasspathEntry[oldClasspathEntries.length + 1];
+ for (int i = 0; i < oldClasspathEntries.length; i++) {
+ newClasspathEntries[i] = oldClasspathEntries[i];
+ }
+ newClasspathEntries[oldClasspathEntries.length] = newClasspath;
+
+ javaProject.setRawClasspath(newClasspathEntries,
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
\ No newline at end of file
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JbossWSClassPathCommand.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
-import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-import org.jboss.tools.ws.core.utils.StatusUtils;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSClassPathCommand extends AbstractDataModelOperation {
-
- IProject project;
- private IDataModel model;
-
- public JbossWSClassPathCommand(IProject project, IDataModel model) {
- this.project = project;
- this.model = model;
- }
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- return executeOverride(monitor);
- }
-
- public IStatus executeOverride(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- boolean isServerSupplied = model
- .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED);
- if (isServerSupplied) {
- project
- .setPersistentProperty(
- IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME,
- IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED);
- } else {
- // store runtime name and runtime location to the project
-
- String runtimeName = model
- .getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID);
- String runtimeLocation = model
- .getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME);
- project
- .setPersistentProperty(
- IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME,
- runtimeName);
- project
- .setPersistentProperty(
- IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION,
- runtimeLocation);
- boolean isDeployed = model
- .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY);
-
- status = addClassPath(project, runtimeName, isDeployed);
- }
-
- } catch (CoreException e) {
- status = StatusUtils.errorStatus(
- JbossWSCoreMessages.Error_Add_Facet_JBossWS, e);
- }
- return status;
- }
-
- public IStatus addClassPath(IProject project, String segment,
- boolean isDeployed) {
- IStatus status = Status.OK_STATUS;
- try {
-
- IClasspathEntry newClasspath;
- IJavaProject javaProject = JavaCore.create(project);
-
- if (isDeployed) {
- IClasspathAttribute depAttrib = JavaCore
- .newClasspathAttribute(
- IClasspathDependencyConstants.CLASSPATH_COMPONENT_DEPENDENCY,
- ClasspathDependencyUtil.getDefaultRuntimePath(
- true).toString());
- newClasspath = JavaCore.newContainerEntry(new Path(
- JbossWSCoreMessages.JBossWS_Runtime_Lib)
- .append(segment), null,
- new IClasspathAttribute[] { depAttrib }, true);
- } else {
- newClasspath = JavaCore.newContainerEntry(new Path(
- JbossWSCoreMessages.JBossWS_Runtime_Lib)
- .append(segment));
- }
-
- IClasspathEntry[] oldClasspathEntries = javaProject
- .readRawClasspath();
-
- boolean isFolderInClassPathAlready = false;
- for (int i = 0; i < oldClasspathEntries.length
- && !isFolderInClassPathAlready; i++) {
- if (oldClasspathEntries[i].getPath().equals(
- newClasspath.getPath())) {
- isFolderInClassPathAlready = true;
- break;
- }
- }
-
- if (!isFolderInClassPathAlready) {
-
- IClasspathEntry[] newClasspathEntries = new IClasspathEntry[oldClasspathEntries.length + 1];
- for (int i = 0; i < oldClasspathEntries.length; i++) {
- newClasspathEntries[i] = oldClasspathEntries[i];
- }
- newClasspathEntries[oldClasspathEntries.length] = newClasspath;
-
- javaProject.setRawClasspath(newClasspathEntries,
- new NullProgressMonitor());
- }
- } catch (JavaModelException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Copy, new String[] { e
- .getLocalizedMessage() }), e);
- return status;
- }
-
- return status;
- }
-
-}
\ No newline at end of file
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,102 @@
+package org.jboss.tools.ws.core.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+import org.jboss.tools.ws.core.utils.StatusUtils;
+
+public class UninstallJBossWSClassPathCommand {
+ IProject project;
+
+ public UninstallJBossWSClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ boolean isServerSupplied = Boolean
+ .getBoolean(project
+ .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME));
+ if (isServerSupplied) {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
+ } else {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION);
+ String runtimeName = project
+ .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+
+ status = removeClassPath(project, runtimeName);
+ }
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JBossWSCoreMessages.Error_Remove_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus removeClassPath(IProject project, String segment) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (!oldClasspathEntries[i].getPath().equals(
+ new Path(JBossWSCoreMessages.JBossWS_Runtime_Lib)
+ .append(segment))) {
+ classpathEntries.add(oldClasspathEntries[i]);
+ }
+ }
+ if (classpathEntries.size() < oldClasspathEntries.length) {
+ javaProject.setRawClasspath(classpathEntries
+ .toArray(new IClasspathEntry[classpathEntries.size()]),
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Remove_Facet_JBossWS,
+ new String[] { e.getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJbossWSClassPathCommand.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,102 +0,0 @@
-package org.jboss.tools.ws.core.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-import org.jboss.tools.ws.core.utils.StatusUtils;
-
-public class UninstallJbossWSClassPathCommand {
- IProject project;
-
- public UninstallJbossWSClassPathCommand(IProject project, IDataModel model) {
- this.project = project;
- }
-
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- return executeOverride(monitor);
- }
-
- public IStatus executeOverride(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- boolean isServerSupplied = Boolean
- .getBoolean(project
- .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME));
- if (isServerSupplied) {
-// project
-// .getPersistentProperties()
-// .remove(
-// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
- } else {
-// project
-// .getPersistentProperties()
-// .remove(
-// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
-// project
-// .getPersistentProperties()
-// .remove(
-// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION);
- String runtimeName = project
- .getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
-
- status = removeClassPath(project, runtimeName);
- }
-
- } catch (CoreException e) {
- status = StatusUtils.errorStatus(
- JbossWSCoreMessages.Error_Remove_Facet_JBossWS, e);
- }
- return status;
- }
-
- public IStatus removeClassPath(IProject project, String segment) {
- IStatus status = Status.OK_STATUS;
- try {
- IJavaProject javaProject = JavaCore.create(project);
- IClasspathEntry[] oldClasspathEntries = javaProject
- .readRawClasspath();
-
- boolean isFolderInClassPathAlready = false;
- List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
- for (int i = 0; i < oldClasspathEntries.length
- && !isFolderInClassPathAlready; i++) {
- if (!oldClasspathEntries[i].getPath().equals(
- new Path(JbossWSCoreMessages.JBossWS_Runtime_Lib)
- .append(segment))) {
- classpathEntries.add(oldClasspathEntries[i]);
- }
- }
- if (classpathEntries.size() < oldClasspathEntries.length) {
- javaProject.setRawClasspath(classpathEntries
- .toArray(new IClasspathEntry[classpathEntries.size()]),
- new NullProgressMonitor());
- }
- } catch (JavaModelException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Remove_Facet_JBossWS,
- new String[] { e.getLocalizedMessage() }), e);
- return status;
- }
-
- return status;
- }
-
-}
Modified: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSFacetInstallDataModelProvider.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -13,7 +13,6 @@
import java.util.Set;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.jboss.tools.ws.core.utils.StatusUtils;
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSInstallRuntimeDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSInstallRuntimeDelegate.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSInstallRuntimeDelegate.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.facet.delegate;
+
+import org.eclipse.core.resources.IProject;
+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.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.ws.core.command.JBossWSClassPathCommand;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSInstallRuntimeDelegate implements IDelegate {
+
+ public void execute(IProject project, IProjectFacetVersion arg1,
+ Object arg2, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(JBossWSCoreMessages.Progress_Install_JBossWS_Runtime,
+ 2);
+
+ IDataModel model = (IDataModel) arg2;
+
+ JBossWSClassPathCommand command = new JBossWSClassPathCommand(project,
+ model);
+ IStatus status = command.executeOverride(monitor);
+ if(!status.equals(Status.OK_STATUS)){
+ throw new CoreException(status);
+ }
+ monitor.worked(1);
+ monitor.done();
+ }
+
+}
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSUnInstallRuntimeDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSUnInstallRuntimeDelegate.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JBossWSUnInstallRuntimeDelegate.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.facet.delegate;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.jboss.tools.ws.core.command.UninstallJBossWSClassPathCommand;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSUnInstallRuntimeDelegate implements IDelegate {
+
+ public void execute(IProject project, IProjectFacetVersion arg1,
+ Object arg2, IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(
+ JBossWSCoreMessages.Progress_UnInstall_JBossWS_Runtime, 2);
+
+ IDataModel model = (IDataModel) arg2;
+
+ UninstallJBossWSClassPathCommand command = new UninstallJBossWSClassPathCommand(
+ project, model);
+ command.executeOverride(monitor);
+ monitor.worked(1);
+ monitor.done();
+ }
+
+}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSInstallRuntimeDelegate.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.facet.delegate;
-
-import org.eclipse.core.resources.IProject;
-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.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IDelegate;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.jboss.tools.ws.core.command.JbossWSClassPathCommand;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSInstallRuntimeDelegate implements IDelegate {
-
- public void execute(IProject project, IProjectFacetVersion arg1,
- Object arg2, IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(JbossWSCoreMessages.Progress_Install_JBossWS_Runtime,
- 2);
-
- IDataModel model = (IDataModel) arg2;
-
- JbossWSClassPathCommand command = new JbossWSClassPathCommand(project,
- model);
- IStatus status = command.executeOverride(monitor);
- if(!status.equals(Status.OK_STATUS)){
- throw new CoreException(status);
- }
- monitor.worked(1);
- monitor.done();
- }
-
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/JbossWSUnInstallRuntimeDelegate.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.facet.delegate;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.project.facet.core.IDelegate;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.jboss.tools.ws.core.command.UninstallJbossWSClassPathCommand;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSUnInstallRuntimeDelegate implements IDelegate {
-
- public void execute(IProject project, IProjectFacetVersion arg1,
- Object arg2, IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(
- JbossWSCoreMessages.Progress_UnInstall_JBossWS_Runtime, 2);
-
- IDataModel model = (IDataModel) arg2;
-
- UninstallJbossWSClassPathCommand command = new UninstallJbossWSClassPathCommand(
- project, model);
- command.executeOverride(monitor);
- monitor.worked(1);
- monitor.done();
- }
-
-}
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCore.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCore.properties (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCore.properties 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,15 @@
+Progress_Install_JBossWS_Runtime=JBoss Web Service Runtime
+Progress_UnInstall_JBossWS_Runtime=Uninstall JBoss Web Service Runtime
+Dir_Lib=lib
+Dir_Client=client
+Dir_Web_Inf=WEB-INF
+Dir_Web_Content=WebContent
+Error_Copy=Exception while copy JBossWS jars
+WS_Location=jbosswsruntimelocation
+JBossWS_Runtime_Lib=JBossWS_Runtime
+JBossWS_Runtime=JBoss WS Runtime
+JBossAS=JBOSS
+Error_WS_Location=The JBoss WS Runtime Location is NULL
+Error_WS_Classpath=A error comes up when create JBoss WS Classpath
+Error_Add_Facet_JBossWS=Exception while install JBossWS facet
+Error_Remove_Facet_JBossWS=Exception while uninstall JBossWS facet
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCoreMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCoreMessages.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JBossWSCoreMessages.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSCoreMessages {
+
+ private static final String BUNDLE_NAME = "org.jboss.tools.ws.core.messages.JBossWSCore"; //$NON-NLS-1$
+
+ private JBossWSCoreMessages() {
+ // Do not instantiate
+ }
+
+ public static String Progress_Install_JBossWS_Runtime;
+ public static String Progress_UnInstall_JBossWS_Runtime;
+ public static String Dir_Lib;
+ public static String Dir_Client;
+ public static String Dir_Web_Inf;
+ public static String Dir_Web_Content;
+ public static String Error_Copy;
+ public static String WS_Location;
+ public static String JBossWS_Runtime_Lib;
+ public static String JBossWS_Runtime;
+ public static String JBossAS;
+ public static String Error_WS_Location;
+ public static String Error_WS_Classpath;
+ public static String Error_Add_Facet_JBossWS;
+ public static String Error_Remove_Facet_JBossWS;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JBossWSCoreMessages.class);
+ }
+}
\ No newline at end of file
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCore.properties 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,15 +0,0 @@
-Progress_Install_JBossWS_Runtime=JBoss Web Service Runtime
-Progress_UnInstall_JBossWS_Runtime=Uninstall JBoss Web Service Runtime
-Dir_Lib=lib
-Dir_Client=client
-Dir_Web_Inf=WEB-INF
-Dir_Web_Content=WebContent
-Error_Copy=Exception while copy JBossWS jars
-WS_Location=jbosswsruntimelocation
-JBossWS_Runtime_Lib=JBossWS_Runtime
-JBossWS_Runtime=JBoss WS Runtime
-JBossAS=JBOSS
-Error_WS_Location=The JBoss WS Runtime Location is NULL
-Error_WS_Classpath=A error comes up when create JBoss WS Classpath
-Error_Add_Facet_JBossWS=Exception while install JBossWS facet
-Error_Remove_Facet_JBossWS=Exception while uninstall JBossWS facet
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/messages/JbossWSCoreMessages.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.messages;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSCoreMessages {
-
- private static final String BUNDLE_NAME = "org.jboss.tools.ws.core.messages.JbossWSCore"; //$NON-NLS-1$
-
- private JbossWSCoreMessages() {
- // Do not instantiate
- }
-
- public static String Progress_Install_JBossWS_Runtime;
- public static String Progress_UnInstall_JBossWS_Runtime;
- public static String Dir_Lib;
- public static String Dir_Client;
- public static String Dir_Web_Inf;
- public static String Dir_Web_Content;
- public static String Error_Copy;
- public static String WS_Location;
- public static String JBossWS_Runtime_Lib;
- public static String JBossWS_Runtime;
- public static String JBossAS;
- public static String Error_WS_Location;
- public static String Error_WS_Classpath;
- public static String Error_Add_Facet_JBossWS;
- public static String Error_Remove_Facet_JBossWS;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JbossWSCoreMessages.class);
- }
-}
\ No newline at end of file
Added: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JBossWSCoreUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JBossWSCoreUtils.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JBossWSCoreUtils.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jst.ws.internal.common.J2EEUtils;
+import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSCoreUtils {
+
+ public static IPath pathToWebProjectContainer(String project) {
+ IPath projectRoot = getProjectRoot(project);
+ IPath currentDynamicWebProjectDir = J2EEUtils
+ .getWebContentPath(getProjectName(project));
+ IPath currentDynamicWebProjectDirWithoutProjectRoot = J2EEUtils
+ .getWebContentPath(getProjectName(project))
+ .removeFirstSegments(1).makeAbsolute();
+ if (projectRoot.toOSString().contains(getWorkspace().toOSString())) {
+ return getWorkspace().append(currentDynamicWebProjectDir);
+ } else {
+ return projectRoot
+ .append(currentDynamicWebProjectDirWithoutProjectRoot);
+ }
+
+ }
+
+ public static IPath getProjectRoot(String project) {
+ String projectString = replaceEscapecharactors(project.toString());
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(
+ getProjectNameFromFramewokNameString(projectString))
+ .getLocation();
+ }
+
+ // Fix for the windows build not working
+ private static String replaceEscapecharactors(String vulnarableString) {
+ if (vulnarableString.indexOf("/") != -1) {
+ vulnarableString = vulnarableString.replace('/', File.separator
+ .charAt(0));
+ }
+ return vulnarableString;
+ }
+
+ private static String getProjectNameFromFramewokNameString(
+ String frameworkProjectString) {
+ if (frameworkProjectString.indexOf(getSplitCharactor()) == -1) {
+ return frameworkProjectString;
+ } else {
+ return frameworkProjectString.split(getSplitCharactors())[1];
+ }
+ }
+
+ private static String getSplitCharactor() {
+ // Windows check (because from inside wtp in return I received a hard
+ // coded path)
+ if (File.separatorChar == '\\') {
+ return "\\";
+ } else {
+ return File.separator;
+ }
+ }
+
+ private static String getSplitCharactors() {
+ // Windows check (because from inside wtp in return I received a hard
+ // coded path)
+ if (File.separatorChar == '\\') {
+ return "\\" + File.separator;
+ } else {
+ return File.separator;
+ }
+ }
+
+ public static IPath getWorkspace() {
+ return ResourcesPlugin.getWorkspace().getRoot().getLocation();
+ }
+
+ public static IWorkspaceRoot getWorkspaceRoot() {
+ return ResourcesPlugin.getWorkspace().getRoot();
+ }
+
+ public static IProject getProjectName(String project) {
+ String projectString = replaceEscapecharactors(project.toString());
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(
+ getProjectNameFromFramewokNameString(projectString));
+ }
+
+ public static IStatus copy(IPath sourcePath, IPath targetPath) {
+
+ IStatus status = Status.OK_STATUS;
+ File sourceDir = sourcePath.toFile();
+ File[] children = sourceDir.listFiles();
+
+ FileInputStream finStream = null;
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].isFile()) {
+ try {
+ finStream = new FileInputStream(children[i]);
+ } catch (FileNotFoundException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ }
+ try {
+ makeFile(getWorkspaceRoot().getContainerForLocation(
+ targetPath), children[i].getName(), finStream);
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ }
+ } else {
+ try {
+ IFolder temp = makeFolder(getWorkspaceRoot()
+ .getContainerForLocation(targetPath), children[i]
+ .getName());
+ copy(sourcePath.append(children[i].getName()), temp
+ .getLocation());
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossWSCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ }
+ }
+ }
+ return status;
+ }
+
+ private static IFolder makeFolder(IContainer parent, String folderName)
+ throws CoreException {
+ IResource child = parent.findMember(folderName);
+ if (child == null) {
+ IFolder folder = parent.getFolder(new Path(folderName));
+ try {
+ folder.create(true, true, null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return folder;
+ } else {
+ if (child.getType() == IResource.FOLDER) {
+ return (IFolder) child;
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR,
+ "ResourceUtils", 0, NLS.bind("ERROR",// EnvironmentMessages.MSG_ERROR_RESOURCE_NOT_FOLDER,
+ new Object[] { parent.getFullPath().append(
+ folderName).toString() }), null));
+ }
+ }
+
+ }
+
+ private static IFile makeFile(IContainer parent, String fileName,
+ InputStream inputStream) throws CoreException {
+ IResource child = parent.findMember(fileName);
+
+ if (child != null) {
+ if (child.getType() == IResource.FILE) {
+
+ // We have permission to overwrite so check if file is read-only
+ if (child.getResourceAttributes() != null
+ && child.getResourceAttributes().isReadOnly()) {
+ IFile[] files = new IFile[1];
+ files[0] = (IFile) child;
+ }
+
+ // Change the contents of the existing file.
+ IFile file = parent.getFile(new Path(fileName));
+ file.setContents(inputStream, true, true, null);
+
+ return file;
+
+ } else {
+ throw new CoreException(new Status(IStatus.ERROR,
+ "ResourceUtils", 0, NLS.bind("ERROR",
+ new Object[] { parent.getFullPath().append(
+ fileName) }), null));
+ }
+ } else {
+ // Create a new file.
+ IFile file = parent.getFile(new Path(fileName));
+ file.create(inputStream, true, null);
+
+ return file;
+ }
+ }
+
+
+
+
+}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/utils/JbossWSCoreUtils.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.ws.internal.common.J2EEUtils;
-import org.eclipse.osgi.util.NLS;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSCoreUtils {
-
- public static IPath pathToWebProjectContainer(String project) {
- IPath projectRoot = getProjectRoot(project);
- IPath currentDynamicWebProjectDir = J2EEUtils
- .getWebContentPath(getProjectName(project));
- IPath currentDynamicWebProjectDirWithoutProjectRoot = J2EEUtils
- .getWebContentPath(getProjectName(project))
- .removeFirstSegments(1).makeAbsolute();
- if (projectRoot.toOSString().contains(getWorkspace().toOSString())) {
- return getWorkspace().append(currentDynamicWebProjectDir);
- } else {
- return projectRoot
- .append(currentDynamicWebProjectDirWithoutProjectRoot);
- }
-
- }
-
- public static IPath getProjectRoot(String project) {
- String projectString = replaceEscapecharactors(project.toString());
- return ResourcesPlugin.getWorkspace().getRoot().getProject(
- getProjectNameFromFramewokNameString(projectString))
- .getLocation();
- }
-
- // Fix for the windows build not working
- private static String replaceEscapecharactors(String vulnarableString) {
- if (vulnarableString.indexOf("/") != -1) {
- vulnarableString = vulnarableString.replace('/', File.separator
- .charAt(0));
- }
- return vulnarableString;
- }
-
- private static String getProjectNameFromFramewokNameString(
- String frameworkProjectString) {
- if (frameworkProjectString.indexOf(getSplitCharactor()) == -1) {
- return frameworkProjectString;
- } else {
- return frameworkProjectString.split(getSplitCharactors())[1];
- }
- }
-
- private static String getSplitCharactor() {
- // Windows check (because from inside wtp in return I received a hard
- // coded path)
- if (File.separatorChar == '\\') {
- return "\\";
- } else {
- return File.separator;
- }
- }
-
- private static String getSplitCharactors() {
- // Windows check (because from inside wtp in return I received a hard
- // coded path)
- if (File.separatorChar == '\\') {
- return "\\" + File.separator;
- } else {
- return File.separator;
- }
- }
-
- public static IPath getWorkspace() {
- return ResourcesPlugin.getWorkspace().getRoot().getLocation();
- }
-
- public static IWorkspaceRoot getWorkspaceRoot() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
-
- public static IProject getProjectName(String project) {
- String projectString = replaceEscapecharactors(project.toString());
- return ResourcesPlugin.getWorkspace().getRoot().getProject(
- getProjectNameFromFramewokNameString(projectString));
- }
-
- public static IStatus copy(IPath sourcePath, IPath targetPath) {
-
- IStatus status = Status.OK_STATUS;
- File sourceDir = sourcePath.toFile();
- File[] children = sourceDir.listFiles();
-
- FileInputStream finStream = null;
- for (int i = 0; i < children.length; i++) {
- if (children[i].isFile()) {
- try {
- finStream = new FileInputStream(children[i]);
- } catch (FileNotFoundException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Copy, new String[] { e
- .getLocalizedMessage() }), e);
- }
- try {
- makeFile(getWorkspaceRoot().getContainerForLocation(
- targetPath), children[i].getName(), finStream);
- } catch (CoreException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Copy, new String[] { e
- .getLocalizedMessage() }), e);
- }
- } else {
- try {
- IFolder temp = makeFolder(getWorkspaceRoot()
- .getContainerForLocation(targetPath), children[i]
- .getName());
- copy(sourcePath.append(children[i].getName()), temp
- .getLocation());
- } catch (CoreException e) {
- status = StatusUtils.errorStatus(NLS.bind(
- JbossWSCoreMessages.Error_Copy, new String[] { e
- .getLocalizedMessage() }), e);
- }
- }
- }
- return status;
- }
-
- private static IFolder makeFolder(IContainer parent, String folderName)
- throws CoreException {
- IResource child = parent.findMember(folderName);
- if (child == null) {
- IFolder folder = parent.getFolder(new Path(folderName));
- try {
- folder.create(true, true, null);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return folder;
- } else {
- if (child.getType() == IResource.FOLDER) {
- return (IFolder) child;
- } else {
- throw new CoreException(new Status(IStatus.ERROR,
- "ResourceUtils", 0, NLS.bind("ERROR",// EnvironmentMessages.MSG_ERROR_RESOURCE_NOT_FOLDER,
- new Object[] { parent.getFullPath().append(
- folderName).toString() }), null));
- }
- }
-
- }
-
- private static IFile makeFile(IContainer parent, String fileName,
- InputStream inputStream) throws CoreException {
- IResource child = parent.findMember(fileName);
-
- if (child != null) {
- if (child.getType() == IResource.FILE) {
-
- // We have permission to overwrite so check if file is read-only
- if (child.getResourceAttributes() != null
- && child.getResourceAttributes().isReadOnly()) {
- IFile[] files = new IFile[1];
- files[0] = (IFile) child;
- }
-
- // Change the contents of the existing file.
- IFile file = parent.getFile(new Path(fileName));
- file.setContents(inputStream, true, true, null);
-
- return file;
-
- } else {
- throw new CoreException(new Status(IStatus.ERROR,
- "ResourceUtils", 0, NLS.bind("ERROR",
- new Object[] { parent.getFullPath().append(
- fileName) }), null));
- }
- } else {
- // Create a new file.
- IFile file = parent.getFile(new Path(fileName));
- file.create(inputStream, true, null);
-
- return file;
- }
- }
-
-
-
-
-}
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC (rev 8979)
@@ -30,7 +30,7 @@
org.eclipse.wst.common.project.facet.core,
org.eclipse.wst.server.core,
org.jboss.tools.common
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.core,
org.jboss.tools.ws.creation.core.commands,
org.jboss.tools.ws.creation.core.data,
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/AbstractGenerateCodeCommand.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -45,7 +45,7 @@
.getWebProjectName());
try {
- String runtimeLocation = JBossWSCreationUtils.getJbossWSRuntimeLocation(project);
+ String runtimeLocation = JBossWSCreationUtils.getJBossWSRuntimeLocation(project);
String commandLocation = runtimeLocation + Path.SEPARATOR + "bin";
IPath path = new Path(commandLocation);
String command = "sh " + cmdFileName_linux;
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialClientCommand.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -30,7 +30,7 @@
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
import org.jboss.tools.ws.creation.core.utils.WSDLPropertyReader;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -55,13 +55,13 @@
try {
String location = JBossWSCreationUtils
- .getJbossWSRuntimeLocation(JBossWSCreationUtils
+ .getJBossWSRuntimeLocation(JBossWSCreationUtils
.getProjectByName(model.getWebProjectName()));
if (location.equals("")) {
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
- } else if (!new Path(location).append(JbossWSUIMessages.Bin)
- .append(JbossWSUIMessages.Command).toFile().exists()) {
+ } else if (!new Path(location).append(JBossWSUIMessages.Bin)
+ .append(JBossWSUIMessages.Command).toFile().exists()) {
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/InitialCommand.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -15,13 +15,13 @@
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
import org.eclipse.wst.ws.internal.wsrt.IWebService;
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
+import org.jboss.tools.ws.core.JBossWSCorePlugin;
import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.core.utils.JBossWSCreationUtils;
import org.jboss.tools.ws.creation.core.utils.WSDLPropertyReader;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
public class InitialCommand extends AbstractDataModelOperation {
@@ -40,11 +40,11 @@
throws ExecutionException {
try {
- String location = JBossWSCreationUtils.getJbossWSRuntimeLocation(JBossWSCreationUtils.getProjectByName(model.getWebProjectName()));
+ String location = JBossWSCreationUtils.getJBossWSRuntimeLocation(JBossWSCreationUtils.getProjectByName(model.getWebProjectName()));
if (location.equals("")) {
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
- } else if(!new Path(location).append(JbossWSUIMessages.Bin).append(JbossWSUIMessages.Command).toFile().exists()){
+ } else if(!new Path(location).append(JBossWSUIMessages.Bin).append(JBossWSUIMessages.Command).toFile().exists()){
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_WS_Location);
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RemoveClientJarsCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RemoveClientJarsCommand.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/RemoveClientJarsCommand.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -22,8 +22,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeClassPathInitializer.JbossWSRuntimeClasspathContainer;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer.JBossWSRuntimeClasspathContainer;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
import org.jboss.tools.ws.creation.core.data.ServiceModel;
@@ -71,9 +70,9 @@
for(IClasspathEntry entry:entries){
IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project);
- if(container instanceof JbossWSRuntimeClasspathContainer){
- ((JbossWSRuntimeClasspathContainer)container).removeEntry("jaxws-rt.jar");
- ((JbossWSRuntimeClasspathContainer)container).removeEntry("jaxws-tools.jar");
+ if(container instanceof JBossWSRuntimeClasspathContainer){
+ ((JBossWSRuntimeClasspathContainer)container).removeEntry("jaxws-rt.jar");
+ ((JBossWSRuntimeClasspathContainer)container).removeEntry("jaxws-tools.jar");
}
}
} catch (JavaModelException e) {
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -44,11 +44,11 @@
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.server.core.IRuntime;
import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
+import org.jboss.tools.ws.core.JBossWSCorePlugin;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
@@ -273,15 +273,15 @@
}
public static boolean validateJBossWSLocation() {
- String location = JbossWSCorePlugin.getDefault().getPreferenceStore()
- .getString(JbossWSCoreMessages.WS_Location);
+ String location = JBossWSCorePlugin.getDefault().getPreferenceStore()
+ .getString(JBossWSCoreMessages.WS_Location);
if (location == null || location.equals("")) {
return false;
}
return true;
}
- public static String getJbossWSRuntimeLocation(IProject project)
+ public static String getJBossWSRuntimeLocation(IProject project)
throws CoreException {
String isServerSupplied = project
@@ -293,7 +293,7 @@
&& !"".equals(jbwsRuntimeName)
&& !IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED
.equals(isServerSupplied)) {
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance()
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance()
.findRuntimeByName(jbwsRuntimeName);
if (jbws != null) {
return jbws.getHomeDir();
@@ -332,7 +332,7 @@
// if no target runtime has been specified, get runtime location from
// default jbossws runtime
if (prjFacetRuntime == null) {
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance()
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance()
.getDefaultRuntime();
if (jbws != null) {
return jbws.getHomeDir();
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC (rev 8979)
@@ -25,5 +25,5 @@
org.eclipse.wst.common.modulecore,
org.eclipse.wst.common.project.facet.ui,
org.jboss.tools.ws.ui
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.ui.wsrt
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -41,13 +41,13 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModelListener;
import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
import org.jboss.tools.ws.core.utils.StatusUtils;
import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
import org.jboss.tools.ws.creation.ui.CreationUIPlugin;
-import org.jboss.tools.ws.ui.preferences.JbossRuntimeListFieldEditor;
+import org.jboss.tools.ws.ui.preferences.JBossRuntimeListFieldEditor;
/**
* @author Dennyxu
@@ -135,7 +135,7 @@
cmbRuntimes.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String runtimeName = cmbRuntimes.getText();
- JbossWSRuntime jr = (JbossWSRuntime) cmbRuntimes
+ JBossWSRuntime jr = (JBossWSRuntime) cmbRuntimes
.getData(runtimeName);
saveJBosswsRuntimeToModel(jr);
}
@@ -166,7 +166,7 @@
}
- protected void saveJBosswsRuntimeToModel(JbossWSRuntime jbws) {
+ protected void saveJBosswsRuntimeToModel(JBossWSRuntime jbws) {
String duplicateMsg = "";
try {
duplicateMsg = getDuplicateJars(jbws.getName());
@@ -214,7 +214,7 @@
IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
false);
String runtimeId = cmbRuntimes.getText();
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance().findRuntimeByName(runtimeId);
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance().findRuntimeByName(runtimeId);
if (jbws != null) {
@@ -233,15 +233,15 @@
}
protected void initializeRuntimesCombo(Combo cmRuntime, String runtimeName) {
- JbossWSRuntime selectedJbws = null;
- JbossWSRuntime defaultJbws = null;
+ JBossWSRuntime selectedJbws = null;
+ JBossWSRuntime defaultJbws = null;
int selectIndex = 0;
int defaultIndex = 0;
cmRuntime.removeAll();
- JbossWSRuntime[] runtimes = JbossWSRuntimeManager.getInstance()
+ JBossWSRuntime[] runtimes = JBossWSRuntimeManager.getInstance()
.getRuntimes();
for (int i = 0; i < runtimes.length; i++) {
- JbossWSRuntime jr = runtimes[i];
+ JBossWSRuntime jr = runtimes[i];
cmRuntime.add(jr.getName());
cmRuntime.setData(jr.getName(), jr);
@@ -269,16 +269,16 @@
* create a new jbossws runtime and set user supplied runtime to the new one
*/
protected void newJBossWSRuntime() {
- List<JbossWSRuntime> exists = new ArrayList<JbossWSRuntime>(Arrays.asList(JbossWSRuntimeManager.getInstance().getRuntimes()));
- List<JbossWSRuntime> added = new ArrayList<JbossWSRuntime>();
+ List<JBossWSRuntime> exists = new ArrayList<JBossWSRuntime>(Arrays.asList(JBossWSRuntimeManager.getInstance().getRuntimes()));
+ List<JBossWSRuntime> added = new ArrayList<JBossWSRuntime>();
- JbossRuntimeListFieldEditor.JbossWSRuntimeNewWizard newRtwizard = new JbossRuntimeListFieldEditor.JbossWSRuntimeNewWizard(
+ JBossRuntimeListFieldEditor.JBossWSRuntimeNewWizard newRtwizard = new JBossRuntimeListFieldEditor.JBossWSRuntimeNewWizard(
exists, added) {
public boolean performFinish() {
- JbossWSRuntime rt = getRuntime();
+ JBossWSRuntime rt = getRuntime();
rt.setDefault(true);
- JbossWSRuntimeManager.getInstance().addRuntime(rt);
- JbossWSRuntimeManager.getInstance().save();
+ JBossWSRuntimeManager.getInstance().addRuntime(rt);
+ JBossWSRuntimeManager.getInstance().save();
return true;
}
@@ -333,11 +333,11 @@
List<String> allExistingJars = new ArrayList<String>();
List<String> runtimeJars = new ArrayList<String>();
- JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance().findRuntimeByName(jbwsName);
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance().findRuntimeByName(jbwsName);
if(jbws.isUserConfigClasspath()){
runtimeJars.addAll(jbws.getLibraries());
}else{
- runtimeJars.addAll(JbossWSRuntimeManager.getInstance().getAllRuntimeJars(jbws));
+ runtimeJars.addAll(JBossWSRuntimeManager.getInstance().getAllRuntimeJars(jbws));
}
String prjName = model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/wsrt/JBossWebService.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -59,7 +59,7 @@
commands.add(new ValidateWSImplCommand(model));
commands.add(new WSProviderInvokeCommand(model));
commands.add(new MergeWebXMLCommand(model));
- //commands.add(new JbossWSRuntimeCommand(ResourcesPlugin.getWorkspace().getRoot().getProject(project)));
+ //commands.add(new JBossWSRuntimeCommand(ResourcesPlugin.getWorkspace().getRoot().getProject(project)));
}
return new SimpleCommandFactory(commands);
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC (rev 8979)
@@ -3,7 +3,7 @@
Bundle-Name: %PLUGIN_NAME
Bundle-SymbolicName: org.jboss.tools.ws.ui;singleton:=true
Bundle-Version: 1.0.0
-Bundle-Activator: org.jboss.tools.ws.ui.JbossWSUIPlugin
+Bundle-Activator: org.jboss.tools.ws.ui.JBossWSUIPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -11,7 +11,7 @@
org.jboss.tools.ws.core,
org.eclipse.ui.ide,
org.eclipse.wst.common.project.facet.core
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.ui,
org.jboss.tools.ws.ui.messages,
org.jboss.tools.ws.ui.preferences
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/plugin.xml 2008-06-27 08:19:24 UTC (rev 8979)
@@ -3,8 +3,8 @@
<page
name="%JBOSSWS_PREFERENCE_PAGE"
category="org.eclipse.wst.ws.internal.ui.preferences.name"
- class="org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage"
- id="org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage">
+ class="org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage"
+ id="org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage">
</page>
</extension>
</plugin>
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JBossWSUIPlugin.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class JBossWSUIPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.ws.ui";
+
+ // The shared instance
+ private static JBossWSUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public JBossWSUIPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static JBossWSUIPlugin getDefault() {
+ return plugin;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ path = "icons/" + path; //$NON-NLS-1$
+ return AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.ws.ui", path); //$NON-NLS-1$
+ }
+}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIPlugin.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIPlugin.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/JbossWSUIPlugin.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class JbossWSUIPlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.tools.ws.ui";
-
- // The shared instance
- private static JbossWSUIPlugin plugin;
-
- /**
- * The constructor
- */
- public JbossWSUIPlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static JbossWSUIPlugin getDefault() {
- return plugin;
- }
-
- public static ImageDescriptor getImageDescriptor(String path) {
- path = "icons/" + path; //$NON-NLS-1$
- return AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.ws.ui", path); //$NON-NLS-1$
- }
-}
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUI.properties 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,37 @@
+Label_JBossWS_Runtime_Load_Error=Error occurred while loading JBossWS Command. Select the correct JBoss Server or JBoss EAP folder.
+
+Command=wsconsume.sh
+Bin=bin
+Client=client
+Lib=lib
+Endorsed=endorsed
+
+Error_JBossWS_Basic_Editor_Composite=Parent control should be Composite
+Error_JBossWS_Basic_Editor_Support=Editor supports only grid layout
+Error_JBossWS_Basic_Editor_Different=Parent for label is different
+JBossWS_Runtime_List_Field_Editor_Name=Name
+JBossWS_Runtime_List_Field_Editor_Version=Version
+JBossWS_Runtime_List_Field_Editor_Path=Path
+JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be=inputElement must be
+JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List=an instance of List<JBossWSRuntime>.
+JBossWS_Runtime_Delete_Confirm_Title=Confirm Runtime Delete
+JBossWS_Runtime_Delete_Used_Confirm=Runtime ''{0}'' is used by JBossWS projects. Are you sure you want to delete it?
+JBossWS_Runtime_Delete_Not_Used_Confirm=Are you sure you want to delete runtime ''{0}''?
+JBossWS_Runtime_List_Field_Editor_Edit_Runtime=Edit JBossWS Runtime
+JBossWS_Runtime_List_Field_Editor_Modify_Runtime=Input new values
+JBossWS_Runtime_List_Field_Editor_New_Runtime=New JBossWS Runtime
+Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty=Path to JBossWS home directory cannot be empty
+JBossWS_Runtime_List_Field_Editor_Already_Exists=' already exists
+JBossWS_Runtime_List_Field_Editor_Runtime=JBossWS Runtime
+Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct=Runtime name is not correct
+Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty=Name cannot be empty
+JBossWS_Runtime_List_Field_Editor_Create_A_Runtime=Create a JBossWS Runtime
+JBossWS_Runtime_List_Field_Editor_Home_Folder=Home Folder:
+JBossWS_Composite_Editor_This_Method_Can_Be_Invoked=This metod can be invoked after getEditorControls(parent) only
+JBossWS_Button_Field_Editor_Browse=Browse...
+Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet=Not implemented yet. Please setup real acion for editor.
+JBossWS_SWT_Field_Editor_Factory_Browse=Browse...
+JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder=Select JBossWS Home Folder
+JBossWS_Runtime_List_Field_Editor_Name2=Name:
+JBossWS_Runtime_Check_Field_Default_Classpath=Configure JBoss Web Service Classpath
+JBossWS_Preference_Page_Runtimes=JBossWS Runtimes
\ No newline at end of file
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JBossWSUIMessages.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public final class JBossWSUIMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
+ "org.jboss.tools.ws.ui.messages.JBossWSUI"; //$NON-NLS-1$
+
+ private JBossWSUIMessages() {
+ // Do not instantiate
+ }
+
+ public static String Label_JBossWS_Runtime_Load_Error;
+
+ public static String Bin;
+ public static String Command;
+ public static String Client;
+ public static String Lib;
+ public static String Endorsed;
+
+ public static String Error_JBossWS_Basic_Editor_Composite;
+ public static String Error_JBossWS_Basic_Editor_Support;
+ public static String Error_JBossWS_Basic_Editor_Different;
+ public static String JBossWS_Runtime_List_Field_Editor_Name;
+ public static String JBossWS_Runtime_List_Field_Editor_Version;
+ public static String JBossWS_Runtime_List_Field_Editor_Path;
+ public static String JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be;
+ public static String JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List;
+ public static String JBossWS_Runtime_Delete_Confirm_Title;
+ public static String JBossWS_Runtime_Delete_Used_Confirm;
+ public static String JBossWS_Runtime_Delete_Not_Used_Confirm;
+ public static String JBossWS_Runtime_List_Field_Editor_Edit_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_Modify_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_New_Runtime;
+ public static String Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty;
+ public static String JBossWS_Runtime_List_Field_Editor_Already_Exists;
+ public static String JBossWS_Runtime_List_Field_Editor_Runtime;
+ public static String Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct;
+ public static String Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty;
+ public static String JBossWS_Runtime_List_Field_Editor_Create_A_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_Home_Folder;
+ public static String JBossWS_Composite_Editor_This_Method_Can_Be_Invoked;
+ public static String JBossWS_Button_Field_Editor_Browse;
+ public static String Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet;
+ public static String JBossWS_SWT_Field_Editor_Factory_Browse;
+ public static String JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder;
+ public static String JBossWS_Runtime_List_Field_Editor_Name2;
+ public static String JBossWS_Runtime_Check_Field_Default_Classpath;
+ public static String JBossWS_Preference_Page_Runtimes;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JBossWSUIMessages.class);
+ }
+}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUI.properties 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,37 +0,0 @@
-Label_JBossWS_Runtime_Load_Error=Error occurred while loading JBossWS runtime. Select the correct JBossWS runtime folder.
-
-Command=wsconsume.sh
-Bin=bin
-Client=client
-Lib=lib
-Endorsed=endorsed
-
-Error_JBossWS_Basic_Editor_Composite=Parent control should be Composite
-Error_JBossWS_Basic_Editor_Support=Editor supports only grid layout
-Error_JBossWS_Basic_Editor_Different=Parent for label is different
-JBossWS_Runtime_List_Field_Editor_Name=Name
-JBossWS_Runtime_List_Field_Editor_Version=Version
-JBossWS_Runtime_List_Field_Editor_Path=Path
-JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be=inputElement must be
-JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List=an instance of List<JBossWSRuntime>.
-JBossWS_Runtime_Delete_Confirm_Title=Confirm Runtime Delete
-JBossWS_Runtime_Delete_Used_Confirm=Runtime ''{0}'' is used by JBossWS projects. Are you sure you want to delete it?
-JBossWS_Runtime_Delete_Not_Used_Confirm=Are you sure you want to delete runtime ''{0}''?
-JBossWS_Runtime_List_Field_Editor_Edit_Runtime=Edit JBossWS Runtime
-JBossWS_Runtime_List_Field_Editor_Modify_Runtime=Input new values
-JBossWS_Runtime_List_Field_Editor_New_Runtime=New JBossWS Runtime
-Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty=Path to JBossWS home directory cannot be empty
-JBossWS_Runtime_List_Field_Editor_Already_Exists=' already exists
-JBossWS_Runtime_List_Field_Editor_Runtime=JBossWS Runtime
-Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct=Runtime name is not correct
-Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty=Name cannot be empty
-JBossWS_Runtime_List_Field_Editor_Create_A_Runtime=Create a JBossWS Runtime
-JBossWS_Runtime_List_Field_Editor_Home_Folder=Home Folder:
-JBossWS_Composite_Editor_This_Method_Can_Be_Invoked=This metod can be invoked after getEditorControls(parent) only
-JBossWS_Button_Field_Editor_Browse=Browse...
-Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet=Not implemented yet. Please setup real acion for editor.
-JBossWS_SWT_Field_Editor_Factory_Browse=Browse...
-JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder=Select JBossWS Home Folder
-JBossWS_Runtime_List_Field_Editor_Name2=Name:
-JBossWS_Runtime_Check_Field_Default_Classpath=Configure JBoss Web Service Classpath
-JBossWS_Preference_Page_Runtimes=JBossWS Runtimes
\ No newline at end of file
Deleted: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/messages/JbossWSUIMessages.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.messages;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @author Grid Qian
- */
-public final class JbossWSUIMessages extends NLS {
-
- private static final String BUNDLE_NAME =
- "org.jboss.tools.ws.ui.messages.JbossWSUI"; //$NON-NLS-1$
-
- private JbossWSUIMessages() {
- // Do not instantiate
- }
-
- public static String Label_JBossWS_Runtime_Load_Error;
-
- public static String Bin;
- public static String Command;
- public static String Client;
- public static String Lib;
- public static String Endorsed;
-
- public static String Error_JBossWS_Basic_Editor_Composite;
- public static String Error_JBossWS_Basic_Editor_Support;
- public static String Error_JBossWS_Basic_Editor_Different;
- public static String JBossWS_Runtime_List_Field_Editor_Name;
- public static String JBossWS_Runtime_List_Field_Editor_Version;
- public static String JBossWS_Runtime_List_Field_Editor_Path;
- public static String JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be;
- public static String JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List;
- public static String JBossWS_Runtime_Delete_Confirm_Title;
- public static String JBossWS_Runtime_Delete_Used_Confirm;
- public static String JBossWS_Runtime_Delete_Not_Used_Confirm;
- public static String JBossWS_Runtime_List_Field_Editor_Edit_Runtime;
- public static String JBossWS_Runtime_List_Field_Editor_Modify_Runtime;
- public static String JBossWS_Runtime_List_Field_Editor_New_Runtime;
- public static String Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty;
- public static String JBossWS_Runtime_List_Field_Editor_Already_Exists;
- public static String JBossWS_Runtime_List_Field_Editor_Runtime;
- public static String Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct;
- public static String Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty;
- public static String JBossWS_Runtime_List_Field_Editor_Create_A_Runtime;
- public static String JBossWS_Runtime_List_Field_Editor_Home_Folder;
- public static String JBossWS_Composite_Editor_This_Method_Can_Be_Invoked;
- public static String JBossWS_Button_Field_Editor_Browse;
- public static String Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet;
- public static String JBossWS_SWT_Field_Editor_Factory_Browse;
- public static String JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder;
- public static String JBossWS_Runtime_List_Field_Editor_Name2;
- public static String JBossWS_Runtime_Check_Field_Default_Classpath;
- public static String JBossWS_Preference_Page_Runtimes;
-
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, JbossWSUIMessages.class);
- }
-}
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/BaseFieldEditor.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -26,7 +26,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -66,8 +66,8 @@
* @param parent
*/
public void doFillIntoGrid(Object parent) {
- Assert.isTrue(parent instanceof Composite, JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
- Assert.isTrue(((Composite)parent).getLayout() instanceof GridLayout,JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Assert.isTrue(parent instanceof Composite, JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite)parent).getLayout() instanceof GridLayout,JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
Composite aComposite = (Composite) parent;
final Control[] controls = (Control[])getEditorControls(aComposite);
GridLayout gl = (GridLayout)((Composite)parent).getLayout();
@@ -110,7 +110,7 @@
labelControl.setText(this.labelText);
} else if(parent!=null) {
if(labelControl.getParent()!=parent)
- throw new IllegalArgumentException(JbossWSUIMessages.Error_JBossWS_Basic_Editor_Different);
+ throw new IllegalArgumentException(JBossWSUIMessages.Error_JBossWS_Basic_Editor_Different);
}
return labelControl;
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/ButtonFieldEditor.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -16,7 +16,7 @@
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -26,10 +26,10 @@
PushButtonField button= null;
int style;
- private ButtonPressedAction buttonAction = new ButtonPressedAction(JbossWSUIMessages.JBossWS_Button_Field_Editor_Browse) {
+ private ButtonPressedAction buttonAction = new ButtonPressedAction(JBossWSUIMessages.JBossWS_Button_Field_Editor_Browse) {
@Override
public void run() {
- throw new RuntimeException(JbossWSUIMessages.Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet);
+ throw new RuntimeException(JBossWSUIMessages.Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet);
}
};
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/CompositeEditor.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -27,7 +27,7 @@
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
* @author Grid Qian
@@ -41,9 +41,9 @@
@Override
public void doFillIntoGrid(Object parent) {
Assert.isTrue(parent instanceof Composite,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
Composite aComposite = (Composite) parent;
final Control[] controls = (Control[]) getEditorControls(aComposite);
@@ -78,7 +78,7 @@
@Override
public Object[] getEditorControls() {
if(controls.size()>0) return controls.toArray();
- else throw new IllegalStateException(JbossWSUIMessages.JBossWS_Composite_Editor_This_Method_Can_Be_Invoked);
+ else throw new IllegalStateException(JBossWSUIMessages.JBossWS_Composite_Editor_This_Method_Can_Be_Invoked);
}
@Override
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossRuntimeListFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossRuntimeListFieldEditor.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossRuntimeListFieldEditor.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,1110 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.preferences;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TableColumn;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+import org.jboss.tools.ws.ui.utils.UIUtils;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntimeListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private CheckboxTableViewer tableView = null;
+
+ private Composite root = null;
+
+ private ActionPanel actionPanel;
+
+ private Map<JBossWSRuntime, JBossWSRuntime> changed = new HashMap<JBossWSRuntime, JBossWSRuntime>();
+
+ private JBossWSRuntime checkedElement = new JBossWSRuntime();
+
+ private List<JBossWSRuntime> added = new ArrayList<JBossWSRuntime>();
+
+ private List<JBossWSRuntime> removed = new ArrayList<JBossWSRuntime>();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Control for editing jbossWSRuntime list
+ *
+ * @param name
+ * String
+ * @param label
+ * String
+ * @param defaultValue
+ * Object
+ */
+ public JBossRuntimeListFieldEditor(String name, String label,
+ Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ /**
+ * TBD
+ *
+ * @return JBossWSRuntime;
+ */
+ public JBossWSRuntime getDefaultJBossWSRuntime() {
+ return checkedElement;
+ }
+
+ public void setDefaultJBossWSRuntime(JBossWSRuntime rt) {
+ checkedElement = rt;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossWSRuntime>
+ */
+ public List<JBossWSRuntime> getAddedJBossWSRuntimes() {
+ return added;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossWSRuntime>
+ */
+ public Map<JBossWSRuntime, JBossWSRuntime> getChangedJBossWSRuntimes() {
+ return changed;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossWSRuntime>
+ */
+ public List<JBossWSRuntime> getRemoved() {
+ return removed;
+ }
+
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ root.setLayout(new FormLayout());
+ createTableView();
+ createActionBar();
+
+ FormData tableData = new FormData();
+ tableData.left = new FormAttachment(0, 5);
+ tableData.right = new FormAttachment(actionPanel, -5);
+ tableData.top = new FormAttachment(0, 5);
+ tableData.bottom = new FormAttachment(100, -5);
+ tableView.getControl().setLayoutData(tableData);
+
+ FormData actionsData = new FormData();
+ actionsData.top = new FormAttachment(0, 5);
+ actionsData.bottom = new FormAttachment(100, -5);
+ actionsData.right = new FormAttachment(100, -5);
+ actionPanel.setLayoutData(actionsData);
+ return new Control[] { root };
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void createTableView() {
+ tableView = CheckboxTableViewer.newCheckList(root, SWT.V_SCROLL
+ | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
+
+ TableColumn tc1 = new TableColumn(tableView.getTable(), SWT.CENTER);
+ tc1.setWidth(TC_DEFAULT_WIDTH);
+ tc1.setResizable(false);
+
+ TableColumn tc2 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc2.setWidth(TC_NAME_WIDTH);
+ tc2.setText(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name);
+
+ TableColumn tc3 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc3.setWidth(TC_VERSION_WIDTH);
+ tc3
+ .setText(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version);
+
+ TableColumn tc4 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc4.setWidth(TC_PATH_WIDTH);
+ tc4.setText(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Path);
+
+ tableView.setContentProvider(new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List<JBossWSRuntime>) inputElement).toArray();
+ } else {
+ throw new IllegalArgumentException(
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
+ + JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ viewer.refresh();
+ }
+ });
+
+ tableView.setLabelProvider(new ITableLabelProvider() {
+
+ private static final int TC_DEFAULT_NUMBER = 0;
+ private static final int TC_NAME_NUMBER = 1;
+ private static final int TC_VERSION_NUMBER = 2;
+ private static final int TC_PATH_NUMBER = 3;
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ JBossWSRuntime rt = (JBossWSRuntime) element;
+ if (columnIndex == TC_DEFAULT_NUMBER) {
+ return ""; //$NON-NLS-1$
+ }
+ if (columnIndex == TC_NAME_NUMBER) {
+ return rt.getName();
+ }
+ if (columnIndex == TC_VERSION_NUMBER) {
+ return rt.getVersion().toString();
+ }
+ if (columnIndex == TC_PATH_NUMBER) {
+ return rt.getHomeDir();
+ }
+ return ""; //$NON-NLS-1$
+ }
+ });
+
+ tableView.setInput(getValue());
+ tableView.getTable().setLinesVisible(true);
+ tableView.getTable().setHeaderVisible(true);
+ tableView.addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ JBossWSRuntime selRt = (JBossWSRuntime) event.getElement();
+ if (event.getChecked()) {
+ JBossWSRuntime deselRt = null;
+ Object[] selRts = tableView.getCheckedElements();
+
+ for (int i = 0; i < selRts.length; i++) {
+ JBossWSRuntime rt = (JBossWSRuntime) selRts[i];
+ if (rt != selRt) {
+ deselRt = rt;
+ break;
+ }
+ }
+
+ if (deselRt != null) {
+ Object[] newChecked = new Object[selRts.length - 1];
+ checkedElement = null;
+ int i = 0;
+ for (Object object : selRts) {
+ JBossWSRuntime rt = (JBossWSRuntime) object;
+ if (rt == selRt) {
+ newChecked[i] = rt;
+ checkedElement = rt;
+ i++;
+ }
+ }
+ tableView.setCheckedElements(newChecked);
+ } else {
+ checkedElement = (JBossWSRuntime) event.getElement();
+ }
+ } else {
+ if (checkedElement == selRt) {
+ checkedElement = null;
+ }
+ }
+ pcs.firePropertyChange(getName(), null, getValue());
+ }
+ });
+
+ for (JBossWSRuntime rt : (List<JBossWSRuntime>) getValue()) {
+ if (rt.isDefault()) {
+ tableView.setChecked(rt, true);
+ checkedElement = rt;
+ }
+ }
+ }
+
+ protected void createActionBar() {
+ actionPanel = new ActionPanel(root, new BaseAction[] { new AddAction(),
+ new EditAction(), new RemoveAction() });
+ tableView.addSelectionChangedListener(actionPanel);
+ }
+
+ /**
+ * Checks all runtimes and set default one if user did not do it.
+ */
+ @SuppressWarnings("unchecked")
+ private void setDefaultRuntime() {
+ List<JBossWSRuntime> runtimes = (List<JBossWSRuntime>) getValue();
+ boolean checked = false;
+ for (JBossWSRuntime jbossWSRuntime : runtimes) {
+
+ if (checkedElement == jbossWSRuntime) {
+ checked = true;
+ tableView.setChecked(checkedElement, true);
+ break;
+ }
+ }
+ if (!checked && runtimes.size() > 0) {
+ if (tableView.getCheckedElements() == null
+ || tableView.getCheckedElements().length == 0) {
+ tableView.setChecked(runtimes.get(0), true);
+ checkedElement = runtimes.get(0);
+ }
+ }
+
+ }
+
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] { root };
+ }
+
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /**
+ * Fill wizard page with editors
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
+ }
+
+ /**
+ * Wizard page for editing JBossWS Runtime parameters
+ *
+ */
+ public static class JBossWSRuntimeWizardPage extends WizardPage implements
+ PropertyChangeListener {
+
+ private static final String SRT_NAME = "name";
+ private static final String SRT_VERSION = "version";
+ private static final String SRT_HOMEDIR = "homeDir";
+
+ private static final int GL_PARENT_COLUMNS = 1;
+ private static final int GL_CONTENT_COLUMNS = 3;
+
+ List<JBossWSRuntime> value = null;
+
+ IFieldEditor name = createTextEditor(SRT_NAME,
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name2, ""); //$NON-NLS-1$
+
+ IFieldEditor version = createTextEditor(SRT_VERSION,
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version, ""); //$NON-NLS-1$
+
+ IFieldEditor homeDir = createBrowseFolderEditor(
+ SRT_HOMEDIR,
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Home_Folder,
+ ""); //$NON-NLS-1$
+
+ JBossWSRuntime current = null;
+
+ IFieldEditor jars = null;
+
+ public JBossWSRuntimeWizardPage(List<JBossWSRuntime> editedList) {
+ super(
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
+
+ setMessage(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Create_A_Runtime);
+ setTitle(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime);
+ value = editedList;
+ }
+
+ /**
+ * Create Wizard page content
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ public void createControl(Composite parent) {
+ parent.setLayout(new GridLayout(GL_PARENT_COLUMNS, false));
+ GridData dg = new GridData();
+ dg.horizontalAlignment = GridData.FILL;
+ dg.grabExcessHorizontalSpace = true;
+ Composite root = new Composite(parent, SWT.NONE);
+ root.setLayoutData(dg);
+ GridLayout gl = new GridLayout(GL_CONTENT_COLUMNS, false);
+ root.setLayout(gl);
+ name.doFillIntoGrid(root);
+ name.addPropertyChangeListener(this);
+ version.doFillIntoGrid(root);
+ version.addPropertyChangeListener(this);
+ homeDir.doFillIntoGrid(root);
+ homeDir.addPropertyChangeListener(this);
+
+ jars = new JBossWSLibraryListFieldEditor("", "", current);
+ jars.doFillIntoGrid(root);
+ jars.addPropertyChangeListener(this);
+ setPageComplete(false);
+ setControl(root);
+ }
+
+ /**
+ * Process evt: setup default values based on JBossWS Home folder and
+ * validate user input
+ *
+ * @param evt
+ * PropertyChangeEvent describes changes in wizard
+ */
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ if ("homeDir".equals(evt.getPropertyName())) {
+ if (name.getValueAsString() == null
+ || "".equals(name.getValueAsString().trim())
+ || this.getErrorMessage() != null) {
+ String homeDirName = homeDir.getValueAsString();
+ if (homeDirName != null && !"".equals(homeDirName.trim())) {
+ File folder = new File(homeDirName);
+ homeDirName = folder.getName();
+ }
+ name.setValue(homeDirName);
+ }
+ }
+
+ if (name.getValueAsString() == null || "".equals(//$NON-NLS-1$
+ name.getValueAsString().toString().trim())) {
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!name.getValueAsString().matches(
+ "[a-zA-Z_][a-zA-Z0-9_\\-\\. ]*")) { //$NON-NLS-1$
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct);
+ setPageComplete(false);
+ return;
+ }
+ for (JBossWSRuntime rt : value) {
+ if (current != null && current.getName().equals(rt.getName())) {
+ continue;
+ }
+ if (rt.getName().equals(name.getValueAsString())) {
+ setErrorMessage(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime
+ + name.getValueAsString()
+ + JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Already_Exists);
+ setPageComplete(false);
+ return;
+ }
+ }
+
+ JBossWSRuntime jarJbws = (JBossWSRuntime) jars.getValue();
+ if (current != null
+ && current.getName().equals(name.getValueAsString())
+ && current.getHomeDir().equals(homeDir.getValueAsString())
+ && current.getVersion().equals(version.getValueAsString())
+ && current.isUserConfigClasspath() == jarJbws
+ .isUserConfigClasspath()
+ && (!jarJbws.isUserConfigClasspath() || hasSameLibraies(
+ current.getLibraries(), jarJbws.getLibraries()))) {
+
+ setErrorMessage(null);
+ setPageComplete(false);
+ return;
+ }
+
+ if (jarJbws.isUserConfigClasspath()
+ && jarJbws.getLibraries().size() == 0) {
+ setErrorMessage("The library must contian at least one jar.");
+ setPageComplete(false);
+ return;
+ }
+
+ if (homeDir.getValueAsString() == null
+ || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
+ setErrorMessage(JBossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!runtimeExist(homeDir.getValueAsString())) {
+ setErrorMessage(JBossWSUIMessages.Label_JBossWS_Runtime_Load_Error);
+ setPageComplete(false);
+ return;
+ }
+
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+
+ private boolean hasSameLibraies(List<String> lib1, List<String> lib2) {
+ if (lib1.size() != lib2.size())
+ return false;
+ for (String jar : lib1) {
+ if (!lib2.contains(jar))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return JBossWS Runtime instance initialized by user input
+ *
+ * @return JBossWSRuntime instance
+ */
+ public JBossWSRuntime getRuntime() {
+ JBossWSRuntime newRt = new JBossWSRuntime();
+ newRt.setName(name.getValueAsString());
+ newRt.setVersion(version.getValueAsString());
+ newRt.setHomeDir(homeDir.getValueAsString());
+ JBossWSRuntime rt = (JBossWSRuntime) jars.getValue();
+ newRt.setLibraries(rt.getLibraries());
+ newRt.setUserConfigClasspath(rt.isUserConfigClasspath());
+ return newRt;
+ }
+
+ public IFieldEditor createTextEditor(String name, String label,
+ String defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name, label,
+ defaultValue);
+ editor.addFieldEditors(new IFieldEditor[] {
+ new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue) });
+ return editor;
+ }
+
+ public IFieldEditor createBrowseFolderEditor(String name, String label,
+ String defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name, label,
+ defaultValue);
+ editor
+ .addFieldEditors(new IFieldEditor[] {
+ new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue),
+ new ButtonFieldEditor(
+ name,
+ createSelectFolderAction(JBossWSUIMessages.JBossWS_SWT_Field_Editor_Factory_Browse),
+ defaultValue) });
+ return editor;
+ }
+
+ public ButtonFieldEditor.ButtonPressedAction createSelectFolderAction(
+ String buttonName) {
+ return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+ @Override
+ public void run() {
+ DirectoryDialog dialog = new DirectoryDialog(Display
+ .getCurrent().getActiveShell());
+ dialog.setFilterPath(getFieldEditor().getValueAsString());
+ dialog
+ .setMessage(JBossWSUIMessages.JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder);
+ dialog.setFilterPath(getFieldEditor().getValueAsString());
+ String directory = dialog.open();
+ if (directory != null) {
+ getFieldEditor().setValue(directory);
+ }
+ }
+ };
+ }
+
+ private boolean runtimeExist(String path) {
+
+ File jbosswsHomeDir = new File(path);
+ if (!jbosswsHomeDir.isDirectory())
+ return false;
+ String[] newNode = { JBossWSUIMessages.Bin,
+ JBossWSUIMessages.Command };
+ String jbosswsBinPath = UIUtils.addNodesToPath(jbosswsHomeDir
+ .getAbsolutePath(), newNode);
+ if (new File(jbosswsBinPath).isFile()
+ && new File(UIUtils.addAnotherNodeToPath(jbosswsHomeDir
+ .getAbsolutePath(), JBossWSUIMessages.Client))
+ .isDirectory()
+ && new File(UIUtils
+ .addNodesToPath(jbosswsHomeDir.getAbsolutePath(),
+ new String[] { JBossWSUIMessages.Lib,
+ JBossWSUIMessages.Endorsed }))
+ .isDirectory()) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Wizard collect information and creates new JBossWSRuntime instances.
+ *
+ */
+ public static class JBossWSRuntimeNewWizard extends Wizard {
+
+ JBossWSRuntimeWizardPage page1 = null;
+ List<JBossWSRuntime> added = null;
+ List<JBossWSRuntime> value = null;
+
+ public JBossWSRuntimeNewWizard(List<JBossWSRuntime> exist,
+ List<JBossWSRuntime> added) {
+ super();
+ setWindowTitle(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
+ page1 = new JBossWSRuntimeWizardPage(exist);
+ addPage(page1);
+ this.value = exist;
+ this.added = added;
+ }
+
+ /**
+ * Do finish steps
+ *
+ * @return boolean
+ */
+ @Override
+ public boolean performFinish() {
+ JBossWSRuntime rt = page1.getRuntime();
+ added.add(rt);
+ value.add(rt);
+
+ return true;
+ }
+
+ protected JBossWSRuntime getRuntime() {
+ return page1.getRuntime();
+ }
+
+ }
+
+ /**
+ * Wizard for editing JBossWS Runtime parameters: name and path to home
+ * folder
+ *
+ */
+ public static class JBossWSRuntimeEditWizard extends Wizard {
+ JBossWSRuntimeWizardPage page1 = null;
+ List<JBossWSRuntime> added = null;
+ Map<JBossWSRuntime, JBossWSRuntime> changed = null;
+ List<JBossWSRuntime> value = null;
+ JBossWSRuntime source = null;
+
+ /**
+ * Constructor with almost all initialization parameters
+ *
+ * @param existing
+ * List<JBossWSRuntime> - edited list of JBossWS
+ * Runtimes
+ * @param source
+ * JBossWSRuntime - edited JBossWS Runtime
+ * @param added
+ * List<JBossWSRuntime> - TBD
+ * @param changed
+ * List<JBossWSRuntime> - TBD
+ */
+ public JBossWSRuntimeEditWizard(List<JBossWSRuntime> existing,
+ JBossWSRuntime source, List<JBossWSRuntime> added,
+ Map<JBossWSRuntime, JBossWSRuntime> changed) {
+ super();
+ setWindowTitle(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
+ page1 = new JBossWSRuntimeWizardPage(existing);
+ page1
+ .setMessage(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Modify_Runtime);
+ page1
+ .setTitle(JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
+ addPage(page1);
+ this.value = existing;
+ this.added = added;
+ this.changed = changed;
+ this.source = source;
+ page1.name.setValue(source.getName());
+ page1.version.setValue(source.getVersion());
+ page1.homeDir.setValue(source.getHomeDir());
+ page1.current = source;
+ }
+
+ /**
+ * Perform operations to finish editing JBossWS Runtime parameters
+ *
+ * @return boolean - always true
+ */
+ @Override
+ public boolean performFinish() {
+ JBossWSRuntime rt = page1.getRuntime();
+
+ if (added.contains(source) || changed.containsKey(source)) {
+ source.setName(rt.getName());
+ source.setHomeDir(rt.getHomeDir());
+ source.setVersion(rt.getVersion());
+ source.setUserConfigClasspath(rt.isUserConfigClasspath());
+ source.setLibraries(rt.getLibraries());
+ } else {
+ changed.put(rt, source);
+ if (source.isDefault()) {
+ rt.setDefault(true);
+ }
+ int i = value.indexOf(source);
+ if (i >= 0) {
+ value.set(i, rt);
+
+ } else {
+ value.remove(source);
+ value.add(rt);
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ */
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ /**
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ */
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private Button button;
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
+ }
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Action that changes state enable/disable based on current table selection
+ *
+ */
+ public abstract class BaseAction extends Action {
+
+ JBossWSRuntime[] runtimes = new JBossWSRuntime[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<JBossWSRuntime> rts = new ArrayList<JBossWSRuntime>();
+ for (Object rt : ((IStructuredSelection) selection).toArray()) {
+ rts.add((JBossWSRuntime) rt);
+ }
+ runtimes = rts.toArray(new JBossWSRuntime[] {});
+ } else {
+ runtimes = new JBossWSRuntime[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ /**
+ * Action that invokes New JBossWS Runtime Dialog
+ *
+ */
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructor create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
+ }
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
+ }
+
+ /**
+ * Invoke New JBossWS Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ Wizard wiz = new JBossWSRuntimeNewWizard(
+ (List<JBossWSRuntime>) getValue(), added);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ setDefaultRuntime();
+ }
+ }
+
+ /**
+ * Action starts an editing selected JBossWS Runtime in Edit JBossWS Runtime
+ * dialog
+ *
+ */
+ public class EditAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Edit";
+
+ /**
+ * Create EditAction with default name
+ *
+ * @param text
+ */
+ public EditAction() {
+ super(ACTION_NAME);
+ }
+
+ /**
+ * Edit action is enabled when the only JBossWS Runtime is selected
+ */
+ @Override
+ protected void updateEnablement() {
+ // available when the only JBossWSRuntime is selected
+ setEnabled(runtimes.length == 1);
+ }
+
+ /**
+ * Start editing selected JBossWS Runtime in Edit JBossWS Runtime Wizard
+ * Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ JBossWSRuntime selected = runtimes[0];
+ Wizard wiz = new JBossWSRuntimeEditWizard(
+ (List<JBossWSRuntime>) getValue(), runtimes[0], added,
+ changed);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ JBossWSRuntime c = null;
+ if (changed.containsValue(selected)) {
+ c = findChangedRuntime(selected);
+ if (c != null) {
+ tableView.setSelection(new StructuredSelection(c));
+ }
+ }
+ if (c != null && c.isDefault()) {
+ checkedElement = c;
+ }
+ setDefaultRuntime();
+ }
+
+ private JBossWSRuntime findChangedRuntime(JBossWSRuntime source) {
+ for (JBossWSRuntime r : changed.keySet()) {
+ if (source == changed.get(r)) {
+ return r;
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Action deletes all selected JBossWS Runtimes. A warning message is shown
+ * for used JBossWS Runtimes
+ *
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(runtimes.length > 0);
+ }
+
+ /**
+ * Remove all selected JBossWS Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (JBossWSRuntime rt : runtimes) {
+ removeRuntime(rt);
+ }
+ tableView.refresh();
+ setDefaultRuntime();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void removeRuntime(JBossWSRuntime r) {
+ boolean used = JBossWSRuntimeManager.isRuntimeUsed(r.getName());
+ String title = JBossWSUIMessages.JBossWS_Runtime_Delete_Confirm_Title;
+ String message = (used) ? NLS.bind(
+ JBossWSUIMessages.JBossWS_Runtime_Delete_Used_Confirm, r
+ .getName()) : NLS.bind(
+ JBossWSUIMessages.JBossWS_Runtime_Delete_Not_Used_Confirm,
+ r.getName());
+ boolean b = MessageDialog.openConfirm(tableView.getControl()
+ .getShell(), title, message);
+ if (b) {
+ if (changed.containsKey(r)) {
+ r = changed.remove(r);
+ }
+ removed.add(r);
+ if (added.contains(r)) {
+ added.remove(r);
+ }
+ ((List) getValue()).remove(r);
+ }
+ if (checkedElement == r) {
+ checkedElement = null;
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSLibraryListFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSLibraryListFieldEditor.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSLibraryListFieldEditor.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,584 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.preferences;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.ui.JBossWSUIPlugin;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSLibraryListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private TreeViewer listView = null;
+
+ private Composite root = null;
+
+ private ActionPanel actionPanel;
+
+ private JBossWSRuntime tempJbws;
+
+
+
+
+ private Group jarGroup;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Control for editing jbossWSRuntime list
+ *
+ * @param name
+ * String
+ * @param label
+ * String
+ * @param defaultValue
+ * Object
+ */
+ public JBossWSLibraryListFieldEditor(String name, String label,
+ JBossWSRuntime jbws) {
+ super(name, label, jbws);
+ this.tempJbws = new JBossWSRuntime();
+ if(jbws != null){
+ this.tempJbws.setUserConfigClasspath(jbws.isUserConfigClasspath());
+ this.tempJbws.getLibraries().addAll(jbws.getLibraries());
+ }
+
+ }
+
+
+ public Object getValue(){
+ return this.tempJbws;
+ }
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ root.setLayout(new GridLayout());
+
+ createCheckButton(root);
+
+ jarGroup = new Group(root, SWT.BORDER);
+ jarGroup.setText("Library Jars");
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+
+
+ jarGroup.setLayoutData(gd);
+ jarGroup.setLayout(new FormLayout());
+
+ createListView(jarGroup);
+ createActionBar(jarGroup);
+
+ FormData listData = new FormData();
+ listData.left = new FormAttachment(0, 5);
+ listData.right = new FormAttachment(actionPanel, -5);
+ listData.top = new FormAttachment(0, 5);
+ listData.bottom = new FormAttachment(100, -5);
+ listView.getControl().setLayoutData(listData);
+
+ FormData actionsData = new FormData();
+ actionsData.top = new FormAttachment(0, 5);
+ actionsData.bottom = new FormAttachment(100, -5);
+ actionsData.right = new FormAttachment(100, -5);
+ actionPanel.setLayoutData(actionsData);
+
+ setJarGroupStatus();
+ return new Control[] { root };
+ }
+
+ protected void createCheckButton(Composite parent){
+ final Button btnDefault = new Button(parent, SWT.CHECK);
+ btnDefault.setText(JBossWSUIMessages.JBossWS_Runtime_Check_Field_Default_Classpath);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ btnDefault.setLayoutData(gd);
+
+ btnDefault.setSelection(tempJbws.isUserConfigClasspath());
+ btnDefault.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ tempJbws.setUserConfigClasspath(btnDefault.getSelection());
+ setJarGroupStatus();
+ setValue(null);
+ }
+ });
+
+
+ }
+
+ protected void setJarGroupStatus(){
+ boolean isUserConfig = tempJbws.isUserConfigClasspath();
+ jarGroup.setEnabled(isUserConfig);
+ listView.getTree().setEnabled(isUserConfig);
+ actionPanel.setEnabled(isUserConfig);
+ }
+
+ protected void createListView(Composite parent) {
+ listView = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ listView.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ listView.setContentProvider(new ITreeContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof JBossWSRuntime) {
+ return ((JBossWSRuntime) inputElement).getLibraries().toArray();
+ } else {
+ throw new IllegalArgumentException(
+ JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
+ + JBossWSUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ viewer.refresh();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ });
+
+ listView.setLabelProvider(new ILabelProvider() {
+
+ Image jarImg;
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getImage(Object element) {
+ if (jarImg == null){
+ ImageDescriptor jarImgDesc = JBossWSUIPlugin.getImageDescriptor("obj16/jar_obj.gif");
+ jarImg = jarImgDesc.createImage();
+ }
+ return jarImg;
+ }
+
+ public String getText(Object element) {
+ String fullName = (String)element;
+ File jarFile = new File(fullName);
+ return jarFile.getName() + " - " + jarFile.getParentFile().toString();
+ }
+ });
+
+
+ listView.setInput(getValue());
+
+ }
+
+ protected void createActionBar(Composite parent) {
+ actionPanel = new ActionPanel(parent, new BaseAction[] { new AddAction(),
+ new RemoveAction() });
+ listView.addSelectionChangedListener(actionPanel);
+ }
+
+
+
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] { root };
+ }
+
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /**
+ * Fill wizard page with editors
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
+ }
+
+
+
+ /**
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ */
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ /**
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ */
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private Button button;
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
+ }
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Action that changes state enable/disable based on current table selection
+ *
+ */
+ public abstract class BaseAction extends Action {
+
+ String[] jars = new String[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<String> rts = new ArrayList<String>();
+ for (Object jarfile : ((IStructuredSelection) selection).toArray()) {
+ rts.add((String) jarfile);
+ }
+ jars = rts.toArray(new String[] {});
+ } else {
+ jars = new String[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ /**
+ * Action that invokes New JBossWS Runtime Dialog
+ *
+ */
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructor create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
+ }
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
+ }
+
+ /**
+ * Invoke New JBossWS Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ FileDialog dialog = new FileDialog(Display.getCurrent()
+ .getActiveShell(), SWT.MULTI);
+ dialog.setFilterExtensions(new String[] { "*.jar;*.zip" });
+ String fileName = dialog.open();
+ String[] fileNames = dialog.getFileNames();
+ if (fileName != null) {
+ File filePath = new File(fileName);
+ filePath = filePath.getParentFile();
+ for (int i = 0; i < fileNames.length; i++) {
+ IPath path = new Path(filePath.getAbsolutePath())
+ .append(fileNames[i]);
+ if (!tempJbws.getLibraries().contains(path.toOSString())) {
+ tempJbws.getLibraries().add(path.toOSString());
+ }
+ }
+
+ listView.refresh();
+ setValue(null);
+ }
+ }
+ }
+
+
+ /**
+ * Action deletes all selected JBossWS Runtimes. A warning message is shown
+ * for used JBossWS Runtimes
+ *
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(jars.length > 0);
+ }
+
+ /**
+ * Remove all selected JBossWS Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (String jar : jars) {
+ tempJbws.getLibraries().remove(jar);
+ }
+ listView.refresh();
+ // just try to fire property change listener
+ setValue(null);
+ }
+
+
+ }
+}
\ No newline at end of file
Added: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSRuntimePreferencePage.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSRuntimePreferencePage.java (rev 0)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JBossWSRuntimePreferencePage.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimePreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage {
+
+ public JBossWSRuntimePreferencePage() {
+ super();
+ noDefaultAndApplyButton();
+ }
+
+ private static final int COLUMNS = 3;
+
+ JBossRuntimeListFieldEditor jbossWSRuntimes = new JBossRuntimeListFieldEditor(
+ "rtlist", JBossWSUIMessages.JBossWS_Preference_Page_Runtimes, new ArrayList<JBossWSRuntime>(Arrays.asList(JBossWSRuntimeManager.getInstance().getRuntimes()))); //$NON-NLS-1$
+
+ /**
+ * Create contents of JBossWS preferences page. JBossWSRuntime list editor
+ * is created
+ *
+ * @return Control
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite root = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout(COLUMNS, false);
+ root.setLayout(gl);
+ jbossWSRuntimes.doFillIntoGrid(root);
+
+ return root;
+ }
+
+ /**
+ * Inherited from IWorkbenchPreferencePage
+ *
+ * @param workbench
+ * {@link IWorkbench}
+ *
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /**
+ * Save JBossWSRuntime list
+ */
+ @Override
+ protected void performApply() {
+ for (JBossWSRuntime rt : jbossWSRuntimes.getAddedJBossWSRuntimes()) {
+ JBossWSRuntimeManager.getInstance().addRuntime(rt);
+ }
+ jbossWSRuntimes.getAddedJBossWSRuntimes().clear();
+ for (JBossWSRuntime rt : jbossWSRuntimes.getRemoved()) {
+ JBossWSRuntimeManager.getInstance().removeRuntime(rt);
+ }
+ jbossWSRuntimes.getRemoved().clear();
+ JBossWSRuntime defaultRuntime = jbossWSRuntimes
+ .getDefaultJBossWSRuntime();
+ // reset default runtime
+ for (JBossWSRuntime jbossWSRuntime : JBossWSRuntimeManager
+ .getInstance().getRuntimes()) {
+ jbossWSRuntime.setDefault(false);
+ }
+ // set deafult runtime
+ if (defaultRuntime != null) {
+ defaultRuntime.setDefault(true);
+ }
+ jbossWSRuntimes.setDefaultJBossWSRuntime(null);
+ Map<JBossWSRuntime, JBossWSRuntime> changed = jbossWSRuntimes
+ .getChangedJBossWSRuntimes();
+ for (JBossWSRuntime c : changed.keySet()) {
+ JBossWSRuntime o = changed.get(c);
+ o.setHomeDir(c.getHomeDir());
+ o.setVersion(c.getVersion());
+ String oldName = o.getName();
+ String newName = c.getName();
+ if (!oldName.equals(newName)) {
+ JBossWSRuntimeManager.getInstance().changeRuntimeName(oldName,
+ newName);
+ }
+ o.setDefault(c.isDefault());
+ o.setUserConfigClasspath(c.isUserConfigClasspath());
+ o.setLibraries(c.getLibraries());
+ }
+ jbossWSRuntimes.getChangedJBossWSRuntimes().clear();
+
+ JBossWSRuntimeManager.getInstance().save();
+ }
+
+ /**
+ * Restore original preferences values
+ */
+ @Override
+ protected void performDefaults() {
+ setValid(true);
+ setMessage(null);
+ performApply();
+ }
+
+ /**
+ * See {@link PreferencePage} for details
+ *
+ * @return Boolean
+ */
+ @Override
+ public boolean performOk() {
+ performApply();
+ return super.performOk();
+ }
+
+ public JBossRuntimeListFieldEditor getJBossWSRuntimes() {
+ return jbossWSRuntimes;
+ }
+}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,1111 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.preferences;
-
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.TableColumn;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
-import org.jboss.tools.ws.ui.utils.UIUtils;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-
-/**
- * @author Grid Qian
- */
-public class JbossRuntimeListFieldEditor extends BaseFieldEditor {
-
- // ------------------------------------------------------------------------
- // Layout parameters
- // ------------------------------------------------------------------------
-
- static final int GL_COLUMNS = 2;
- static final int GL_HINT_HEIGHT = 200;
- static final int TC_DEFAULT_WIDTH = 21;
- static final int TC_NAME_WIDTH = 100;
- static final int TC_VERSION_WIDTH = 50;
- static final int TC_PATH_WIDTH = 100;
-
- // ------------------------------------------------------------------------
- // Field declarations
- // ------------------------------------------------------------------------
-
- private CheckboxTableViewer tableView = null;
-
- private Composite root = null;
-
- private ActionPanel actionPanel;
-
- private Map<JbossWSRuntime, JbossWSRuntime> changed = new HashMap<JbossWSRuntime, JbossWSRuntime>();
-
- private JbossWSRuntime checkedElement = new JbossWSRuntime();
-
- private List<JbossWSRuntime> added = new ArrayList<JbossWSRuntime>();
-
- private List<JbossWSRuntime> removed = new ArrayList<JbossWSRuntime>();
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Control for editing jbossWSRuntime list
- *
- * @param name
- * String
- * @param label
- * String
- * @param defaultValue
- * Object
- */
- public JbossRuntimeListFieldEditor(String name, String label,
- Object defaultValue) {
- super(name, label, defaultValue);
- }
-
- /**
- * TBD
- *
- * @return JbossWSRuntime;
- */
- public JbossWSRuntime getDefaultJbossWSRuntime() {
- return checkedElement;
- }
-
- public void setDefaultJbossWSRuntime(JbossWSRuntime rt) {
- checkedElement = rt;
- }
-
- /**
- * TBD
- *
- * @return List<JbossWSRuntime>
- */
- public List<JbossWSRuntime> getAddedJbossWSRuntimes() {
- return added;
- }
-
- /**
- * TBD
- *
- * @return List<JbossWSRuntime>
- */
- public Map<JbossWSRuntime, JbossWSRuntime> getChangedJbossWSRuntimes() {
- return changed;
- }
-
- /**
- * TBD
- *
- * @return List<JbossWSRuntime>
- */
- public List<JbossWSRuntime> getRemoved() {
- return removed;
- }
-
- /**
- * TBD
- *
- * @param composite
- * Object - instance of Composite
- * @return Object[]
- */
- @Override
- public Object[] getEditorControls(Object composite) {
-
- root = new Composite((Composite) composite, SWT.NONE);
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- root.setLayoutData(gd);
-
- root.setLayout(new FormLayout());
- createTableView();
- createActionBar();
-
- FormData tableData = new FormData();
- tableData.left = new FormAttachment(0, 5);
- tableData.right = new FormAttachment(actionPanel, -5);
- tableData.top = new FormAttachment(0, 5);
- tableData.bottom = new FormAttachment(100, -5);
- tableView.getControl().setLayoutData(tableData);
-
- FormData actionsData = new FormData();
- actionsData.top = new FormAttachment(0, 5);
- actionsData.bottom = new FormAttachment(100, -5);
- actionsData.right = new FormAttachment(100, -5);
- actionPanel.setLayoutData(actionsData);
- return new Control[] { root };
- }
-
- @SuppressWarnings("unchecked")
- protected void createTableView() {
- tableView = CheckboxTableViewer.newCheckList(root, SWT.V_SCROLL
- | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
-
- TableColumn tc1 = new TableColumn(tableView.getTable(), SWT.CENTER);
- tc1.setWidth(TC_DEFAULT_WIDTH);
- tc1.setResizable(false);
-
- TableColumn tc2 = new TableColumn(tableView.getTable(), SWT.LEFT);
- tc2.setWidth(TC_NAME_WIDTH);
- tc2.setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name);
-
- TableColumn tc3 = new TableColumn(tableView.getTable(), SWT.LEFT);
- tc3.setWidth(TC_VERSION_WIDTH);
- tc3
- .setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version);
-
- TableColumn tc4 = new TableColumn(tableView.getTable(), SWT.LEFT);
- tc4.setWidth(TC_PATH_WIDTH);
- tc4.setText(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Path);
-
- tableView.setContentProvider(new IStructuredContentProvider() {
-
- @SuppressWarnings("unchecked")
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof List) {
- return ((List<JbossWSRuntime>) inputElement).toArray();
- } else {
- throw new IllegalArgumentException(
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
- + JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
- }
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- viewer.refresh();
- }
- });
-
- tableView.setLabelProvider(new ITableLabelProvider() {
-
- private static final int TC_DEFAULT_NUMBER = 0;
- private static final int TC_NAME_NUMBER = 1;
- private static final int TC_VERSION_NUMBER = 2;
- private static final int TC_PATH_NUMBER = 3;
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- JbossWSRuntime rt = (JbossWSRuntime) element;
- if (columnIndex == TC_DEFAULT_NUMBER) {
- return ""; //$NON-NLS-1$
- }
- if (columnIndex == TC_NAME_NUMBER) {
- return rt.getName();
- }
- if (columnIndex == TC_VERSION_NUMBER) {
- return rt.getVersion().toString();
- }
- if (columnIndex == TC_PATH_NUMBER) {
- return rt.getHomeDir();
- }
- return ""; //$NON-NLS-1$
- }
- });
-
- tableView.setInput(getValue());
- tableView.getTable().setLinesVisible(true);
- tableView.getTable().setHeaderVisible(true);
- tableView.addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(CheckStateChangedEvent event) {
- JbossWSRuntime selRt = (JbossWSRuntime) event.getElement();
- if (event.getChecked()) {
- JbossWSRuntime deselRt = null;
- Object[] selRts = tableView.getCheckedElements();
-
- for (int i = 0; i < selRts.length; i++) {
- JbossWSRuntime rt = (JbossWSRuntime) selRts[i];
- if (rt != selRt) {
- deselRt = rt;
- break;
- }
- }
-
- if (deselRt != null) {
- Object[] newChecked = new Object[selRts.length - 1];
- checkedElement = null;
- int i = 0;
- for (Object object : selRts) {
- JbossWSRuntime rt = (JbossWSRuntime) object;
- if (rt == selRt) {
- newChecked[i] = rt;
- checkedElement = rt;
- i++;
- }
- }
- tableView.setCheckedElements(newChecked);
- } else {
- checkedElement = (JbossWSRuntime) event.getElement();
- }
- } else {
- if (checkedElement == selRt) {
- checkedElement = null;
- }
- }
- pcs.firePropertyChange(getName(), null, getValue());
- }
- });
-
- for (JbossWSRuntime rt : (List<JbossWSRuntime>) getValue()) {
- if (rt.isDefault()) {
- tableView.setChecked(rt, true);
- checkedElement = rt;
- }
- }
- }
-
- protected void createActionBar() {
- actionPanel = new ActionPanel(root, new BaseAction[] { new AddAction(),
- new EditAction(), new RemoveAction() });
- tableView.addSelectionChangedListener(actionPanel);
- }
-
- /**
- * Checks all runtimes and set default one if user did not do it.
- */
- @SuppressWarnings("unchecked")
- private void setDefaultRuntime() {
- List<JbossWSRuntime> runtimes = (List<JbossWSRuntime>) getValue();
- boolean checked = false;
- for (JbossWSRuntime jbossWSRuntime : runtimes) {
-
- if (checkedElement == jbossWSRuntime) {
- checked = true;
- tableView.setChecked(checkedElement, true);
- break;
- }
- }
- if (!checked && runtimes.size() > 0) {
- if (tableView.getCheckedElements() == null
- || tableView.getCheckedElements().length == 0) {
- tableView.setChecked(runtimes.get(0), true);
- checkedElement = runtimes.get(0);
- }
- }
-
- }
-
- /**
- * Return array of Controls that forms and editor
- *
- * @return Control[]
- */
- @Override
- public Object[] getEditorControls() {
- return new Control[] { root };
- }
-
- /**
- * Return number of controls in editor
- *
- * @return int
- */
- @Override
- public int getNumberOfControls() {
- return 1;
- }
-
- /**
- * Fill wizard page with editors
- *
- * @param parent
- * Composite - parent composite
- */
- @Override
- public void doFillIntoGrid(Object parent) {
- Assert.isTrue(parent instanceof Composite,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
- Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
- Composite aComposite = (Composite) parent;
- getEditorControls(aComposite);
- GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
-
- GridData gd = new GridData();
- gd.horizontalSpan = gl.numColumns;
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
-
- ((Control) getEditorControls()[0]).setLayoutData(gd);
- }
-
- /**
- * Wizard page for editing JbossWS Runtime parameters
- *
- */
- public static class JbossWSRuntimeWizardPage extends WizardPage implements
- PropertyChangeListener {
-
- private static final String SRT_NAME = "name";
- private static final String SRT_VERSION = "version";
- private static final String SRT_HOMEDIR = "homeDir";
-
- private static final int GL_PARENT_COLUMNS = 1;
- private static final int GL_CONTENT_COLUMNS = 3;
-
- List<JbossWSRuntime> value = null;
-
- IFieldEditor name = createTextEditor(SRT_NAME,
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Name2, ""); //$NON-NLS-1$
-
- IFieldEditor version = createTextEditor(SRT_VERSION,
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Version, ""); //$NON-NLS-1$
-
- IFieldEditor homeDir = createBrowseFolderEditor(
- SRT_HOMEDIR,
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Home_Folder,
- ""); //$NON-NLS-1$
-
- JbossWSRuntime current = null;
-
- IFieldEditor jars = null;
-
- public JbossWSRuntimeWizardPage(List<JbossWSRuntime> editedList) {
- super(
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
-
- setMessage(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Create_A_Runtime);
- setTitle(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime);
- value = editedList;
- }
-
- /**
- * Create Wizard page content
- *
- * @param parent
- * Composite - parent composite
- */
- public void createControl(Composite parent) {
- parent.setLayout(new GridLayout(GL_PARENT_COLUMNS, false));
- GridData dg = new GridData();
- dg.horizontalAlignment = GridData.FILL;
- dg.grabExcessHorizontalSpace = true;
- Composite root = new Composite(parent, SWT.NONE);
- root.setLayoutData(dg);
- GridLayout gl = new GridLayout(GL_CONTENT_COLUMNS, false);
- root.setLayout(gl);
- name.doFillIntoGrid(root);
- name.addPropertyChangeListener(this);
- version.doFillIntoGrid(root);
- version.addPropertyChangeListener(this);
- homeDir.doFillIntoGrid(root);
- homeDir.addPropertyChangeListener(this);
-
- jars = new JbwsLibraryListFieldEditor("", "", current);
- jars.doFillIntoGrid(root);
- jars.addPropertyChangeListener(this);
- setPageComplete(false);
- setControl(root);
- }
-
- /**
- * Process evt: setup default values based on JbossWS Home folder and
- * validate user input
- *
- * @param evt
- * PropertyChangeEvent describes changes in wizard
- */
- public void propertyChange(java.beans.PropertyChangeEvent evt) {
- if ("homeDir".equals(evt.getPropertyName())) {
- if (name.getValueAsString() == null
- || "".equals(name.getValueAsString().trim())
- || this.getErrorMessage() != null) {
- String homeDirName = homeDir.getValueAsString();
- if (homeDirName != null && !"".equals(homeDirName.trim())) {
- File folder = new File(homeDirName);
- homeDirName = folder.getName();
- }
- name.setValue(homeDirName);
- }
- }
-
- if (name.getValueAsString() == null || "".equals(//$NON-NLS-1$
- name.getValueAsString().toString().trim())) {
- setErrorMessage(JbossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty);
- setPageComplete(false);
- return;
- }
-
- if (!name.getValueAsString().matches(
- "[a-zA-Z_][a-zA-Z0-9_\\-\\. ]*")) { //$NON-NLS-1$
- setErrorMessage(JbossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct);
- setPageComplete(false);
- return;
- }
- for (JbossWSRuntime rt : value) {
- if (current != null && current.getName().equals(rt.getName())) {
- continue;
- }
- if (rt.getName().equals(name.getValueAsString())) {
- setErrorMessage(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime
- + name.getValueAsString()
- + JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Already_Exists);
- setPageComplete(false);
- return;
- }
- }
-
- JbossWSRuntime jarJbws = (JbossWSRuntime) jars.getValue();
- if (current != null
- && current.getName().equals(name.getValueAsString())
- && current.getHomeDir().equals(homeDir.getValueAsString())
- && current.getVersion().equals(version.getValueAsString())
- && current.isUserConfigClasspath() == jarJbws
- .isUserConfigClasspath()
- && (!jarJbws.isUserConfigClasspath() || hasSameLibraies(
- current.getLibraries(), jarJbws.getLibraries()))) {
-
- setErrorMessage(null);
- setPageComplete(false);
- return;
- }
-
- if (jarJbws.isUserConfigClasspath()
- && jarJbws.getLibraries().size() == 0) {
- setErrorMessage("The library must contian at least one jar.");
- setPageComplete(false);
- return;
- }
-
- if (homeDir.getValueAsString() == null
- || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
- setErrorMessage(JbossWSUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty);
- setPageComplete(false);
- return;
- }
-
- if (!runtimeExist(homeDir.getValueAsString())) {
- setErrorMessage(JbossWSUIMessages.Label_JBossWS_Runtime_Load_Error);
- setPageComplete(false);
- return;
- }
-
- setErrorMessage(null);
- setPageComplete(true);
- }
-
- private boolean hasSameLibraies(List<String> lib1, List<String> lib2) {
- if (lib1.size() != lib2.size())
- return false;
- for (String jar : lib1) {
- if (!lib2.contains(jar))
- return false;
- }
-
- return true;
- }
-
- /**
- * Return JbossWS Runtime instance initialized by user input
- *
- * @return JbossWSRuntime instance
- */
- public JbossWSRuntime getRuntime() {
- JbossWSRuntime newRt = new JbossWSRuntime();
- newRt.setName(name.getValueAsString());
- newRt.setVersion(version.getValueAsString());
- newRt.setHomeDir(homeDir.getValueAsString());
- JbossWSRuntime rt = (JbossWSRuntime) jars.getValue();
- newRt.setLibraries(rt.getLibraries());
- newRt.setUserConfigClasspath(rt.isUserConfigClasspath());
- return newRt;
- }
-
- public IFieldEditor createTextEditor(String name, String label,
- String defaultValue) {
- CompositeEditor editor = new CompositeEditor(name, label,
- defaultValue);
- editor.addFieldEditors(new IFieldEditor[] {
- new LabelFieldEditor(name, label),
- new TextFieldEditor(name, label, defaultValue) });
- return editor;
- }
-
- public IFieldEditor createBrowseFolderEditor(String name, String label,
- String defaultValue) {
- CompositeEditor editor = new CompositeEditor(name, label,
- defaultValue);
- editor
- .addFieldEditors(new IFieldEditor[] {
- new LabelFieldEditor(name, label),
- new TextFieldEditor(name, label, defaultValue),
- new ButtonFieldEditor(
- name,
- createSelectFolderAction(JbossWSUIMessages.JBossWS_SWT_Field_Editor_Factory_Browse),
- defaultValue) });
- return editor;
- }
-
- public ButtonFieldEditor.ButtonPressedAction createSelectFolderAction(
- String buttonName) {
- return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
- @Override
- public void run() {
- DirectoryDialog dialog = new DirectoryDialog(Display
- .getCurrent().getActiveShell());
- dialog.setFilterPath(getFieldEditor().getValueAsString());
- dialog
- .setMessage(JbossWSUIMessages.JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder);
- dialog.setFilterPath(getFieldEditor().getValueAsString());
- String directory = dialog.open();
- if (directory != null) {
- getFieldEditor().setValue(directory);
- }
- }
- };
- }
-
- private boolean runtimeExist(String path) {
-
- File jbosswsHomeDir = new File(path);
- if (!jbosswsHomeDir.isDirectory())
- return false;
- String[] newNode = { JbossWSUIMessages.Bin,
- JbossWSUIMessages.Command };
- String jbosswsBinPath = UIUtils.addNodesToPath(jbosswsHomeDir
- .getAbsolutePath(), newNode);
- if (new File(jbosswsBinPath).isFile()
- && new File(UIUtils.addAnotherNodeToPath(jbosswsHomeDir
- .getAbsolutePath(), JbossWSUIMessages.Client))
- .isDirectory()
- && new File(UIUtils
- .addNodesToPath(jbosswsHomeDir.getAbsolutePath(),
- new String[] { JbossWSUIMessages.Lib,
- JbossWSUIMessages.Endorsed }))
- .isDirectory()) {
- return true;
- }
- return false;
- }
- }
-
- /**
- * Wizard collect information and creates new JbossWSRuntime instances.
- *
- */
- public static class JbossWSRuntimeNewWizard extends Wizard {
-
- JbossWSRuntimeWizardPage page1 = null;
- List<JbossWSRuntime> added = null;
- List<JbossWSRuntime> value = null;
-
- public JbossWSRuntimeNewWizard(List<JbossWSRuntime> exist,
- List<JbossWSRuntime> added) {
- super();
- setWindowTitle(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
- page1 = new JbossWSRuntimeWizardPage(exist);
- addPage(page1);
- this.value = exist;
- this.added = added;
- }
-
- /**
- * Do finish steps
- *
- * @return boolean
- */
- @Override
- public boolean performFinish() {
- JbossWSRuntime rt = page1.getRuntime();
- added.add(rt);
- value.add(rt);
-
- return true;
- }
-
- protected JbossWSRuntime getRuntime() {
- return page1.getRuntime();
- }
-
- }
-
- /**
- * Wizard for editing JbossWS Runtime parameters: name and path to home
- * folder
- *
- */
- public static class JbossWSRuntimeEditWizard extends Wizard {
- JbossWSRuntimeWizardPage page1 = null;
- List<JbossWSRuntime> added = null;
- Map<JbossWSRuntime, JbossWSRuntime> changed = null;
- List<JbossWSRuntime> value = null;
- JbossWSRuntime source = null;
-
- /**
- * Constructor with almost all initialization parameters
- *
- * @param existing
- * List<JbossWSRuntime> - edited list of JbossWS
- * Runtimes
- * @param source
- * JbossWSRuntime - edited JbossWS Runtime
- * @param added
- * List<JbossWSRuntime> - TBD
- * @param changed
- * List<JbossWSRuntime> - TBD
- */
- public JbossWSRuntimeEditWizard(List<JbossWSRuntime> existing,
- JbossWSRuntime source, List<JbossWSRuntime> added,
- Map<JbossWSRuntime, JbossWSRuntime> changed) {
- super();
- setWindowTitle(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
- page1 = new JbossWSRuntimeWizardPage(existing);
- page1
- .setMessage(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Modify_Runtime);
- page1
- .setTitle(JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
- addPage(page1);
- this.value = existing;
- this.added = added;
- this.changed = changed;
- this.source = source;
- page1.name.setValue(source.getName());
- page1.version.setValue(source.getVersion());
- page1.homeDir.setValue(source.getHomeDir());
- page1.current = source;
- }
-
- /**
- * Perform operations to finish editing JbossWS Runtime parameters
- *
- * @return boolean - always true
- */
- @Override
- public boolean performFinish() {
- JbossWSRuntime rt = page1.getRuntime();
-
- if (added.contains(source) || changed.containsKey(source)) {
- source.setName(rt.getName());
- source.setHomeDir(rt.getHomeDir());
- source.setVersion(rt.getVersion());
- source.setUserConfigClasspath(rt.isUserConfigClasspath());
- source.setLibraries(rt.getLibraries());
- } else {
- changed.put(rt, source);
- if (source.isDefault()) {
- rt.setDefault(true);
- }
- int i = value.indexOf(source);
- if (i >= 0) {
- value.set(i, rt);
-
- } else {
- value.remove(source);
- value.add(rt);
- }
- }
- return true;
- }
- }
-
- /**
- * Composite that holds list of BaseActions and presents them as column of
- * buttons
- *
- */
- public static class ActionPanel extends Composite implements
- ISelectionChangedListener {
-
- private BaseAction[] actions = null;
-
- /**
- * Constructor creates panel with style, grid layout and buttons
- * represented the actions
- *
- * @param parent
- * Composite
- * @param style
- * int
- * @param actions
- * BaseAction[]
- */
- public ActionPanel(Composite parent, int style, BaseAction[] actions) {
- super(parent, style);
- this.actions = actions;
- setLayout(new GridLayout(1, false));
- for (BaseAction action : this.actions) {
- new ActionButton(this, SWT.PUSH, action);
- }
- }
-
- /**
- * Constructor creates panel with default style, grid layout and buttons
- * represented the actions
- *
- * @param parent
- * Composite
- * @param actions
- * BaseAction[]
- */
- public ActionPanel(Composite parent, BaseAction[] actions) {
- this(parent, SWT.NONE, actions);
- }
-
- /**
- * Listen to the selection changes and update actions state
- * (enable/disable)
- *
- * @param event
- * SelectionChangeEvent
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- for (BaseAction action : actions) {
- action.setSelection(event.getSelection());
- }
- }
- }
-
- /**
- * Class represents an BaseAction as SWT button control and runs action when
- * button is prtessed
- *
- */
- public static class ActionButton implements IPropertyChangeListener {
-
- private Button button;
- private BaseAction action;
-
- /**
- * Create Button control with parent control and style that represents
- * action
- *
- * @param parent
- * Composite
- * @param style
- * int
- * @param action
- * BaseAction
- */
- public ActionButton(Composite parent, int style, BaseAction action) {
- this.button = new Button(parent, style);
- this.action = action;
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL,
- GridData.CENTER, false, false);
-
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- this.button.setLayoutData(gd);
- this.action.addPropertyChangeListener(this);
- this.button.setText(action.getText());
- this.button.setEnabled(action.isEnabled());
- this.button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- ActionButton.this.action.run();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- }
-
- /**
- * Return SWT button control that calls provided action
- *
- * @return Control - button swt control
- */
- public Control getControl() {
- return button;
- }
-
- /**
- * Update enabled/disabled button state
- *
- * @param event
- * PropertyChangeEvent
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IAction.ENABLED)) {
- button.setEnabled(((Boolean) event.getNewValue())
- .booleanValue());
- }
- }
- }
-
- /**
- * Action that changes state enable/disable based on current table selection
- *
- */
- public abstract class BaseAction extends Action {
-
- JbossWSRuntime[] runtimes = new JbossWSRuntime[0];
-
- /**
- * Constructor creates action with provided name
- *
- * @param name
- * String - action name
- */
- public BaseAction(String name) {
- super(name);
- updateEnablement();
- }
-
- /**
- * Set current selection
- *
- * @param selection
- * ISelection - selected items
- */
- public void setSelection(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- List<JbossWSRuntime> rts = new ArrayList<JbossWSRuntime>();
- for (Object rt : ((IStructuredSelection) selection).toArray()) {
- rts.add((JbossWSRuntime) rt);
- }
- runtimes = rts.toArray(new JbossWSRuntime[] {});
- } else {
- runtimes = new JbossWSRuntime[0];
- }
- updateEnablement();
- }
-
- protected abstract void updateEnablement();
- }
-
- /**
- * Action that invokes New JbossWS Runtime Dialog
- *
- */
- public class AddAction extends BaseAction {
-
- static final String ACTION_NAME = "&Add";
-
- /**
- * Constructor create Add action with default name
- */
- public AddAction() {
- super(ACTION_NAME);
- // This action is always available
- setEnabled(true);
- }
-
- /**
- * Do nothing, because Add action should be always available
- */
- @Override
- protected void updateEnablement() {
- // Add button is always available
- }
-
- /**
- * Invoke New JbossWS Runtime Dialog
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @SuppressWarnings("unchecked")
- @Override
- public void run() {
- Wizard wiz = new JbossWSRuntimeNewWizard(
- (List<JbossWSRuntime>) getValue(), added);
- WizardDialog dialog = new WizardDialog(Display.getCurrent()
- .getActiveShell(), wiz);
- dialog.open();
- tableView.refresh();
- setDefaultRuntime();
- }
- }
-
- /**
- * Action starts an editing selected JbossWS Runtime in Edit JbossWS Runtime
- * dialog
- *
- */
- public class EditAction extends BaseAction {
-
- static final String ACTION_NAME = "&Edit";
-
- /**
- * Create EditAction with default name
- *
- * @param text
- */
- public EditAction() {
- super(ACTION_NAME);
- }
-
- /**
- * Edit action is enabled when the only JbossWS Runtime is selected
- */
- @Override
- protected void updateEnablement() {
- // available when the only JbossWSRuntime is selected
- setEnabled(runtimes.length == 1);
- }
-
- /**
- * Start editing selected JbossWS Runtime in Edit JbossWS Runtime Wizard
- * Dialog
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @SuppressWarnings("unchecked")
- @Override
- public void run() {
- JbossWSRuntime selected = runtimes[0];
- Wizard wiz = new JbossWSRuntimeEditWizard(
- (List<JbossWSRuntime>) getValue(), runtimes[0], added,
- changed);
- WizardDialog dialog = new WizardDialog(Display.getCurrent()
- .getActiveShell(), wiz);
- dialog.open();
- tableView.refresh();
- JbossWSRuntime c = null;
- if (changed.containsValue(selected)) {
- c = findChangedRuntime(selected);
- if (c != null) {
- tableView.setSelection(new StructuredSelection(c));
- }
- }
- if (c != null && c.isDefault()) {
- checkedElement = c;
- }
- setDefaultRuntime();
- }
-
- private JbossWSRuntime findChangedRuntime(JbossWSRuntime source) {
- for (JbossWSRuntime r : changed.keySet()) {
- if (source == changed.get(r)) {
- return r;
- }
- }
- return null;
- }
- }
-
- /**
- * Action deletes all selected JbossWS Runtimes. A warning message is shown
- * for used JbossWS Runtimes
- *
- */
- public class RemoveAction extends BaseAction {
-
- static final String ACTION_NAME = "&Remove";
-
- /**
- * Create DeleteAction action with default name
- */
- public RemoveAction() {
- super(ACTION_NAME);
- }
-
- @Override
- protected void updateEnablement() {
- setEnabled(runtimes.length > 0);
- }
-
- /**
- * Remove all selected JbossWS Runtimes one by one
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- for (JbossWSRuntime rt : runtimes) {
- removeRuntime(rt);
- }
- tableView.refresh();
- setDefaultRuntime();
- }
-
- @SuppressWarnings("unchecked")
- private void removeRuntime(JbossWSRuntime r) {
- boolean used = JbossWSRuntimeManager.isRuntimeUsed(r.getName());
- String title = JbossWSUIMessages.JBossWS_Runtime_Delete_Confirm_Title;
- String message = (used) ? NLS.bind(
- JbossWSUIMessages.JBossWS_Runtime_Delete_Used_Confirm, r
- .getName()) : NLS.bind(
- JbossWSUIMessages.JBossWS_Runtime_Delete_Not_Used_Confirm,
- r.getName());
- boolean b = MessageDialog.openConfirm(tableView.getControl()
- .getShell(), title, message);
- if (b) {
- if (changed.containsKey(r)) {
- r = changed.remove(r);
- }
- removed.add(r);
- if (added.contains(r)) {
- added.remove(r);
- }
- ((List) getValue()).remove(r);
- }
- if (checkedElement == r) {
- checkedElement = null;
- }
- }
- }
-}
\ No newline at end of file
Deleted: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossWSRuntimePreferencePage.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.preferences;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Map;
-
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimePreferencePage extends PreferencePage implements
- IWorkbenchPreferencePage {
-
- public JbossWSRuntimePreferencePage() {
- super();
- noDefaultAndApplyButton();
- }
-
- private static final int COLUMNS = 3;
-
- JbossRuntimeListFieldEditor jbossWSRuntimes = new JbossRuntimeListFieldEditor(
- "rtlist", JbossWSUIMessages.JBossWS_Preference_Page_Runtimes, new ArrayList<JbossWSRuntime>(Arrays.asList(JbossWSRuntimeManager.getInstance().getRuntimes()))); //$NON-NLS-1$
-
- /**
- * Create contents of JbossWS preferences page. JbossWSRuntime list editor
- * is created
- *
- * @return Control
- */
- @Override
- protected Control createContents(Composite parent) {
- Composite root = new Composite(parent, SWT.NONE);
- GridLayout gl = new GridLayout(COLUMNS, false);
- root.setLayout(gl);
- jbossWSRuntimes.doFillIntoGrid(root);
-
- return root;
- }
-
- /**
- * Inherited from IWorkbenchPreferencePage
- *
- * @param workbench
- * {@link IWorkbench}
- *
- */
- public void init(IWorkbench workbench) {
- }
-
- /**
- * Save JbossWSRuntime list
- */
- @Override
- protected void performApply() {
- for (JbossWSRuntime rt : jbossWSRuntimes.getAddedJbossWSRuntimes()) {
- JbossWSRuntimeManager.getInstance().addRuntime(rt);
- }
- jbossWSRuntimes.getAddedJbossWSRuntimes().clear();
- for (JbossWSRuntime rt : jbossWSRuntimes.getRemoved()) {
- JbossWSRuntimeManager.getInstance().removeRuntime(rt);
- }
- jbossWSRuntimes.getRemoved().clear();
- JbossWSRuntime defaultRuntime = jbossWSRuntimes
- .getDefaultJbossWSRuntime();
- // reset default runtime
- for (JbossWSRuntime jbossWSRuntime : JbossWSRuntimeManager
- .getInstance().getRuntimes()) {
- jbossWSRuntime.setDefault(false);
- }
- // set deafult runtime
- if (defaultRuntime != null) {
- defaultRuntime.setDefault(true);
- }
- jbossWSRuntimes.setDefaultJbossWSRuntime(null);
- Map<JbossWSRuntime, JbossWSRuntime> changed = jbossWSRuntimes
- .getChangedJbossWSRuntimes();
- for (JbossWSRuntime c : changed.keySet()) {
- JbossWSRuntime o = changed.get(c);
- o.setHomeDir(c.getHomeDir());
- o.setVersion(c.getVersion());
- String oldName = o.getName();
- String newName = c.getName();
- if (!oldName.equals(newName)) {
- JbossWSRuntimeManager.getInstance().changeRuntimeName(oldName,
- newName);
- }
- o.setDefault(c.isDefault());
- o.setUserConfigClasspath(c.isUserConfigClasspath());
- o.setLibraries(c.getLibraries());
- }
- jbossWSRuntimes.getChangedJbossWSRuntimes().clear();
-
- JbossWSRuntimeManager.getInstance().save();
- }
-
- /**
- * Restore original preferences values
- */
- @Override
- protected void performDefaults() {
- setValid(true);
- setMessage(null);
- performApply();
- }
-
- /**
- * See {@link PreferencePage} for details
- *
- * @return Boolean
- */
- @Override
- public boolean performOk() {
- performApply();
- return super.performOk();
- }
-
- public JbossRuntimeListFieldEditor getJbossWSRuntimes() {
- return jbossWSRuntimes;
- }
-}
Deleted: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbwsLibraryListFieldEditor.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,586 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.preferences;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.ui.JbossWSUIPlugin;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
-
-/**
- * @author Grid Qian
- */
-public class JbwsLibraryListFieldEditor extends BaseFieldEditor {
-
- // ------------------------------------------------------------------------
- // Layout parameters
- // ------------------------------------------------------------------------
-
- static final int GL_COLUMNS = 2;
- static final int GL_HINT_HEIGHT = 200;
- static final int TC_DEFAULT_WIDTH = 21;
- static final int TC_NAME_WIDTH = 100;
- static final int TC_VERSION_WIDTH = 50;
- static final int TC_PATH_WIDTH = 100;
-
- // ------------------------------------------------------------------------
- // Field declarations
- // ------------------------------------------------------------------------
-
- private TreeViewer listView = null;
-
- private Composite root = null;
-
- private ActionPanel actionPanel;
-
- private JbossWSRuntime tempJbws;
-
-
-
-
- private Group jarGroup;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Control for editing jbossWSRuntime list
- *
- * @param name
- * String
- * @param label
- * String
- * @param defaultValue
- * Object
- */
- public JbwsLibraryListFieldEditor(String name, String label,
- JbossWSRuntime jbws) {
- super(name, label, jbws);
- this.tempJbws = new JbossWSRuntime();
- if(jbws != null){
- this.tempJbws.setUserConfigClasspath(jbws.isUserConfigClasspath());
- this.tempJbws.getLibraries().addAll(jbws.getLibraries());
- }
-
- }
-
-
- public Object getValue(){
- return this.tempJbws;
- }
- /**
- * TBD
- *
- * @param composite
- * Object - instance of Composite
- * @return Object[]
- */
- @Override
- public Object[] getEditorControls(Object composite) {
-
- root = new Composite((Composite) composite, SWT.NONE);
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- root.setLayoutData(gd);
-
- root.setLayout(new GridLayout());
-
- createCheckButton(root);
-
- jarGroup = new Group(root, SWT.BORDER);
- jarGroup.setText("Library Jars");
- gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
-
-
- jarGroup.setLayoutData(gd);
- jarGroup.setLayout(new FormLayout());
-
- createListView(jarGroup);
- createActionBar(jarGroup);
-
- FormData listData = new FormData();
- listData.left = new FormAttachment(0, 5);
- listData.right = new FormAttachment(actionPanel, -5);
- listData.top = new FormAttachment(0, 5);
- listData.bottom = new FormAttachment(100, -5);
- listView.getControl().setLayoutData(listData);
-
- FormData actionsData = new FormData();
- actionsData.top = new FormAttachment(0, 5);
- actionsData.bottom = new FormAttachment(100, -5);
- actionsData.right = new FormAttachment(100, -5);
- actionPanel.setLayoutData(actionsData);
-
- setJarGroupStatus();
- return new Control[] { root };
- }
-
- protected void createCheckButton(Composite parent){
- final Button btnDefault = new Button(parent, SWT.CHECK);
- btnDefault.setText(JbossWSUIMessages.JBossWS_Runtime_Check_Field_Default_Classpath);
- GridData gd = new GridData();
- gd.horizontalSpan = 2;
- btnDefault.setLayoutData(gd);
-
- btnDefault.setSelection(tempJbws.isUserConfigClasspath());
- btnDefault.addSelectionListener(new SelectionAdapter(){
- public void widgetSelected(SelectionEvent e) {
- tempJbws.setUserConfigClasspath(btnDefault.getSelection());
- setJarGroupStatus();
- setValue(null);
- }
- });
-
-
- }
-
- protected void setJarGroupStatus(){
- boolean isUserConfig = tempJbws.isUserConfigClasspath();
- jarGroup.setEnabled(isUserConfig);
- listView.getTree().setEnabled(isUserConfig);
- actionPanel.setEnabled(isUserConfig);
- }
- @SuppressWarnings("unchecked")
- protected void createListView(Composite parent) {
- listView = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- listView.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
-
- listView.setContentProvider(new ITreeContentProvider() {
-
- @SuppressWarnings("unchecked")
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof JbossWSRuntime) {
- return ((JbossWSRuntime) inputElement).getLibraries().toArray();
- } else {
- throw new IllegalArgumentException(
- JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
- + JbossWSUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
- }
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- viewer.refresh();
- }
-
- public Object[] getChildren(Object parentElement) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object getParent(Object element) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public boolean hasChildren(Object element) {
- // TODO Auto-generated method stub
- return false;
- }
- });
-
- listView.setLabelProvider(new ILabelProvider() {
-
- Image jarImg;
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
-
- public Image getImage(Object element) {
- if (jarImg == null){
- ImageDescriptor jarImgDesc = JbossWSUIPlugin.getImageDescriptor("obj16/jar_obj.gif");
- jarImg = jarImgDesc.createImage();
- }
- return jarImg;
- }
-
- public String getText(Object element) {
- String fullName = (String)element;
- File jarFile = new File(fullName);
- return jarFile.getName() + " - " + jarFile.getParentFile().toString();
- }
- });
-
-
- listView.setInput(getValue());
-
- }
-
- protected void createActionBar(Composite parent) {
- actionPanel = new ActionPanel(parent, new BaseAction[] { new AddAction(),
- new RemoveAction() });
- listView.addSelectionChangedListener(actionPanel);
- }
-
-
-
- /**
- * Return array of Controls that forms and editor
- *
- * @return Control[]
- */
- @Override
- public Object[] getEditorControls() {
- return new Control[] { root };
- }
-
- /**
- * Return number of controls in editor
- *
- * @return int
- */
- @Override
- public int getNumberOfControls() {
- return 1;
- }
-
- /**
- * Fill wizard page with editors
- *
- * @param parent
- * Composite - parent composite
- */
- @Override
- public void doFillIntoGrid(Object parent) {
- Assert.isTrue(parent instanceof Composite,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
- Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
- JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
- Composite aComposite = (Composite) parent;
- getEditorControls(aComposite);
- GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
-
- GridData gd = new GridData();
- gd.horizontalSpan = gl.numColumns;
- gd.grabExcessHorizontalSpace = true;
- gd.horizontalAlignment = GridData.FILL;
-
- ((Control) getEditorControls()[0]).setLayoutData(gd);
- }
-
-
-
- /**
- * Composite that holds list of BaseActions and presents them as column of
- * buttons
- *
- */
- public static class ActionPanel extends Composite implements
- ISelectionChangedListener {
-
- private BaseAction[] actions = null;
-
- /**
- * Constructor creates panel with style, grid layout and buttons
- * represented the actions
- *
- * @param parent
- * Composite
- * @param style
- * int
- * @param actions
- * BaseAction[]
- */
- public ActionPanel(Composite parent, int style, BaseAction[] actions) {
- super(parent, style);
- this.actions = actions;
- setLayout(new GridLayout(1, false));
- for (BaseAction action : this.actions) {
- new ActionButton(this, SWT.PUSH, action);
- }
- }
-
- /**
- * Constructor creates panel with default style, grid layout and buttons
- * represented the actions
- *
- * @param parent
- * Composite
- * @param actions
- * BaseAction[]
- */
- public ActionPanel(Composite parent, BaseAction[] actions) {
- this(parent, SWT.NONE, actions);
- }
-
- /**
- * Listen to the selection changes and update actions state
- * (enable/disable)
- *
- * @param event
- * SelectionChangeEvent
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- for (BaseAction action : actions) {
- action.setSelection(event.getSelection());
- }
- }
- }
-
- /**
- * Class represents an BaseAction as SWT button control and runs action when
- * button is prtessed
- *
- */
- public static class ActionButton implements IPropertyChangeListener {
-
- private Button button;
- private BaseAction action;
-
- /**
- * Create Button control with parent control and style that represents
- * action
- *
- * @param parent
- * Composite
- * @param style
- * int
- * @param action
- * BaseAction
- */
- public ActionButton(Composite parent, int style, BaseAction action) {
- this.button = new Button(parent, style);
- this.action = action;
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL,
- GridData.CENTER, false, false);
-
- gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
- this.button.setLayoutData(gd);
- this.action.addPropertyChangeListener(this);
- this.button.setText(action.getText());
- this.button.setEnabled(action.isEnabled());
- this.button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- ActionButton.this.action.run();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- }
-
- /**
- * Return SWT button control that calls provided action
- *
- * @return Control - button swt control
- */
- public Control getControl() {
- return button;
- }
-
- /**
- * Update enabled/disabled button state
- *
- * @param event
- * PropertyChangeEvent
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(IAction.ENABLED)) {
- button.setEnabled(((Boolean) event.getNewValue())
- .booleanValue());
- }
- }
- }
-
- /**
- * Action that changes state enable/disable based on current table selection
- *
- */
- public abstract class BaseAction extends Action {
-
- String[] jars = new String[0];
-
- /**
- * Constructor creates action with provided name
- *
- * @param name
- * String - action name
- */
- public BaseAction(String name) {
- super(name);
- updateEnablement();
- }
-
- /**
- * Set current selection
- *
- * @param selection
- * ISelection - selected items
- */
- public void setSelection(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- List<String> rts = new ArrayList<String>();
- for (Object jarfile : ((IStructuredSelection) selection).toArray()) {
- rts.add((String) jarfile);
- }
- jars = rts.toArray(new String[] {});
- } else {
- jars = new String[0];
- }
- updateEnablement();
- }
-
- protected abstract void updateEnablement();
- }
-
- /**
- * Action that invokes New JbossWS Runtime Dialog
- *
- */
- public class AddAction extends BaseAction {
-
- static final String ACTION_NAME = "&Add";
-
- /**
- * Constructor create Add action with default name
- */
- public AddAction() {
- super(ACTION_NAME);
- // This action is always available
- setEnabled(true);
- }
-
- /**
- * Do nothing, because Add action should be always available
- */
- @Override
- protected void updateEnablement() {
- // Add button is always available
- }
-
- /**
- * Invoke New JbossWS Runtime Dialog
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @SuppressWarnings("unchecked")
- @Override
- public void run() {
- FileDialog dialog = new FileDialog(Display.getCurrent()
- .getActiveShell(), SWT.MULTI);
- dialog.setFilterExtensions(new String[] { "*.jar;*.zip" });
- String fileName = dialog.open();
- String[] fileNames = dialog.getFileNames();
- if (fileName != null) {
- File filePath = new File(fileName);
- filePath = filePath.getParentFile();
- for (int i = 0; i < fileNames.length; i++) {
- IPath path = new Path(filePath.getAbsolutePath())
- .append(fileNames[i]);
- if (!tempJbws.getLibraries().contains(path.toOSString())) {
- tempJbws.getLibraries().add(path.toOSString());
- }
- }
-
- listView.refresh();
- setValue(null);
- }
- }
- }
-
-
- /**
- * Action deletes all selected JbossWS Runtimes. A warning message is shown
- * for used JbossWS Runtimes
- *
- */
- public class RemoveAction extends BaseAction {
-
- static final String ACTION_NAME = "&Remove";
-
- /**
- * Create DeleteAction action with default name
- */
- public RemoveAction() {
- super(ACTION_NAME);
- }
-
- @Override
- protected void updateEnablement() {
- setEnabled(jars.length > 0);
- }
-
- /**
- * Remove all selected JbossWS Runtimes one by one
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- for (String jar : jars) {
- tempJbws.getLibraries().remove(jar);
- }
- listView.refresh();
- // just try to fire property change listener
- setValue(null);
- }
-
-
- }
-}
\ No newline at end of file
Modified: trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/TextFieldEditor.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -22,7 +22,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
-import org.jboss.tools.ws.ui.messages.JbossWSUIMessages;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
/**
*
@@ -68,8 +68,8 @@
@Override
public void doFillIntoGrid(Object aParent) {
- Assert.isTrue(aParent instanceof Composite, JbossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
- Assert.isTrue(((Composite)aParent).getLayout() instanceof GridLayout,JbossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Assert.isTrue(aParent instanceof Composite, JBossWSUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite)aParent).getLayout() instanceof GridLayout,JBossWSUIMessages.Error_JBossWS_Basic_Editor_Support);
Composite aComposite = (Composite) aParent;
getEditorControls(aComposite);
GridLayout gl = (GridLayout)((Composite)aParent).getLayout();
Modified: trunk/ws/tests/org.jboss.tools.ws.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC (rev 8979)
@@ -30,4 +30,4 @@
org.eclipse.jdt.core,
org.eclipse.ui.console;bundle-version="3.3.0",
org.eclipse.jface.text;bundle-version="3.4.0"
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Added: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.test;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jboss.tools.ws.core.test.classpath.JBossWSRuntimeManagerTest;
+import org.jboss.tools.ws.core.test.command.JBossWSJavaFirstCommandTest;
+import org.jboss.tools.ws.core.test.command.JBossWSClientCommandTest;
+
+public class JBossWSCoreAllTests extends TestCase {
+ public static final String PLUGIN_ID = "org.jboss.tools.common.test";
+ public static Test suite ()
+ {
+ TestSuite suite = new TestSuite(JBossWSCoreAllTests.class.getName());
+ suite.addTestSuite(JBossWSRuntimeManagerTest.class);
+ suite.addTestSuite(JBossWSJavaFirstCommandTest.class);
+ suite.addTestSuite(JBossWSClientCommandTest.class);
+
+ return suite;
+ }
+}
\ No newline at end of file
Property changes on: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JBossWSCoreAllTests.java
___________________________________________________________________
Name: svn:executable
+ *
Deleted: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JbossWSCoreAllTests.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JbossWSCoreAllTests.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/JbossWSCoreAllTests.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.ws.core.test;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.jboss.tools.ws.core.test.classpath.JbossWSRuntimeManagerTest;
-import org.jboss.tools.ws.core.test.command.JavaFirstCommandTest;
-import org.jboss.tools.ws.core.test.command.WSClientCommandTest;
-
-public class JbossWSCoreAllTests extends TestCase {
- public static final String PLUGIN_ID = "org.jboss.tools.common.test";
- public static Test suite ()
- {
- TestSuite suite = new TestSuite(JbossWSCoreAllTests.class.getName());
- suite.addTestSuite(JbossWSRuntimeManagerTest.class);
- suite.addTestSuite(JavaFirstCommandTest.class);
- suite.addTestSuite(WSClientCommandTest.class);
-
- return suite;
- }
-}
\ No newline at end of file
Added: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JBossWSRuntimeManagerTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JBossWSRuntimeManagerTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JBossWSRuntimeManagerTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.core.test.classpath;
+
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimeManagerTest extends TestCase {
+
+ JBossWSRuntimeManager manager;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ manager = JBossWSRuntimeManager.getInstance();
+ assertNotNull("Cannot obtainJBossWSRuntimeManager instance", manager);
+ if (manager.findRuntimeByName("JBossWS Runtime 4.2") != null)
+ return;
+ manager.addRuntime("JBossWS Runtime 4.2", "runtimelocation", "4.2",
+ true);
+ }
+
+ public void testGetRuntimes() {
+ JBossWSRuntime[] rtms = manager.getRuntimes();
+ assertTrue("JBossWS runtime 'JBossWS Runtime 4.2' is not created",
+ rtms.length == 1);
+ assertTrue("JBossWS runtime 'JBossWS Runtime 4.2' is not created",
+ rtms[0].getName().equals("JBossWS Runtime 4.2"));
+ }
+
+ public void testFindRuntimeByName() {
+ JBossWSRuntime srt = manager.findRuntimeByName("JBossWS Runtime 4.2");
+ assertNotNull("Cannot find runtime 'JBossWS Runtime 4.2'", srt);
+ }
+
+ public void testGetDefaultRuntime() {
+ assertNotNull("Cannot obtain default runtime 'JBossWS Runtime 4.2'",
+ manager.getDefaultRuntime());
+ }
+}
Deleted: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JbossWSRuntimeManagerTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JbossWSRuntimeManagerTest.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/classpath/JbossWSRuntimeManagerTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.core.test.classpath;
-
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-
-import junit.framework.TestCase;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimeManagerTest extends TestCase {
-
- JbossWSRuntimeManager manager;
-
- protected void setUp() throws Exception {
- super.setUp();
- manager = JbossWSRuntimeManager.getInstance();
- assertNotNull("Cannot obtainJbossWSRuntimeManager instance", manager);
- if (manager.findRuntimeByName("JBossWS Runtime 4.2") != null)
- return;
- manager.addRuntime("JBossWS Runtime 4.2", "runtimelocation", "4.2",
- true);
- }
-
- public void testGetRuntimes() {
- JbossWSRuntime[] rtms = manager.getRuntimes();
- assertTrue("JbossWS runtime 'JBossWS Runtime 4.2' is not created",
- rtms.length == 1);
- assertTrue("JbossWS runtime 'JBossWS Runtime 4.2' is not created",
- rtms[0].getName().equals("JBossWS Runtime 4.2"));
- }
-
- public void testFindRuntimeByName() {
- JbossWSRuntime srt = manager.findRuntimeByName("JBossWS Runtime 4.2");
- assertNotNull("Cannot find runtime 'JBossWS Runtime 4.2'", srt);
- }
-
- public void testGetDefaultRuntime() {
- assertNotNull("Cannot obtain default runtime 'JBossWS Runtime 4.2'",
- manager.getDefaultRuntime());
- }
-}
Modified: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/AbstractJBossWSCommandTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -261,7 +261,7 @@
String jbosshome = System.getProperty(JBOSS_RUNTIME_42, JBOSSWS_HOME_DEFAULT);
File runtimelocation = new File(jbosshome);
- assertTrue("Please set Jboss EAP Home in system property:" + JBOSS_RUNTIME_42, runtimelocation.exists());
+ assertTrue("Please set JBoss EAP Home in system property:" + JBOSS_RUNTIME_42, runtimelocation.exists());
String cmdFileLocation = jbosshome + File.separator + "bin" + File.separator + "wsconsume.sh";
assertTrue(jbosshome + " is not a valid jboss EAP home", new File(cmdFileLocation).exists());
Added: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSClientCommandTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSClientCommandTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSClientCommandTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+package org.jboss.tools.ws.core.test.command;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaModel;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.internal.Server;
+import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
+import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceClientInfo;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeClassPathInitializer.JBossWSRuntimeClasspathContainer;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
+import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
+import org.jboss.tools.ws.creation.core.commands.ClientSampleCreationCommand;
+import org.jboss.tools.ws.creation.core.commands.InitialClientCommand;
+import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
+import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.ui.wsrt.JBossWebServiceClient;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSClientCommandTest extends AbstractJBossWSCommandTest {
+
+ protected static final String JBOSSWS_HOME_DEFAULT = "/home/grid/Software/jboss-4.2.2.GA";
+ private static final String RuntimeName;
+ private static final boolean isDeployed;
+
+ static {
+ RuntimeName = "testjbosswsruntime";
+ isDeployed = false;
+ }
+
+ public JBossWSClientCommandTest() {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
+ getJBossWSHomeFolder().toString(), "", true);
+
+ // create jbossws web project
+ fproject = createJBossWSProject("JBossWSTestProject",
+ isServerSupplied());
+ IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
+
+ assertTrue(wsdlFile.exists());
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ resourcesToCleanup.clear();
+ JBossWSRuntime runtime = JBossWSRuntimeManager.getInstance()
+ .findRuntimeByName(RuntimeName);
+ JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
+ }
+
+ public void testInitialClientCommand() throws CoreException,
+ ExecutionException {
+
+ IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ // model.setWsdlURI(wsdlFile.getLocation().toOSString());
+
+ WebServiceClientInfo info = new WebServiceClientInfo();
+ info.setWsdlURL(wsdlFile.getLocation().toOSString());
+ IWebServiceClient ws = new JBossWebServiceClient(info);
+
+ // test initial command
+ InitialClientCommand cmdInitial = new InitialClientCommand(model, ws,
+ WebServiceScenario.CLIENT);
+ IStatus status = cmdInitial.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ assertTrue(model.getServiceNames().contains("SOAPService"));
+ assertEquals(wsdlFile.getLocation().toOSString(), model.getWsdlURI());
+ assertTrue(model.getPortTypes().contains("Greeter"));
+ assertEquals("org.apache.hello_world_soap_http", model
+ .getCustomPackage());
+
+ }
+
+ public void testClientCodeGenerationCommand() throws ExecutionException {
+
+ ServiceModel model = createServiceModel();
+ IProject project = fproject.getProject();
+ // test wsdl2Javacommand
+ WSDL2JavaCommand cmdW2j = new WSDL2JavaCommand(model);
+ IStatus status = cmdW2j.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+ assertTrue(project.getFile(
+ "src/org/apache/hello_world_soap_http/Greeter.java").exists());
+
+ // test ClientSampleCreationCommand
+ ClientSampleCreationCommand cmdImpl = new ClientSampleCreationCommand(
+ model);
+ status = cmdImpl.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+ assertTrue(
+ "failed to generate sample class",
+ project
+ .getFile(
+ "src/org/apache/hello_world_soap_http/clientsample/ClientSample.java")
+ .exists());
+
+ }
+
+ public void testRemoveClientJarsCommand() throws ExecutionException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+
+ RemoveClientJarsCommand command = new RemoveClientJarsCommand(model);
+ IStatus status = command.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+ try {
+ IClasspathEntry[] entries = getJavaProjectByName(
+ fproject.getProject().getName()).getRawClasspath();
+
+ for (IClasspathEntry entry : entries) {
+ IClasspathContainer container = JavaCore.getClasspathContainer(
+ entry.getPath(), getJavaProjectByName(fproject
+ .getProject().getName()));
+ if (container instanceof JBossWSRuntimeClasspathContainer) {
+ boolean nojar = true;
+ for (IClasspathEntry jar : ((JBossWSRuntimeClasspathContainer) container)
+ .getClasspathEntries()) {
+ if (jar.getPath().toString().contains("jaxws-rt.jar")) {
+ nojar = false;
+ }
+ }
+ assertTrue(nojar);
+ }
+ }
+ } catch (JavaModelException e) {
+ JBossWSCreationCore.getDefault().logError(e);
+ }
+
+ }
+
+ public static IJavaProject getJavaProjectByName(String projectName)
+ throws JavaModelException {
+
+ IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()
+ .getRoot());
+ model.open(null);
+
+ IJavaProject[] projects = model.getJavaProjects();
+
+ for (IJavaProject proj : projects) {
+ if (proj.getProject().getName().equals(projectName)) {
+ return proj;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ IDataModel createJBossWSDataModel(boolean isServerSupplied) {
+ IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
+ .create();
+ if (isServerSupplied) {
+ config
+ .setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
+ true);
+ } else {
+ config.setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
+ isDeployed);
+ config.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
+ RuntimeName);
+ config.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
+ getJBossWSHomeFolder().toString());
+ }
+ return config;
+ }
+
+}
Added: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSJavaFirstCommandTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,305 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+package org.jboss.tools.ws.core.test.command;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.AbstractConsole;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleListener;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.TextConsole;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.ws.internal.wsrt.IWebService;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
+import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
+import org.jboss.tools.ws.creation.core.commands.InitialCommand;
+import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
+import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
+import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
+import org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand;
+import org.jboss.tools.ws.creation.core.data.ServiceModel;
+import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
+import org.jboss.tools.ws.creation.ui.wsrt.JBossWebService;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSJavaFirstCommandTest extends AbstractJBossWSCommandTest {
+ protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
+ protected static final IWorkbench wb = PlatformUI.getWorkbench();
+
+ protected static final String JBOSSWS_HOME_DEFAULT = "/home/grid/Software/jboss-4.2.2.GA";
+ private static final String RuntimeName;
+ private static final boolean isDeployed;
+
+ static {
+ RuntimeName = "testjbosswsruntime";
+ isDeployed = false;
+ }
+
+ public JBossWSJavaFirstCommandTest() {
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
+ getJBossWSHomeFolder().toString(), "", true);
+ // create jbossws web project
+ fproject = createJBossWSProject("JavaFirstTestProject",
+ isServerSupplied());
+
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ resourcesToCleanup.clear();
+ JBossWSRuntime runtime = JBossWSRuntimeManager.getInstance()
+ .findRuntimeByName(RuntimeName);
+ JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
+ }
+
+ public void testInitialCommand() throws CoreException, ExecutionException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ WebServiceInfo info = new WebServiceInfo();
+ info.setImplURL("org.example.www.helloworld.HelloWorld");
+ IWebService ws = new JBossWebService(info);
+
+ // test initial command
+ InitialCommand cmdInitial = new InitialCommand(model, ws,
+ WebServiceScenario.BOTTOMUP);
+ IStatus status = cmdInitial.execute(null, null);
+
+ assertTrue(status.getMessage(), status.isOK());
+ assertTrue(model.getServiceClasses().get(0).equals(
+ "org.example.www.helloworld.HelloWorld"));
+ }
+
+ public void testValidateWSImplCommand() throws ExecutionException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ model.addServiceClasses("org.example.www.helloworld.HelloWorld");
+
+ ValidateWSImplCommand command = new ValidateWSImplCommand(model);
+ IStatus status = command.execute(null, null);
+
+ assertTrue(status.getMessage(), status.isOK());
+
+ }
+
+ public void testWSProviderInvokeCommand() throws ExecutionException, CoreException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+ model.addServiceClasses("org.example.www.helloworld.HelloWorld");
+ model.setGenWSDL(true);
+ IProject project = fproject.getProject();
+
+ fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+ WSProviderInvokeCommand command = new WSProviderInvokeCommand(model);
+ IStatus status = command.execute(null, null);
+
+ assertTrue(status.getMessage(), status.isOK());
+ assertTrue(project.getFile(
+ "src/org/example/www/helloworld/jaxws/SayHello.java").exists());
+ assertTrue(project.getFile("WebContent/wsdl/HelloWorldService.wsdl")
+ .exists());
+ }
+
+ public void testDeployResult() throws ExecutionException, CoreException,
+ IOException {
+
+ ServiceModel model = new ServiceModel();
+ model.setWebProjectName(fproject.getProject().getName());
+
+ WebServiceInfo info = new WebServiceInfo();
+ info.setImplURL("org.example.www.helloworld.HelloWorld");
+ IWebService ws = new JBossWebService(info);
+
+ // test initial command
+ AbstractDataModelOperation cmd = new InitialCommand(model, ws,
+ WebServiceScenario.BOTTOMUP);
+ IStatus status = cmd.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+
+ cmd = new WSProviderInvokeCommand(model);
+ status = cmd.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ cmd = new MergeWebXMLCommand(model);
+ status = cmd.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ publishWebProject();
+
+ assertTrue(currentServer.getModules().length > 0);
+ String webServiceUrl = "http://localhost:8080/JavaFirstTestProject/HelloWorld?wsdl";
+ URL url = new URL(webServiceUrl);
+ URLConnection conn = url.openConnection();
+
+ startup();
+
+ assertEquals("unable to start JBoss server", IServer.STATE_STARTED,
+ currentServer.getServerState());
+
+ conn.connect();
+ conn.getContent();
+
+ IProject pro = createProject("ClientTest");
+ model = new ServiceModel();
+ model.setWebProjectName("ClientTest");
+
+ cmd = new RemoveClientJarsCommand(model);
+ status = cmd.execute(null, null);
+ assertTrue(status.getMessage(), status.isOK());
+
+ pro.open(null);
+ pro.refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ ILaunchManager launchManager = DebugPlugin.getDefault()
+ .getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType = launchManager
+ .getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
+ ILaunchConfigurationWorkingCopy wc = launchConfigurationType
+ .newInstance(null, "ClientSample");
+ wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES", "1");
+ wc.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE",
+ "org.example.www.helloworld.clientsample.ClientSample");
+ wc.setAttribute("org.eclipse.jdt.launching.PROGRAM_ARGUMENTS", "Test");
+ wc.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", "ClientTest");
+ wc.doSave();
+ wc.launch(ILaunchManager.RUN_MODE, null);
+ IConsoleManager consolemanager = getConsoleManager();
+ checkText(consolemanager.getConsoles());
+ }
+
+ private void checkText(IConsole[] consoles) {
+ // test run result
+ for (IConsole console : consoles) {
+ if (console.getName().contains("ClientSample")) {
+ int i = 0;
+ while (i < 10
+ && !isContainString(
+ console,
+ JBossWSCreationCoreMessages.Client_Sample_Run_Over)) {
+ delay(1000);
+ i++;
+ }
+ assertTrue("Sample run over!", isContainString(console,
+ JBossWSCreationCoreMessages.Client_Sample_Run_Over));
+ }
+ }
+ }
+
+ public static boolean isContainString(IConsole console, String str) {
+ return ((TextConsole) console).getDocument().get().contains(str);
+ }
+
+ public static void delay(long durationInMilliseconds) {
+ Display display = Display.getCurrent();
+ if (display != null) {
+ long t2 = System.currentTimeMillis() + durationInMilliseconds;
+ while (System.currentTimeMillis() < t2) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ display.update();
+ } else {
+ try {
+ Thread.sleep(durationInMilliseconds);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ public static IConsoleManager getConsoleManager() {
+ IConsoleManager consolemanager = ConsolePlugin.getDefault()
+ .getConsoleManager();
+
+ consolemanager.addConsoleListener(new IConsoleListener() {
+ public void consolesAdded(IConsole[] consoles) {
+ for (int i = 0; i < consoles.length; i++) {
+ ((AbstractConsole) consoles[i]).activate();
+ }
+
+ }
+
+ public void consolesRemoved(IConsole[] consoles) {
+ for (int i = 0; i < consoles.length; i++) {
+ ((AbstractConsole) consoles[i]).destroy();
+ }
+
+ }
+ });
+ return consolemanager;
+ }
+
+ @Override
+ IDataModel createJBossWSDataModel(boolean isServerSupplied) {
+ IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
+ .create();
+ if (isServerSupplied) {
+ config
+ .setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
+ true);
+ } else {
+ config.setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
+ isDeployed);
+ config.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
+ RuntimeName);
+ config.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
+ getJBossWSHomeFolder().toString());
+ }
+ return config;
+ }
+
+}
Modified: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSTopDownCommandTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSTopDownCommandTest.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JBossWSTopDownCommandTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -37,8 +37,8 @@
import org.eclipse.wst.ws.internal.wsrt.IWebService;
import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
import org.jboss.tools.ws.creation.core.commands.ImplementationClassCreationCommand;
@@ -72,7 +72,7 @@
protected void setUp() throws Exception {
super.setUp();
- JbossWSRuntimeManager.getInstance().addRuntime(RuntimeName, getJBossWSHomeFolder().toString(), "", true);
+ JBossWSRuntimeManager.getInstance().addRuntime(RuntimeName, getJBossWSHomeFolder().toString(), "", true);
//create jbossws web project
fproject = createJBossWSProject("JBossWSTestProject", isServerSupplied());
@@ -87,8 +87,8 @@
// Wait until all jobs is finished to avoid delete project problems
super.tearDown();
resourcesToCleanup.clear();
- JbossWSRuntime runtime = JbossWSRuntimeManager.getInstance().findRuntimeByName(RuntimeName);
- JbossWSRuntimeManager.getInstance().removeRuntime(runtime);
+ JBossWSRuntime runtime = JBossWSRuntimeManager.getInstance().findRuntimeByName(RuntimeName);
+ JBossWSRuntimeManager.getInstance().removeRuntime(runtime);
Deleted: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JavaFirstCommandTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JavaFirstCommandTest.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/JavaFirstCommandTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package org.jboss.tools.ws.core.test.command;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.AbstractConsole;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleListener;
-import org.eclipse.ui.console.IConsoleManager;
-import org.eclipse.ui.console.TextConsole;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.ws.internal.wsrt.IWebService;
-import org.eclipse.wst.ws.internal.wsrt.WebServiceInfo;
-import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
-import org.jboss.tools.ws.creation.core.commands.InitialCommand;
-import org.jboss.tools.ws.creation.core.commands.MergeWebXMLCommand;
-import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
-import org.jboss.tools.ws.creation.core.commands.ValidateWSImplCommand;
-import org.jboss.tools.ws.creation.core.commands.WSProviderInvokeCommand;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
-import org.jboss.tools.ws.creation.core.messages.JBossWSCreationCoreMessages;
-import org.jboss.tools.ws.creation.ui.wsrt.JBossWebService;
-
-/**
- * @author Grid Qian
- */
-public class JavaFirstCommandTest extends AbstractJBossWSCommandTest {
- protected static final IWorkspace ws = ResourcesPlugin.getWorkspace();
- protected static final IWorkbench wb = PlatformUI.getWorkbench();
-
- protected static final String JBOSSWS_HOME_DEFAULT = "/home/grid/Software/jboss-4.2.2.GA";
- private static final String RuntimeName;
- private static final boolean isDeployed;
-
- static {
- RuntimeName = "testjbosswsruntime";
- isDeployed = false;
- }
-
- public JavaFirstCommandTest() {
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- JbossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
- getJBossWSHomeFolder().toString(), "", true);
- // create jbossws web project
- fproject = createJBossWSProject("JavaFirstTestProject",
- isServerSupplied());
-
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
-
- resourcesToCleanup.clear();
- JbossWSRuntime runtime = JbossWSRuntimeManager.getInstance()
- .findRuntimeByName(RuntimeName);
- JbossWSRuntimeManager.getInstance().removeRuntime(runtime);
- }
-
- public void testInitialCommand() throws CoreException, ExecutionException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- WebServiceInfo info = new WebServiceInfo();
- info.setImplURL("org.example.www.helloworld.HelloWorld");
- IWebService ws = new JBossWebService(info);
-
- // test initial command
- InitialCommand cmdInitial = new InitialCommand(model, ws,
- WebServiceScenario.BOTTOMUP);
- IStatus status = cmdInitial.execute(null, null);
-
- assertTrue(status.getMessage(), status.isOK());
- assertTrue(model.getServiceClasses().get(0).equals(
- "org.example.www.helloworld.HelloWorld"));
- }
-
- public void testValidateWSImplCommand() throws ExecutionException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.addServiceClasses("org.example.www.helloworld.HelloWorld");
-
- ValidateWSImplCommand command = new ValidateWSImplCommand(model);
- IStatus status = command.execute(null, null);
-
- assertTrue(status.getMessage(), status.isOK());
-
- }
-
- public void testWSProviderInvokeCommand() throws ExecutionException, CoreException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- model.addServiceClasses("org.example.www.helloworld.HelloWorld");
- model.setGenWSDL(true);
- IProject project = fproject.getProject();
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
-
- WSProviderInvokeCommand command = new WSProviderInvokeCommand(model);
- IStatus status = command.execute(null, null);
-
- assertTrue(status.getMessage(), status.isOK());
- assertTrue(project.getFile(
- "src/org/example/www/helloworld/jaxws/SayHello.java").exists());
- assertTrue(project.getFile("WebContent/wsdl/HelloWorldService.wsdl")
- .exists());
- }
-
- public void testDeployResult() throws ExecutionException, CoreException,
- IOException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
-
- WebServiceInfo info = new WebServiceInfo();
- info.setImplURL("org.example.www.helloworld.HelloWorld");
- IWebService ws = new JBossWebService(info);
-
- // test initial command
- AbstractDataModelOperation cmd = new InitialCommand(model, ws,
- WebServiceScenario.BOTTOMUP);
- IStatus status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
-
- cmd = new WSProviderInvokeCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- cmd = new MergeWebXMLCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- fproject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
- fproject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
- publishWebProject();
-
- assertTrue(currentServer.getModules().length > 0);
- String webServiceUrl = "http://localhost:8080/JavaFirstTestProject/HelloWorld?wsdl";
- URL url = new URL(webServiceUrl);
- URLConnection conn = url.openConnection();
-
- startup();
-
- assertEquals("unable to start JBoss server", IServer.STATE_STARTED,
- currentServer.getServerState());
-
- conn.connect();
- conn.getContent();
-
- IProject pro = createProject("ClientTest");
- model = new ServiceModel();
- model.setWebProjectName("ClientTest");
-
- cmd = new RemoveClientJarsCommand(model);
- status = cmd.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- pro.open(null);
- pro.refreshLocal(IResource.DEPTH_INFINITE, null);
-
- ILaunchManager launchManager = DebugPlugin.getDefault()
- .getLaunchManager();
- ILaunchConfigurationType launchConfigurationType = launchManager
- .getLaunchConfigurationType("org.eclipse.jdt.launching.localJavaApplication");
- ILaunchConfigurationWorkingCopy wc = launchConfigurationType
- .newInstance(null, "ClientSample");
- wc.setAttribute("org.eclipse.debug.core.MAPPED_RESOURCE_TYPES", "1");
- wc.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE",
- "org.example.www.helloworld.clientsample.ClientSample");
- wc.setAttribute("org.eclipse.jdt.launching.PROGRAM_ARGUMENTS", "Test");
- wc.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", "ClientTest");
- wc.doSave();
- wc.launch(ILaunchManager.RUN_MODE, null);
- IConsoleManager consolemanager = getConsoleManager();
- checkText(consolemanager.getConsoles());
- }
-
- private void checkText(IConsole[] consoles) {
- // test run result
- for (IConsole console : consoles) {
- if (console.getName().contains("ClientSample")) {
- int i = 0;
- while (i < 10
- && !isContainString(
- console,
- JBossWSCreationCoreMessages.Client_Sample_Run_Over)) {
- delay(1000);
- i++;
- }
- assertTrue("Sample run over!", isContainString(console,
- JBossWSCreationCoreMessages.Client_Sample_Run_Over));
- }
- }
- }
-
- public static boolean isContainString(IConsole console, String str) {
- return ((TextConsole) console).getDocument().get().contains(str);
- }
-
- public static void delay(long durationInMilliseconds) {
- Display display = Display.getCurrent();
- if (display != null) {
- long t2 = System.currentTimeMillis() + durationInMilliseconds;
- while (System.currentTimeMillis() < t2) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- display.update();
- } else {
- try {
- Thread.sleep(durationInMilliseconds);
- } catch (InterruptedException e) {
- }
- }
- }
-
- public static IConsoleManager getConsoleManager() {
- IConsoleManager consolemanager = ConsolePlugin.getDefault()
- .getConsoleManager();
-
- consolemanager.addConsoleListener(new IConsoleListener() {
- public void consolesAdded(IConsole[] consoles) {
- for (int i = 0; i < consoles.length; i++) {
- ((AbstractConsole) consoles[i]).activate();
- }
-
- }
-
- public void consolesRemoved(IConsole[] consoles) {
- for (int i = 0; i < consoles.length; i++) {
- ((AbstractConsole) consoles[i]).destroy();
- }
-
- }
- });
- return consolemanager;
- }
-
- @Override
- IDataModel createJBossWSDataModel(boolean isServerSupplied) {
- IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
- .create();
- if (isServerSupplied) {
- config
- .setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
- true);
- } else {
- config.setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
- isDeployed);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
- RuntimeName);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
- getJBossWSHomeFolder().toString());
- }
- return config;
- }
-
-}
Deleted: trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/WSClientCommandTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/WSClientCommandTest.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.core.test/src/org/jboss/tools/ws/core/test/command/WSClientCommandTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package org.jboss.tools.ws.core.test.command;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaModel;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.server.core.internal.Server;
-import org.eclipse.wst.server.core.internal.ServerWorkingCopy;
-import org.eclipse.wst.ws.internal.wsrt.IWebServiceClient;
-import org.eclipse.wst.ws.internal.wsrt.WebServiceClientInfo;
-import org.eclipse.wst.ws.internal.wsrt.WebServiceScenario;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeClassPathInitializer.JbossWSRuntimeClasspathContainer;
-import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
-import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
-import org.jboss.tools.ws.creation.core.JBossWSCreationCore;
-import org.jboss.tools.ws.creation.core.commands.ClientSampleCreationCommand;
-import org.jboss.tools.ws.creation.core.commands.InitialClientCommand;
-import org.jboss.tools.ws.creation.core.commands.RemoveClientJarsCommand;
-import org.jboss.tools.ws.creation.core.commands.WSDL2JavaCommand;
-import org.jboss.tools.ws.creation.core.data.ServiceModel;
-import org.jboss.tools.ws.creation.ui.wsrt.JBossWebServiceClient;
-
-/**
- * @author Grid Qian
- */
-public class WSClientCommandTest extends AbstractJBossWSCommandTest {
-
- protected static final String JBOSSWS_HOME_DEFAULT = "/home/grid/Software/jboss-4.2.2.GA";
- private static final String RuntimeName;
- private static final boolean isDeployed;
-
- static {
- RuntimeName = "testjbosswsruntime";
- isDeployed = false;
- }
-
- public WSClientCommandTest() {
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- JbossWSRuntimeManager.getInstance().addRuntime(RuntimeName,
- getJBossWSHomeFolder().toString(), "", true);
-
- // create jbossws web project
- fproject = createJBossWSProject("JBossWSTestProject",
- isServerSupplied());
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
-
- assertTrue(wsdlFile.exists());
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- resourcesToCleanup.clear();
- JbossWSRuntime runtime = JbossWSRuntimeManager.getInstance()
- .findRuntimeByName(RuntimeName);
- JbossWSRuntimeManager.getInstance().removeRuntime(runtime);
- }
-
- public void testInitialClientCommand() throws CoreException,
- ExecutionException {
-
- IFile wsdlFile = fproject.getProject().getFile(wsdlFileName);
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
- // model.setWsdlURI(wsdlFile.getLocation().toOSString());
-
- WebServiceClientInfo info = new WebServiceClientInfo();
- info.setWsdlURL(wsdlFile.getLocation().toOSString());
- IWebServiceClient ws = new JBossWebServiceClient(info);
-
- // test initial command
- InitialClientCommand cmdInitial = new InitialClientCommand(model, ws,
- WebServiceScenario.CLIENT);
- IStatus status = cmdInitial.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
-
- assertTrue(model.getServiceNames().contains("SOAPService"));
- assertEquals(wsdlFile.getLocation().toOSString(), model.getWsdlURI());
- assertTrue(model.getPortTypes().contains("Greeter"));
- assertEquals("org.apache.hello_world_soap_http", model
- .getCustomPackage());
-
- }
-
- public void testClientCodeGenerationCommand() throws ExecutionException {
-
- ServiceModel model = createServiceModel();
- IProject project = fproject.getProject();
- // test wsdl2Javacommand
- WSDL2JavaCommand cmdW2j = new WSDL2JavaCommand(model);
- IStatus status = cmdW2j.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
- assertTrue(project.getFile(
- "src/org/apache/hello_world_soap_http/Greeter.java").exists());
-
- // test ClientSampleCreationCommand
- ClientSampleCreationCommand cmdImpl = new ClientSampleCreationCommand(
- model);
- status = cmdImpl.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
- assertTrue(
- "failed to generate sample class",
- project
- .getFile(
- "src/org/apache/hello_world_soap_http/clientsample/ClientSample.java")
- .exists());
-
- }
-
- public void testRemoveClientJarsCommand() throws ExecutionException {
-
- ServiceModel model = new ServiceModel();
- model.setWebProjectName(fproject.getProject().getName());
-
- RemoveClientJarsCommand command = new RemoveClientJarsCommand(model);
- IStatus status = command.execute(null, null);
- assertTrue(status.getMessage(), status.isOK());
- try {
- IClasspathEntry[] entries = getJavaProjectByName(
- fproject.getProject().getName()).getRawClasspath();
-
- for (IClasspathEntry entry : entries) {
- IClasspathContainer container = JavaCore.getClasspathContainer(
- entry.getPath(), getJavaProjectByName(fproject
- .getProject().getName()));
- if (container instanceof JbossWSRuntimeClasspathContainer) {
- boolean nojar = true;
- for (IClasspathEntry jar : ((JbossWSRuntimeClasspathContainer) container)
- .getClasspathEntries()) {
- if (jar.getPath().toString().contains("jaxws-rt.jar")) {
- nojar = false;
- }
- }
- assertTrue(nojar);
- }
- }
- } catch (JavaModelException e) {
- JBossWSCreationCore.getDefault().logError(e);
- }
-
- }
-
- public static IJavaProject getJavaProjectByName(String projectName)
- throws JavaModelException {
-
- IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace()
- .getRoot());
- model.open(null);
-
- IJavaProject[] projects = model.getJavaProjects();
-
- for (IJavaProject proj : projects) {
- if (proj.getProject().getName().equals(projectName)) {
- return proj;
- }
- }
-
- return null;
- }
-
- @Override
- IDataModel createJBossWSDataModel(boolean isServerSupplied) {
- IDataModel config = (IDataModel) new JBossWSFacetInstallDataModelProvider()
- .create();
- if (isServerSupplied) {
- config
- .setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
- true);
- } else {
- config.setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
- isDeployed);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID,
- RuntimeName);
- config.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
- getJBossWSHomeFolder().toString());
- }
- return config;
- }
-
-}
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.test/META-INF/MANIFEST.MF 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.test/META-INF/MANIFEST.MF 2008-06-27 08:19:24 UTC (rev 8979)
@@ -10,4 +10,4 @@
org.jboss.tools.tests,
org.jboss.tools.ws.ui,
org.jboss.tools.ws.core
-Eclipse-LazyStart: true
+Bundle-ActivationPolicy: lazy
Added: trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/JBossWSUIAllTests.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/JBossWSUIAllTests.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/JBossWSUIAllTests.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.test;
+
+import org.jboss.tools.ws.ui.test.preferences.JBossWSRuntimePreferencePageTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSUIAllTests extends TestCase {
+ public static final String PLUGIN_ID = "org.jboss.tools.common.test";
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(JBossWSUIAllTests.class.getName());
+ suite.addTestSuite(JBossWSRuntimePreferencePageTest.class);
+
+ return suite;
+ }
+}
Added: trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JBossWSRuntimePreferencePageTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JBossWSRuntimePreferencePageTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JBossWSRuntimePreferencePageTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.test.preferences;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.jboss.tools.test.util.WorkbenchUtils;
+import org.jboss.tools.ws.core.JBossWSCorePlugin;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntime;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeListConverter;
+import org.jboss.tools.ws.core.classpath.JBossWSRuntimeManager;
+import org.jboss.tools.ws.core.messages.JBossWSCoreMessages;
+import org.jboss.tools.ws.ui.preferences.JBossRuntimeListFieldEditor;
+import org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossWSRuntimePreferencePageTest extends TestCase {
+
+ /**
+ * Test that preference page is showed up without errors
+ */
+ public void testShowJBossWSRuntimePreferencePage() {
+
+ PreferenceDialog prefDialog = WorkbenchUtils
+ .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage");
+ try {
+ Object object = openPreferencepage(prefDialog);
+ assertTrue(
+ "Selected page is not an instance of JBossWSRuntimePreferencePage",
+ object instanceof JBossWSRuntimePreferencePage);
+ } finally {
+ prefDialog.close();
+ }
+ }
+
+ private Object openPreferencepage(PreferenceDialog prefDialog) {
+ prefDialog.setBlockOnOpen(false);
+ prefDialog.open();
+ return prefDialog.getSelectedPage();
+ }
+
+ /**
+ * Test correct contents in that preference page
+ */
+ @SuppressWarnings("unchecked")
+ public void testDisplayJBossWSRuntimePreferencePage() {
+ PreferenceDialog prefDialog = WorkbenchUtils
+ .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage");
+ JBossWSRuntimePreferencePage selectedPage = null;
+ try {
+ Object object = openPreferencepage(prefDialog);
+ String runtime = getRuntimeList();
+ selectedPage = (JBossWSRuntimePreferencePage) object;
+ JBossRuntimeListFieldEditor jbossWSRuntimes = selectedPage
+ .getJBossWSRuntimes();
+ if (runtime.equals("")) {
+ assertTrue(
+ "The JBoss Ws Runtime locations are not displayed",
+ ((ArrayList<JBossWSRuntime>) jbossWSRuntimes.getValue())
+ .size() == 0);
+ } else {
+ JBossWSRuntimeListConverter converter = new JBossWSRuntimeListConverter();
+ Map<String, JBossWSRuntime> runtimes = converter
+ .getMap(runtime);
+ assertTrue(
+ "The JBoss Ws Runtime locations are not displayed",
+ runtimes.values().size() == ((ArrayList<JBossWSRuntime>) jbossWSRuntimes
+ .getValue()).size());
+ }
+ } finally {
+ prefDialog.close();
+ }
+
+ }
+
+ /**
+ * Set and Test correct contents in that preference page
+ */
+ @SuppressWarnings("unchecked")
+ public void testSetAndDisplayJBossWSRuntimePreferencePage() {
+ setRuntimeList();
+ PreferenceDialog prefDialog = WorkbenchUtils
+ .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JBossWSRuntimePreferencePage");
+ JBossWSRuntimePreferencePage selectedPage = null;
+ try {
+ Object object = openPreferencepage(prefDialog);
+ String runtime = getRuntimeList();
+ selectedPage = (JBossWSRuntimePreferencePage) object;
+ JBossRuntimeListFieldEditor jbossWSRuntimes = selectedPage
+ .getJBossWSRuntimes();
+ assertTrue("The preference store for jboss ws runtime is wrong",
+ !runtime.equals(""));
+ JBossWSRuntimeListConverter converter = new JBossWSRuntimeListConverter();
+ Map<String, JBossWSRuntime> runtimes = converter.getMap(runtime);
+ assertTrue(
+ "The JBoss Ws Runtime locations are not displayed correctly",
+ runtimes.values().size() == ((ArrayList<JBossWSRuntime>) jbossWSRuntimes
+ .getValue()).size());
+ } finally {
+ prefDialog.close();
+ }
+
+ }
+
+ private void setRuntimeList() {
+ String jbosshome = System.getProperty("jbosstools.test.jboss.home.4.2",
+ "/home/grid/Software/jboss-4.2.2.GA");
+ String runtime = "name|jboss-4.2.2.GA|version|2.0|homeDir|" + jbosshome
+ + "|default|false|userConfig|true|libraries|" + jbosshome
+ + "/lib/commons-codec.jar,name|jboss|version|2.0|homeDir|"
+ + jbosshome + "|default|true|userConfig|false|libraries|";
+ JBossWSCorePlugin.getDefault().getPreferenceStore().setValue(
+ JBossWSCoreMessages.WS_Location, runtime);
+ IPreferenceStore store = JBossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore) store).save();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ JBossWSRuntimeManager.getInstance().load();
+
+ }
+
+ private String getRuntimeList() {
+ IPreferenceStore ps = JBossWSCorePlugin.getDefault()
+ .getPreferenceStore();
+ String runtimeListString = ps
+ .getString(JBossWSCoreMessages.WS_Location);
+ return runtimeListString;
+ }
+
+}
Deleted: trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JbossWSRuntimePreferencePageTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JbossWSRuntimePreferencePageTest.java 2008-06-27 06:07:21 UTC (rev 8978)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.test/src/org/jboss/tools/ws/ui/test/preferences/JbossWSRuntimePreferencePageTest.java 2008-06-27 08:19:24 UTC (rev 8979)
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-
-package org.jboss.tools.ws.ui.test.preferences;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Map;
-
-import org.eclipse.jface.preference.IPersistentPreferenceStore;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.jboss.tools.test.util.WorkbenchUtils;
-import org.jboss.tools.ws.core.JbossWSCorePlugin;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntime;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeListConverter;
-import org.jboss.tools.ws.core.classpath.JbossWSRuntimeManager;
-import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-import org.jboss.tools.ws.ui.preferences.JbossRuntimeListFieldEditor;
-import org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage;
-
-import junit.framework.TestCase;
-
-/**
- * @author Grid Qian
- */
-public class JbossWSRuntimePreferencePageTest extends TestCase {
-
- /**
- * Test that preference page is showed up without errors
- */
- public void testShowJbossWSRuntimePreferencePage() {
-
- PreferenceDialog prefDialog = WorkbenchUtils
- .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage");
- try {
- Object object = openPreferencepage(prefDialog);
- assertTrue(
- "Selected page is not an instance of JbossWSRuntimePreferencePage",
- object instanceof JbossWSRuntimePreferencePage);
- } finally {
- prefDialog.close();
- }
- }
-
- private Object openPreferencepage(PreferenceDialog prefDialog) {
- prefDialog.setBlockOnOpen(false);
- prefDialog.open();
- return prefDialog.getSelectedPage();
- }
-
- /**
- * Test correct contents in that preference page
- */
- @SuppressWarnings("unchecked")
- public void testDisplayJbossWSRuntimePreferencePage() {
- PreferenceDialog prefDialog = WorkbenchUtils
- .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage");
- JbossWSRuntimePreferencePage selectedPage = null;
- try {
- Object object = openPreferencepage(prefDialog);
- String runtime = getRuntimeList();
- selectedPage = (JbossWSRuntimePreferencePage) object;
- JbossRuntimeListFieldEditor jbossWSRuntimes = selectedPage
- .getJbossWSRuntimes();
- if (runtime.equals("")) {
- assertTrue(
- "The JBoss Ws Runtime locations are not displayed",
- ((ArrayList<JbossWSRuntime>) jbossWSRuntimes.getValue())
- .size() == 0);
- } else {
- JbossWSRuntimeListConverter converter = new JbossWSRuntimeListConverter();
- Map<String, JbossWSRuntime> runtimes = converter
- .getMap(runtime);
- assertTrue(
- "The JBoss Ws Runtime locations are not displayed",
- runtimes.values().size() == ((ArrayList<JbossWSRuntime>) jbossWSRuntimes
- .getValue()).size());
- }
- } finally {
- prefDialog.close();
- }
-
- }
-
- /**
- * Set and Test correct contents in that preference page
- */
- @SuppressWarnings("unchecked")
- public void testSetAndDisplayJbossWSRuntimePreferencePage() {
- setRuntimeList();
- PreferenceDialog prefDialog = WorkbenchUtils
- .createPreferenceDialog("org.jboss.tools.ws.ui.preferences.JbossWSRuntimePreferencePage");
- JbossWSRuntimePreferencePage selectedPage = null;
- try {
- Object object = openPreferencepage(prefDialog);
- String runtime = getRuntimeList();
- selectedPage = (JbossWSRuntimePreferencePage) object;
- JbossRuntimeListFieldEditor jbossWSRuntimes = selectedPage
- .getJbossWSRuntimes();
- assertTrue("The preference store for jboss ws runtime is wrong",
- !runtime.equals(""));
- JbossWSRuntimeListConverter converter = new JbossWSRuntimeListConverter();
- Map<String, JbossWSRuntime> runtimes = converter.getMap(runtime);
- assertTrue(
- "The JBoss Ws Runtime locations are not displayed correctly",
- runtimes.values().size() == ((ArrayList<JbossWSRuntime>) jbossWSRuntimes
- .getValue()).size());
- } finally {
- prefDialog.close();
- }
-
- }
-
- private void setRuntimeList() {
- String jbosshome = System.getProperty("jbosstools.test.jboss.home.4.2",
- "/home/grid/Software/jboss-4.2.2.GA");
- String runtime = "name|jboss-4.2.2.GA|version|2.0|homeDir|" + jbosshome
- + "|default|false|userConfig|true|libraries|" + jbosshome
- + "/lib/commons-codec.jar,name|jboss|version|2.0|homeDir|"
- + jbosshome + "|default|true|userConfig|false|libraries|";
- JbossWSCorePlugin.getDefault().getPreferenceStore().setValue(
- JbossWSCoreMessages.WS_Location, runtime);
- IPreferenceStore store = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
- if (store instanceof IPersistentPreferenceStore) {
- try {
- ((IPersistentPreferenceStore) store).save();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- JbossWSRuntimeManager.getInstance().load();
-
- }
-
- private String getRuntimeList() {
- IPreferenceStore ps = JbossWSCorePlugin.getDefault()
- .getPreferenceStore();
- String runtimeListString = ps
- .getString(JbossWSCoreMessages.WS_Location);
- return runtimeListString;
- }
-
-}
15 years, 10 months
JBoss Tools SVN: r8978 - in trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui: widgets and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dennyxu
Date: 2008-06-27 02:07:21 -0400 (Fri, 27 Jun 2008)
New Revision: 8978
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/widgets/ProviderInvokeCodeGenConfigWidget.java
Log:
JBIDE-2262: if the user don't configure the facet on the page, do not allow him to add the facet to the project
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java 2008-06-27 05:26:45 UTC (rev 8977)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java 2008-06-27 06:07:21 UTC (rev 8978)
@@ -22,7 +22,6 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
@@ -75,6 +74,22 @@
this.model = (IDataModel) config;
}
+
+ private void setInitialValues(){
+ boolean isServerSupplied = model.getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED);
+ String runtimeName = model.getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID);
+ boolean isDeploy = model.getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY);
+ if(isServerSupplied){
+ btnServerSupplied.setSelection(true);
+ }else if(runtimeName != null && !runtimeName.equals("")){
+ btnUserSupplied.setSelection(true);
+ if(isDeploy){
+ btnDeploy.setSelection(true);
+ }
+ }
+ initializeRuntimesCombo(cmbRuntimes, runtimeName);
+
+ }
public void createControl(Composite parent) {
initializeDialogUnits(parent);
@@ -108,6 +123,7 @@
lblServerSupplied.setLayoutData(gd);
btnUserSupplied = new Button(composite, SWT.RADIO);
+
btnUserSupplied.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setUserSuppliedSelection(e);
@@ -115,7 +131,6 @@
});
cmbRuntimes = new Combo(composite, SWT.READ_ONLY);
- initializeRuntimesCombo(cmbRuntimes);
cmbRuntimes.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
cmbRuntimes.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@@ -144,7 +159,8 @@
changePageStatus();
}
});
-
+
+ setInitialValues();
setControl(composite);
changePageStatus();
@@ -216,7 +232,11 @@
}
- protected void initializeRuntimesCombo(Combo cmRuntime) {
+ protected void initializeRuntimesCombo(Combo cmRuntime, String runtimeName) {
+ JbossWSRuntime selectedJbws = null;
+ JbossWSRuntime defaultJbws = null;
+ int selectIndex = 0;
+ int defaultIndex = 0;
cmRuntime.removeAll();
JbossWSRuntime[] runtimes = JbossWSRuntimeManager.getInstance()
.getRuntimes();
@@ -224,13 +244,25 @@
JbossWSRuntime jr = runtimes[i];
cmRuntime.add(jr.getName());
cmRuntime.setData(jr.getName(), jr);
-
+
+ if(jr.getName().equals(runtimeName)){
+ selectedJbws = jr;
+ selectIndex = i;
+ }
// get default jbossws runtime
if (jr.isDefault()) {
- cmRuntime.select(i);
- saveJBosswsRuntimeToModel(jr);
+ defaultJbws = jr;
+ defaultIndex = i;
}
}
+
+ if(selectedJbws != null){
+ cmRuntime.select(selectIndex);
+ saveJBosswsRuntimeToModel(selectedJbws);
+ }else{
+ cmRuntime.select(defaultIndex);
+ saveJBosswsRuntimeToModel(defaultJbws);
+ }
}
/*
@@ -254,7 +286,7 @@
WizardDialog dialog = new WizardDialog(Display.getCurrent()
.getActiveShell(), newRtwizard);
if (dialog.open() == WizardDialog.OK) {
- initializeRuntimesCombo(cmbRuntimes);
+ initializeRuntimesCombo(cmbRuntimes, null);
//cmbRuntimes.select(0);
}
}
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/widgets/ProviderInvokeCodeGenConfigWidget.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/widgets/ProviderInvokeCodeGenConfigWidget.java 2008-06-27 05:26:45 UTC (rev 8977)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/widgets/ProviderInvokeCodeGenConfigWidget.java 2008-06-27 06:07:21 UTC (rev 8978)
@@ -14,7 +14,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
15 years, 10 months
JBoss Tools SVN: r8977 - in trunk: as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-06-27 01:26:45 -0400 (Fri, 27 Jun 2008)
New Revision: 8977
Removed:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/asf/DirectoryScanner.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java
Log:
This is a big commit regarding a huge flaw with the model for dealing with an eclipse VFS. Specifically, multiple eclipse file links can in fact point to the same absolute file, so using the absolute file as a key to map backwards to an eclipse-based path is unacceptable and can yield more than one answer.
This commit will cause archives unit test regressions, which I will work on fixing.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -33,26 +33,25 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ModuleFile;
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.core.model.IModuleFile;
import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
+import org.eclipse.wst.server.core.util.ModuleFile;
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.IArchiveNodeVisitor;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.osgi.service.prefs.BackingStoreException;
/**
*
@@ -182,7 +181,9 @@
public static interface IExtendedModuleResource extends IModuleResource {
public IPath getSourcePath();
public IArchiveNode getNode();
+ // deep destination is the full path this resource represents, even if it's inside a jar
public IPath getDeepDestination();
+ // the concrete file this resource is part of... so the top most zipped jar or, if all is exploded, the file itself
public IPath getConcreteDestFile();
}
@@ -234,20 +235,20 @@
public static class ArchiveContainerResource implements IModuleFolder, IExtendedModuleResource {
protected IPath moduleRelativePath;
+ protected IPath fsRelative;
protected IArchiveNode node;
protected String name;
private HashMap<IPath, IModuleResource> members;
-
+
// represents source folder on disk. only used if node is fileset
- private IPath folderGlobalPath = null;
+// private IPath folderGlobalPath = null;
public ArchiveContainerResource(String name,IArchiveNode node,IPath moduleRelativePath ) {
this.name = name;
this.node = node;
this.moduleRelativePath = moduleRelativePath;
members = new HashMap<IPath, IModuleResource>();
- if( node instanceof IArchiveFileSet) {
- IPath tmp = moduleRelativePath.removeFirstSegments(node.getParent().getRootArchiveRelativePath().segmentCount());
- folderGlobalPath = ((IArchiveFileSet)node).getGlobalSourcePath().append(tmp);
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
+ fsRelative = moduleRelativePath.removeFirstSegments(node.getParent().getRootArchiveRelativePath().segmentCount());
}
}
@@ -275,30 +276,28 @@
}
public void addFilesetAsChild(IArchiveFileSet fs) {
- IPath[] paths = fs.findMatchingPaths(); // file-system based source paths
- IPath globalSource = fs.getGlobalSourcePath();
- for( int i = 0; i < paths.length; i++ ) {
- addFilesetPathAsChild(fs, globalSource, paths[i]);
+ FileWrapper[] files = fs.findMatchingPaths(); // file-system based source paths
+ for( int i = 0; i < files.length; i++ ) {
+ addFilesetPathAsChild(fs, files[i]);
}
}
- public void addFilesetPathAsChild(IArchiveFileSet fs, IPath globalSource, IPath path) {
- IPath archiveRelative = fs.getRootArchiveRelativePath(path);
- IPath fsRelative = path.removeFirstSegments(globalSource.segmentCount());
- ArchiveContainerResource parent = find(fs, globalSource, fsRelative.removeLastSegments(1), true);
- ExtendedModuleFile emf = new ExtendedModuleFile(archiveRelative.lastSegment(), archiveRelative, path.toFile().lastModified(), path, fs);
+ public void addFilesetPathAsChild(IArchiveFileSet fs, FileWrapper file) {
+ IPath fsRelative = new Path(file.getFilesetRelative());
+ ArchiveContainerResource parent = find(fs, fsRelative.removeLastSegments(1), true);
+ ExtendedModuleFile emf = new ExtendedModuleFile(file, fs);
parent.addChild(emf);
}
public void removeFilesetPathAsChild(IArchiveFileSet fs, IPath path) {
IPath globalSource = fs.getGlobalSourcePath();
IPath fsRelative = path.removeFirstSegments(globalSource.segmentCount());
- ArchiveContainerResource parent = find(fs, globalSource, fsRelative.removeLastSegments(1), false);
+ ArchiveContainerResource parent = find(fs, fsRelative.removeLastSegments(1), false);
if( parent != null )
parent.removeFilesetPathAsChild(fs, path);
}
- protected ArchiveContainerResource find(IArchiveFileSet fs, IPath globalSource, IPath fsRelative, boolean create) {
+ protected ArchiveContainerResource find(IArchiveFileSet fs, IPath fsRelative, boolean create) {
ArchiveContainerResource resource = this;
ArchiveContainerResource tmpResource;
IPath tmpPath = fs.getRootArchiveRelativePath();
@@ -335,12 +334,16 @@
}
public IPath getDeepDestination() {
- IPath tmp = node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET ?
- ((IArchiveFileSet)node).getRootArchiveRelativePath(folderGlobalPath) : node.getRootArchiveRelativePath();
+ IPath tmp = node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET
+ ? moduleRelativePath : node.getRootArchiveRelativePath();
return node.getRootArchive().getGlobalDestinationPath().append(tmp);
}
+
public IPath getConcreteDestFile() {
- return ModelUtil.getBaseDestinationFile(node,folderGlobalPath);
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET )
+ return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node,fsRelative);
+ else
+ return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node);
}
public IArchiveNode getNode() {
return node;
@@ -353,29 +356,27 @@
}
public static class ExtendedModuleFile extends ModuleFile implements IExtendedModuleResource {
- private IPath srcPath;
+ private FileWrapper wrapper;
private IArchiveFileSet node;
- public ExtendedModuleFile(String name, IPath relativePath, long stamp,
- IPath srcPath, IArchiveFileSet fs) {
- super(name, relativePath, stamp);
- this.srcPath = srcPath;
+ public ExtendedModuleFile(FileWrapper wrapper, IArchiveFileSet fs) {
+ super(wrapper.getOutputName(), wrapper.getRootArchiveRelative(), wrapper.lastModified());
this.node = fs;
}
public int hashCode() {
return getName().hashCode() * 37 + getPath().hashCode();
}
- public IPath getPath() { return srcPath; }
+ public IPath getPath() { return new Path(wrapper.getAbsolutePath()); }
public IArchiveNode getNode() { return node; }
public IPath getDeepDestination() {
- return node.getRootArchive().getGlobalDestinationPath().append(node.getRootArchiveRelativePath(getModuleRelativePath()));
+ return node.getRootArchive().getGlobalDestinationPath().append(wrapper.getRootArchiveRelative());
}
public IPath getSourcePath() {
- return this.srcPath;
+ return new Path(this.wrapper.getAbsolutePath());
}
public IPath getConcreteDestFile() {
- return ModelUtil.getBaseDestinationFile(node, srcPath);
+ return ModelUtil.getBaseDestinationFile(node, new Path(this.wrapper.getFilesetRelative()));
}
public boolean equals(Object other) {
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -162,8 +162,11 @@
protected void countConcreteFiles(IModuleResource mr, ArrayList list) {
if( mr instanceof IExtendedModuleResource) {
IExtendedModuleResource emr = ((IExtendedModuleResource)mr);
- IPath p = emr.getConcreteDestFile();
- if( mr instanceof IModuleFile && !list.contains(p)) list.add(p);
+ if( mr instanceof IModuleFile ) {
+ IPath p = emr.getConcreteDestFile();
+ if( !list.contains(p))
+ list.add(p);
+ }
if( mr instanceof IModuleFolder) {
IModuleResource[] children = ((IModuleFolder)mr).members();
for( int i = 0; i < children.length; i++ )
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -81,7 +81,8 @@
import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
+import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.ui.util.composites.FilesetPreviewComposite;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
@@ -302,8 +303,9 @@
Fileset fs = (Fileset)parentElement;
IPath[] paths = null;
try {
- paths = ArchivesModelCore.findMatchingPaths(
- new Path(fs.getFolder()), fs.getIncludesPattern(), fs.getExcludesPattern());
+ paths = findPaths(fs.getFolder(),
+ fs.getIncludesPattern(),
+ fs.getExcludesPattern());
} catch( BuildException be ) {
return new Object[]{};
}
@@ -588,6 +590,24 @@
return null;
}
+ private IPath[] findPaths(String dir, String includes, String excludes) {
+ IPath[] paths = new IPath[0];
+ try {
+ if( dir != null ) {
+ DirectoryScanner scanner =
+ DirectoryScannerFactory.createDirectoryScanner(new Path(dir), includes, excludes, true);
+ if( scanner != null ) {
+ String[] files = scanner.getIncludedFiles();
+ paths = new IPath[files.length];
+ for( int i = 0; i < files.length; i++ ) {
+ paths[i] = new Path(files[i]);
+ }
+ }
+ }
+ } catch( IllegalStateException ise ) {}
+ return paths;
+ }
+
protected class FilesetDialog extends TitleAreaDialog {
protected Fileset fileset;
private String name, dir, includes, excludes;
@@ -721,10 +741,9 @@
}
private void updatePreview() {
- IPath files[] = ArchivesModelCore.findMatchingPaths(new Path(dir), includesText.getText(), excludesText.getText());
- preview.setInput(files);
+ preview.setInput(findPaths(dir, includes, excludes));
}
-
+
public String getDir() {
return dir;
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -30,8 +30,8 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
/**
* @author rob.stryker <rob.stryker(a)redhat.com>
@@ -66,7 +66,7 @@
Thread.currentThread().setContextClassLoader(myCL);
ArchivesModel.instance().registerProject(projectPath, monitor);
- ArchivesModelCore.buildProject(projectPath, monitor);
+ new ArchiveBuildDelegate().fullProjectBuild(projectPath);
} catch(RuntimeException e ) {
e.printStackTrace();
throw e;
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -8,8 +8,8 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
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.IArchiveBuildListener;
@@ -40,7 +40,7 @@
IPath path = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(new Path(task.getEclipseProject()));
if( verifyBuildPrereqs(path) ) {
task.log("Building archives for project project: " + path, Project.MSG_VERBOSE);
- ArchivesModelCore.buildProject(path, null);
+ new ArchiveBuildDelegate().fullProjectBuild(path);
} else {
throw new BuildException("Eclipse-relative paths missing absolute path mappings.");
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/asf/DirectoryScanner.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/asf/DirectoryScanner.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/asf/DirectoryScanner.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -1162,15 +1162,24 @@
boolean included = false;
if (isExcluded(name)) {
exc.add(name);
+ postExclude(file, name);
} else if (isSelected(name, file)) {
included = true;
inc.add(name);
+ postInclude(file, name);
} else {
des.add(name);
}
everythingIncluded &= included;
}
+ protected void postInclude(File f, String name) {
+ // do nothing
+ }
+
+ protected void postExclude(File f, String name) {
+ // do nothing
+ }
/**
* Test whether or not a name matches against at least one include
* pattern.
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -36,6 +36,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
@@ -141,7 +142,7 @@
// reset the scanner. It *is* a full build afterall
fileset.resetScanner();
- IPath[] paths = fileset.findMatchingPaths();
+ FileWrapper[] paths = fileset.findMatchingPaths();
ModelTruezipBridge.fullFilesetBuild(fileset);
EventManager.filesUpdated(topLevel, fileset, paths);
@@ -182,7 +183,9 @@
path = i.next();
matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
- ModelTruezipBridge.copyFiles(matchingFilesets, new IPath[] { path }, false);
+ for( int j = 0; j < matchingFilesets.length; j++ ) {
+ ModelTruezipBridge.copyFiles(matchingFilesets[j], matchingFilesets[j].getMatches(path));
+ }
EventManager.fileUpdated(path, matchingFilesets);
}
@@ -191,7 +194,9 @@
path = ((IPath)i.next());
matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
- ModelTruezipBridge.deleteFiles(matchingFilesets, new IPath[] { path }, false);
+ for( int j = 0; j < matchingFilesets.length; j++ ) {
+ ModelTruezipBridge.deleteFiles(matchingFilesets[j], matchingFilesets[j].getMatches(path));
+ }
EventManager.fileRemoved(path, matchingFilesets);
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -33,6 +33,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
@@ -183,8 +184,8 @@
IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(added);
for( int i = 0; i < filesets.length; i++ ) {
ModelTruezipBridge.fullFilesetBuild(filesets[i]);
- IPath[] paths = filesets[i].findMatchingPaths();
- EventManager.filesUpdated(filesets[i].getRootArchive(), filesets[i], paths);
+ FileWrapper[] files = filesets[i].findMatchingPaths();
+ EventManager.filesUpdated(filesets[i].getRootArchive(), filesets[i], files);
}
postChange(added);
}
Deleted: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -1,88 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.archives.core.model;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
-import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
-
-/**
- * Utility methods and entry points for model-related APIs
- * @author Rob Stryker (rob.stryker(a)redhat.com)
- *
- */
-public class ArchivesModelCore {
-
- /**
- * Builds all of a project's packages. Note that this does not call any builders before or after the package builder (i.e. the JDT builder).
- * If you are looking to run all the builders on a project use project.build()
- * @param project The project to build
- * @param buildType FULL_BUILD, INCREMENTAL_BUILD, CLEAN_BUILD, etc
- * @param monitor A progress monitor
- */
- public static void buildProject (IPath project, IProgressMonitor monitor) {
- if (monitor == null) monitor = new NullProgressMonitor();
- new ArchiveBuildDelegate().fullProjectBuild(project);
- }
-
- /**
- * Build the passed-in package.
- * @param pkg The package to build
- */
- public static void buildArchive (IArchive pkg, IProgressMonitor monitor) {
- if (monitor == null) monitor = new NullProgressMonitor();
- new ArchiveBuildDelegate().fullArchiveBuild(pkg);
- }
-
- public static boolean packageFileExists (IPath project) {
- return project.append(IArchiveModel.DEFAULT_PACKAGES_FILE).toFile().exists();
- }
-
- public static boolean projectRegistered(IPath project) {
- return ArchivesModel.instance().getRoot(project) == null ? false : true;
- }
-
- public static IPath[] findMatchingPaths(IPath root, String includes, String excludes) {
- try {
- if(root==null) return new IPath[0];
-
- DirectoryScanner scanner =
- DirectoryScannerFactory.createDirectoryScanner(root, includes, excludes, true);
-
- if( scanner == null )
- return new IPath[] {};
-
- String[] files = scanner.getIncludedFiles();
- IPath[] paths = new IPath[files.length];
- for( int i = 0; i < files.length; i++ ) {
- paths[i] = new Path(files[i]);
- }
- return paths;
- } catch( IllegalStateException ise ) {
- return new IPath[]{};
- }
- }
-
-}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -22,6 +22,7 @@
package org.jboss.ide.eclipse.archives.core.model;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashMap;
import org.eclipse.core.runtime.IPath;
@@ -34,39 +35,38 @@
* @author rob.stryker(a)jboss.com
*/
public class DirectoryScannerFactory {
+ private static class ScannableFileSet {
+ public IPath rawPath;
+ public IPath rootArchiveRelativePath;
+ public String includes;
+ public String excludes;
+ public boolean inWorkspace;
+ };
- public static DirectoryScannerExtension createDirectoryScanner (IPath filesystemFolder, String includes, String excludes, boolean scan) {
- if (includes == null) includes = "";
- if (excludes == null) excludes = "";
- if( filesystemFolder == null )
- return null;
-
- DirectoryScannerExtension scanner = new DirectoryScannerExtension(false);
- String excludesList[] = excludes.split(" ?, ?");
- String includesList[] = includes.split(" ?, ?");
-
- scanner.setBasedir2(filesystemFolder);
- scanner.setExcludes(excludesList);
- scanner.setIncludes(includesList);
- if (scan) {
- scanner.scan();
- }
-
- return scanner;
+ public static DirectoryScannerExtension createDirectoryScanner(IArchiveFileSet fs, boolean scan) {
+ return createDirectoryScanner(fs.getSourcePath(), fs.getRootArchiveRelativePath(), fs.getIncludesPattern(), fs.getExcludesPattern(), fs.isInWorkspace(), scan);
}
- public static DirectoryScannerExtension createDirectoryScanner(IArchiveFileSet fs, boolean scan) {
- if( !fs.isInWorkspace()) {
- return createDirectoryScanner(fs.getGlobalSourcePath(), fs.getIncludesPattern(), fs.getExcludesPattern(), scan);
- }
-
- // in workspace
+ // THIS SHOULD NOT BE USED ;) just here for now
+ // eradicate all uses!
+ public static DirectoryScannerExtension createDirectoryScanner (IPath rawPath, String includes, String excludes, boolean scan) {
+ return createDirectoryScanner(rawPath, null, includes, excludes, false, scan);
+ }
+
+ public static DirectoryScannerExtension createDirectoryScanner (IPath rawPath, IPath rootArchiveRelativePath, String includes, String excludes, boolean inWorkspace, boolean scan) {
+ ScannableFileSet fs = new ScannableFileSet();
+ fs.rawPath = rawPath;
+ fs.rootArchiveRelativePath = rootArchiveRelativePath;
+ fs.includes = includes;
+ fs.excludes = excludes;
+ fs.inWorkspace = inWorkspace;
DirectoryScannerExtension scanner = new DirectoryScannerExtension(fs);
if (scan) {
scanner.scan();
}
return scanner;
}
+
/**
* Exposes the isIncluded method so that entire scans do not need to occur
@@ -76,54 +76,52 @@
*/
public static class DirectoryScannerExtension extends DirectoryScanner {
protected boolean workspaceRelative;
- // maps a File to it's workspace path
- protected HashMap<File, IPath> absoluteToWorkspace;
- protected IArchiveFileSet fs;
-
- public DirectoryScannerExtension(boolean relative) {
- workspaceRelative = relative;
- absoluteToWorkspace = new HashMap<File, IPath>();
- }
-
- public DirectoryScannerExtension(IArchiveFileSet fs) {
+ protected ScannableFileSet fs;
+ protected ArrayList<FileWrapper> matches;
+ protected HashMap<String, ArrayList<FileWrapper>> matchesMap;
+ public DirectoryScannerExtension(ScannableFileSet fs) {
this.fs = fs;
- String includes = fs.getIncludesPattern() == null ? "" : fs.getIncludesPattern();
- String excludes = fs.getExcludesPattern() == null ? "" : fs.getExcludesPattern();
+ String includes = fs.includes == null ? "" : fs.includes;
+ String excludes = fs.excludes == null ? "" : fs.excludes;
String includesList[] = includes.split(" ?, ?");
String excludesList[] = excludes.split(" ?, ?");
setExcludes(excludesList);
setIncludes(includesList);
- workspaceRelative = fs.isInWorkspace();
- absoluteToWorkspace = new HashMap<File, IPath>();
- setBasedir2(fs.getSourcePath());
+ workspaceRelative = fs.inWorkspace;
+ matches = new ArrayList<FileWrapper>();
+ matchesMap = new HashMap<String, ArrayList<FileWrapper>>();
+ setBasedir2(fs.rawPath);
}
+ /* TODO:
+ * This *must* translate all variables out before
+ * setting in superclass. Ant will not understand
+ * variables!
+ */
public void setBasedir2(IPath path) {
- IPath p = path;
if( workspaceRelative ) {
- p = ArchivesCore.getInstance().getVFS()
+ IPath p = ArchivesCore.getInstance().getVFS()
.workspacePathToAbsolutePath(path);
- absoluteToWorkspace.put(p.toFile(), path);
+ setBasedir(new FileWrapper(p.toFile(), path));
+ } else {
+ setBasedir(new FileWrapper(path.toFile(), path));
}
- setBasedir(p.toFile());
}
- public IPath getWorkspacePath(IPath absolutePath) {
- return absoluteToWorkspace.get(absolutePath.toFile());
- }
-
- protected File[] list2(File file) {
- return workspaceRelative ? list3(file) : file.listFiles();
+ protected String getName(File file) {
+ return workspaceRelative ? ((FileWrapper)file).getOutputName() : super.getName(file);
}
- protected String getName(File file) {
- return workspaceRelative ? absoluteToWorkspace.get(file).lastSegment() : super.getName(file);
+ /* Only used when workspace relative! */
+ protected File[] list2(File file) {
+ if( fs.inWorkspace )
+ return list2workspace(file);
+ else
+ return list2absolute(file);
}
- /* Only used when workspace relative! */
- protected File[] list3(File file) {
- IPath workspaceRelative = absoluteToWorkspace.get(file);
-
+ protected File[] list2workspace(File file) {
+ IPath workspaceRelative = ((FileWrapper)file).getWrapperPath();
if( workspaceRelative == null )
return new File[0];
@@ -133,32 +131,87 @@
.getVFS().workspacePathToAbsolutePath(childrenWorkspace);
File[] files = new File[childrenAbsolute.length];
for( int i = 0; i < files.length; i++ ) {
- files[i] = childrenAbsolute[i].toFile();
- if( files[i] != null && childrenWorkspace[i] != null )
- absoluteToWorkspace.put(files[i], childrenWorkspace[i]);
+ files[i] = new FileWrapper(childrenAbsolute[i].toFile(), childrenWorkspace[i]);
}
return files;
}
+
+ protected File[] list2absolute(File file) {
+ File[] children = file.listFiles();
+ FileWrapper[] children2 = new FileWrapper[children.length];
+ for( int i = 0; i < children.length; i++ )
+ children2[i] = new FileWrapper(children[i], new Path(children[i].getAbsolutePath()));
+ return children2;
+ }
- public boolean isUltimatelyIncluded(String name) {
- return super.isIncluded(name) && !super.isExcluded(name);
+ protected void postInclude(File f, String relative) {
+ if( f.isFile() ) {
+ if( f instanceof FileWrapper ) {
+ FileWrapper f2 = ((FileWrapper)f);
+ f2.setFilesetRelative(relative);
+ matches.add(f2);
+ ArrayList<FileWrapper> l = matchesMap.get(f2);
+ if( l == null ) {
+ l = new ArrayList<FileWrapper>();
+ matchesMap.put(((FileWrapper)f).getAbsolutePath(), l);
+ }
+ l.add(f2);
+ }
+ }
}
+
+ // what files are being added
+ public FileWrapper[] getMatchedArray() {
+ return (FileWrapper[]) matches.toArray(new FileWrapper[matches.size()]);
+ }
- public IPath[] getAbsoluteIncludedFiles() {
- String[] relative = super.getIncludedFiles();
- if( workspaceRelative ) {
- IPath[] absolutes = new IPath[relative.length];
- for( int i = 0; i < relative.length; i++ )
- absolutes[i] = ArchivesCore.getInstance()
- .getVFS().workspacePathToAbsolutePath(fs.getSourcePath().append(relative[i]));
- return absolutes;
- } else {
- IPath base2 = new Path(basedir.getAbsolutePath());
- IPath[] absolutes = new IPath[relative.length];
- for( int i = 0; i < relative.length; i++ )
- absolutes[i] = base2.append(relative[i]);
- return absolutes;
- }
+ public HashMap<String, ArrayList<FileWrapper>> getMatchedMap() {
+ return matchesMap;
}
+
+ public class FileWrapper extends File {
+ // The actual source file
+ File f;
+
+ // The path of this file, either workspace relative or global
+ IPath path;
+
+ // the path of this file relative to the fileset
+ String fsRelative;
+
+ public FileWrapper(File delegate, IPath path2) {
+ super(delegate.getAbsolutePath());
+ f = delegate;
+ path = path2;
+ }
+ public IPath getWrapperPath() {
+ return path;
+ }
+ // workspace name is the one we care about, or absolute if not in workspace
+ public String getOutputName() {
+ return path.lastSegment();
+ }
+ public String getFilesetRelative() {
+ return fsRelative;
+ }
+
+ void setFilesetRelative(String s) {
+ fsRelative = s;
+ }
+
+ public IPath getRootArchiveRelative() {
+ if( fs.rootArchiveRelativePath != null )
+ return fs.rootArchiveRelativePath.append(fsRelative);
+ return null;
+ }
+
+ public boolean equals(Object o) {
+ if( o instanceof FileWrapper ) {
+ FileWrapper fo = (FileWrapper)o;
+ return f.equals(fo.f) && path.equals(fo.path);
+ }
+ return false;
+ }
+ }
}
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -23,7 +23,9 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
/**
* The event manager to fire events
@@ -105,9 +107,9 @@
}
// Bulk events
- public static void filesUpdated(IArchive topLevelArchive, IArchiveFileSet fileset, IPath[] filePath) {
+ public static void filesUpdated(IArchive topLevelArchive, IArchiveFileSet fileset, FileWrapper[] filePath) {
for( int i = 0; i < filePath.length; i++ ) {
- fileUpdated(topLevelArchive, fileset, filePath[i]);
+ fileUpdated(topLevelArchive, fileset, new Path(filePath[i].getAbsolutePath()));
}
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -22,6 +22,7 @@
package org.jboss.ide.eclipse.archives.core.model;
import org.eclipse.core.runtime.IPath;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
/**
* <p>
@@ -81,15 +82,33 @@
/**
* @return An array of matching IPath's in the filesystem (for external filesystem filesets)
*/
- public IPath[] findMatchingPaths();
+ public FileWrapper[] findMatchingPaths();
/**
+ * Get the FileWrapper objects that match this path
+ * @param path
+ * @return
+ */
+ public FileWrapper[] getMatches(IPath path);
+
+ /**
* @param path The absolute path on the filesystem to check
* @return Whether or not this fileset matches the passed-in path
*/
public boolean matchesPath(IPath path);
/**
+ * Does this global path file match this fileset
+ * at the specific fileset-relative location?
+ *
+ * If fsRelative is null, just match the path
+ * @param globalPath
+ * @param fsRelative
+ * @return
+ */
+ public boolean matchesPath(IPath globalPath, String fsRelative);
+
+ /**
* Sets the "root" or "source" of this fileset (file-system or workspace relative)
* @param path The absolute path that is the source of this fileset
*/
@@ -119,18 +138,4 @@
*/
public void setFlattened(boolean flattened);
- /**
- * Get the relative path of the input file to the root archive
- * @param inputFile
- * @return
- */
- public IPath getRootArchiveRelativePath(IPath inputFile);
-
- /**
- * Get a path relative only to the folder or archive that is the direct parent of the fileset
- * @param inputFile
- * @return
- */
- public IPath getPathRelativeToParent(IPath inputFile);
-
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -22,7 +22,7 @@
package org.jboss.ide.eclipse.archives.core.model.internal;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.HashMap;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
@@ -32,6 +32,7 @@
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
/**
@@ -43,7 +44,8 @@
IArchiveFileSet {
private DirectoryScannerExtension scanner;
- private ArrayList<IPath> matchingPaths;
+ private FileWrapper[] matchingPaths;
+ private HashMap<String, ArrayList<FileWrapper>> matchingMap;
private boolean rescanRequired = true;
public ArchiveFileSetImpl() {
@@ -55,14 +57,6 @@
}
/*
- * @see IArchiveFileSet#findMatchingPaths()
- */
- public synchronized IPath[] findMatchingPaths () {
- getScanner(); // ensure up to date
- return matchingPaths == null ? new IPath[0] : matchingPaths.toArray(new IPath[matchingPaths.size()]);
- }
-
- /*
* @see IArchiveFileSet#getExcludesPattern()
*/
public String getExcludesPattern() {
@@ -118,21 +112,43 @@
* @see IArchiveFileSet#matchesPath(IPath)
*/
public boolean matchesPath(IPath path) {
- return matchesPath(getScanner(), path);
+ return matchesPath(path, null);
}
- private boolean matchesPath(DirectoryScannerExtension scanner, IPath path) {
- IPath global = getGlobalSourcePath();
- if( global != null ) {
- if( global.isPrefixOf(path)) {
- String s = path.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
- return scanner.isUltimatelyIncluded(s);
+ public boolean matchesPath(IPath globalPath, String fsRelative) {
+ getScanner();
+ ArrayList<FileWrapper> result = matchingMap.get(globalPath.toFile().getAbsolutePath());
+ if( result != null ) {
+ if( result.size() > 0 && fsRelative == null )
+ return true;
+
+ FileWrapper tmp;
+ for( int i = 0; i < result.size(); i++ ) {
+ tmp = result.get(i);
+ if( tmp.getFilesetRelative().equals(fsRelative))
+ return true;
}
- }
+ }
return false;
}
+ public FileWrapper[] getMatches(IPath path) {
+ getScanner();
+ ArrayList<FileWrapper> l = matchingMap.get(path.toFile().getAbsolutePath());
+ if( l != null )
+ return (FileWrapper[]) l.toArray(new FileWrapper[l.size()]);
+ return new FileWrapper[0];
+ }
+
/*
+ * @see IArchiveFileSet#findMatchingPaths()
+ */
+ public synchronized FileWrapper[] findMatchingPaths () {
+ getScanner();
+ return matchingPaths;
+ }
+
+ /*
* Will re-scan if required, or use cached scanner
* @return
*/
@@ -142,8 +158,10 @@
try {
scanner = DirectoryScannerFactory.createDirectoryScanner(this, true);
- if( scanner != null )
- matchingPaths = new ArrayList(Arrays.asList(scanner.getAbsoluteIncludedFiles()));
+ if( scanner != null ) {
+ matchingPaths = scanner.getMatchedArray();
+ matchingMap = scanner.getMatchedMap();
+ }
} catch( IllegalStateException ise ) {
ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, "Could not create directory scanner", ise);
}
@@ -192,7 +210,7 @@
public void setFlattened(boolean flat) {
attributeChanged(FLATTENED_ATTRIBUTE, new Boolean(isFlattened()), new Boolean(flat));
getFileSetDelegate().setFlattened(flat);
- //TODO: rescanRequired = true;
+ rescanRequired = true;
}
/*
@@ -220,29 +238,7 @@
public IPath getRootArchiveRelativePath() {
return getParent().getRootArchiveRelativePath();
}
-
- /*
- * @see IArchiveFileSet#getRootArchiveRelativePath(IPath)
- */
- public IPath getRootArchiveRelativePath(IPath inputFile) {
- if( matchesPath(inputFile)) {
- return getParent().getRootArchiveRelativePath().append(getPathRelativeToParent(inputFile));
- }
- return null;
- }
- /*
- * @see org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#getPathRelativeToParent(org.eclipse.core.runtime.IPath)
- */
- public IPath getPathRelativeToParent(IPath inputFile) {
- String s;
- if( isFlattened() )
- s = inputFile.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
- else
- s = inputFile.lastSegment();
- return new Path(s);
- }
-
/*
* @see IArchiveFileSet#resetScanner()
*/
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -28,6 +28,7 @@
import java.util.List;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
@@ -39,6 +40,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveActionImpl;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFileSetImpl;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFolderImpl;
@@ -134,8 +136,8 @@
}
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, IPath path) {
- return otherFilesetMatchesPathAndOutputLocation(fileset, path, null);
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, FileWrapper file) {
+ return otherFilesetMatchesPathAndOutputLocation(fileset, file, null);
}
@@ -146,8 +148,14 @@
* @param root a node to start with, or null if the entire model
* @return
*/
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, IPath path, IArchiveNode root) {
- IArchiveFileSet[] filesets = ModelUtil.getMatchingFilesets(root, path);
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, FileWrapper file, IArchiveNode root) {
+ return otherFilesetMatchesPathAndOutputLocation(fileset, new Path(file.getAbsolutePath()), file.getFilesetRelative(), root);
+ }
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, IPath absolute, IArchiveNode root) {
+ return otherFilesetMatchesPathAndOutputLocation(fileset, absolute, null, root);
+ }
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset, IPath absolute, String fsRelative, IArchiveNode root) {
+ IArchiveFileSet[] filesets = ModelUtil.getMatchingFilesets(root, absolute);
if( filesets.length == 0 || (filesets.length == 1 && Arrays.asList(filesets).contains(fileset))) {
return false;
} else {
@@ -156,7 +164,7 @@
boolean destinationsMatch;
for( int i = 0; i < filesets.length; i++ ) {
if( fileset.equals(filesets[i])) continue;
- relativePathsMatch = fileset.getRootArchiveRelativePath(path).equals(filesets[i].getRootArchiveRelativePath(path));
+ relativePathsMatch = filesets[i].matchesPath(absolute, fsRelative);
destinationsMatch = fileset.getRootArchive().getArchiveFilePath().equals(filesets[i].getRootArchive().getArchiveFilePath());
if( relativePathsMatch && destinationsMatch ) {
@@ -167,16 +175,6 @@
}
return false;
}
-
- /**
- * Get the raw file for this node, specifically,
- * the file actually saved as an OS file.
- * @param node
- * @return
- */
- public static IPath getBaseDestinationFile(IArchiveNode node) {
- return getBaseDestinationFile(node, null);
- }
/**
* Get the raw file for this node, specifically,
@@ -184,8 +182,7 @@
* @param node
* @return
*/
- public static IPath getBaseDestinationFile(IArchiveNode node, IPath absolutePath) {
- IArchiveNode parameterNode = node;
+ public static IPath getBaseDestinationFile(IArchiveNode node) {
ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
while( node != null && !(node instanceof ArchiveModelNode)) {
list.add(node);
@@ -208,26 +205,16 @@
lastConcrete = lastConcrete.append(((IArchiveFolder)nodes[i]).getName());
}
}
-
- if( absolutePath != null && parameterNode.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
- IArchiveFileSet fs = ((IArchiveFileSet)parameterNode);
- IPath sourcePath = fs.getGlobalSourcePath();
- if( sourcePath.isPrefixOf(absolutePath)) {
- lastConcrete = lastConcrete.append(absolutePath.removeFirstSegments(sourcePath.segmentCount()));
- }
- }
return lastConcrete;
}
-
-// public static IPath workspacePathToAbsolutePath (IPath workspacePath) {
-// String projectName = workspacePath.segment(0);
-// if( projectName == null ) return null;
-// IPath projectPath = ArchivesCore.getInstance().getVariables().getProjectPath(projectName);
-// if( projectPath == null ) return null;
-// return projectPath.append(workspacePath.removeFirstSegments(1));
-// }
-
+ public static IPath getBaseDestinationFile(IArchiveFileSet node, IPath fsRelative) {
+ IPath last = getBaseDestinationFile(node);
+ if( fsRelative != null )
+ last = last.append(fsRelative);
+ return last;
+ }
+
public static void fillArchiveModel( XbPackages node, IArchiveModelRootNode modelNode) throws ArchivesModelException {
for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
XbPackageNode child = (XbPackageNode) iter.next();
@@ -277,7 +264,7 @@
if( root == null ) return new IArchive[0];
IArchiveNode[] archives = model.getRoot(project).getAllChildren();
List<IArchiveNode> list = Arrays.asList(archives);
- return (IArchive[]) list.toArray(new IArchive[list.size()]);
+ return list.toArray(new IArchive[list.size()]);
}
return null;
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -31,7 +31,7 @@
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.IArchiveNodeVisitor;
-import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFileSetImpl;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import de.schlichtherle.io.ArchiveDetector;
@@ -72,8 +72,8 @@
fullFilesetBuild(fileset, true);
}
public static void fullFilesetBuild(final IArchiveFileSet fileset, boolean sync) {
- IPath[] paths = fileset.findMatchingPaths();
- copyFiles(fileset, paths, false);
+ FileWrapper[] files = fileset.findMatchingPaths();
+ copyFiles(fileset, files, false);
if( sync )
TrueZipUtil.sync();
}
@@ -88,15 +88,15 @@
// Let them know which files were removed, for events
public static IPath[] fullFilesetRemove(final IArchiveFileSet fileset, boolean sync) {
- IPath[] paths = fileset.findMatchingPaths();
- final ArrayList<IPath> list = new ArrayList<IPath>();
- list.addAll(Arrays.asList(paths));
- for( int i = 0; i < paths.length; i++ ) {
- if( !ModelUtil.otherFilesetMatchesPathAndOutputLocation(fileset, paths[i])) {
+ FileWrapper[] files = fileset.findMatchingPaths();
+ final ArrayList<FileWrapper> list = new ArrayList<FileWrapper>();
+ list.addAll(Arrays.asList(files));
+ for( int i = 0; i < files.length; i++ ) {
+ if( !ModelUtil.otherFilesetMatchesPathAndOutputLocation(fileset, files[i])) {
// remove
- deleteFiles(fileset, new IPath[] {paths[i]}, false);
+ deleteFiles(fileset, new FileWrapper[] {files[i]}, false);
} else {
- list.remove(paths[i]);
+ list.remove(files[i]);
}
}
@@ -109,7 +109,7 @@
if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
createFile(node);
} else if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- createFile(node);
+ createFile(node);
}
return true;
}
@@ -122,26 +122,27 @@
}
- public static void copyFiles(IArchiveFileSet[] filesets, IPath[] paths) {
- copyFiles(filesets, paths, true);
+ public static void copyFiles(IArchiveFileSet[] filesets, FileWrapper[] files) {
+ copyFiles(filesets, files, true);
}
- public static void copyFiles(final IArchiveFileSet[] filesets, final IPath[] paths, boolean sync) {
+ public static void copyFiles(final IArchiveFileSet[] filesets, final FileWrapper[] files, boolean sync) {
for( int i = 0; i < filesets.length; i++ ) {
- copyFiles(filesets[i], paths, false);
+ copyFiles(filesets[i], files, false);
}
if( sync )
TrueZipUtil.sync();
}
- public static void copyFiles(IArchiveFileSet fileset, final IPath[] paths) {
- copyFiles(fileset, paths, true);
+ public static void copyFiles(IArchiveFileSet fileset, final FileWrapper[] files) {
+ copyFiles(fileset, files, true);
}
- public static void copyFiles(IArchiveFileSet fileset, final IPath[] sourcePaths, boolean sync) {
- final File[] destFiles = getFiles(sourcePaths, fileset);
- for( int i = 0; i < sourcePaths.length; i++ ) {
- TrueZipUtil.copyFile(sourcePaths[i].toOSString(), destFiles[i]);
+
+ public static void copyFiles(IArchiveFileSet fileset, final FileWrapper[] files, boolean sync) {
+ final File[] destFiles = getFiles(files, fileset);
+ for( int i = 0; i < files.length; i++ ) {
+ TrueZipUtil.copyFile(files[i].getAbsolutePath(), destFiles[i]);
}
if( sync )
TrueZipUtil.sync();
@@ -151,23 +152,23 @@
/*
* Deleting files
*/
- public static void deleteFiles(IArchiveFileSet[] filesets, IPath[] paths ) {
- deleteFiles(filesets, paths, true);
+ public static void deleteFiles(IArchiveFileSet[] filesets, FileWrapper[] files ) {
+ deleteFiles(filesets, files, true);
}
- public static void deleteFiles(final IArchiveFileSet[] filesets, final IPath[] paths, boolean sync ) {
+ public static void deleteFiles(final IArchiveFileSet[] filesets, final FileWrapper[] files, boolean sync ) {
for( int i = 0; i < filesets.length; i++ ) {
- deleteFiles(filesets[i], paths, false);
+ deleteFiles(filesets[i], files, false);
}
if( sync )
TrueZipUtil.sync();
}
- public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths ) {
+ public static void deleteFiles(IArchiveFileSet fileset, final FileWrapper[] paths ) {
deleteFiles(fileset, paths, true);
}
- public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths, boolean sync ) {
- final File[] destFiles = getFiles(paths, fileset);
- for( int i = 0; i < paths.length; i++ ) {
+ public static void deleteFiles(IArchiveFileSet fileset, final FileWrapper[] files, boolean sync ) {
+ final File[] destFiles = getFiles(files, fileset);
+ for( int i = 0; i < files.length; i++ ) {
TrueZipUtil.deleteAll(destFiles[i]);
}
@@ -197,11 +198,12 @@
/**
* Gets all properly-created de.sch destination files for a fileset
+ * - // TODO MAKE SURE VARIABLES ARE TRANSLATED
* @param inputFiles
* @param fs
* @return
*/
- private static File[] getFiles(IPath[] inputFiles, IArchiveFileSet fs ) {
+ private static File[] getFiles(FileWrapper[] inputFiles, IArchiveFileSet fs ) {
String filesetRelative;
File fsFile = getFile(fs);
if( fsFile == null )
@@ -210,14 +212,9 @@
File[] returnFiles = new File[inputFiles.length];
for( int i = 0; i < inputFiles.length; i++ ) {
if( fs.isFlattened() )
- filesetRelative = inputFiles[i].lastSegment();
- else if( fs.isInWorkspace() ){
- IPath wsPath = ((ArchiveFileSetImpl)fs).getScanner().getWorkspacePath(inputFiles[i]);
- filesetRelative = wsPath.removeFirstSegments(fs.getSourcePath().segmentCount()).toString();
- } else {
- int fsLength = fs.getGlobalSourcePath().toOSString().length()+1;
- filesetRelative = inputFiles[i].toOSString().substring(fsLength);
- }
+ filesetRelative = inputFiles[i].getOutputName();
+ else
+ filesetRelative = inputFiles[i].getFilesetRelative();
File parentFile;
if(new Path(filesetRelative).segmentCount() > 1 ) {
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -38,7 +38,6 @@
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
@@ -234,8 +233,8 @@
if( !project.isAccessible() ) {
book.showPage(noSelectionComposite);
- } else if( ArchivesModelCore.packageFileExists(project.getLocation()) ) {
- if( ArchivesModelCore.projectRegistered(project.getLocation()))
+ } else if( ArchivesModel.instance().canReregister(project.getLocation()) ) {
+ if( ArchivesModel.instance().isProjectRegistered(project.getLocation()))
book.showPage(viewerComposite);
else {
this.project = project;
@@ -293,7 +292,7 @@
IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
ArrayList<IProject> list = new ArrayList<IProject>();
for( int i = 0; i < projects2.length; i++ ) {
- if( projects2[i].isAccessible() && ArchivesModelCore.packageFileExists(projects2[i].getLocation())) {
+ if( projects2[i].isAccessible() && ArchivesModel.instance().canReregister(projects2[i].getLocation())) {
list.add(projects2[i]);
}
}
Modified: trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java
===================================================================
--- trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java 2008-06-27 05:21:09 UTC (rev 8976)
+++ trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java 2008-06-27 05:26:45 UTC (rev 8977)
@@ -30,9 +30,10 @@
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.ide.IDE;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
import org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveFilesetDestinationComposite;
@@ -349,14 +350,17 @@
}
private void changePreview() {
- IPath inputFiles[] = ArchivesModelCore.findMatchingPaths(rootDir, includes, excludes);
+ IPath path = rootDirIsWorkspaceRelative ? new Path(workspaceRelativeRootDir) : rootDir;
+ DirectoryScannerExtension ds = DirectoryScannerFactory.createDirectoryScanner(
+ path, null, includes, excludes, rootDirIsWorkspaceRelative, true);
+ String[] fsRelative = ds.getIncludedFiles();
IPath filesetRelative;
ArrayList<IPath> list = new ArrayList<IPath>();
- for( int i = 0; i < inputFiles.length; i++ ) {
+ for( int i = 0; i < fsRelative.length; i++ ) {
if( flattened )
- filesetRelative = new Path(inputFiles[i].lastSegment());
+ filesetRelative = new Path(new Path(fsRelative[i]).lastSegment());
else
- filesetRelative = inputFiles[i];
+ filesetRelative = new Path(fsRelative[i]);
if( !list.contains(filesetRelative))
list.add(filesetRelative);
}
15 years, 10 months
JBoss Tools SVN: r8976 - trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-06-27 01:21:09 -0400 (Fri, 27 Jun 2008)
New Revision: 8976
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam20WARNewOperationTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2432
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam20WARNewOperationTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam20WARNewOperationTest.java 2008-06-27 04:48:35 UTC (rev 8975)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam20WARNewOperationTest.java 2008-06-27 05:21:09 UTC (rev 8976)
@@ -56,8 +56,7 @@
@Override
protected File getSeamHomeFolder() {
- return new File(System.getProperty(SEAM_2_0_HOME),
- "E:/Java/JBoss/Seam/jboss-seam-2.0.1.GA");
+ return new File(System.getProperty(SEAM_2_0_HOME));
}
@Override
15 years, 10 months
JBoss Tools SVN: r8975 - trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-06-27 00:48:35 -0400 (Fri, 27 Jun 2008)
New Revision: 8975
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam20EARNewOperationTest.java
Log:
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam20EARNewOperationTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam20EARNewOperationTest.java 2008-06-27 00:48:50 UTC (rev 8974)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam20EARNewOperationTest.java 2008-06-27 04:48:35 UTC (rev 8975)
@@ -57,8 +57,7 @@
@Override
protected File getSeamHomeFolder() {
- return new File(System.getProperty(SEAM_2_0_HOME),
- "E:/Java/JBoss/Seam/jboss-seam-2.0.1.GA");
+ return new File(System.getProperty(SEAM_2_0_HOME));
}
@Override
15 years, 10 months