Author: rob.stryker(a)jboss.com
Date: 2012-02-23 03:26:39 -0500 (Thu, 23 Feb 2012)
New Revision: 39035
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/CustomRuntimeClasspathModel.java
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/CustomClasspathPreferencePage.java
Log:
JBIDE-11032 - to trunk handling exceptions
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-02-23
08:25:05 UTC (rev 39034)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/ejb3/EJB3ClasspathContainer.java 2012-02-23
08:26:39 UTC (rev 39035)
@@ -14,6 +14,8 @@
import java.io.FileNotFoundException;
import java.util.ArrayList;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
@@ -55,36 +57,38 @@
public EJB3ClasspathContainer(IPath path, IJavaProject project) {
this.path = path;
this.javaProject = project;
-
- try {
- String configName = path.segment(1);
- IServer servers[] = ServerCore.getServers();
-
- if (configName == null) {
- // old classpath container, try finding the persisten property
- configName =
project.getProject().getPersistentProperty(JBOSS_EJB3_CONFIGURATION);
- if (configName != null) {
- // go ahead and remove the persistent property
- project.getProject().setPersistentProperty(JBOSS_EJB3_CONFIGURATION,
null);
- }
- }
-
- for (int i = 0; i < servers.length; i++) {
- if (servers[i].getName().equals(configName)) {
- jbossServer = (JBossServer) servers[i].loadAdapter(JBossServer.class, new
NullProgressMonitor());
- try {
- homePath = jbossServer.getServer().getRuntime().getLocation();
- configPath = new Path(jbossServer.getConfigDirectory());
- } catch( Exception e ) {
- IStatus status = new Status(IStatus.ERROR,
ClasspathCorePlugin.PLUGIN_ID,Messages.EJB3ClasspathContainer_could_not_determine_home,
e);
- ClasspathCorePlugin.getDefault().getLog().log(status);
- }
- break;
- }
- }
- } catch (CoreException e) {
+ String configName = path.segment(1);
+ IServer servers[] = ServerCore.getServers();
+ IProject p = project.getProject();
+ if( p.exists() && p.isOpen() /* && Deprecated :
p.isLocal(IResource.DEPTH_INFINITE)*/) {
+ try {
+ if (configName == null) {
+ // old classpath container, try finding the persisten property
+ configName =
project.getProject().getPersistentProperty(JBOSS_EJB3_CONFIGURATION);
+ if (configName != null) {
+ // go ahead and remove the persistent property
+ project.getProject().setPersistentProperty(JBOSS_EJB3_CONFIGURATION, null);
+ }
+ }
+ } catch( CoreException ce ) {
+ // This should never occur. If it does, it regards legacy situations.
+ // The project is opened and accessible. There are no reasons for this
+ // to ever occur.
+ }
+ }
+ for (int i = 0; i < servers.length; i++) {
+ if (servers[i].getName().equals(configName)) {
+ jbossServer = (JBossServer) servers[i].loadAdapter(JBossServer.class, new
NullProgressMonitor());
+ try {
+ homePath = jbossServer.getServer().getRuntime().getLocation();
+ configPath = new Path(jbossServer.getConfigDirectory());
+ } catch( Exception e ) {
+ IStatus status = new Status(IStatus.ERROR,
ClasspathCorePlugin.PLUGIN_ID,Messages.EJB3ClasspathContainer_could_not_determine_home,
e);
+ ClasspathCorePlugin.getDefault().getLog().log(status);
+ }
+ break;
+ }
}
-
}
public String getDescription() {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/CustomRuntimeClasspathModel.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/CustomRuntimeClasspathModel.java 2012-02-23
08:25:05 UTC (rev 39034)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.core/src/org/jboss/ide/eclipse/as/classpath/core/runtime/CustomRuntimeClasspathModel.java 2012-02-23
08:26:39 UTC (rev 39035)
@@ -225,11 +225,19 @@
}
return null;
}
+
+ /**
+ * Return a list of filesets, or null if none are found
+ * @param file
+ * @param server
+ * @return
+ */
public static Fileset[] loadFilesets(File file, IServer server) {
- if( file != null && file.exists()) {
- try {
+ try {
+ if( file != null && file.exists())
return FilesetUtil.loadFilesets(new FileInputStream(file), server);
- } catch( FileNotFoundException fnfe) {}
+ } catch( FileNotFoundException fnfe) {
+ return null;
}
return null;
}
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/CustomClasspathPreferencePage.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/CustomClasspathPreferencePage.java 2012-02-23
08:25:05 UTC (rev 39034)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.classpath.ui/src/org/jboss/ide/eclipse/as/classpath/ui/containers/custom/CustomClasspathPreferencePage.java 2012-02-23
08:26:39 UTC (rev 39035)
@@ -54,6 +54,7 @@
import org.jboss.ide.eclipse.as.classpath.core.RuntimeKey;
import org.jboss.ide.eclipse.as.classpath.core.runtime.CustomRuntimeClasspathModel;
import
org.jboss.ide.eclipse.as.classpath.core.runtime.CustomRuntimeClasspathModel.IDefaultPathProvider;
+import org.jboss.ide.eclipse.as.classpath.ui.ClasspathUIPlugin;
import org.jboss.ide.eclipse.as.classpath.ui.Messages;
import org.jboss.ide.eclipse.as.ui.JBossServerUIPlugin;
import org.jboss.ide.eclipse.as.ui.preferences.ServerTypePreferencePage;
@@ -95,6 +96,8 @@
try {
prefs.flush();
} catch(BackingStoreException e) {
+ // IGNORE this since it is only a setting to remember what was the last selected
+ // runtime. This is extremely not necessary to log or inform the user about.
}
MessageDialog dialog= new MessageDialog(getShell(),
@@ -115,7 +118,7 @@
// A full build is not enough
jp.setRawClasspath(jp.getRawClasspath(), new NullProgressMonitor());
} catch( JavaModelException jme ) {
- // TODO
+ return jme.getStatus();
}
CoreUtility.getBuildJob(jp.getProject()).schedule();
}
@@ -146,6 +149,8 @@
IProject[] allProjs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for( int i = 0; i < allProjs.length; i++ ) {
try {
+ if( !allProjs[i].exists() || !allProjs[i].isOpen())
+ continue;
if(FacetedProjectFramework.isFacetedProject(allProjs[i])) {
IFacetedProject fp = ProjectFacetsManager.create(allProjs[i]);
org.eclipse.wst.common.project.facet.core.runtime.IRuntime primary =
fp.getPrimaryRuntime();
@@ -156,7 +161,10 @@
}
}
} catch(CoreException ce) {
- // Exception thrown if project does not exist or is closed, can ignore safely
+ // Exception thrown if project does not exist or is closed,
+ // can ignore safely because we checked that, and also,
+ // if this project is erroring, we do not want to error every time
+ // this is checked. Simply recognize this project is not suitable
}
}
return matching.toArray(new IProject[matching.size()]);
Show replies by date