Author: Grid.Qian
Date: 2008-06-11 00:46:33 -0400 (Wed, 11 Jun 2008)
New Revision: 8702
Modified:
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/JbossWSRuntimeManager.java
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java
Log:
JBIDE-2261: validation for removing runtime
Modified:
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-11
03:15:05 UTC (rev 8701)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeClassPathInitializer.java 2008-06-11
04:46:33 UTC (rev 8702)
@@ -13,7 +13,6 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.JavaRuntime;
import org.jboss.tools.ws.core.messages.JbossWSCoreMessages;
-import org.jboss.tools.ws.core.utils.JbossWSCoreUtils;
/**
* @author Grid Qian
@@ -23,6 +22,7 @@
public JbossWSRuntimeClassPathInitializer() {
}
+
private String segment;
@Override
@@ -33,10 +33,10 @@
JbossWSCoreMessages.JBossWS_Runtime_Lib)) {
JbossWSRuntimeClasspathContainer container = new JbossWSRuntimeClasspathContainer(
containerPath);
+ segment = containerPath.segment(1);
JavaCore.setClasspathContainer(containerPath,
new IJavaProject[] { project },
new IClasspathContainer[] { container }, null);
- segment = containerPath.segment(1);
}
}
@@ -68,8 +68,12 @@
public IClasspathEntry[] getClasspathEntries() {
if (entries == null) {
ArrayList<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
- JbossWSRuntime jbws =
JbossWSRuntimeManager.getInstance().findRuntimeByName(segment);
- IPath wsPath = new Path(jbws.getHomeDir());
+ JbossWSRuntime jbws = JbossWSRuntimeManager.getInstance()
+ .findRuntimeByName(segment);
+ IPath wsPath = null;
+ if (jbws != null) {
+ wsPath = new Path(jbws.getHomeDir());
+ }
if (wsPath != null) {
IPath libPath = wsPath.append(JbossWSCoreMessages.Dir_Lib);
list.addAll(Arrays.asList(getEntries(libPath)));
@@ -101,15 +105,16 @@
}
return list.toArray(new IClasspathEntry[list.size()]);
}
- public void removeEntry(String jarName){
- if(entries == null){
- return;
+
+ 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;
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
+ int i = 0;
+ for (IClasspathEntry entry : entries) {
+ if (!entry.toString().contains(jarName)) {
+ newEntries[i++] = entry;
}
}
entries = newEntries;
Modified:
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-11
03:15:05 UTC (rev 8701)
+++
trunk/ws/plugins/org.jboss.tools.ws.core/src/org/jboss/tools/ws/core/classpath/JbossWSRuntimeManager.java 2008-06-11
04:46:33 UTC (rev 8702)
@@ -249,9 +249,11 @@
QualifiedName qRuntimeName =
IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
String name = null;
try {
- name = facetedProject.getProject().getPersistentProperty(qRuntimeName);
+ name = facetedProject.getProject().getPersistentProperty(
+ qRuntimeName);
if (name != null && name.equals(oldName)) {
- facetedProject.getProject().setPersistentProperty(qRuntimeName, newName);
+ facetedProject.getProject().setPersistentProperty(
+ qRuntimeName, newName);
}
} catch (CoreException e) {
// TODO Auto-generated catch block
@@ -261,4 +263,27 @@
}
}
+ 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;
+ }
+
}
\ No newline at end of file
Modified:
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-11
03:15:05 UTC (rev 8701)
+++
trunk/ws/plugins/org.jboss.tools.ws.ui/src/org/jboss/tools/ws/ui/preferences/JbossRuntimeListFieldEditor.java 2008-06-11
04:46:33 UTC (rev 8702)
@@ -58,6 +58,7 @@
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
@@ -337,7 +338,8 @@
}
}
if (!checked) {
- if (tableView.getCheckedElements() == null) {
+ if (tableView.getCheckedElements() == null
+ || tableView.getCheckedElements().length == 0) {
tableView.setChecked(runtimes.get(0), true);
checkedElement = runtimes.get(0);
}
@@ -1031,7 +1033,7 @@
@SuppressWarnings("unchecked")
private void removeRuntime(JbossWSRuntime r) {
- boolean used = isRuntimeUsed(r.getName());
+ 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
@@ -1054,17 +1056,5 @@
checkedElement = null;
}
}
-
- private boolean isRuntimeUsed(String runtimeName) {
- // IProject[] ps = ResourcesPlugin.getWorkspace().getRoot()
- // .getProjects();
- // for (int i = 0; i < ps.length; i++) {
- // ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
- // if (sp != null && runtimeName.equals(sp.getRuntimeName())) {
- // return true;
- // }
- // }
- return false;
- }
}
}
\ No newline at end of file
Show replies by date