Author: scabanovich
Date: 2007-09-17 11:01:11 -0400 (Mon, 17 Sep 2007)
New Revision: 3657
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/DeleteManagedBeanHandler.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/JSPAdopt.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/ClassExistsCheck.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/JSFRenameFieldChange.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectsRoot.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFNature.java
Log:
JBIDE-895
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/DeleteManagedBeanHandler.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/DeleteManagedBeanHandler.java 2007-09-17
14:08:06 UTC (rev 3656)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/DeleteManagedBeanHandler.java 2007-09-17
15:01:11 UTC (rev 3657)
@@ -12,9 +12,11 @@
import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.*;
import org.jboss.tools.common.meta.action.SignificanceMessageFactory;
+import org.jboss.tools.common.meta.action.impl.SpecialWizardSupport;
import org.jboss.tools.common.meta.action.impl.handlers.DefaultRemoveHandler;
import org.jboss.tools.common.model.*;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -42,8 +44,9 @@
if(unregister) {
try {
if(f != null && f.exists()) f.delete(true, null);
- } catch (Exception e) {
- //ignore
+ } catch (CoreException e) {
+ ServiceDialog d = object.getModel().getService();
+ d.showDialog("Failure", "Cannot delete file " + f, new
String[]{SpecialWizardSupport.CLOSE}, null, ServiceDialog.ERROR);
}
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/JSPAdopt.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/JSPAdopt.java 2007-09-17
14:08:06 UTC (rev 3656)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/JSPAdopt.java 2007-09-17
15:01:11 UTC (rev 3657)
@@ -17,6 +17,7 @@
import org.jboss.tools.common.model.filesystems.XFileObject;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.meta.*;
+import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.model.pv.JSFProjectBean;
import org.jboss.tools.jsf.project.JSFNature;
import org.jboss.tools.jsf.web.JSFWebProject;
@@ -57,12 +58,7 @@
public void adoptProperty(XModelObject target, XModelObject object, Properties p) {
if(p == null) return;
- int c = -1;
- try {
- c = Integer.parseInt(p.getProperty("pos"));
- } catch (Exception e) {
- //ignore
- }
+ int c = getPos(p);
if(c < 0) return;
String bean = object.getParent().getAttributeValue("managed-bean-name");
String name = object.getAttributeValue("property-name");
@@ -85,12 +81,7 @@
JSFUrlPattern pattern =
JSFWebProject.getInstance(object.getModel()).getPatternLoader().getUrlPattern();
res = pattern.getJSFUrl(res);
}
- int pos = -1;
- try {
- pos = Integer.parseInt(p.getProperty("pos"));
- } catch (Exception e) {
- //ignore
- }
+ int pos = getPos(p);
if(res.startsWith("/") && pos >= 0 &&
isInsideResponseRedirect(p.getProperty("text"), pos)) {
res = res.substring(1);
}
@@ -142,12 +133,7 @@
public void adoptPropertyReference(XModelObject target, XModelObject object, Properties
p) {
if(p == null) return;
- int c = -1;
- try {
- c = Integer.parseInt(p.getProperty("pos"));
- } catch (Exception e) {
- //ignore
- }
+ int c = getPos(p);
if(c < 0) return;
String s = object.getAttributeValue("name");
XModelObject o = object;
@@ -169,6 +155,19 @@
p.setProperty("start text", start);
}
+ int getPos(Properties p) {
+ int c = -1;
+ if(p == null) return -1;
+ String s = p.getProperty("pos");
+ if(s == null || s.trim().length() == 0) return c;
+ try {
+ c = Integer.parseInt(s.trim());
+ } catch (NumberFormatException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
+ }
+ return c;
+ }
+
public boolean isAdoptableMapEntry(XModelObject object) {
return "JSFMapEntry".equals(object.getModelEntity().getName());
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/ClassExistsCheck.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/ClassExistsCheck.java 2007-09-17
14:08:06 UTC (rev 3656)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/ClassExistsCheck.java 2007-09-17
15:01:11 UTC (rev 3657)
@@ -27,12 +27,9 @@
public void setModelContext(XModelObject context) {
this.context = context;
- try {
- IProject project = EclipseResourceUtil.getResource(context).getProject();
- javaProject = EclipseResourceUtil.getJavaProject(project);
- } catch (Exception e) {
- JSFModelPlugin.getPluginLog().logError(e);
- }
+ IResource resource = EclipseResourceUtil.getResource(context);
+ IProject project = resource.getProject();
+ javaProject = EclipseResourceUtil.getJavaProject(project);
qualifiedClassName = "";
existingClass = null;
valid = false;
@@ -60,7 +57,7 @@
}
try {
if(javaProject != null) existingClass = javaProject.findType(qualifiedClassName);
- } catch (Exception e) {
+ } catch (JavaModelException e) {
existingClass = null;
JSFModelPlugin.getPluginLog().logError(e);
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/JSFRenameFieldChange.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/JSFRenameFieldChange.java 2007-09-17
14:08:06 UTC (rev 3656)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/JSFRenameFieldChange.java 2007-09-17
15:01:11 UTC (rev 3657)
@@ -28,15 +28,11 @@
}
private static XModel getModel(IField field) {
- try {
- IProject project = field.getJavaProject().getProject();
- if (!project.hasNature(JSFNature.NATURE_ID)) return null;
- IModelNature n = EclipseResourceUtil.getModelNature(project);
- return (n != null) ? n.getModel() : null;
- } catch (Exception e) {
- //ignore
- return null;
- }
+ if(field == null || field.getJavaProject() == null) return null;
+ IProject project = field.getJavaProject().getProject();
+ if(!JSFNature.hasJSFNature(project)) return null;
+ IModelNature n = EclipseResourceUtil.getModelNature(project);
+ return (n != null) ? n.getModel() : null;
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java 2007-09-17
14:08:06 UTC (rev 3656)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java 2007-09-17
15:01:11 UTC (rev 3657)
@@ -60,7 +60,7 @@
if(loaded) {
try {
update();
- } catch (Exception e) {
+ } catch (JavaModelException e) {
JSFModelPlugin.getPluginLog().logError(e);
}
}
@@ -72,7 +72,7 @@
isLoading = true;
try {
update();
- } catch (Exception e) {
+ } catch (JavaModelException e) {
JSFModelPlugin.getPluginLog().logError(e);
}
isLoading = false;
@@ -84,7 +84,7 @@
return super.hasChildren();
}
- public void update() throws Exception {
+ public void update() throws JavaModelException {
if(!loaded) return;
Map<String,XModelObject> map = new HashMap<String,XModelObject>();
Set<String> properties = new HashSet<String>();
@@ -92,7 +92,7 @@
for (int i = 0; i < cs.length; i++) map.put(cs[i].getPathPart(), cs[i]);
if(type != null) {
IField[] fs = type.getFields();
- for (int i = 0; i < fs.length; i++) {
+ if(fs != null) for (int i = 0; i < fs.length; i++) {
String n = fs[i].getElementName();
JSFProjectBeanMember c = (JSFProjectBeanMember)map.get(n);
if(c != null &&
!c.getModelEntity().getName().equals("JSFProjectBeanProperty")) {
@@ -112,7 +112,7 @@
properties.add(n);
}
IMethod[] ms = type.getMethods();
- for (int i = 0; i < ms.length; i++) {
+ if(ms != null) for (int i = 0; i < ms.length; i++) {
if(ms[i].isConstructor()) continue;
if(!Flags.isPublic(ms[i].getFlags())) continue;
String n = ms[i].getElementName();
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectsRoot.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectsRoot.java 2007-09-17
14:08:06 UTC (rev 3656)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectsRoot.java 2007-09-17
15:01:11 UTC (rev 3657)
@@ -12,12 +12,14 @@
import java.util.*;
import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.impl.ExtraRootImpl;
import org.jboss.tools.common.model.util.*;
+import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
import org.jboss.tools.jst.web.model.pv.WebProjectNode;
@@ -127,7 +129,7 @@
if(org.jboss.tools.common.model.project.WatcherLoader.isLocked(getModel())) return 0;
if(!isLoaded()) {
IProject p = EclipseResourceUtil.getProject(fs);
- try {
+ if(p != null && p.exists() && p.isAccessible()) try {
IMarker[] ms = p.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
if(ms != null && ms.length > 0) {
for (int i = 0; i < ms.length; i++) {
@@ -135,8 +137,8 @@
}
}
return 0;
- } catch (Exception e) {
- //ignore
+ } catch (CoreException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
return 0;
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFNature.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFNature.java 2007-09-17
14:08:06 UTC (rev 3656)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFNature.java 2007-09-17
15:01:11 UTC (rev 3657)
@@ -26,10 +26,11 @@
}
public static boolean hasJSFNature(IProject project) {
+ if(project == null || !project.isAccessible()) return false;
try {
- return project != null && project.hasNature(NATURE_ID);
- } catch (Exception e) {
- //ignore
+ return project.hasNature(NATURE_ID);
+ } catch (CoreException e) {
+ JSFModelPlugin.getPluginLog().logError(e);
return false;
}
}