summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-03-15 03:32:07 (EDT)
committerSteffen Kriese2011-03-15 03:32:07 (EDT)
commitdeb4bf9be6302b293e1e68d4f5f5b4c1dcabf4f3 (patch)
tree931210c800efd34364efc6a69fdf383665f0fc89
parent9da8738c713aa84b8271690c21f0f434fe41486a (diff)
downloadorg.eclipse.riena.toolbox-deb4bf9be6302b293e1e68d4f5f5b4c1dcabf4f3.zip
org.eclipse.riena.toolbox-deb4bf9be6302b293e1e68d4f5f5b4c1dcabf4f3.tar.gz
org.eclipse.riena.toolbox-deb4bf9be6302b293e1e68d4f5f5b4c1dcabf4f3.tar.bz2
Code Cleaning in toolbox
-rw-r--r--org.eclipse.riena.toolbox.feature/feature.xml4
-rw-r--r--org.eclipse.riena.toolbox.previewer/plugin.xml2
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ClassFinder.java65
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/Preview.java1
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/ReflectionUtil.java24
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/WorkbenchUtil.java19
6 files changed, 65 insertions, 50 deletions
diff --git a/org.eclipse.riena.toolbox.feature/feature.xml b/org.eclipse.riena.toolbox.feature/feature.xml
index 5eac0c1..8e5b963 100644
--- a/org.eclipse.riena.toolbox.feature/feature.xml
+++ b/org.eclipse.riena.toolbox.feature/feature.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="org.eclipse.riena.toolbox.feature"
- label="Riena Eclipse IDE Toolbox"
+ label="Riena AssemblyEditor"
version="3.0.0.qualifier">
<description>
- Riena Eclipse IDE Toolbox
+ Treebased Editor for Riena Assembly-Extensionpoint
</description>
<copyright>
diff --git a/org.eclipse.riena.toolbox.previewer/plugin.xml b/org.eclipse.riena.toolbox.previewer/plugin.xml
index e86fbc1..9843833 100644
--- a/org.eclipse.riena.toolbox.previewer/plugin.xml
+++ b/org.eclipse.riena.toolbox.previewer/plugin.xml
@@ -49,7 +49,7 @@
class="org.eclipse.riena.toolbox.previewer.ui.Preview"
icon="icons/sample.gif"
id="org.eclipse.riena.toolbox.previewer.ui.Preview"
- name="Riena Previewer"
+ name="Previewer"
restorable="true">
</view>
</extension>
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ClassFinder.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ClassFinder.java
index 9d9f578..edda865 100644
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ClassFinder.java
+++ b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ClassFinder.java
@@ -23,6 +23,7 @@ import org.eclipse.ui.part.ViewPart;
import org.eclipse.riena.toolbox.internal.previewer.Activator;
import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
+import org.eclipse.riena.toolbox.previewer.ui.WorkbenchUtil;
public class ClassFinder {
@@ -35,9 +36,10 @@ public class ClassFinder {
public ICompilationUnit getSelectionFromPackageExplorer() {
selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
- ITreeSelection selection = (ITreeSelection) selectionService.getSelection("org.eclipse.jdt.ui.PackageExplorer"); //$NON-NLS-1$
+ final ITreeSelection selection = (ITreeSelection) selectionService
+ .getSelection("org.eclipse.jdt.ui.PackageExplorer"); //$NON-NLS-1$
- Object firstSelection = selection.getFirstElement();
+ final Object firstSelection = selection.getFirstElement();
if (!(firstSelection instanceof ICompilationUnit)) {
return null;
@@ -46,15 +48,15 @@ public class ClassFinder {
return (ICompilationUnit) firstSelection;
}
- public ViewPartInfo loadClass(ICompilationUnit comp) {
+ public ViewPartInfo loadClass(final ICompilationUnit comp) {
- IPath path = comp.getPath();
+ final IPath path = comp.getPath();
if (path.segmentCount() < 2) {
return null;
}
- StringBuilder className = new StringBuilder();
+ final StringBuilder className = new StringBuilder();
for (int i = 2; i < path.segmentCount(); i++) {
String segment = path.segment(i);
@@ -68,43 +70,44 @@ public class ClassFinder {
}
}
- IPreviewCustomizer contrib = getContributedPreviewCustomizer();
+ final IPreviewCustomizer contrib = getContributedPreviewCustomizer();
Class<?> parentClass = ViewPart.class;
if (null != contrib && null != contrib.getParentClass()) {
- parentClass = contrib.getParentClass();
+ parentClass = contrib.getParentClass();
}
- URLClassLoader classLoader = createClassloader(parentClass.getClassLoader(), comp.getJavaProject());
+ final URLClassLoader classLoader = createClassloader(parentClass.getClassLoader(), comp.getJavaProject());
try {
if (null != contrib) {
contrib.beforeClassLoad(classLoader);
}
- Class<?> viewClass = classLoader.loadClass(className.toString());
+ final Class<?> viewClass = classLoader.loadClass(className.toString());
if (!isValidType(viewClass)) {
return null;
}
return new ViewPartInfo(className.toString(), viewClass, comp);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- } catch (IllegalArgumentException e) {
- throw new RuntimeException(e);
- } catch (SecurityException e) {
- throw new RuntimeException(e);
+ } catch (final ClassNotFoundException e) {
+ WorkbenchUtil.handleException(e);
+ } catch (final IllegalArgumentException e) {
+ WorkbenchUtil.handleException(e);
+ } catch (final SecurityException e) {
+ WorkbenchUtil.handleException(e);
}
+ return null;
}
public static IPreviewCustomizer getContributedPreviewCustomizer() {
- IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ final IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(
Activator.getDefault().getBundle().getSymbolicName() + ".previewCustomizer"); //$NON-NLS-1$
- for (IConfigurationElement elm : config) {
+ for (final IConfigurationElement elm : config) {
try {
- IPreviewCustomizer listenerContrib = (IPreviewCustomizer) elm.createExecutableExtension("class"); //$NON-NLS-1$
+ final IPreviewCustomizer listenerContrib = (IPreviewCustomizer) elm.createExecutableExtension("class"); //$NON-NLS-1$
return listenerContrib;
- } catch (CoreException e) {
- e.printStackTrace();
+ } catch (final CoreException e) {
+ WorkbenchUtil.handleException(e);
}
}
return null;
@@ -113,33 +116,35 @@ public class ClassFinder {
/**
* @param type
*/
- public boolean isValidType(Class<?> type) {
+ public boolean isValidType(final Class<?> type) {
return (Composite.class.isAssignableFrom(type) || ViewPart.class.isAssignableFrom(type));
}
- private URLClassLoader createClassloader(ClassLoader parentClass, IJavaProject project) {
+ private URLClassLoader createClassloader(final ClassLoader parentClass, final IJavaProject project) {
try {
String[] classPathEntries = null;
try {
classPathEntries = JavaRuntime.computeDefaultRuntimeClassPath(project);
- } catch (JavaModelException ex) {
+ } catch (final JavaModelException ex) {
+ WorkbenchUtil.handleException(ex);
return null;
}
- List<URL> urlList = new ArrayList<URL>();
- for (String entry : classPathEntries) {
+ final List<URL> urlList = new ArrayList<URL>();
+ for (final String entry : classPathEntries) {
urlList.add(new Path(entry).toFile().toURI().toURL());
}
- URL[] urls = (URL[]) urlList.toArray(new URL[urlList.size()]);
+ final URL[] urls = urlList.toArray(new URL[urlList.size()]);
return new URLClassLoader(urls, parentClass);
- } catch (CoreException e) {
- throw new RuntimeException(e);
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
+ } catch (final CoreException e) {
+ WorkbenchUtil.handleException(e);
+ } catch (final MalformedURLException e) {
+ WorkbenchUtil.handleException(e);
}
+ return null;
}
}
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/Preview.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/Preview.java
index 364009d..14f40f9 100644
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/Preview.java
+++ b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/Preview.java
@@ -193,6 +193,7 @@ public class Preview extends ViewPart {
}
} catch (final CoreException e) {
+ WorkbenchUtil.handleException(e);
throw new RuntimeException(e);
}
}
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/ReflectionUtil.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/ReflectionUtil.java
index ede683e..ee1d0c6 100644
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/ReflectionUtil.java
+++ b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/ReflectionUtil.java
@@ -25,11 +25,11 @@ public final class ReflectionUtil {
try {
method.invoke(viewPart, parent);
} catch (final IllegalArgumentException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
} catch (final IllegalAccessException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
} catch (final InvocationTargetException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
}
return true;
}
@@ -60,14 +60,15 @@ public final class ReflectionUtil {
constructor.setAccessible(true);
return constructor.newInstance(params);
} catch (final IllegalArgumentException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
} catch (final InstantiationException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
} catch (final IllegalAccessException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
} catch (final InvocationTargetException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
}
+ return null;
}
/**
@@ -77,14 +78,15 @@ public final class ReflectionUtil {
try {
return viewPart.getType().newInstance();
} catch (final IllegalArgumentException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
} catch (final SecurityException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
} catch (final InstantiationException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
} catch (final IllegalAccessException e) {
- throw new RuntimeException(e);
+ WorkbenchUtil.handleException(e);
}
+ return null;
}
private ReflectionUtil() {
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/WorkbenchUtil.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/WorkbenchUtil.java
index e0a1836..c923c25 100644
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/WorkbenchUtil.java
+++ b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/WorkbenchUtil.java
@@ -1,25 +1,32 @@
package org.eclipse.riena.toolbox.previewer.ui;
+import org.eclipse.core.runtime.Status;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.riena.toolbox.internal.previewer.Activator;
import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
public class WorkbenchUtil {
-
- public static void showView(ViewPartInfo info) {
- if (null == info){
+
+ public static void showView(final ViewPartInfo info) {
+ if (null == info) {
return;
}
try {
- IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- Preview previewer = (Preview) activePage.showView(Preview.ID);
+ final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ final Preview previewer = (Preview) activePage.showView(Preview.ID);
previewer.showView(info);
previewer.setFocus();
- } catch (PartInitException e) {
+ } catch (final PartInitException e) {
e.printStackTrace();
}
}
+
+ public static void handleException(final Exception e) {
+ Activator.getDefault().getLog().log(new Status(Status.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
+ throw new RuntimeException(e);
+ }
}