summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-03-02 04:24:22 (EST)
committerSteffen Kriese2011-03-02 04:24:22 (EST)
commit4ce8bb3512256fdb22ead57fed3c7757af1ad71b (patch)
treebb329643bbb023a6209ae3e22cf37dcd4a558861
parent3c765d0d4a584dbdf216199312b56e646c97751b (diff)
downloadorg.eclipse.riena.toolbox-4ce8bb3512256fdb22ead57fed3c7757af1ad71b.zip
org.eclipse.riena.toolbox-4ce8bb3512256fdb22ead57fed3c7757af1ad71b.tar.gz
org.eclipse.riena.toolbox-4ce8bb3512256fdb22ead57fed3c7757af1ad71b.tar.bz2
code cleaning: toolbox previewer
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/internal/previewer/Activator.java3
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ClassFinder.java5
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/WorkspaceEquinoxContainer.java98
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/CompilationUnitPropertyTester.java5
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewActiveEditorHandler.java27
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewPackageExplorerSelectionHandler.java1
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/Preview.java10
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/ReflectionUtil.java3
-rw-r--r--org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/ui/WorkbenchUtil.java3
9 files changed, 31 insertions, 124 deletions
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/internal/previewer/Activator.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/internal/previewer/Activator.java
index 3ef98b1..bb9fad7 100644
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/internal/previewer/Activator.java
+++ b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/internal/previewer/Activator.java
@@ -2,9 +2,10 @@ package org.eclipse.riena.toolbox.internal.previewer;
import java.beans.Beans;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
/**
* The activator class controls the plug-in life cycle
*/
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 289f820..9d9f578 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
@@ -16,13 +16,14 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.riena.toolbox.internal.previewer.Activator;
-import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.riena.toolbox.internal.previewer.Activator;
+import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
+
public class ClassFinder {
private static final String EXTENSION_JAVA = ".java"; //$NON-NLS-1$
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/WorkspaceEquinoxContainer.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/WorkspaceEquinoxContainer.java
deleted file mode 100644
index c3c5cdf..0000000
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/WorkspaceEquinoxContainer.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.riena.toolbox.previewer;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-
-public class WorkspaceEquinoxContainer {
- private Object bundleContext;
-
- public void start() {
- String args[] = { "-consoleLog"};
- try {
- bundleContext = createClassLoader();
-
- for (IProject workspaceProject : ResourcesPlugin.getWorkspace().getRoot().getProjects()){
- String bundleLocation = "file://" + getWorkspacePath() + workspaceProject.getName();
- System.out.println("install bundle " + bundleLocation);
- installBundle(bundleLocation);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- private Object installBundle(String bundlePath){
- try {
- Method installBundle = bundleContext.getClass().getMethod("installBundle", String.class); //$NON-NLS-1$
- installBundle.invoke(bundleContext, bundlePath);
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
- private String getWorkspacePath(){
-// IWorkspace workspace = ResourcesPlugin.getWorkspace();
-// IWorkspaceRoot root = workspace.getRoot();
-// IPath location = root.getLocation();
- return "C:/build/workspaces/toolbox_runtime3/";
- }
-
- @SuppressWarnings("restriction")
- private Object createClassLoader(){
- try {
- //ClassLoader parentClassLoder = BundleContextImpl.class.getClassLoader();
- ClassLoader parentClassLoder = null;
- URLClassLoader equinoxClassLoader = new URLClassLoader(new URL[]{new Path("C:/build/develop/eclipse-SDK-3.7M2a-win32/eclipse/plugins/org.eclipse.osgi_3.7.0.v20100910.jar").toFile().toURI().toURL()}, parentClassLoder); //$NON-NLS-1$
- Class<?> eclipseStarterClass = equinoxClassLoader.loadClass("org.eclipse.core.runtime.adaptor.EclipseStarter"); //$NON-NLS-1$
- Object eclipseStarter = eclipseStarterClass.newInstance();
- Method startupMethod = eclipseStarter.getClass().getMethod("startup", String[].class, Runnable.class); //$NON-NLS-1$
- return startupMethod.invoke(eclipseStarter, new String[]{"-consoleLog -console 12345"}, null);
- } catch (MalformedURLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SecurityException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-}
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/CompilationUnitPropertyTester.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/CompilationUnitPropertyTester.java
index 5c572fe..13a960b 100644
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/CompilationUnitPropertyTester.java
+++ b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/CompilationUnitPropertyTester.java
@@ -2,11 +2,12 @@ package org.eclipse.riena.toolbox.previewer.handler;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.riena.toolbox.previewer.ClassFinder;
-import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.riena.toolbox.previewer.ClassFinder;
+import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
+
/**
* Checks if a given {@link ICompilationUnit} is a instance of {@link Composite} or {@link ViewPart}.
*
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewActiveEditorHandler.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewActiveEditorHandler.java
index 62bb750..749bf3d 100644
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewActiveEditorHandler.java
+++ b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewActiveEditorHandler.java
@@ -7,30 +7,31 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
import org.eclipse.jdt.ui.IWorkingCopyManager;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.handlers.HandlerUtil;
+
import org.eclipse.riena.toolbox.previewer.ClassFinder;
import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
import org.eclipse.riena.toolbox.previewer.ui.Preview;
import org.eclipse.riena.toolbox.previewer.ui.WorkbenchUtil;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
/**
- * Shows the content of the active editor in the {@link Preview}
- *
+ * Shows the content of the active editor in the {@link Preview}
+ *
*/
+@SuppressWarnings("restriction")
public class PreviewActiveEditorHandler extends AbstractHandler {
- @SuppressWarnings("restriction")
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
-
- if (activeEditor instanceof CompilationUnitEditor){
- IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
- ICompilationUnit unit= manager.getWorkingCopy(activeEditor.getEditorInput());
- ViewPartInfo viewPart = new ClassFinder().loadClass(unit);
+ public Object execute(final ExecutionEvent event) throws ExecutionException {
+ final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
+
+ if (activeEditor instanceof CompilationUnitEditor) {
+ final IWorkingCopyManager manager = JavaPlugin.getDefault().getWorkingCopyManager();
+ final ICompilationUnit unit = manager.getWorkingCopy(activeEditor.getEditorInput());
+ final ViewPartInfo viewPart = new ClassFinder().loadClass(unit);
WorkbenchUtil.showView(viewPart);
}
-
+
return null;
}
diff --git a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewPackageExplorerSelectionHandler.java b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewPackageExplorerSelectionHandler.java
index 8ec038c..8e0e397 100644
--- a/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewPackageExplorerSelectionHandler.java
+++ b/org.eclipse.riena.toolbox.previewer/src/org/eclipse/riena/toolbox/previewer/handler/PreviewPackageExplorerSelectionHandler.java
@@ -3,6 +3,7 @@ package org.eclipse.riena.toolbox.previewer.handler;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+
import org.eclipse.riena.toolbox.previewer.ClassFinder;
import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
import org.eclipse.riena.toolbox.previewer.ui.WorkbenchUtil;
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 3558a6a..b42883e 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
@@ -8,10 +8,6 @@ import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.ContributionItem;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.riena.toolbox.previewer.ClassFinder;
-import org.eclipse.riena.toolbox.previewer.IPreviewCustomizer;
-import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -25,11 +21,13 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.riena.toolbox.previewer.ClassFinder;
+import org.eclipse.riena.toolbox.previewer.IPreviewCustomizer;
+import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
+
public class Preview extends ViewPart{
public final static String ID = "org.eclipse.riena.toolbox.previewer.ui.Preview"; //$NON-NLS-1$
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 994a2b4..44f290c 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
@@ -5,10 +5,11 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
-import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
+
public final class 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 3b273c6..e0a1836 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,10 +1,11 @@
package org.eclipse.riena.toolbox.previewer.ui;
-import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.riena.toolbox.previewer.model.ViewPartInfo;
+
public class WorkbenchUtil {
public static void showView(ViewPartInfo info) {