summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-10-17 09:04:50 (EDT)
committerSteffen Kriese2011-10-17 09:04:50 (EDT)
commit60c7daf156ef782b6b1705ea84ef5a9c4ab3605e (patch)
treed04ee79105493c3f18235193780699b1f5197936
parent968dbab38265c9b3ab83b731681617bee5aa679f (diff)
downloadorg.eclipse.riena.toolbox-60c7daf156ef782b6b1705ea84ef5a9c4ab3605e.zip
org.eclipse.riena.toolbox-60c7daf156ef782b6b1705ea84ef5a9c4ab3605e.tar.gz
org.eclipse.riena.toolbox-60c7daf156ef782b6b1705ea84ef5a9c4ab3605e.tar.bz2
improved adduicontrol-parsing and fixed bug when generating configuRidgets
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/ReflectionUtil.java28
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ApplicationPreviewer.java73
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/CodeGenerator.java4
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/RidgetGenerator.java4
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/SWTControlInstantiationVisitor.java21
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/views/AssemblyView.java73
6 files changed, 25 insertions, 178 deletions
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/ReflectionUtil.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/ReflectionUtil.java
index 7468632..5992334 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/ReflectionUtil.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/ReflectionUtil.java
@@ -11,10 +11,11 @@
package org.eclipse.riena.toolbox;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.riena.core.util.ReflectionFailure;
+import org.eclipse.riena.core.util.ReflectionUtils;
import org.eclipse.riena.toolbox.assemblyeditor.model.ViewPartInfo;
// FIXME move ReflectionUtil to common-bundle
@@ -27,25 +28,14 @@ public final class ReflectionUtil {
* @throws InvocationTargetException
*/
public static boolean invokeMethod(final String methodName, final Object viewPart, final Composite parent) {
- for (final Method method : viewPart.getClass().getDeclaredMethods()) {
- if (methodName.equals(method.getName())) {
- method.setAccessible(true);
- try {
- method.invoke(viewPart, parent);
- return true;
- } catch (final IllegalArgumentException e) {
- Util.showError(e);
- return false;
- } catch (final IllegalAccessException e) {
- Util.showError(e);
- return false;
- } catch (final InvocationTargetException e) {
- Util.showError(e);
- return false;
- }
- }
+ try {
+
+ ReflectionUtils.invokeHidden(viewPart, methodName, parent);
+ return true;
+ } catch (final ReflectionFailure f) {
+ Util.logError(f);
+ return false;
}
- return false;
}
/**
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ApplicationPreviewer.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ApplicationPreviewer.java
deleted file mode 100644
index eed5876..0000000
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ApplicationPreviewer.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 compeople AG and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * compeople AG - initial API and implementation
- *******************************************************************************/
-package org.eclipse.riena.toolbox.assemblyeditor;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-import org.eclipse.osgi.framework.internal.core.EquinoxLauncher;
-
-/**
- *
- */
-@SuppressWarnings("restriction")
-public class ApplicationPreviewer {
-
- private final static String TP = "reference:file:/C:/build/targets/Riena-target-201104130523-win32/eclipse/plugins/"; //$NON-NLS-1$
-
- private final List<String> targetPlatformBundles = Arrays.asList(new String[] {//
- "com.caucho.hessian_3.2.0.jar", //
- "org.eclipse.core.databinding_1.4.0.I20110111-0800.jar",//
- "org.eclipse.core.databinding.beans_1.2.100.I20100824-0800.jar",//
- "org.eclipse.core.databinding.property_1.4.0.I20110222-0800.jar",//
- "org.eclipse.riena.beans.common_3.0.0.HEAD.jar", //
- "org.eclipse.riena.communication.console_3.0.0.HEAD.jar",//
- "org.eclipse.riena.communication.core_3.0.0.HEAD.jar",//
- "org.eclipse.riena.communication.factory.hessian_3.0.0.HEAD.jar",//
- "org.eclipse.riena.core_3.0.0.HEAD.jar",//
- "org.eclipse.riena.ui.common_3.0.0.HEAD",//
- "org.eclipse.riena.ui.core_3.0.0.HEAD",//
- "org.eclipse.riena.ui.filter_3.0.0.HEAD",//
- "org.eclipse.riena.ui.ridgets_3.0.0.HEAD",//
- "org.eclipse.riena.ui.ridgets.swt_3.0.0.HEAD",//
- "org.eclipse.riena.navigation_3.0.0.HEAD",//
- "org.eclipse.riena.navigation.ui_3.0.0.HEAD",//
- "org.eclipse.riena.navigation.ui.swt_3.0.0.HEAD",//
- "org.apache.oro_2.0.8.v200903061218.jar" });
-
- public void start() throws BundleException {
- final Map<String, String> configuration = new HashMap<String, String>();
- final EquinoxLauncher launcher = new EquinoxLauncher(configuration);
- launcher.start();
- final BundleContext ctx = launcher.getBundleContext();
-
- // for (final String tpBundle : targetPlatformBundles) {
- // ctx.installBundle(TP + tpBundle);
- // System.out.println(">> " + tpBundle);
- //
- // for (final Bundle installed : ctx.getBundles()) {
- // System.out.println("installed " + installed.getSymbolicName());
- // }
- // }
-
- final Bundle minimalBundle = ctx
- .installBundle("reference:file:C:/build/workspaces/toolbox_runtime/org.eclipse.riena.toolbox.minimal"); //$NON-NLS-1$
- minimalBundle.start();
-
- }
-
-}
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/CodeGenerator.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/CodeGenerator.java
index 6821804..d33c539 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/CodeGenerator.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/CodeGenerator.java
@@ -244,7 +244,7 @@ public class CodeGenerator implements ICodeGenerator {
try {
return CodeGeneration.getTypeComment(newClassCompilationUnit, fullClassName, typeParamNames, lineDelimiter);
} catch (final NullPointerException e) {
- return "";
+ return ""; //$NON-NLS-1$
}
}
@@ -254,7 +254,7 @@ public class CodeGenerator implements ICodeGenerator {
try {
return CodeGeneration.getFileComment(newClassCompilationUnit, lineDelimiter);
} catch (final NullPointerException e) {
- return "";
+ return ""; //$NON-NLS-1$
}
}
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/RidgetGenerator.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/RidgetGenerator.java
index 4435ef9..43a569f 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/RidgetGenerator.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/RidgetGenerator.java
@@ -114,7 +114,6 @@ public class RidgetGenerator {
* @param fullyQualifiedClassName
* @return all found SwtControls, or an empty list
*/
- @SuppressWarnings("unchecked")
public List<SwtControl> findSwtControls(final String fullyQualifiedClassName) {
final CompilationUnit astNode = findCompilationUnit(fullyQualifiedClassName);
if (null == astNode) {
@@ -189,7 +188,6 @@ public class RidgetGenerator {
* @param controls
* @return true if the given class was found, otherwise false
*/
- @SuppressWarnings("unchecked")
public boolean generateConfigureRidgets(final String fullyQualifiedControllerClassName,
final List<SwtControl> controls) {
final ICompilationUnit unit = findICompilationUnit(fullyQualifiedControllerClassName);
@@ -247,7 +245,6 @@ public class RidgetGenerator {
* @param parentMethod
* @param controls
*/
- @SuppressWarnings("unchecked")
private void generateGetRidgetCalls(final AST ast, final MethodDeclaration parentMethod,
final List<SwtControl> controls) {
@@ -287,7 +284,6 @@ public class RidgetGenerator {
* @param unit
* @param controls
*/
- @SuppressWarnings("unchecked")
private void addImportStatements(final AST ast, final CompilationUnit unit, final List<SwtControl> controls) {
for (final SwtControl swtControl : controls) {
if (!hasImportStatement(unit, swtControl.getFullyQualifiedRidgetClassName())) {
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/SWTControlInstantiationVisitor.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/SWTControlInstantiationVisitor.java
index 689220b..4162c03 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/SWTControlInstantiationVisitor.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/SWTControlInstantiationVisitor.java
@@ -20,10 +20,13 @@ import java.util.Set;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
+import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
+import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.StringLiteral;
import org.eclipse.jdt.core.dom.VariableDeclaration;
@@ -88,7 +91,6 @@ public class SWTControlInstantiationVisitor extends ASTVisitor {
if (parent instanceof VariableDeclaration) {
final VariableDeclaration decl = (VariableDeclaration) parent;
-
final String varName = decl.getName().getFullyQualifiedName();
final MethodDeclaration enclosingMethod = findDeclaringMethod(node);
@@ -96,8 +98,13 @@ public class SWTControlInstantiationVisitor extends ASTVisitor {
Util.logWarning("could not detect enclosing method for " + node); //$NON-NLS-1$
return false;
}
-
- if (!variabelCache.isRegistered(enclosingMethod, varName)) {
+ generateAddUIControlCall(enclosingMethod, varName);
+ } else if (parent instanceof Assignment) {
+ final Assignment ass = (Assignment) parent;
+ final Expression left = ass.getLeftHandSide();
+ if (left instanceof SimpleName) {
+ final String varName = ((SimpleName) left).getFullyQualifiedName();
+ final MethodDeclaration enclosingMethod = findDeclaringMethod(node);
generateAddUIControlCall(enclosingMethod, varName);
}
}
@@ -105,18 +112,18 @@ public class SWTControlInstantiationVisitor extends ASTVisitor {
return super.visit(node);
}
- @SuppressWarnings("unchecked")
private void generateAddUIControlCall(final MethodDeclaration enclosingMethod, final String variableName) {
- final AST ast = enclosingMethod.getAST();
+ if (variabelCache.isRegistered(enclosingMethod, variableName)) {
+ return;
+ }
+ final AST ast = enclosingMethod.getAST();
final MethodInvocation methodAddUIControl = ast.newMethodInvocation();
-
methodAddUIControl.setName(ast.newSimpleName("addUIControl")); //$NON-NLS-1$
methodAddUIControl.arguments().add(ast.newSimpleName(variableName));
final StringLiteral ridgetId = ast.newStringLiteral();
ridgetId.setLiteralValue(variableName);
methodAddUIControl.arguments().add(ridgetId);
-
enclosingMethod.getBody().statements().add(ast.newExpressionStatement(methodAddUIControl));
}
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/views/AssemblyView.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/views/AssemblyView.java
index 04d52f3..0ad8566 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/views/AssemblyView.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/views/AssemblyView.java
@@ -14,8 +14,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Set;
-import org.osgi.framework.BundleException;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
@@ -58,7 +56,6 @@ import org.eclipse.ui.part.ViewPart;
import org.eclipse.riena.toolbox.Activator;
import org.eclipse.riena.toolbox.Util;
import org.eclipse.riena.toolbox.assemblyeditor.AddUIControlCallGenerator;
-import org.eclipse.riena.toolbox.assemblyeditor.ApplicationPreviewer;
import org.eclipse.riena.toolbox.assemblyeditor.ResourceChangeListener;
import org.eclipse.riena.toolbox.assemblyeditor.RidgetGenerator;
import org.eclipse.riena.toolbox.assemblyeditor.api.INodeFactory;
@@ -103,7 +100,6 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
private GenerateAddUIControlCallsAction generateAddUIControlCallsAction;
private final PluginXmlResourceChangeListener changeListener = new PluginXmlResourceChangeListener();
private RegisterPerspectiveAction registerPerspectiveAction;
- private ShowPreview showApplicationPreview;
private LinkWithEditorAction linkWidthEditorAction;
private OnlyShowProjectsWithAssembliesAction onlyShowProjectsWithAssembliesAction;
@@ -130,7 +126,6 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
generateAddUIControlCallsAction = new GenerateAddUIControlCallsAction();
refreshAction = new RefreshAction();
registerPerspectiveAction = new RegisterPerspectiveAction();
- showApplicationPreview = new ShowPreview();
linkWidthEditorAction = new LinkWithEditorAction();
onlyShowProjectsWithAssembliesAction = new OnlyShowProjectsWithAssembliesAction();
}
@@ -167,58 +162,6 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
});
}
- // private class DropDownAction extends Action implements IMenuCreator {
- // private Menu dropDownMenu;
- //
- // public DropDownAction() {
- // setToolTipText("Settings");
- // setImageDescriptor(null);
- // setText("");
- // setMenuCreator(this);
- // }
- //
- // public void dispose() {
- // if (dropDownMenu != null) {
- // dropDownMenu.dispose();
- // dropDownMenu = null;
- // }
- // }
- //
- // public Menu getMenu(final Menu parent) {
- // return null;
- // }
- //
- // public Menu getMenu(final Control parent) {
- // if (dropDownMenu != null) {
- // dropDownMenu.dispose();
- // }
- //
- // dropDownMenu = new Menu(parent);
- // addActionToMenu(dropDownMenu, onlyShowProjectsWithAssembliesAction);
- // addActionToMenu(dropDownMenu, linkWidthEditorAction);
- //
- // return dropDownMenu;
- // }
- //
- // protected void addActionToMenu(final Menu parent, final Action action) {
- // final ActionContributionItem item = new ActionContributionItem(action);
- // item.fill(parent, -1);
- // }
- //
- // @Override
- // public void run() {
- //
- // }
- //
- // /**
- // * Get's rid of the menu, because the menu hangs on to the searches,
- // * etc.
- // */
- // void clear() {
- // dispose();
- // }
- // }
-
public void openClassInEditor(final SubModuleNode submod, final String className) {
if (className == null) {
Util.logWarning("Controller is null " + submod); //$NON-NLS-1$
@@ -1039,22 +982,6 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
}
}
- private class ShowPreview extends Action {
- public ShowPreview() {
- setText("Preview Application");
- setId("org.eclipse.riena.toolbox.assemblyeditor.ui.views.showpreview.action"); //$NON-NLS-1$
- }
-
- @Override
- public void run() {
- try {
- new ApplicationPreviewer().start();
- } catch (final BundleException e) {
- e.printStackTrace();
- }
- }
- }
-
private class OnlyShowProjectsWithAssembliesAction extends Action {
public OnlyShowProjectsWithAssembliesAction() {
super("Hide Empty Projects", Action.AS_CHECK_BOX);