Author: dgolovin
Date: 2008-08-28 14:23:13 -0400 (Thu, 28 Aug 2008)
New Revision: 9945
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDocumentBuilderFactory.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlStore.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbQuery.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldResource.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/SchemaNodeFactory.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/AbstractModelActionDelegate.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/MultiPageContributor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/PropertiesTextEditorComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorSupport.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextMerge.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorStandAlone.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/dnd/TextEditorDrop.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/EditorsPreferencesPage.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/ReplaceTabsAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteAdapter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteTaglibInserter.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteViewPart.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/HttpUtil.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/DtdResolver.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SAXValidator.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SafeDocumentBuilderFactory.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLUtilities.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-893
Fix PMD violations
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/FileUtil.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -30,7 +30,7 @@
if(encoding == null) return new String(bs.bs, 0, bs.length);
try {
return new String(bs.bs, 0, bs.length, encoding);
- } catch (Exception e) {
+ } catch (UnsupportedEncodingException e) {
return new String(bs.bs, 0, bs.length);
}
}
@@ -46,7 +46,7 @@
br.close();
fr.close();
return new ReadBytes(bs, l);
- } catch (Exception e) {
+ } catch (IOException e) {
return null;
}
}
@@ -66,7 +66,7 @@
if(bs == null) return null;
try {
return new String(bs.bs, 0, bs.length, encoding);
- } catch (Exception e) {
+ } catch (UnsupportedEncodingException e) {
return null;
}
}
@@ -83,7 +83,7 @@
br.close();
fr.close();
return isText(new String(cs));
- } catch (Exception e) {
+ } catch (IOException e) {
return false;
}
}
@@ -108,7 +108,7 @@
sb.append(new String(b, 0, l));
}
is.close();
- } catch (Exception e) {
+ } catch (IOException e) {
CommonPlugin.getPluginLog().logError(e);
}
return sb.toString();
@@ -134,15 +134,17 @@
try {
if(f.isFile() && !isSameFile(f)) f.delete();
if(!f.exists()) f.createNewFile();
- } catch (Exception e) {
+ } catch (IOException e) {
CommonPlugin.getPluginLog().logError("Problem writing to file " +
f, e);
+ } catch (SecurityException e) {
+ CommonPlugin.getPluginLog().logError("Problem writing to file " +
f, e);
}
PrintWriter pw = new PrintWriter(new FileWriter(f));
pw.print(value);
pw.flush();
pw.close();
return true;
- } catch (Exception e) {
+ } catch (IOException e) {
return false;
}
}
@@ -174,7 +176,7 @@
os = new BufferedOutputStream(new FileOutputStream(dest), 16 * 1024);
copyStream(is, os);
return true;
- } catch (Exception e) {
+ } catch (IOException e) {
CommonPlugin.getPluginLog().logError(e);
return false;
} finally {
@@ -230,9 +232,9 @@
try {
String cn = f.getCanonicalFile().getName();
return fn.equals(cn);
- } catch (Exception e) {
+ } catch (IOException e) {
return false;
- }
+ }
}
public static void copyDir(File from, File to) {
@@ -377,7 +379,7 @@
} else {
try {
jos.putNextEntry(entry);
- } catch (Exception e) {
+ } catch (IOException e) {
return;
}
FileInputStream is = new FileInputStream(f);
@@ -485,7 +487,7 @@
char[] cs = new char[bs.length];
int l = r.read(cs, 0, cs.length);
return new String(cs, 0, l);
- } catch (Exception e) {
+ } catch (IOException e) {
if("UTF-8".equals(encoding)) return text;
return encode(text, "UTF-8");
}
@@ -534,9 +536,12 @@
pw.flush();
pw.close();
return true;
- } catch (Exception e) {
+ } catch (FileNotFoundException e) {
//ignore
return writeFileDefault(f, value);
+ } catch (UnsupportedEncodingException e) {
+ //ignore
+ return writeFileDefault(f, value);
}
}
@@ -569,7 +574,7 @@
}
validEncodings.add(encoding);
return encoding;
- } catch (Exception e) {
+ } catch (UnsupportedEncodingException e) {
invalidEncodings.add(encoding);
return defaultEncoding;
}
@@ -591,7 +596,7 @@
try {
String encoding = getEncoding(new String(bs, 0, i, "UTF-16"));
return validateEncoding(encoding, "UTF-16");
- } catch (Exception e) {
+ } catch (UnsupportedEncodingException e) {
return null;
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/HttpUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/HttpUtil.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/HttpUtil.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.util;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -37,7 +38,7 @@
* @return InputStream of responce to http GET request. Use proxy settings from
preferences.
* @throws Exception
*/
- public static InputStream getInputStreamFromUrlByGetMethod(String url) throws Exception
{
+ public static InputStream getInputStreamFromUrlByGetMethod(String url) throws
IOException {
InputStream is = executeGetMethod(url).getResponseBodyAsStream();
return is;
}
@@ -47,7 +48,7 @@
* @return InputStream of responce to http GET request. Use proxy settings from
preferences.
* @throws Exception
*/
- public static InputStream getInputStreamFromUrlByGetMethod(String url, IProxyService
proxyService) throws Exception {
+ public static InputStream getInputStreamFromUrlByGetMethod(String url, IProxyService
proxyService) throws IOException {
InputStream is = executeGetMethod(url, proxyService).getResponseBodyAsStream();
return is;
}
@@ -58,7 +59,7 @@
* @return Status code of responce to http GET request. Use given proxy settings.
* @throws Exception
*/
- public static int getStatusCodeFromUrlByGetMethod(String url, IProxyService
proxyService) throws Exception {
+ public static int getStatusCodeFromUrlByGetMethod(String url, IProxyService
proxyService) throws IOException {
int code = executeGetMethod(url, proxyService).getStatusCode();
return code;
}
@@ -68,7 +69,7 @@
* @return Status code of responce to http GET request. Use proxy settings from
preferences.
* @throws Exception
*/
- public static int getStatusCodeFromUrlByGetMethod(String url) throws Exception {
+ public static int getStatusCodeFromUrlByGetMethod(String url) throws IOException {
int code = executeGetMethod(url).getStatusCode();
return code;
}
@@ -78,7 +79,7 @@
* @return InputStream of responce to http POST request. Use proxy settings from
preferences.
* @throws Exception
*/
- public static InputStream getInputStreamFromUrlByPostMethod(String url) throws Exception
{
+ public static InputStream getInputStreamFromUrlByPostMethod(String url) throws
IOException {
InputStream is = executePostMethod(url).getResponseBodyAsStream();
return is;
}
@@ -89,7 +90,7 @@
* @return Status code of responce to http POST request. Use given proxy settings.
* @throws Exception
*/
- public static int getStatusCodeFromUrlByPostMethod(String url, IProxyService
proxyService) throws Exception {
+ public static int getStatusCodeFromUrlByPostMethod(String url, IProxyService
proxyService) throws IOException {
int code = executePostMethod(url, proxyService).getStatusCode();
return code;
}
@@ -99,17 +100,17 @@
* @return Status code of responce to http POST request. Use proxy settings from
preferences.
* @throws Exception
*/
- public static int getStatusCodeFromUrlByPostMethod(String url) throws Exception {
+ public static int getStatusCodeFromUrlByPostMethod(String url) throws IOException {
int code = executePostMethod(url).getStatusCode();
return code;
}
- private static GetMethod executeGetMethod(String url) throws Exception {
+ private static GetMethod executeGetMethod(String url) throws IOException {
IProxyService proxyService = getProxyService();
return executeGetMethod(url, proxyService);
}
- private static PostMethod executePostMethod(String url) throws Exception {
+ private static PostMethod executePostMethod(String url) throws IOException {
IProxyService proxyService = getProxyService();
return executePostMethod(url, proxyService);
}
@@ -120,14 +121,14 @@
* @return
* @throws Exception
*/
- public static GetMethod executeGetMethod(String url, IProxyService proxyService) throws
Exception {
+ public static GetMethod executeGetMethod(String url, IProxyService proxyService) throws
IOException {
GetMethod httpGet = new GetMethod(url);
HttpClient httpClient = createHttpClient(url, proxyService);
httpClient.executeMethod(httpGet);
return httpGet;
}
- private static PostMethod executePostMethod(String url, IProxyService proxyService)
throws Exception {
+ private static PostMethod executePostMethod(String url, IProxyService proxyService)
throws IOException {
PostMethod httpPost = new PostMethod(url);
HttpClient httpClient = createHttpClient(url, proxyService);
httpClient.executeMethod(httpPost);
@@ -139,11 +140,11 @@
* @return HttpClient with internet proxy settings;
* @throws Exception
*/
- public static HttpClient createHttpClient(String url) throws Exception {
+ public static HttpClient createHttpClient(String url) throws IOException {
return createHttpClient(url, getProxyService());
}
- private static HttpClient createHttpClient(String url, IProxyService proxyService)
throws Exception {
+ private static HttpClient createHttpClient(String url, IProxyService proxyService)
throws IOException {
HttpClient httpClient = new HttpClient();
if(proxyService.isProxiesEnabled()) {
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/DtdResolver.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/DtdResolver.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/DtdResolver.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -12,8 +12,10 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.Set;
@@ -78,7 +80,7 @@
} else if("jar".equals(url.getProtocol())) {
return url.openStream();
}
- } catch(Exception e) {
+ } catch(FileNotFoundException e) {
CommonPlugin.getPluginLog().logError("Error in DtdResolver: " +
e.getMessage());
}
}
@@ -98,10 +100,13 @@
if("http".equals(url.getProtocol())) {
is = HttpUtil.getInputStreamFromUrlByGetMethod(systemId);
}
- } catch (Exception e) {
+ } catch (MalformedURLException e) {
CommonPlugin.getPluginLog().logError( e.getMessage());
// don't handle any exeptions. Bug #ESL-306
- }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
return is;
}
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SAXValidator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SAXValidator.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SAXValidator.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -19,12 +19,13 @@
import org.apache.xerces.util.XMLCatalogResolver;
import org.apache.xerces.xni.XMLResourceIdentifier;
-import org.apache.xerces.xni.XNIException;
import org.eclipse.core.runtime.Platform;
import org.jboss.tools.common.CommonPlugin;
import org.jboss.tools.common.util.FileUtil;
import org.osgi.framework.Bundle;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;
@@ -56,7 +57,7 @@
try {
parserInstance =
XMLReaderFactory.createXMLReader(DEFAULT_SAX_PARSER_CLASS_NAME);
- } catch (Exception e) {
+ } catch (SAXException e) {
return null;
}
@@ -70,9 +71,11 @@
try {
parserInstance.setProperty(ENTITY_RESOLVER_PROPERTY_ID, new
XMLEntityResolverImpl());
- } catch (Exception e1) {
+ } catch (SAXNotRecognizedException e1) {
CommonPlugin.getPluginLog().logError( e1.getMessage()+"", e1);
- }
+ } catch (SAXNotSupportedException e1) {
+ CommonPlugin.getPluginLog().logError( e1.getMessage()+"", e1);
+ }
parserInstance.setContentHandler(handler);
parserInstance.setErrorHandler(handler);
@@ -124,11 +127,17 @@
return new String[]{ "error: Unable to instantiate parser
("+DEFAULT_SAX_PARSER_CLASS_NAME+")"};
parser.setErrorHandler(h);
parser.parse(is);
- } catch (Exception e) {
- if(h.errors.isEmpty())
+ } catch (SAXException e) {
+ if(h.errors.isEmpty()) {
// TODO - Move to NLS bundle
- return new String[]{"Unidentified parser error:0:0"};
- } finally {
+ return new String[]{"Unidentified parser error:0:0",e.getMessage()};
+ }
+ } catch (IOException e) {
+ if(h.errors.isEmpty()) {
+ // TODO - Move to NLS bundle
+ return new String[]{"Unidentified parser error:0:0",e.getMessage()};
+ }
+ } finally {
// Thread.currentThread().setContextClassLoader(cc);
}
return (String[])h.errors.toArray(new String[0]);
@@ -140,12 +149,8 @@
* @return
*/
public String[] getXMLErrors(Reader reader) {
- try {
org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader);
return getXMLErrors(inSource);
- } catch (Exception e) {
- return new String[]{e.getMessage()};
- }
}
/**
@@ -164,15 +169,13 @@
urlString = url.toString();
if(!urlString.endsWith("/")) urlString += "/";
urlString += "schemas";
- } catch (Exception e) {
+ } catch (IOException e) {
CommonPlugin.getPluginLog().logError(e);
}
File f1 = new File(url.getFile() + "/schemas/catalog.xml");
File f2 = new File(location + "schemas/catalog.xml");
- if(f2.exists()) try {
+ if(f2.exists()) {
return "file:///" + location + "schemas/catalog.xml";
- } catch (Exception e) {
- return null;
}
FileUtil.copyDir(f1.getParentFile(), f2.getParentFile(), true);
String text = FileUtil.readFile(f2);
@@ -200,7 +203,7 @@
/**
*
*/
- public String resolveIdentifier(XMLResourceIdentifier resourceIdentifier) throws
IOException, XNIException {
+ public String resolveIdentifier(XMLResourceIdentifier resourceIdentifier) throws
IOException {
String literal = resourceIdentifier.getLiteralSystemId();
if(literal != null && !literals.contains(literal)) {
literals.add(literal);
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SafeDocumentBuilderFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SafeDocumentBuilderFactory.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/SafeDocumentBuilderFactory.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -14,6 +14,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import org.jboss.tools.common.CommonPlugin;
import org.xml.sax.EntityResolver;
@@ -49,7 +50,7 @@
d.setEntityResolver(EMPTY_RESOLVER);
}
d.setErrorHandler(new ErrorHandlerImpl());
- } catch (Exception e) {
+ } catch (ParserConfigurationException e) {
CommonPlugin.getPluginLog().logError(e);
} finally {
Thread.currentThread().setContextClassLoader(loader);
@@ -64,7 +65,7 @@
try {
t.start();
t.join();
- } catch (Exception e) {
+ } catch (InterruptedException e) {
t.run();
}
return t.d;
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLEntityResolverImpl.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -14,12 +14,11 @@
import java.io.InputStream;
import org.apache.xerces.xni.XMLResourceIdentifier;
-import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLInputSource;
-
import org.eclipse.wst.wsdl.validation.internal.resolver.URIResolver;
import org.jboss.tools.common.CommonPlugin;
+import org.xml.sax.SAXException;
/**
* @author Igels
@@ -35,7 +34,7 @@
this.uriResolver = uriResolver;
}
- public XMLInputSource resolveEntity(XMLResourceIdentifier rid) throws XNIException,
IOException {
+ public XMLInputSource resolveEntity(XMLResourceIdentifier rid) throws IOException {
XMLInputSource result = null;
String systemId = null;
String publicId = null;
@@ -44,18 +43,13 @@
systemId =
rid.getBaseSystemId()==null?rid.getLiteralSystemId():rid.getExpandedSystemId();
publicId = rid.getPublicId();
- if(systemId != null && systemId.indexOf("www.ibm.com") >=
0) {
-// CommonPlugin.getPluginLog().logError( "ignore");
-// return null;
- }
-
InputStream is = resolver.getInputStream(rid.getPublicId(), systemId);
if(is!=null) {
result = new XMLInputSource(rid.getPublicId(), systemId,
rid.getBaseSystemId(), is, null);
}
- } catch (Exception e) {
+ } catch (SAXException e) {
CommonPlugin.getPluginLog().logError( "Exception publicId=" + publicId
+ " systemId=" + systemId + " exception=" + e.getClass().getName() +
":" + e.getMessage());
- }
+ }
return result;
}
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLUtilities.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLUtilities.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/xml/XMLUtilities.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -110,7 +110,7 @@
DOMImplementation domImpl = createDocumentBuilder().getDOMImplementation();
DocumentType docType = domImpl.createDocumentType(qName, publicId,
systemId);
d = domImpl.createDocument(namespaceURI, name, docType);
- } catch (Exception e) {
+ } catch (DOMException e) {
return null;
}
Element de = d.getDocumentElement();
@@ -141,7 +141,7 @@
} finally {
try {
if (fr != null) fr.close();
- } catch (Exception e) {
+ } catch (IOException e) {
CommonPlugin.getPluginLog().logError(e);
}
}
@@ -157,8 +157,10 @@
try {
org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader);
return getDocument(inSource, resolver);
- } catch (Exception e) {
+ } catch (SAXException e) {
return null;
+ } catch (IOException e) {
+ return null;
}
}
@@ -166,8 +168,10 @@
try {
org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(is);
return getElement(inSource, resolver);
- } catch (Exception e) {
+ } catch (SAXException e) {
return null;
+ } catch (IOException e) {
+ return null;
}
}
@@ -186,12 +190,8 @@
}
public static String[] getXMLErrors(Reader reader, boolean checkDTD, EntityResolver
resolver) {
- try {
- org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader);
- return getXMLErrors(inSource, checkDTD, resolver);
- } catch (Exception e) {
- return new String[]{e.getMessage()};
- }
+ org.xml.sax.InputSource inSource = new org.xml.sax.InputSource(reader);
+ return getXMLErrors(inSource, checkDTD, resolver);
}
public static String[] getXMLErrors(org.xml.sax.InputSource is, EntityResolver resolver)
{
@@ -205,9 +205,11 @@
if(resolver != null) builder.setEntityResolver(resolver);
builder.setErrorHandler(h);
builder.parse(is);
- } catch (Exception e) {
- if(h.errors.isEmpty()) return new String[]{"Unidentified parser
error:0:0"};
- }
+ } catch (IOException e) {
+ if(h.errors.isEmpty()) return new String[]{"Unexpected parser
error:0:0",e.toString()};
+ } catch (SAXException e) {
+ if(h.errors.isEmpty()) return new String[]{"Unexpected parser
error:0:0",e.toString()};
+ }
return h.errors.toArray(new String[0]);
}
@@ -219,13 +221,15 @@
serialize(element, new BufferedWriter(fw));
fw.close();
}
-
+ static final String ENCODING = "encoding=\"";
+ static final String UTF8 = "UTF-8";
+
public static String getEncoding(String body) {
- int i = body.indexOf("encoding=\"");
- if(i < 0) return "UTF-8";
- i = i + "encoding=\"".length();
+ int i = body.indexOf(ENCODING);
+ if(i < 0) return UTF8;
+ i = i + ENCODING.length();
int j = body.indexOf('"', i);
- if(j < 0) return "UTF-8";
+ if(j < 0) return UTF8;
return body.substring(i, j);
}
@@ -238,14 +242,14 @@
public static final boolean serialize(Element element, Writer w) throws IOException
{
if(element == null) return false;
- serialize(element, new XMLSerializer(w, createOutputFormat("UTF-8")));
+ serialize(element, new XMLSerializer(w, createOutputFormat(UTF8)));
w.close();
return true;
}
public static final boolean serialize(Element element, OutputStream w) throws
IOException {
if(element == null) return false;
- serialize(element, new XMLSerializer(w, createOutputFormat("UTF-8")));
+ serialize(element, new XMLSerializer(w, createOutputFormat(UTF8)));
w.close();
return true;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDocumentBuilderFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDocumentBuilderFactory.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbDocumentBuilderFactory.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -14,6 +14,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
@@ -29,7 +30,7 @@
public static synchronized DocumentBuilder createDocumentBuilder(boolean validating) {
try {
return new DocumentBuilderCreator().createDocumentBuilder(validating);
- } catch (Exception t) {
+ } catch (InterruptedException t) {
KbPlugin.getPluginLog().logError("Cannot create document builder.", t);
return null;
}
@@ -39,10 +40,11 @@
boolean validate = false;
DocumentBuilder documentBuilder = null;
- public DocumentBuilder createDocumentBuilder(boolean validate) throws Exception {
+ public DocumentBuilder createDocumentBuilder(boolean validate) throws
InterruptedException {
this.validate = validate;
setContextClassLoader(getClass().getClassLoader());
start();
+ // FIXME: Verify that we still need it
join();
return documentBuilder;
}
@@ -64,7 +66,7 @@
}
});
}
- } catch (Exception t) {
+ } catch (ParserConfigurationException t) {
KbPlugin.getPluginLog().logError("Document builder creation failed.", t);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlStore.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlStore.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbHtmlStore.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -11,6 +11,8 @@
package org.jboss.tools.common.kb;
import java.io.File;
+import java.io.IOException;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -18,11 +20,14 @@
import java.util.Map;
import java.util.StringTokenizer;
+import javax.xml.parsers.DocumentBuilder;
+
import org.jboss.tools.common.kb.configuration.KbConfigurationFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
/**
* @author eskimo
@@ -351,6 +356,8 @@
}
private synchronized boolean activateHtmlSchema() {
+ String ERR_CANNNOT_LOAD_SCHEME = "Can't load HTML schema
''{0}''"; //$NON-NLS-N$
+ String ERR_EXCEPTION_DURING_PARSING = "Exception happend during parsing
''{0}''"; //$NON-NLS-N$
if(htmlSchemaIsActivating()) {
return false;
}
@@ -361,16 +368,21 @@
File schemaLocation = new File(htmlSchemaLocation);
if((schemaLocation == null)||(!schemaLocation.exists())) {
- KbPlugin.getPluginLog().logError("Can't load HTML schema " +
schemaLocation);
+ KbPlugin.getPluginLog().logError(MessageFormat.format(ERR_CANNNOT_LOAD_SCHEME,
schemaLocation));
return false;
}
- try {
- htmlSchema = KbDocumentBuilderFactory.createDocumentBuilder(false).parse(new
File(htmlSchemaLocation));
- } catch (Exception e) {
- KbPlugin.getPluginLog().logError(e);
- return false;
+ DocumentBuilder builder = KbDocumentBuilderFactory.createDocumentBuilder(false);
+ if(builder!=null) {
+ try {
+ htmlSchema = builder.parse(new File(htmlSchemaLocation));
+ } catch (SAXException e) {
+ KbPlugin.getPluginLog().logError(MessageFormat.format(ERR_EXCEPTION_DURING_PARSING,
schemaLocation),e);
+ } catch (IOException e) {
+ KbPlugin.getPluginLog().logError(MessageFormat.format(ERR_EXCEPTION_DURING_PARSING,
schemaLocation),e);
+ }
}
+
return true;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbQuery.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbQuery.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbQuery.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -159,7 +159,7 @@
if(++endCode<s.length()) {
result.append(s.substring(endCode));
}
- } catch(Exception e) {
+ } catch(NumberFormatException e) {
String message = "ERROR: can't decode string=" + s;
KbPlugin.getPluginLog().logError(message, e);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldConvertor.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -21,6 +21,8 @@
import java.util.Properties;
import java.util.StringTokenizer;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.w3c.dom.CDATASection;
@@ -29,6 +31,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
/**
* Class helps to convert TLD to Schema
@@ -120,25 +123,31 @@
* @return
*/
public Document convertToSchema(InputStream inputStream, Properties attributes, boolean
jsfTld) {
+
+ final String ERR_CANNOT_PARSE_TLD = "ERROR: Can't parse TLD file for
converting to the Schema."; //$NON-NLS-N$
Document tldDocument = null;
+ Document schema = null;
+
try {
- tldDocument =
KbDocumentBuilderFactory.createDocumentBuilder(false).parse(inputStream);
- } catch (Exception e) {
- String message = "ERROR: Can't parse TLD file for converting to the
Schema.";
- KbPlugin.getPluginLog().logError(message, e);
- return null;
+ DocumentBuilder builder = KbDocumentBuilderFactory.createDocumentBuilder(false);
+ if(builder!=null) {
+ tldDocument = builder.parse(inputStream);
+ Element rootTldElement = tldDocument.getDocumentElement();
+
+ String prefix = getShortName(rootTldElement);
+ if((prefix!=null)&&(prefix.length()>0)) {
+ attributes.setProperty(SchemaNodeFactory.PREFIX_ATTRIBUTE, prefix);
+ }
+
+ schema = SchemaNodeFactory.getInstance().createSchemaDocument(attributes);
+ addElementTypes(rootTldElement, schema, jsfTld);
+ }
+ } catch (IOException e) {
+ KbPlugin.getPluginLog().logError(ERR_CANNOT_PARSE_TLD, e);
+ } catch (SAXException e) {
+ KbPlugin.getPluginLog().logError(ERR_CANNOT_PARSE_TLD, e);
}
-
- Element rootTldElement = tldDocument.getDocumentElement();
-
- String prefix = getShortName(rootTldElement);
- if((prefix!=null)&&(prefix.length()>0)) {
- attributes.setProperty(SchemaNodeFactory.PREFIX_ATTRIBUTE, prefix);
- }
-
- Document schema = SchemaNodeFactory.getInstance().createSchemaDocument(attributes);
- addElementTypes(rootTldElement, schema, jsfTld);
-
+
return schema;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldResource.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldResource.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldResource.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -14,8 +14,12 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
@@ -103,6 +107,7 @@
}
private InputStream getInputStreamFromTldLocation() {
+ final String ERR_TLD_FILE_DOSENT_EXIST = "ERROR: TLD file ''{0}''
doesn't exist!";
InputStream is = null;
if (tldLocation == null) {
return null;
@@ -135,12 +140,15 @@
}
}
*/
- } catch (Exception e) {
- if(KbPlugin.isDebugEnabled()) {
- String message = "ERROR: TLD file (" + tldLocation + ")
doesn't exist!";
- KbPlugin.getPluginLog().logError(message, e);
+ } catch (MalformedURLException e) {
+ if(KbPlugin.isDebugEnabled()) {
+
KbPlugin.getPluginLog().logError(MessageFormat.format(ERR_TLD_FILE_DOSENT_EXIST,
tldLocation), e);
}
- }
+ } catch (IOException e) {
+ if(KbPlugin.isDebugEnabled()) {
+
KbPlugin.getPluginLog().logError(MessageFormat.format(ERR_TLD_FILE_DOSENT_EXIST,
tldLocation), e);
+ }
+ }
return is;
}
@@ -234,7 +242,7 @@
try {
File file = new File(tldLocation);
lastModifiedTld = file.lastModified();
- } catch(Exception e) {
+ } catch(SecurityException e) {
return false;
}
/*
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/KbTldStore.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -25,6 +25,8 @@
import java.util.Map;
import java.util.Set;
+import javax.xml.parsers.DocumentBuilder;
+
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.eclipse.core.runtime.FileLocator;
@@ -42,6 +44,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
/**
* Describes store whish contains all TLD schemas.
@@ -570,13 +573,19 @@
Document document = null;
try {
- document =
KbDocumentBuilderFactory.createDocumentBuilder(false).parse(schemaLocation);
- } catch (Exception e) {
+ DocumentBuilder builder = KbDocumentBuilderFactory.createDocumentBuilder(false);
+ if(builder!=null) {
+ document = builder.parse(schemaLocation);
+ }
+ } catch (IOException e) {
KbPlugin.getPluginLog().logError(e);
- return;
+ } catch (SAXException e) {
+ KbPlugin.getPluginLog().logError(e);
}
-
- activeDocuments.put(regResource, document);
+
+ if(document!=null) {
+ activeDocuments.put(regResource, document);
+ }
}
private synchronized void activateResources(Collection resources) {
@@ -661,10 +670,18 @@
for(int i=0; i<schemas.length; i++) {
Document document = null;
try {
- document = KbDocumentBuilderFactory.createDocumentBuilder(false).parse(schemas[i]);
- } catch (Exception e) {
+ DocumentBuilder builder = KbDocumentBuilderFactory.createDocumentBuilder(false);
+ if(builder!=null) {
+ document = builder.parse(schemas[i]);
+ } else {
+ continue;
+ }
+ } catch (IOException e) {
KbPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, KbPlugin.PLUGIN_ID,
IStatus.OK, "Can't parse Schema (location: " + schemas[i] + ")",
e));
continue;
+ } catch (SAXException e) {
+ KbPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, KbPlugin.PLUGIN_ID,
IStatus.OK, "Can't parse Schema (location: " + schemas[i] + ")",
e));
+ continue;
}
// String tldLocation = schemas[i].getAbsolutePath();
String tldLocation =
document.getDocumentElement().getAttribute(SchemaNodeFactory.LOCATION_ATTRIBUTE);
@@ -1076,7 +1093,7 @@
os.close();
// TransformerFactory.newInstance().newTransformer().transform(new
DOMSource(document), new StreamResult(schemaFile));
- } catch (Exception e) {
+ } catch (IOException e) {
KbPlugin.getPluginLog().logError(e);
schemaFile.deleteOnExit();
loadingResources.remove(resource);
Modified:
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/SchemaNodeFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/SchemaNodeFactory.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.kb/src/org/jboss/tools/common/kb/SchemaNodeFactory.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -13,6 +13,8 @@
import java.util.Enumeration;
import java.util.Properties;
+import javax.xml.parsers.DocumentBuilder;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -72,7 +74,16 @@
* @return
*/
public Document createSchemaDocument(Properties attributes) {
- Document document =
KbDocumentBuilderFactory.createDocumentBuilder(false).newDocument();
+ Document document =
createSchemaDocument(KbDocumentBuilderFactory.createDocumentBuilder(false),attributes);
+ return document;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Document createSchemaDocument(DocumentBuilder builder, Properties attributes) {
+ Document document = builder.newDocument();
Element element = createDocumentElement(SCHEMA_NODE, document, new Properties());
initAttributes(element, attributes);
document.appendChild(element);
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ObjectMultiPageEditor.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -377,8 +377,16 @@
Method m = AbstractTextEditor.class.getDeclaredMethod("performSave", new
Class[]{boolean.class, IProgressMonitor.class});
m.setAccessible(true);
m.invoke(textEditor, new Object[]{Boolean.TRUE, monitor});
- } catch (Exception e) {
+ } catch (SecurityException e) {
ModelUIPlugin.getPluginLog().logError(e);
+ } catch (NoSuchMethodException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ } catch (IllegalArgumentException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ } catch (InvocationTargetException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ } catch (IllegalAccessException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
}
}
@@ -1096,11 +1104,7 @@
e.setInput(e2);
e.updateTitle();
if(e.textEditor instanceof AbstractTextEditor) {
- try {
- ((AbstractTextEditor)e.textEditor).setInput(e2);
- } catch (Exception exc) {
- ModelUIPlugin.getPluginLog().logError(exc);
- }
+ ((AbstractTextEditor)e.textEditor).setInput(e2);
((XModelObjectEditorInput)ei).synchronize();
if(((XModelObjectEditorInput)ei).getXModelObject() != o) {
closeEditor();
@@ -1348,8 +1352,12 @@
IActionDelegate delegate = null;
try {
delegate = (IActionDelegate)bundle.loadClass(actionClass).newInstance();
- } catch (Exception e) {
+ } catch (ClassNotFoundException e) {
//ignore
+ } catch (InstantiationException e) {
+ //ignore
+ } catch (IllegalAccessException e) {
+ //ignore
}
if(delegate == null) return;
delegate.selectionChanged(null, new StructuredSelection(resource));
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/TreeFormPage.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -459,7 +459,7 @@
public void doOperation(int operation) {
if (operation>actionMapping.size()) {
- ModelUIPlugin.getPluginLog().logError(new RuntimeException("Can not find global
action with index: "+operation));
+ ModelUIPlugin.getPluginLog().logError(new IllegalArgumentException("Can not find
global action with index: "+operation));
} else {
String globalAction = (String)actionMapping.get(operation);
this.doGlobalAction(globalAction);
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/AbstractModelActionDelegate.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/AbstractModelActionDelegate.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/action/AbstractModelActionDelegate.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -61,12 +61,12 @@
public void run(IAction action) {
try {
doRun();
- } catch (Exception e) {
+ } catch (XModelException e) {
ModelUIPlugin.getPluginLog().logError(e);
}
}
- protected abstract void doRun() throws Exception;
+ protected abstract void doRun() throws XModelException;
public void dispose() {}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/MultiPageContributor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/MultiPageContributor.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/MultiPageContributor.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -18,8 +18,6 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.wst.sse.ui.internal.actions.StructuredTextEditorActionConstants;
-
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.text.xml.xpl.ToggleOccurencesMarkUpAction;
/**
@@ -80,12 +78,8 @@
actionBars.updateActionBars();
}
- try {
- fToggleOccurencesMarkUp.setEditor(getTextEditor(part));
- fToggleOccurencesMarkUp.update();
- } catch (Exception x) {
- ModelUIPlugin.getPluginLog().logError(x);
- }
+ fToggleOccurencesMarkUp.setEditor(getTextEditor(part));
+ fToggleOccurencesMarkUp.update();
updateStatus();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/PropertiesTextEditorComponent.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/PropertiesTextEditorComponent.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/PropertiesTextEditorComponent.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -14,10 +14,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.tools.common.editor.ObjectTextEditor;
-import org.jboss.tools.common.propertieseditor.text.*;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import
org.jboss.tools.common.model.ui.texteditors.propertyeditor.PropertiesTextEditorStub;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
@@ -38,9 +34,12 @@
import org.eclipse.ui.texteditor.ResourceAction;
import org.eclipse.ui.texteditor.RevertToSavedAction;
import org.eclipse.ui.texteditor.SaveAction;
-
+import org.jboss.tools.common.editor.ObjectTextEditor;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
+import
org.jboss.tools.common.model.ui.texteditors.propertyeditor.PropertiesTextEditorStub;
+import org.jboss.tools.common.propertieseditor.text.PropertyTextEditorSupport;
/**
* @author Jeremy
@@ -93,11 +92,7 @@
String text = null;
if(getSourceViewer() == null) return null;
if(getSourceViewer().getDocument() == null) return null;
- try {
- text = getSourceViewer().getDocument().get();
- } catch (Exception ex) {
- ModelUIPlugin.getPluginLog().logError(ex);
- }
+ text = getSourceViewer().getDocument().get();
return (text == null) ? "" : text;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorComponent.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorComponent.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorComponent.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -10,22 +10,45 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.texteditors;
-import java.util.*;
-import org.eclipse.jface.preference.*;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.internal.ui.preferences.OverlayPreferenceStore;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.*;
-import org.eclipse.jface.text.source.*;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.custom.ST;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.jface.action.*;
-import org.eclipse.ui.texteditor.*;
-import org.eclipse.jdt.internal.ui.preferences.OverlayPreferenceStore;
-import org.jboss.tools.common.model.*;
+import org.eclipse.ui.texteditor.IStatusField;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.texteditor.ITextEditorExtension;
+import org.eclipse.ui.texteditor.TextNavigationAction;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
import org.jboss.tools.common.model.util.XModelObjectCache;
@@ -165,11 +188,7 @@
public String getText() {
String text = null;
- try {
- if (document != null) text = document.get();
- } catch (Exception ex) {
- ModelUIPlugin.getPluginLog().logError(ex);
- }
+ if (document != null) text = document.get();
return (text == null) ? "" : text;
}
@@ -183,7 +202,7 @@
try {
FileAnyImpl f = (FileAnyImpl)getModelObject();
if(f != null) f.edit(getText());
- } catch (Exception e) {
+ } catch (XModelException e) {
ModelUIPlugin.getPluginLog().logError(e);
} finally {
lock = false;
@@ -195,7 +214,7 @@
try {
int i = document.getLineOffset(line - 1) + position -1;
preview.setSelectedRange(i, 0);
- } catch (Exception e) {
+ } catch (BadLocationException e) {
//ignore
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorSupport.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorSupport.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextEditorSupport.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -11,11 +11,14 @@
package org.jboss.tools.common.model.ui.texteditors;
import java.util.Properties;
-import org.jboss.tools.common.meta.action.*;
-import org.jboss.tools.common.model.*;
+
+import org.jboss.tools.common.meta.action.XAction;
+import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.model.XModelException;
+import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.model.util.*;
+import org.jboss.tools.common.model.util.XModelObjectCache;
public class TextEditorSupport {
protected XModelObjectCache object = null;
@@ -55,11 +58,7 @@
protected String loadContent() {
XModelObject o = getModelObject();
- try {
- return ((FileAnyImpl)o).getAsText();
- } catch (Exception e) {
- return "";
- }
+ return ((FileAnyImpl)o).getAsText();
}
public void setModified(boolean set) {
@@ -87,7 +86,7 @@
try {
FileAnyImpl f = (FileAnyImpl)getModelObject();
if(f != null) f.edit(provider.getText());
- } catch (Exception e) {
+ } catch (XModelException e) {
ModelUIPlugin.getPluginLog().logError(e);
} finally {
lock--;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextMerge.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextMerge.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/TextMerge.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.texteditors;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
public class TextMerge {
@@ -45,7 +46,7 @@
}
try {
document.replace(b, e - b, text.substring(b, e2));
- } catch (Exception exc) {
+ } catch (BadLocationException exc) {
return false;
}
return true;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorComponent.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorComponent.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorComponent.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -21,9 +21,6 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.jboss.tools.common.editor.ObjectTextEditor;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.model.ui.texteditors.xmleditor.XMLTextEditor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
@@ -47,14 +44,17 @@
import org.eclipse.ui.texteditor.RevertToSavedAction;
import org.eclipse.ui.texteditor.SaveAction;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.jboss.tools.common.editor.ObjectTextEditor;
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.impl.DiscardFileHandler;
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
import org.jboss.tools.common.model.filesystems.impl.FolderLoader;
import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
+import org.jboss.tools.common.model.ui.texteditors.xmleditor.XMLTextEditor;
import org.jboss.tools.common.model.util.PositionSearcher;
-import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
public class XMLTextEditorComponent extends XMLTextEditor implements ObjectTextEditor,
ITextProvider {
protected TextEditorSupport support = createSupport();
@@ -202,7 +202,7 @@
}
if(old.isModified()) try {
new DiscardFileHandler().executeHandler(old, new Properties());
- } catch (Exception e) {
+ } catch (XModelException e) {
//ignore
// ModelUIPlugin.log(e);
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorStandAlone.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorStandAlone.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/XMLTextEditorStandAlone.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -11,19 +11,22 @@
package org.jboss.tools.common.model.ui.texteditors;
import org.eclipse.core.runtime.CoreException;
-import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
-import org.jboss.tools.common.model.ui.ModelUIPlugin;
-import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.*;
-
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.jboss.tools.common.core.resources.XModelObjectEditorInput;
import org.jboss.tools.common.meta.action.XAction;
import org.jboss.tools.common.meta.action.XActionInvoker;
+import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.event.XModelTreeListener;
import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
public class XMLTextEditorStandAlone extends XMLTextEditorComponent implements
XModelTreeListener {
protected XModelTreeListenerSWTSync syncListener = new XModelTreeListenerSWTSync(this);
@@ -67,7 +70,7 @@
} else if(o.getParent() instanceof FolderImpl) {
((FolderImpl)o.getParent()).discardChildFile(o);
}
- } catch (Exception e) {
+ } catch (XModelException e) {
//ignore
}
}
@@ -92,13 +95,9 @@
class U implements Runnable {
public void run() {
lock2 = true;
- try {
+ update0();
+ while(needsUpdate()) {
update0();
- while(needsUpdate()) {
- update0();
- }
- } catch (Exception t) {
- ModelUIPlugin.getPluginLog().logError("Error in updating editor", t);
}
lock2 = false;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/dnd/TextEditorDrop.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/dnd/TextEditorDrop.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/dnd/TextEditorDrop.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -73,45 +73,32 @@
}
private int getPosition(int x, int y) {
- try {
- ISourceViewer v = provider.getSourceViewer();
- StyledText t = v.getTextWidget();
- Point pp = t.toControl(x, y);
- x = pp.x;
- y = pp.y;
- int lineIndex = (t.getTopPixel() + y) / t.getLineHeight();
- if (lineIndex >= t.getLineCount()) {
- return t.getCharCount();
- } else {
- int c = 0;
- try {
- c = t.getOffsetAtLocation(new Point(x, y));
- if(c < 0) c = 0;
- } catch (Exception ex) {
- c = t.getOffsetAtLine(lineIndex + 1) -
- (t.getLineDelimiter() == null ? 0 :
t.getLineDelimiter().length());
- }
- return c;
- }
- } catch (Exception e) {
- return 0;
+ ISourceViewer v = provider.getSourceViewer();
+ StyledText t = v.getTextWidget();
+ Point pp = t.toControl(x, y);
+ x = pp.x;
+ y = pp.y;
+ int lineIndex = (t.getTopPixel() + y) / t.getLineHeight();
+ if (lineIndex >= t.getLineCount()) {
+ return t.getCharCount();
+ } else {
+ int c = 0;
+ c = t.getOffsetAtLocation(new Point(x, y));
+ if(c < 0) c = 0;
+ return c;
}
}
public void drop(Properties p) {
- try {
- ISourceViewer v = provider.getSourceViewer();
- int x = ((Integer)p.get("drop.x")).intValue();
- int y = ((Integer)p.get("drop.y")).intValue();
- int c = getPosition(x, y);
- Point sp = v.getTextWidget().getSelectionRange();
- if(sp == null || c < sp.x || c >= sp.x + sp.y) {
- v.getTextWidget().setCaretOffset(c);
- }
- provider.insert(p);
- } catch (Exception e) {
- ModelUIPlugin.getPluginLog().logError(e);
+ ISourceViewer v = provider.getSourceViewer();
+ int x = ((Integer)p.get("drop.x")).intValue();
+ int y = ((Integer)p.get("drop.y")).intValue();
+ int c = getPosition(x, y);
+ Point sp = v.getTextWidget().getSelectionRange();
+ if(sp == null || c < sp.x || c >= sp.x + sp.y) {
+ v.getTextWidget().setCaretOffset(c);
}
+ provider.insert(p);
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/EditorsPreferencesPage.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/EditorsPreferencesPage.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/EditorsPreferencesPage.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -33,16 +33,14 @@
private static XModel _getPreferenceModel() {
XModel model = ModelUtilities.getPreferenceModel();
- try {
- initialize();
- } catch (Exception t) {
- ModelUIPlugin.getPluginLog().logError("Error in initializing editors preference
page", t);
- }
+ initialize();
return model;
}
protected static IPreferenceStore store;
+
+ // FIXME: Remove Reflection
private static void initialize() {
if(store != null) return;
AbstractUIPlugin plugin =
(AbstractUIPlugin)Platform.getPlugin("org.jboss.tools.common.text.xml");
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/ReplaceTabsAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/ReplaceTabsAdapter.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/preferences/ReplaceTabsAdapter.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -29,11 +29,7 @@
XModelObject o = (XModelObject)object;
if(!o.isActive()) return;
if(EditorsPreferencesPage.store == null) return;
- try {
- EditorsPreferencesPage.store.setValue(PROPERTY, "true".equals(value));
- } catch (Exception e) {
- ModelUIPlugin.getPluginLog().logError(e);
- }
+ EditorsPreferencesPage.store.setValue(PROPERTY, "true".equals(value));
}
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/texteditors/xmleditor/XMLTextEditor.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -64,6 +64,7 @@
import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.model.XModelBuffer;
+import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.XModelTransferBuffer;
import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
@@ -153,8 +154,7 @@
setModified(false);
getDocumentListenerRegister().unregister();
getDocumentListenerRegister().register();
- try {
- Object dtid =
+ Object dtid =
getSourceViewer().getTextWidget().getData("DropTarget");
if (dtid != null) {
if (dtid instanceof DropTarget) {
@@ -181,64 +181,50 @@
}
public void dragEnter(DropTargetEvent event) {
- try {
- getFreeCaretControl(
- event.widget).enableFreeCaret(
- true);
- } catch (Exception x) {
- //ignore
- }
- }
+ FreeCaretStyledText fcst =getFreeCaretControl(
+ event.widget);
+ if(fcst != null) {
+ fcst.enableFreeCaret(true);
+ }
+ }
public void dragLeave(DropTargetEvent event) {
- try {
- getFreeCaretControl(
- event.widget).enableFreeCaret(
- false);
- } catch (Exception x) {
- //ignore
- }
- }
+ FreeCaretStyledText fcst =getFreeCaretControl(
+ event.widget);
+ if(fcst != null) {
+ fcst.enableFreeCaret(false);
+ }
+ }
public void dragOperationChanged(DropTargetEvent event) {
- try {
- getFreeCaretControl(
- event.widget).enableFreeCaret(
- false);
- } catch (Exception x) {
- //ignore
- }
- }
+ FreeCaretStyledText fcst =getFreeCaretControl(
+ event.widget);
+ if(fcst != null) {
+ fcst.enableFreeCaret(false);
+ }
+ }
public void dragOver(DropTargetEvent event) {
- try {
FreeCaretStyledText fcst =
getFreeCaretControl(event.widget);
- int pos = getPosition(fcst, event.x, event.y);
- Point p = fcst.getLocationAtOffset(pos);
- fcst.myRedraw(p.x, p.y);
- } catch (Exception x) {
- //ignore
- }
+ if(fcst != null) {
+ int pos = getPosition(fcst, event.x, event.y);
+ Point p = fcst.getLocationAtOffset(pos);
+ fcst.myRedraw(p.x, p.y);
+ }
}
public void drop(DropTargetEvent event) {
- try {
- getFreeCaretControl(
- event.widget).enableFreeCaret(
- false);
- } catch (Exception x) {
- //ignore
- }
+ FreeCaretStyledText fcst =getFreeCaretControl(
+ event.widget);
+ if(fcst != null) {
+ fcst.enableFreeCaret(false);
+ }
}
});
}
}
- } catch (Exception x) {
- //ignore
- }
-
}
/*
@@ -291,7 +277,7 @@
try {
FileAnyImpl f = (FileAnyImpl)getModelObject();
if(f != null) f.edit(getSourceViewer().getDocument().get());
- } catch (Exception e) {
+ } catch (XModelException e) {
ModelUIPlugin.getPluginLog().logError(e);
} finally {
setModified(false);
@@ -323,11 +309,7 @@
super.doSetInput(input);
this.input = input;
if (input instanceof IModelObjectEditorInput){
- try {
- object = ((IModelObjectEditorInput)input).getXModelObject();
- } catch (Exception ex) {
- ModelUIPlugin.getPluginLog().logError("Error while getting model object from
editor input", ex);
- }
+ object = ((IModelObjectEditorInput)input).getXModelObject();
}
if(getSourceViewer() != null && getSourceViewer().getDocument() != null) {
getDocumentListenerRegister().unregister();
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteAdapter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteAdapter.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteAdapter.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -43,6 +43,7 @@
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.event.ActionDeclinedException;
import org.jboss.tools.common.model.event.XModelTreeEvent;
@@ -406,7 +407,7 @@
} catch (ActionDeclinedException de) {
//ignore - this exception is thrown to inform that user
//selected cancel option in dialog.
- } catch (Exception e) {
+ } catch (XModelException e) {
message(e);
}
} else {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteInsertHelper.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -69,14 +69,10 @@
d.showDialog("Warning", mes, new String[]{"OK"}, null,
ServiceDialog.WARNING);
return;
}
- try {
- IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
- ISelectionProvider selProvider = editor.getSelectionProvider();
- p.put(PROPOPERTY_SELECTION_PROVIDER, selProvider);
- insertIntoEditorInternal(doc, p);
- } catch (Exception x) {
- ModelUIPlugin.getPluginLog().logError(x);
- }
+ IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ ISelectionProvider selProvider = editor.getSelectionProvider();
+ p.put(PROPOPERTY_SELECTION_PROVIDER, selProvider);
+ insertIntoEditorInternal(doc, p);
}
static boolean isEditable(ITextEditor editor) {
@@ -96,59 +92,51 @@
}
public static void insertIntoEditor(ISourceViewer v, Properties p) {
- try {
- String tagname = p.getProperty(PROPOPERTY_TAG_NAME);
- String startText = p.getProperty(PROPOPERTY_START_TEXT);
- String endText = p.getProperty(PROPOPERTY_END_TEXT);
- String uri = p.getProperty(PROPOPERTY_TAGLIBRARY_URI);
+ String tagname = p.getProperty(PROPOPERTY_TAG_NAME);
+ String startText = p.getProperty(PROPOPERTY_START_TEXT);
+ String endText = p.getProperty(PROPOPERTY_END_TEXT);
+ String uri = p.getProperty(PROPOPERTY_TAGLIBRARY_URI);
- ISelectionProvider selProvider =
(ISelectionProvider)p.get(PROPOPERTY_SELECTION_PROVIDER);
- if(selProvider == null) p.put(PROPOPERTY_SELECTION_PROVIDER,
v.getSelectionProvider());
+ ISelectionProvider selProvider =
(ISelectionProvider)p.get(PROPOPERTY_SELECTION_PROVIDER);
+ if(selProvider == null) p.put(PROPOPERTY_SELECTION_PROVIDER, v.getSelectionProvider());
- IDocument d = v.getDocument();
- String[] texts = new String[]{startText, endText};
+ IDocument d = v.getDocument();
+ String[] texts = new String[]{startText, endText};
- if(startText!=null && startText.startsWith("<%@ taglib")) {
- if(PaletteTaglibInserter.inserTaglibInXml(v, p)) {
- return;
- }
- } else {
- p = PaletteTaglibInserter.inserTaglib(v, p);
- }
+ if(startText!=null && startText.startsWith("<%@ taglib")) {
+ if(PaletteTaglibInserter.inserTaglibInXml(v, p)) {
+ return;
+ }
+ } else {
+ p = PaletteTaglibInserter.inserTaglib(v, p);
+ }
- String defaultPrefix = p.getProperty(PROPOPERTY_DEFAULT_PREFIX);
- applyPrefix(texts, d, tagname, uri, defaultPrefix);
- startText = texts[0];
- endText = texts[1];
+ String defaultPrefix = p.getProperty(PROPOPERTY_DEFAULT_PREFIX);
+ applyPrefix(texts, d, tagname, uri, defaultPrefix);
+ startText = texts[0];
+ endText = texts[1];
- if(startText != null) p.setProperty(PROPOPERTY_START_TEXT, startText);
- if(endText != null) p.setProperty(PROPOPERTY_END_TEXT, endText);
+ if(startText != null) p.setProperty(PROPOPERTY_START_TEXT, startText);
+ if(endText != null) p.setProperty(PROPOPERTY_END_TEXT, endText);
- try {
- if (v != null ) {
- IEditorPart activeEditor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- IDocument doc = v.getDocument();
- insertIntoEditorInternal(doc, p);
- /*
- * Leave as is
- */
- if(v instanceof IIgnoreSelection) {
- ((IIgnoreSelection)v).setIgnore(true);
- }
- if (activeEditor != null)
- activeEditor.getSite().getPage().activate(activeEditor);
- /*
- * Set Ignore false, to prevent focus losing.
- */
- if(v instanceof IIgnoreSelection) {
- ((IIgnoreSelection)v).setIgnore(false);
- }
- }
- } catch (Exception x) {
- ModelUIPlugin.getPluginLog().logError("Error while inserting text into
editor", x);
- }
- } catch (Exception e) {
- ModelUIPlugin.getPluginLog().logError(e);
+ if (v != null ) {
+ IEditorPart activeEditor =
ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ IDocument doc = v.getDocument();
+ insertIntoEditorInternal(doc, p);
+ /*
+ * Leave as is
+ */
+ if(v instanceof IIgnoreSelection) {
+ ((IIgnoreSelection)v).setIgnore(true);
+ }
+ if (activeEditor != null)
+ activeEditor.getSite().getPage().activate(activeEditor);
+ /*
+ * Set Ignore false, to prevent focus losing.
+ */
+ if(v instanceof IIgnoreSelection) {
+ ((IIgnoreSelection)v).setIgnore(false);
+ }
}
}
@@ -265,7 +253,7 @@
if (lineOffset + lineLength - offset - length == 0)
appendLastDelimiter = false;
- } catch (Exception ex) {
+ } catch (BadLocationException ex) {
ModelUIPlugin.getPluginLog().logError(ex);
}
@@ -343,12 +331,7 @@
}
private static int getTabWidth() {
- try {
- return Platform.getPreferencesService().getInt("org.eclipse.ui.editors",
AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4, new
IScopeContext[]{new InstanceScope()});
- } catch (Exception e) {
- ModelUIPlugin.getPluginLog().logError(e);
- return 4;
- }
+ return Platform.getPreferencesService().getInt("org.eclipse.ui.editors",
AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4, new
IScopeContext[]{new InstanceScope()});
}
private static boolean useSpaces() {
@@ -440,7 +423,7 @@
int line = d.getLineOfOffset(offset);
String lineText = d.get(d.getLineOffset(line), d.getLineLength(line));
return getIndentOfLine(lineText, getLineDelimiter(d));
- } catch (Exception ex) {
+ } catch (BadLocationException ex) {
ModelUIPlugin.getPluginLog().logError(ex);
}
return indent;
@@ -504,14 +487,10 @@
public static void applyPrefix(String[] text, ITextEditor editor, String tagname, String
uri, String defaultPrefix) {
if(defaultPrefix == null || defaultPrefix.length() == 0) return;
IDocument doc = null;
- try {
- if(editor != null && editor.getDocumentProvider() != null) {
- doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
- }
- } catch (Exception x) {
- ModelUIPlugin.getPluginLog().logError(x);
- }
- applyPrefix(text, doc, tagname, uri, defaultPrefix);
+ if(editor != null && editor.getDocumentProvider() != null) {
+ doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ }
+ applyPrefix(text, doc, tagname, uri, defaultPrefix);
}
public static void applyPrefix(String[] text, IDocument doc, String tagname, String uri,
String defaultPrefix) {
@@ -540,13 +519,9 @@
String uri = "";
String defaultPrefix = "";
String pr = "";
- try {
- uri = text.substring(i + 8, j1);
- defaultPrefix = text.substring(j1 + 1, j);
- pr = prefixes.getProperty(uri, defaultPrefix);
- } catch (Exception e) {
- ModelUIPlugin.getPluginLog().logError(e);
- }
+ uri = text.substring(i + 8, j1);
+ defaultPrefix = text.substring(j1 + 1, j);
+ pr = prefixes.getProperty(uri, defaultPrefix);
if(pr.length() > 0) {
text = text.substring(0, i) + pr + ":" + text.substring(j + 1);
} else {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteTaglibInserter.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteTaglibInserter.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteTaglibInserter.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -14,6 +14,7 @@
import java.util.List;
import java.util.Properties;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.source.ISourceViewer;
@@ -108,7 +109,7 @@
}
}
}
- } catch (Exception e) {
+ } catch (BadLocationException e) {
ModelUIPlugin.getPluginLog().logError(e);
} finally {
if (model != null) model.releaseFromRead();
@@ -200,8 +201,6 @@
checkTL(root, v, p, d);
return true;
}
- } catch (Exception e) {
- ModelUIPlugin.getPluginLog().logError(e);
} finally {
if (model != null) model.releaseFromRead();
}
@@ -282,7 +281,7 @@
}
selectedSource.insert(selectedSource.length()-1, attribute);
d.replace(so, seo-so, selectedSource.toString());
- } catch (Exception t) {
+ } catch (BadLocationException t) {
ModelUIPlugin.getPluginLog().logError("", t);
}
}
@@ -330,7 +329,7 @@
return st;
}
- private static boolean checkplace(IDOMDocument xmlDocument, IDocument d, String st,
StringBuffer tg, Properties p, ISourceViewer v) throws Exception {
+ private static boolean checkplace(IDOMDocument xmlDocument, IDocument d, String st,
StringBuffer tg, Properties p, ISourceViewer v) throws BadLocationException {
NodeList nl = xmlDocument.getChildNodes();
boolean docType = false;
IndexedRegion irdt = null;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteViewPart.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteViewPart.java 2008-08-28
15:51:57 UTC (rev 9944)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/views/palette/PaletteViewPart.java 2008-08-28
18:23:13 UTC (rev 9945)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.model.ui.views.palette;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;
import org.eclipse.core.runtime.Platform;
@@ -37,6 +38,7 @@
import org.jboss.tools.jst.web.tld.URIConstants;
public class PaletteViewPart extends ViewPart implements IPartListener {
+
public static final String VIEW_ID =
"org.jboss.tools.common.model.ui.views.palette.PaletteView";
public static final String PALETTE_GEF_ID = "org.jboss.tools.vpe.ui.palette";
@@ -68,8 +70,12 @@
Bundle b = Platform.getBundle(PALETTE_GEF_ID);
Class cls = b == null ? null :
b.loadClass("org.jboss.tools.vpe.ui.palette.PaletteAdapter");
if(cls != null) return (IPaletteAdapter)cls.newInstance();
- } catch (Exception t) {
+ } catch (ClassNotFoundException t) {
//ignore
+ } catch (InstantiationException e) {
+ //ignore
+ } catch (IllegalAccessException e) {
+ //ignore
}
return new PaletteAdapter();
}
@@ -178,9 +184,15 @@
return true;
} catch (NoSuchMethodException ne) {
return false;
- } catch (Exception e) {
+ } catch (IllegalAccessException e) {
ModelUIPlugin.getPluginLog().logError(e);
return false;
+ } catch (IllegalArgumentException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ return false;
+ } catch (InvocationTargetException e) {
+ ModelUIPlugin.getPluginLog().logError(e);
+ return false;
}
}
private boolean dropIntoEditor2(ITextEditor editor, XModelObject macro) {
@@ -200,6 +212,10 @@
return lastPart != null; //lastTextEditor != null;
}
+ // TODO: NLS support
+ private static final String ERROR_GETTING_ACTIVE_EDITOR = "Error while getting
active text editor";
+
+ // FIXME: Rewrite without reflection
private ITextEditor getActiveTextEditor(IWorkbenchPart part) {
ITextEditor editor = null;
if (part instanceof EditorPartWrapper) {
@@ -215,8 +231,14 @@
if (o instanceof ITextEditor) {
editor = (ITextEditor)o;
}
- } catch (Exception t) {
- ModelUIPlugin.getPluginLog().logError("Error while getting active text
editor", t);
+ } catch (NoSuchMethodException t) {
+ ModelUIPlugin.getPluginLog().logError(ERROR_GETTING_ACTIVE_EDITOR, t);
+ } catch (IllegalArgumentException t) {
+ ModelUIPlugin.getPluginLog().logError(ERROR_GETTING_ACTIVE_EDITOR, t);
+ } catch (IllegalAccessException t) {
+ ModelUIPlugin.getPluginLog().logError(ERROR_GETTING_ACTIVE_EDITOR, t);
+ } catch (InvocationTargetException t) {
+ ModelUIPlugin.getPluginLog().logError(ERROR_GETTING_ACTIVE_EDITOR, t);
}
}
return editor;