Author: dennyxu
Date: 2008-09-11 23:36:51 -0400 (Thu, 11 Sep 2008)
New Revision: 10213
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/IMessageNotifier.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSPropertyPage.java
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSRuntimeConfigBlock.java
Modified:
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/IJBossWSFacetDataModelProperties.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java
Log:
JBIDE-2634: add a propertypage to change project jbossws runtime
JBIDE-2632: fix the inconsistent disabled/enabled server setup issue
Modified:
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-09-12
03:02:28 UTC (rev 10212)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/JBossWSClassPathCommand.java 2008-09-12
03:36:51 UTC (rev 10213)
@@ -62,6 +62,18 @@
.setPersistentProperty(
IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME,
IJBossWSFacetDataModelProperties.DEFAULT_VALUE_IS_SERVER_SUPPLIED);
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME,
+ null);
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION,
+ null);
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_ISDEPLOYED,
+ null);
} else {
// store runtime name and runtime location to the project
@@ -69,6 +81,7 @@
.getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID);
String runtimeLocation = model
.getStringProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME);
+ boolean isDeployed =
model.getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY);
project
.setPersistentProperty(
IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME,
@@ -77,8 +90,13 @@
.setPersistentProperty(
IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION,
runtimeLocation);
- boolean isDeployed = model
- .getBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY);
+ project.setPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_ISDEPLOYED,
+ String.valueOf(isDeployed));
+
+ project
+ .setPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME,
+ null);
status = addClassPath(project, runtimeName, isDeployed);
}
Modified:
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-09-12
03:02:28 UTC (rev 10212)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/command/UninstallJBossWSClassPathCommand.java 2008-09-12
03:36:51 UTC (rev 10213)
@@ -69,6 +69,10 @@
public IStatus removeClassPath(IProject project, String segment) {
IStatus status = Status.OK_STATUS;
+ if(segment == null || "".equals(segment)){
+ return status;
+ }
+
try {
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] oldClasspathEntries = javaProject
Modified:
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/IJBossWSFacetDataModelProperties.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/IJBossWSFacetDataModelProperties.java 2008-09-12
03:02:28 UTC (rev 10212)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/facet/delegate/IJBossWSFacetDataModelProperties.java 2008-09-12
03:36:51 UTC (rev 10213)
@@ -27,13 +27,15 @@
String PERSISTENT_PROPERTY_IS_SERVER_SUPPLIED_RUNTIME =
"is.server.supplied.runtime";
String JBOSS_WS_RUNTIME_HOME = "jboss.ws.runtime.home";
- String DEFAULT_VALUE_IS_SERVER_SUPPLIED = "1";
+ String DEFAULT_VALUE_IS_SERVER_SUPPLIED = "true";
static QualifiedName PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME = new
QualifiedName(QUALIFIEDNAME_IDENTIFIER,
JBOSS_WS_RUNTIME_ID);
static QualifiedName PERSISTENCE_PROPERTY_RNTIME_LOCATION = new
QualifiedName(QUALIFIEDNAME_IDENTIFIER,
JBOSS_WS_RUNTIME_HOME);
+ static QualifiedName PERSISTENCE_PROPERTY_ISDEPLOYED = new
QualifiedName(QUALIFIEDNAME_IDENTIFIER,
+ JBOSS_WS_DEPLOY);
static QualifiedName PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME = new QualifiedName(
QUALIFIEDNAME_IDENTIFIER,
PERSISTENT_PROPERTY_IS_SERVER_SUPPLIED_RUNTIME);
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2008-09-12
03:02:28 UTC (rev 10212)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2008-09-12
03:36:51 UTC (rev 10213)
@@ -36,7 +36,7 @@
JBossWSFacetInstallPage_Title=JBossWS Facet
JBossWSFacetInstallPage_Description=Select JBossWS Web Service runtime
JBossWSFacetInstallPage_ServerSuppliedJBossWS=Server Supplied JBossWS Runtime
-JBossWSFacetInstallPage_Deploy=Deploy
+JBossWSFacetInstallPage_Deploy= Add all JBossWS runtime jars into the deploy archive
JBossWSFacetInstallPage_New=New...
Client_Sample_Run_Over= Call Over!
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2008-09-12 03:02:28 UTC
(rev 10212)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.ui/plugin.xml 2008-09-12 03:36:51 UTC
(rev 10213)
@@ -62,5 +62,13 @@
</page>
</wizard-pages>
</extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+
class="org.jboss.tools.ws.creation.ui.project.facet.JBossWSPropertyPage"
+ id="org.jboss.tools.ws.creation.ui.page"
+ name="JBossWS Runtime">
+ </page>
+ </extension>
</plugin>
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/IMessageNotifier.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/IMessageNotifier.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/IMessageNotifier.java 2008-09-12
03:36:51 UTC (rev 10213)
@@ -0,0 +1,7 @@
+package org.jboss.tools.ws.creation.ui.project.facet;
+
+public interface IMessageNotifier {
+
+ void notify(String msg);
+
+}
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-09-12
03:02:28 UTC (rev 10212)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSFacetInstallPage.java 2008-09-12
03:36:51 UTC (rev 10213)
@@ -10,59 +10,25 @@
******************************************************************************/
package org.jboss.tools.ws.creation.ui.project.facet;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.EventObject;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.core.JavaModelException;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
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.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;
/**
* @author Dennyxu
*
*/
public class JBossWSFacetInstallPage extends AbstractFacetWizardPage implements
- IFacetWizardPage, IDataModelListener {
+ IFacetWizardPage, IDataModelListener, IMessageNotifier {
- private Button btnServerSupplied;
- private Button btnUserSupplied;
- private Combo cmbRuntimes;
- private Button btnDeploy;
- private Button btnNew;
+
private IDataModel model;
+ private JBossWSRuntimeConfigBlock block;
public JBossWSFacetInstallPage() {
super(JBossWSCreationCoreMessages.JBossWSFacetInstallPage_Title);
@@ -74,299 +40,23 @@
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);
-
- Composite composite = new Composite(parent, SWT.NONE);
-
- GridLayout gridLayout = new GridLayout(4, false);
- composite.setLayout(gridLayout);
-
- btnServerSupplied = new Button(composite, SWT.RADIO);
- btnServerSupplied.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setServerSuppliedSelection(e);
- }
- });
- GridData gd = new GridData();
-
- gd.horizontalSpan = 1;
- btnServerSupplied.setLayoutData(gd);
-
- Label lblServerSupplied = new Label(composite, SWT.NONE);
- lblServerSupplied.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- btnServerSupplied.setSelection(true);
- setServerSuppliedSelection(e);
- }
- });
- lblServerSupplied.setText(JBossWSCreationCoreMessages.JBossWSFacetInstallPage_ServerSuppliedJBossWS);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 3;
- lblServerSupplied.setLayoutData(gd);
-
- btnUserSupplied = new Button(composite, SWT.RADIO);
-
- btnUserSupplied.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setUserSuppliedSelection(e);
- }
- });
-
- cmbRuntimes = new Combo(composite, SWT.READ_ONLY);
- cmbRuntimes.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- cmbRuntimes.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- String runtimeName = cmbRuntimes.getText();
- JBossWSRuntime jr = (JBossWSRuntime) cmbRuntimes
- .getData(runtimeName);
- saveJBosswsRuntimeToModel(jr);
- }
- });
-
- btnDeploy = new Button(composite, SWT.CHECK);
- btnDeploy.setText(JBossWSCreationCoreMessages.JBossWSFacetInstallPage_Deploy);
- btnDeploy.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- model.setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
- btnDeploy.getSelection());
- }
- });
-
- btnNew = new Button(composite, SWT.NONE);
- btnNew.setText(JBossWSCreationCoreMessages.JBossWSFacetInstallPage_New);
- btnNew.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- newJBossWSRuntime();
- changePageStatus();
- }
- });
-
- setInitialValues();
- setControl(composite);
- changePageStatus();
-
+ block = new JBossWSRuntimeConfigBlock(model);
+ block.setMessageNotifier(this);
+ setControl(block.createControl(parent));
+ setPageComplete(block.isPageComplete());
}
-
- protected void saveJBosswsRuntimeToModel(JBossWSRuntime jbws) {
- String duplicateMsg = "";
- try {
- duplicateMsg = getDuplicateJars(jbws.getName());
- } catch (JavaModelException e1) {
- CreationUIPlugin.getDefault().getLog().log(
- StatusUtils.errorStatus(e1));
- }
- if ("".equals(duplicateMsg)) {
- model.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
- jbws.getHomeDir());
- model.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID, jbws
- .getName());
- }else{
- model.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID, null);
- model.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME, null);
- }
- }
- protected void setServerSuppliedSelection(EventObject e) {
- btnServerSupplied.setSelection(true);
- btnUserSupplied.setSelection(false);
- model
- .setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
- true);
- //remove user supplied properties
- model.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID, null);
- model.setStringProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME, null);
- enableUserSupplied(false);
- changePageStatus();
-
- }
-
- protected void setUserSuppliedSelection(EventObject e) {
- btnServerSupplied.setSelection(false);
- btnUserSupplied.setSelection(true);
- model
- .setBooleanProperty(
- IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
- false);
- String runtimeId = cmbRuntimes.getText();
- JBossWSRuntime jbws =
JBossWSRuntimeManager.getInstance().findRuntimeByName(runtimeId);
+ public void propertyChanged(DataModelEvent event) {
-
- if (jbws != null) {
- saveJBosswsRuntimeToModel(jbws);
- }
- enableUserSupplied(true);
- changePageStatus();
-
}
- protected void enableUserSupplied(boolean enabled) {
- cmbRuntimes.setEnabled(enabled);
- btnDeploy.setEnabled(enabled);
- btnNew.setEnabled(enabled);
-
+ public void notify(String msg) {
+ setErrorMessage(msg);
+ setPageComplete(block.isPageComplete());
}
-
- 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();
- for (int i = 0; i < runtimes.length; i++) {
- 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()) {
- defaultJbws = jr;
- defaultIndex = i;
- }
- }
-
- if(selectedJbws != null){
- cmRuntime.select(selectIndex);
- saveJBosswsRuntimeToModel(selectedJbws);
- }else if(defaultJbws != null){
- cmRuntime.select(defaultIndex);
- saveJBosswsRuntimeToModel(defaultJbws);
- }
- }
-
- /*
- * 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>();
-
- JBossRuntimeListFieldEditor.JBossWSRuntimeNewWizard newRtwizard = new
JBossRuntimeListFieldEditor.JBossWSRuntimeNewWizard(
- exists, added) {
- public boolean performFinish() {
- JBossWSRuntime rt = getRuntime();
- rt.setDefault(true);
- JBossWSRuntimeManager.getInstance().addRuntime(rt);
- JBossWSRuntimeManager.getInstance().save();
-
- return true;
- }
- };
- WizardDialog dialog = new WizardDialog(Display.getCurrent()
- .getActiveShell(), newRtwizard);
- if (dialog.open() == WizardDialog.OK) {
- initializeRuntimesCombo(cmbRuntimes, null);
- //cmbRuntimes.select(0);
- }
- }
-
- protected void changePageStatus() {
-
- if (btnUserSupplied.getSelection()
- && cmbRuntimes.getSelectionIndex() == -1) {
- setErrorMessage(JBossWSCreationCoreMessages.Error_WS_No_Runtime_Specifed);
- } else if (!btnUserSupplied.getSelection()
- && !btnServerSupplied.getSelection()) {
- setErrorMessage(JBossWSCreationCoreMessages.Error_WS_Chose_runtime);
- }else if(btnUserSupplied.getSelection()){
- String duplicateMsg = "";
- try {
- duplicateMsg = getDuplicateJars(cmbRuntimes.getText());
- } catch (JavaModelException e1) {
- CreationUIPlugin.getDefault().getLog().log(StatusUtils.errorStatus(e1));
- }
- if(!duplicateMsg.equals("")){
- setErrorMessage("Duplicated jar on classpath:" + duplicateMsg);
- }else{
- setErrorMessage(null);
- }
- }else{
- setErrorMessage(null);
- }
-
- setPageComplete(isPageComplete());
- }
-
- @Override
- public boolean isPageComplete() {
- if (btnServerSupplied.getSelection()
- || (btnUserSupplied.getSelection() && cmbRuntimes
- .getSelectionIndex() != -1)) {
- return true;
- } else {
- return false;
- }
- }
-
- public void propertyChanged(DataModelEvent event) {
-
- }
- protected String getDuplicateJars(String jbwsName) throws JavaModelException{
- List<String> allExistingJars = new ArrayList<String>();
- List<String> runtimeJars = new ArrayList<String>();
+
- JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance().findRuntimeByName(jbwsName);
- if(jbws.isUserConfigClasspath()){
- runtimeJars.addAll(jbws.getLibraries());
- }else{
- runtimeJars.addAll(JBossWSRuntimeManager.getInstance().getAllRuntimeJars(jbws));
- }
-
- String prjName =
model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(prjName);
- IJavaProject javaProject = JavaCore.create(project);
- IClasspathEntry[] entries = javaProject.getRawClasspath();
- for(IClasspathEntry entry: entries){
- if(entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER){
- IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(),
javaProject);
- for(IClasspathEntry containedEntry: container.getClasspathEntries()){
- allExistingJars.add(containedEntry.getPath().toOSString());
- }
- }else if(entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY){
- allExistingJars.add(entry.getPath().toOSString());
- }
- }
-
- for(String jarName: runtimeJars){
- if(allExistingJars.contains(jarName)){
- return jarName;
- }
- }
-
- return "";
-
- }
-
}
\ No newline at end of file
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSPropertyPage.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSPropertyPage.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSPropertyPage.java 2008-09-12
03:36:51 UTC (rev 10213)
@@ -0,0 +1,71 @@
+package org.jboss.tools.ws.creation.ui.project.facet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.ws.core.command.JBossWSClassPathCommand;
+import org.jboss.tools.ws.core.command.UninstallJBossWSClassPathCommand;
+import org.jboss.tools.ws.core.facet.delegate.IJBossWSFacetDataModelProperties;
+import org.jboss.tools.ws.core.facet.delegate.JBossWSFacetInstallDataModelProvider;
+
+public class JBossWSPropertyPage extends PropertyPage implements
+ IMessageNotifier {
+
+ private IDataModel model;
+ private IProject project;
+
+ public JBossWSPropertyPage() {
+ super();
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ project = (IProject)this.getElement();
+ model = (IDataModel)new JBossWSFacetInstallDataModelProvider().create();
+ try {
+ String isDeploy =
project.getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_ISDEPLOYED);
+ String runtimeid =
project.getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+ String runtimeLocation =
project.getPersistentProperty(IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION);
+ String serverSupplied = project.getPersistentProperty(
+ IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
+ model.setProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
Boolean.valueOf(isDeploy));
+ model.setProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
runtimeLocation);
+ model.setProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID, runtimeid);
+ model.setStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME,
project.getName());
+ model.setBooleanProperty(IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
Boolean.valueOf(serverSupplied));
+ //model.setProperty(IJBossWSFacetDataModelProperties.PERSISTENT_PROPERTY_IS_SERVER_SUPPLIED_RUNTIME,
Boolean.valueOf(serverSupplied));
+ } catch (CoreException e) {
+ //ignore
+ }
+
+ JBossWSRuntimeConfigBlock block = new JBossWSRuntimeConfigBlock(model);
+ block.setMessageNotifier(this);
+ return block.createControl(parent);
+ }
+
+ public void notify(String msg) {
+ setErrorMessage(msg);
+ }
+
+ @Override
+ protected void performApply() {
+
+ UninstallJBossWSClassPathCommand uninstall = new UninstallJBossWSClassPathCommand(
+ project, model);
+ uninstall.executeOverride(null);
+
+ JBossWSClassPathCommand install = new JBossWSClassPathCommand(project, model);
+ install.executeOverride(null);
+
+ super.performApply();
+ }
+
+
+
+}
Added:
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSRuntimeConfigBlock.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSRuntimeConfigBlock.java
(rev 0)
+++
trunk/ws/plugins/org.jboss.tools.ws.creation.ui/src/org/jboss/tools/ws/creation/ui/project/facet/JBossWSRuntimeConfigBlock.java 2008-09-12
03:36:51 UTC (rev 10213)
@@ -0,0 +1,383 @@
+package org.jboss.tools.ws.creation.ui.project.facet;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EventObject;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+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.core.JavaModelException;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import
org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelEvent;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+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;
+
+public class JBossWSRuntimeConfigBlock {
+
+ private Button btnServerSupplied;
+ private Button btnUserSupplied;
+ private Combo cmbRuntimes;
+ private Button btnDeploy;
+ private Button btnNew;
+
+ private String errMsg;
+ private IMessageNotifier notifier;
+
+ private IDataModel model;
+
+ public JBossWSRuntimeConfigBlock(Object config){
+ this.model = (IDataModel) config;
+
+ }
+
+
+ public void setMessageNotifier(IMessageNotifier notifier){
+ this.notifier = notifier;
+ }
+
+
+
+ public Composite createControl(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ GridLayout gridLayout = new GridLayout(3, false);
+ composite.setLayout(gridLayout);
+
+ btnServerSupplied = new Button(composite, SWT.RADIO);
+ btnServerSupplied.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setServerSuppliedSelection(e);
+ }
+ });
+ GridData gd = new GridData();
+
+ gd.horizontalSpan = 1;
+ btnServerSupplied.setLayoutData(gd);
+
+ Label lblServerSupplied = new Label(composite, SWT.NONE);
+ lblServerSupplied.addMouseListener(new MouseAdapter() {
+ public void mouseDown(MouseEvent e) {
+ btnServerSupplied.setSelection(true);
+ setServerSuppliedSelection(e);
+ }
+ });
+ lblServerSupplied.setText(JBossWSCreationCoreMessages.JBossWSFacetInstallPage_ServerSuppliedJBossWS);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ lblServerSupplied.setLayoutData(gd);
+
+ btnUserSupplied = new Button(composite, SWT.RADIO);
+
+ btnUserSupplied.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ setUserSuppliedSelection(e);
+ }
+ });
+
+ cmbRuntimes = new Combo(composite, SWT.READ_ONLY);
+ cmbRuntimes.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ cmbRuntimes.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ String runtimeName = cmbRuntimes.getText();
+ JBossWSRuntime jr = (JBossWSRuntime) cmbRuntimes
+ .getData(runtimeName);
+ saveJBosswsRuntimeToModel(jr);
+ changePageStatus();
+ }
+ });
+
+ btnNew = new Button(composite, SWT.NONE);
+ btnNew.setText(JBossWSCreationCoreMessages.JBossWSFacetInstallPage_New);
+ btnNew.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ newJBossWSRuntime();
+ changePageStatus();
+ }
+ });
+
+ btnDeploy = new Button(composite, SWT.CHECK);
+ btnDeploy.setText(JBossWSCreationCoreMessages.JBossWSFacetInstallPage_Deploy);
+ btnDeploy.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ model.setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_DEPLOY,
+ btnDeploy.getSelection());
+ }
+ });
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+ btnDeploy.setLayoutData(gd);
+
+ setInitialValues();
+ changePageStatus();
+
+ return composite;
+
+ }
+
+ 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);
+ enableUserSupplied(false);
+ }else if(runtimeName != null && !runtimeName.equals("")){
+ btnUserSupplied.setSelection(true);
+ if(isDeploy){
+ btnDeploy.setSelection(true);
+ }
+
+ }
+ initializeRuntimesCombo(cmbRuntimes, runtimeName);
+
+ }
+
+ protected void saveJBosswsRuntimeToModel(JBossWSRuntime jbws) {
+ String duplicateMsg = "";
+ try {
+ duplicateMsg = getDuplicateJars(jbws.getName());
+ } catch (JavaModelException e1) {
+ CreationUIPlugin.getDefault().getLog().log(
+ StatusUtils.errorStatus(e1));
+ }
+ if ("".equals(duplicateMsg)) {
+ model.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME,
+ jbws.getHomeDir());
+ model.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID, jbws
+ .getName());
+ }else{
+ model.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID, null);
+ model.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME, null);
+ }
+ }
+
+ protected void setServerSuppliedSelection(EventObject e) {
+ btnServerSupplied.setSelection(true);
+ btnUserSupplied.setSelection(false);
+ model
+ .setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
+ true);
+ //remove user supplied properties
+ model.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_ID, null);
+ model.setStringProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_HOME, null);
+ enableUserSupplied(false);
+ changePageStatus();
+
+ }
+
+ protected void setUserSuppliedSelection(EventObject e) {
+ btnServerSupplied.setSelection(false);
+ btnUserSupplied.setSelection(true);
+ model
+ .setBooleanProperty(
+ IJBossWSFacetDataModelProperties.JBOSS_WS_RUNTIME_IS_SERVER_SUPPLIED,
+ false);
+ String runtimeId = cmbRuntimes.getText();
+ JBossWSRuntime jbws =
JBossWSRuntimeManager.getInstance().findRuntimeByName(runtimeId);
+
+
+ if (jbws != null) {
+ saveJBosswsRuntimeToModel(jbws);
+ }
+ enableUserSupplied(true);
+ changePageStatus();
+
+ }
+
+ protected void enableUserSupplied(boolean enabled) {
+ cmbRuntimes.setEnabled(enabled);
+ btnDeploy.setEnabled(enabled);
+ btnNew.setEnabled(enabled);
+
+ }
+
+ 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();
+ for (int i = 0; i < runtimes.length; i++) {
+ 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()) {
+ defaultJbws = jr;
+ defaultIndex = i;
+ }
+ }
+
+ if(selectedJbws != null){
+ cmRuntime.select(selectIndex);
+ saveJBosswsRuntimeToModel(selectedJbws);
+ }else if(defaultJbws != null){
+ cmRuntime.select(defaultIndex);
+ saveJBosswsRuntimeToModel(defaultJbws);
+ }
+ }
+
+ /*
+ * 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>();
+
+ JBossRuntimeListFieldEditor.JBossWSRuntimeNewWizard newRtwizard = new
JBossRuntimeListFieldEditor.JBossWSRuntimeNewWizard(
+ exists, added) {
+ public boolean performFinish() {
+ JBossWSRuntime rt = getRuntime();
+ rt.setDefault(true);
+ JBossWSRuntimeManager.getInstance().addRuntime(rt);
+ JBossWSRuntimeManager.getInstance().save();
+
+ return true;
+ }
+ };
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), newRtwizard);
+ if (dialog.open() == WizardDialog.OK) {
+ initializeRuntimesCombo(cmbRuntimes, null);
+ //cmbRuntimes.select(0);
+ }
+ }
+
+ protected void changePageStatus() {
+
+ if (btnUserSupplied.getSelection()
+ && cmbRuntimes.getSelectionIndex() == -1) {
+ setErrorMessage(JBossWSCreationCoreMessages.Error_WS_No_Runtime_Specifed);
+ } else if (!btnUserSupplied.getSelection()
+ && !btnServerSupplied.getSelection()) {
+ setErrorMessage(JBossWSCreationCoreMessages.Error_WS_Chose_runtime);
+ }else if(btnUserSupplied.getSelection()){
+ String duplicateMsg = "";
+ try {
+ duplicateMsg = getDuplicateJars(cmbRuntimes.getText());
+ } catch (JavaModelException e1) {
+ CreationUIPlugin.getDefault().getLog().log(StatusUtils.errorStatus(e1));
+ }
+ if(!duplicateMsg.equals("")){
+ setErrorMessage("Duplicated jar on classpath:" + duplicateMsg);
+ }else{
+ setErrorMessage(null);
+ }
+ }else{
+ setErrorMessage(null);
+ }
+
+ //notify the parent property page to set error message
+ if(notifier != null){
+ notifier.notify(errMsg);
+ }
+ }
+
+ private void setErrorMessage(String msg){
+ this.errMsg = msg;
+ }
+
+ public boolean isPageComplete() {
+ if(errMsg != null && !"".equals(errMsg)){
+ return false;
+ }
+ if (btnServerSupplied.getSelection()
+ || (btnUserSupplied.getSelection() && cmbRuntimes
+ .getSelectionIndex() != -1)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void propertyChanged(DataModelEvent event) {
+
+ }
+
+ protected String getDuplicateJars(String jbwsName) throws JavaModelException{
+ String prjName =
model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
+
+ if(prjName == null || "".equals(prjName)){
+ return "";
+ }
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(prjName);
+ if(!project.exists()){
+ return "";
+ }
+
+ List<String> allExistingJars = new ArrayList<String>();
+ List<String> runtimeJars = new ArrayList<String>();
+
+ JBossWSRuntime jbws = JBossWSRuntimeManager.getInstance().findRuntimeByName(jbwsName);
+ if(jbws.isUserConfigClasspath()){
+ runtimeJars.addAll(jbws.getLibraries());
+ }else{
+ runtimeJars.addAll(JBossWSRuntimeManager.getInstance().getAllRuntimeJars(jbws));
+ }
+
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ for(IClasspathEntry entry: entries){
+ if(entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER){
+ if("JBossWS_Runtime".equals(entry.getPath().segment(0))){
+ continue;
+ }
+ IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(),
javaProject);
+ for(IClasspathEntry containedEntry: container.getClasspathEntries()){
+ allExistingJars.add(containedEntry.getPath().toOSString());
+ }
+ }else if(entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY){
+ allExistingJars.add(entry.getPath().toOSString());
+ }
+ }
+
+ for(String jarName: runtimeJars){
+ if(allExistingJars.contains(jarName)){
+ return jarName;
+ }
+ }
+
+ return "";
+
+ }
+}