Author: dgolovin
Date: 2009-06-08 20:50:43 -0400 (Mon, 08 Jun 2009)
New Revision: 15794
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/wtp/JspWtpKbConnector.java
trunk/common/plugins/org.jboss.tools.common.meta.ui/src/org/jboss/tools/common/meta/ui/editor/MetaLoaderUtil.java
trunk/common/plugins/org.jboss.tools.common.meta.ui/src/org/jboss/tools/common/meta/ui/search/MetaSearchQuery.java
trunk/common/plugins/org.jboss.tools.common.projecttemplates/src/org/jboss/tools/common/projecttemplates/ProjectTemplatesPlugin.java
trunk/common/plugins/org.jboss.tools.common.verification.ui/src/org/jboss/tools/common/verification/ui/vrules/wizard/config/VRulesConfigurationWizard.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java
Log:
code clean up. this update contains uncommited changes left from brevious code clean up
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/wtp/JspWtpKbConnector.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/wtp/JspWtpKbConnector.java 2009-06-08
22:05:10 UTC (rev 15793)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/wtp/JspWtpKbConnector.java 2009-06-09
00:50:43 UTC (rev 15794)
@@ -146,10 +146,10 @@
}
KbTldStore store = KbTldStore.getInstance();
KbQuery kbQuery = new KbQuery(query, registerResources);
- Collection proposals = store.queryProposal(kbQuery);
- if(proposals.size()>0) {
- Iterator iterator = proposals.iterator();
- KbProposal p = (KbProposal)iterator.next();
+ Collection<KbProposal> proposals = store.queryProposal(kbQuery);
+ if(!proposals.isEmpty()) {
+ Iterator<KbProposal> iterator = proposals.iterator();
+ KbProposal p = iterator.next();
getProposalCache().put(query, p);
return p;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.meta.ui/src/org/jboss/tools/common/meta/ui/editor/MetaLoaderUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.meta.ui/src/org/jboss/tools/common/meta/ui/editor/MetaLoaderUtil.java 2009-06-08
22:05:10 UTC (rev 15793)
+++
trunk/common/plugins/org.jboss.tools.common.meta.ui/src/org/jboss/tools/common/meta/ui/editor/MetaLoaderUtil.java 2009-06-09
00:50:43 UTC (rev 15794)
@@ -10,12 +10,19 @@
******************************************************************************/
package org.jboss.tools.common.meta.ui.editor;
-import java.util.*;
-import org.w3c.dom.*;
-import org.jboss.tools.common.model.*;
-import org.jboss.tools.common.meta.*;
-import org.jboss.tools.common.model.util.*;
+import java.util.Hashtable;
+import java.util.Properties;
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.XChild;
+import org.jboss.tools.common.meta.XModelEntity;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.XMLUtil;
+import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
public class MetaLoaderUtil extends XModelObjectLoaderUtil {
public MetaLoaderUtil() {
@@ -43,9 +50,7 @@
XModelEntity entity = o.getModelEntity();
XChild[] childs = entity.getChildren();
for (int i = 0; i < childs.length; i++) if(childs[i].isRequired()) {
- try {
- o.addChild(o.getModel().createModelObject(childs[i].getName(), new
Properties()));
- } catch (Exception e) {}
+ o.addChild(o.getModel().createModelObject(childs[i].getName(), new
Properties()));
}
for (int i = 0; i < childs.length; i++) {
String en = childs[i].getName();
Modified:
trunk/common/plugins/org.jboss.tools.common.meta.ui/src/org/jboss/tools/common/meta/ui/search/MetaSearchQuery.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.meta.ui/src/org/jboss/tools/common/meta/ui/search/MetaSearchQuery.java 2009-06-08
22:05:10 UTC (rev 15793)
+++
trunk/common/plugins/org.jboss.tools.common.meta.ui/src/org/jboss/tools/common/meta/ui/search/MetaSearchQuery.java 2009-06-09
00:50:43 UTC (rev 15794)
@@ -62,7 +62,11 @@
if(resource instanceof IContainer) {
IContainer c = (IContainer)resource;
IResource[] rs = null;
- try { rs = c.members(); } catch (Exception e) {}
+ try {
+ rs = c.members();
+ } catch (CoreException e) {
+ // TODO add activator and route error reporting to it
+ }
if(rs != null) for (int i = 0; i < rs.length; i++) processResource(rs[i]);
} else if(resource instanceof IFile) {
IFile f = (IFile)resource;
Modified:
trunk/common/plugins/org.jboss.tools.common.projecttemplates/src/org/jboss/tools/common/projecttemplates/ProjectTemplatesPlugin.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.projecttemplates/src/org/jboss/tools/common/projecttemplates/ProjectTemplatesPlugin.java 2009-06-08
22:05:10 UTC (rev 15793)
+++
trunk/common/plugins/org.jboss.tools.common.projecttemplates/src/org/jboss/tools/common/projecttemplates/ProjectTemplatesPlugin.java 2009-06-09
00:50:43 UTC (rev 15794)
@@ -12,6 +12,7 @@
import java.io.File;
import java.io.FileFilter;
+import java.io.IOException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
@@ -19,9 +20,9 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.common.util.FileUtil;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.jboss.tools.common.util.FileUtil;
public class ProjectTemplatesPlugin extends AbstractUIPlugin{
public static final String PLUGIN_ID =
"org.jboss.tools.common.projecttemplates";
@@ -41,11 +42,7 @@
public void start(BundleContext context) throws Exception {
super.start(context);
- try {
- copyProjectTemplates();
- } catch (Exception e) {
- log(e);
- }
+ copyProjectTemplates();
}
public static String getInstallPath() {
@@ -53,7 +50,7 @@
URL url = null;
try {
url = bundle == null ? null : FileLocator.resolve(bundle.getEntry("/"));
- } catch (Exception e) {
+ } catch (IOException e) {
url = bundle.getEntry("/");
}
return (url == null) ? null : url.getPath();
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java 2009-06-08
22:05:10 UTC (rev 15793)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/impl/VTaskImpl.java 2009-06-09
00:50:43 UTC (rev 15794)
@@ -8,7 +8,18 @@
import java.util.ArrayList;
import java.util.List;
-import org.jboss.tools.common.verification.vrules.*;
+
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.SafeRunner;
+import org.jboss.tools.common.verification.vrules.VAction;
+import org.jboss.tools.common.verification.vrules.VEntity;
+import org.jboss.tools.common.verification.vrules.VHelper;
+import org.jboss.tools.common.verification.vrules.VManager;
+import org.jboss.tools.common.verification.vrules.VObject;
+import org.jboss.tools.common.verification.vrules.VResult;
+import org.jboss.tools.common.verification.vrules.VRule;
+import org.jboss.tools.common.verification.vrules.VTask;
+import org.jboss.tools.common.verification.vrules.VTaskListener;
import org.jboss.tools.common.verification.vrules.plugin.VerificationPlugin;
/**
@@ -112,18 +123,20 @@
if(!running) return;
if (entity != null && entities[i] != null &&
entity.getName().equals(entities[i].getName())) {
VAction action = rule.getAction();
- if (action == null) continue;// should not happen
- try {
- VResult[] results = action.check(object);
- notifyApplied(rule, object, results);
- } catch (Exception e) {
- VerificationPlugin.getPluginLog().logError("Exception in action
"+action+" ignored: "+e, e);
+ if (action == null) {
+ continue;// should not happen
}
+ VResult[] results = action.check(object);
+ notifyApplied(rule, object, results);
checked = true;
- if (checkChildren) break;
+ if (checkChildren) {
+ break;
+ }
} else if (entity.isDescendant(entities[i].getName())) {
checkChildren = true;
- if (checked) break;
+ if (checked) {
+ break;
+ }
}
}
if (checkChildren) {
@@ -139,12 +152,7 @@
sleeping = false;
synchronized (listeners) {
for (int i = 0; i < listeners.size(); i++) {
- VTaskListener listener = (VTaskListener)listeners.get(i);
- try {
- listener.onStart();
- } catch (Exception e) {
- logListener(listener, e);
- }
+ SafeRunner.run(new OnStartNotifier((VTaskListener)listeners.get(i)));
}
}
}
@@ -156,12 +164,7 @@
private void notifyApplied(VRule rule, VObject object, VResult[] results) {
synchronized (listeners) {
for (int i = 0; i < listeners.size(); i++) {
- VTaskListener listener = (VTaskListener)listeners.get(i);
- try {
- listener.onRuleApplied(rule, object, results);
- } catch (Exception e) {
- logListener(listener, e);
- }
+ SafeRunner.run(new
OnRuleAppliedNotifier((VTaskListener)listeners.get(i),rule, object, results));
}
}
}
@@ -170,12 +173,7 @@
if(!running) return;
synchronized (listeners) {
for (int i = 0; i < listeners.size(); i++) {
- VTaskListener listener = (VTaskListener)listeners.get(i);
- try {
- listener.onRuleFinished(rule, object);
- } catch (Exception e) {
- logListener(listener, e);
- }
+ SafeRunner.run(new
OnRuleFinishedNotifier((VTaskListener)listeners.get(i),rule, object));
}
}
}
@@ -184,12 +182,7 @@
if(!running) return;
synchronized (listeners) {
for (int i = 0; i < listeners.size(); i++) {
- VTaskListener listener = (VTaskListener)listeners.get(i);
- try {
- listener.onPause();
- } catch (Exception e) {
- logListener(listener, e);
- }
+ SafeRunner.run(new OnPauseNotifier((VTaskListener)listeners.get(i)));
}
}
}
@@ -198,12 +191,7 @@
if(!running) return;
synchronized (listeners) {
for (int i = 0; i < listeners.size(); i++) {
- VTaskListener listener = (VTaskListener)listeners.get(i);
- try {
- listener.onResume();
- } catch (Exception e) {
- logListener(listener, e);
- }
+ SafeRunner.run(new OnResumeNotifier((VTaskListener)listeners.get(i)));
}
}
}
@@ -217,11 +205,7 @@
ls = (VTaskListener[])listeners.toArray(new VTaskListener[0]);
}
for (int i = 0; i < ls.length; i++) {
- try {
- ls[i].onFinish();
- } catch (Exception e) {
- logListener(ls[i], e);
- }
+ SafeRunner.run(new OnFinishNotifier(ls[i]));
}
}
@@ -237,4 +221,80 @@
}
}
+ public class SafeNotifier implements ISafeRunnable {
+
+ protected VTaskListener listener;
+
+ public SafeNotifier(VTaskListener listener) {
+ this.listener = listener;
+ }
+ public void run() throws Exception {
+ listener.onStart();
+ }
+ public void handleException(Throwable exception) {
+ logListener(listener, exception);
+ }
+ }
+
+ public class OnStartNotifier extends SafeNotifier {
+ public OnStartNotifier(VTaskListener listener) {
+ super(listener);
+ }
+ public void run() throws Exception {
+ listener.onStart();
+ }
+ }
+
+ public class OnPauseNotifier extends SafeNotifier {
+ public OnPauseNotifier(VTaskListener listener) {
+ super(listener);
+ }
+ public void run() throws Exception {
+ listener.onPause();
+ }
+ }
+
+ public class OnResumeNotifier extends SafeNotifier {
+ public OnResumeNotifier(VTaskListener listener) {
+ super(listener);
+ }
+ public void run() throws Exception {
+ listener.onResume();
+ }
+ }
+
+ public class OnFinishNotifier extends SafeNotifier {
+ public OnFinishNotifier(VTaskListener listener) {
+ super(listener);
+ }
+ public void run() throws Exception {
+ listener.onFinish();
+ }
+ }
+
+ public class OnRuleFinishedNotifier extends SafeNotifier {
+ VRule rule;
+ VObject object;
+ public OnRuleFinishedNotifier(VTaskListener listener,VRule rule, VObject object) {
+ super(listener);
+ this.rule = rule;
+ this.object = object;
+ }
+ public void run() throws Exception {
+ listener.onRuleFinished(rule, object);
+ }
+ }
+
+ public class OnRuleAppliedNotifier extends OnRuleFinishedNotifier {
+ VResult[] results;
+ public OnRuleAppliedNotifier(VTaskListener listener,VRule rule, VObject object,
VResult[] results) {
+ super(listener,rule,object);
+ this.results =results;
+ }
+ public void run() throws Exception {
+ listener.onRuleApplied(rule, object, results);
+ }
+ }
+
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java 2009-06-08
22:05:10 UTC (rev 15793)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VManagerModel.java 2009-06-09
00:50:43 UTC (rev 15794)
@@ -24,7 +24,6 @@
import org.jboss.tools.common.verification.vrules.impl.VManagerImpl;
import org.jboss.tools.common.verification.vrules.layer.VModelFactory;
import org.jboss.tools.common.verification.vrules.layer.VModelImpl;
-import org.jboss.tools.common.verification.vrules.plugin.VerificationPlugin;
/**
*
@@ -74,13 +73,7 @@
if(bundle != null) {
return bundle;
}
- try {
- bundle = ResourceBundle.getBundle(baseName);
- } catch (RuntimeException e) {
- if(VerificationPlugin.isDebugEnabled()) {
- VerificationPlugin.getPluginLog().logError(e);
- }
- }
+ bundle = ResourceBundle.getBundle(baseName);
Object bo = (bundle == null) ? (Object)"null" : bundle;
bundles.put(baseName, bo);
return bundle;
@@ -96,16 +89,10 @@
}
protected void loadChildren() {
- try {
- if(getParent() != null) VHelper.setManager(this);
- //it would be nice to remove this init
- //but then menu will not be initialized
- if (manager == null && getParent() != null) init();
- } catch (Exception e) {
- if(VerificationPlugin.isDebugEnabled()) {
- ModelPlugin.getPluginLog().logError(e);
- }
- }
+ if(getParent() != null) VHelper.setManager(this);
+ //it would be nice to remove this init
+ //but then menu will not be initialized
+ if (manager == null && getParent() != null) init();
}
public boolean addChild(XModelObject child) {
Modified:
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java 2009-06-08
22:05:10 UTC (rev 15793)
+++
trunk/common/plugins/org.jboss.tools.common.verification/src/org/jboss/tools/common/verification/vrules/model/VRuleSetsLoader.java 2009-06-09
00:50:43 UTC (rev 15794)
@@ -75,11 +75,11 @@
c.setAttributeValue("installed", "true");
installed.add(c.getPathPart());
}
- } catch (Exception e) {
- if(VerificationPlugin.isDebugEnabled()) {
- VerificationPlugin.getPluginLog().logError(e);
- }
- }
+ } catch (XModelException e) {
+ VerificationPlugin.getPluginLog().logError(e);
+ } catch (IOException e) {
+ VerificationPlugin.getPluginLog().logError(e);
+ }
}
XModelObject[] ch = object.getChildren();
for (int i = 0; i < ch.length; i++) {
Modified:
trunk/common/plugins/org.jboss.tools.common.verification.ui/src/org/jboss/tools/common/verification/ui/vrules/wizard/config/VRulesConfigurationWizard.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.verification.ui/src/org/jboss/tools/common/verification/ui/vrules/wizard/config/VRulesConfigurationWizard.java 2009-06-08
22:05:10 UTC (rev 15793)
+++
trunk/common/plugins/org.jboss.tools.common.verification.ui/src/org/jboss/tools/common/verification/ui/vrules/wizard/config/VRulesConfigurationWizard.java 2009-06-09
00:50:43 UTC (rev 15794)
@@ -10,17 +10,12 @@
******************************************************************************/
package org.jboss.tools.common.verification.ui.vrules.wizard.config;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizard;
public class VRulesConfigurationWizard extends AbstractQueryWizard {
public VRulesConfigurationWizard() {
- try {
- setView(new VRulesConfigurationWizardView());
- } catch (Exception e) {
- ModelPlugin.getPluginLog().logError(e);
- }
+ setView(new VRulesConfigurationWizardView());
}
}