summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Kriese2011-10-20 02:51:41 (EDT)
committerSteffen Kriese2011-10-20 02:51:41 (EDT)
commite883f8e778e8430a8395f1ef19dd1d65d6108ac5 (patch)
treef968d774159eeea28845593f3b78c3c32a4a25f9
parent60c7daf156ef782b6b1705ea84ef5a9c4ab3605e (diff)
downloadorg.eclipse.riena.toolbox-e883f8e778e8430a8395f1ef19dd1d65d6108ac5.zip
org.eclipse.riena.toolbox-e883f8e778e8430a8395f1ef19dd1d65d6108ac5.tar.gz
org.eclipse.riena.toolbox-e883f8e778e8430a8395f1ef19dd1d65d6108ac5.tar.bz2
fixed bug: openclasslink did not work for controller/view in some cases
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/AssemblyDataProvider.java1
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/CodeGenerator.java1
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/PluginXmlParser.java12
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/RidgetGenerator.java9
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/UIControlVisitor.java3
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/model/RCPView.java19
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/OpenClassLink.java24
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/composites/SubModuleComposite.java56
-rw-r--r--org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/views/AssemblyView.java18
9 files changed, 104 insertions, 39 deletions
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/AssemblyDataProvider.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/AssemblyDataProvider.java
index b675136..d27f548 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/AssemblyDataProvider.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/AssemblyDataProvider.java
@@ -160,6 +160,7 @@ public class AssemblyDataProvider implements IAssemblyDataProvider {
*/
private List<BundleNode> findBundles(final AssemblyModel model) {
final List<BundleNode> bundles = new ArrayList<BundleNode>();
+
for (final IProject proj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
final IFile pluginXml = proj.getFile(PLUGIN_XML);
if (isJavaProject(proj)) {
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 d33c539..b71c560 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
@@ -122,6 +122,7 @@ public class CodeGenerator implements ICodeGenerator {
properties);
final RCPView view = new RCPView();
+ view.setBundle(subModule.getBundle());
view.setViewClass(classFileName);
view.setId(classFileName);
view.setName(classFileName);
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/PluginXmlParser.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/PluginXmlParser.java
index 07b5de4..1f2098e 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/PluginXmlParser.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/PluginXmlParser.java
@@ -52,16 +52,9 @@ public class PluginXmlParser extends AbstractXmlProvider implements IPluginXmlPa
}
public Set<RCPView> getRcpViews(final BundleNode bundleNode) {
- return parseViewIds(getDocument(bundleNode));
+ return parseViewIds(getDocument(bundleNode), bundleNode);
}
- /*
- * (non-Javadoc)
- *
- * @seeorg.eclipse.riena.toolbox.assemblyeditor.api.IPluginXmlParser#
- * getRcpPerspectives
- * (org.eclipse.riena.toolbox.assemblyeditor.model.BundleNode)
- */
public Set<RCPPerspective> getRcpPerspectives(final BundleNode bundleNode) {
return parsePerspectiveIds(getDocument(bundleNode));
}
@@ -98,7 +91,7 @@ public class PluginXmlParser extends AbstractXmlProvider implements IPluginXmlPa
return viewIds;
}
- private Set<RCPView> parseViewIds(final Document doc) {
+ private Set<RCPView> parseViewIds(final Document doc, final BundleNode bundleNode) {
final Set<RCPView> viewIds = new HashSet<RCPView>();
if (null == doc) {
@@ -119,6 +112,7 @@ public class PluginXmlParser extends AbstractXmlProvider implements IPluginXmlPa
final Element elmView = (Element) nlViews.item(j);
final RCPView view = parseView(elmView);
+ view.setBundle(bundleNode);
viewIds.add(view);
}
}
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 43a569f..f01be56 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
@@ -49,6 +49,7 @@ import org.eclipse.text.edits.TextEdit;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
+import org.eclipse.riena.core.util.StringUtils;
import org.eclipse.riena.toolbox.ReflectionUtil;
import org.eclipse.riena.toolbox.Util;
import org.eclipse.riena.toolbox.assemblyeditor.model.SwtControl;
@@ -76,6 +77,10 @@ public class RidgetGenerator {
* @return if found the CompilationUnit, otherwise false
*/
public ICompilationUnit findICompilationUnit(final String fullyQualifiedClassName) {
+ if (!StringUtils.isGiven(fullyQualifiedClassName)) {
+ return null;
+ }
+
try {
if (project.isNatureEnabled(NATURE_JAVA)) {
final IJavaProject javaProject = JavaCore.create(project);
@@ -87,6 +92,9 @@ public class RidgetGenerator {
final String className = m.group(2);
final IPackageFragment viewPackage = findPackage(javaProject, packageName);
+ if (null == viewPackage) {
+ return null;
+ }
for (final ICompilationUnit unit : viewPackage.getCompilationUnits()) {
if (unit.getElementName().equals(className + EXTENSION_JAVA)) {
return unit;
@@ -190,6 +198,7 @@ public class RidgetGenerator {
*/
public boolean generateConfigureRidgets(final String fullyQualifiedControllerClassName,
final List<SwtControl> controls) {
+
final ICompilationUnit unit = findICompilationUnit(fullyQualifiedControllerClassName);
if (null == unit) {
Util.logWarning("controller not found " + fullyQualifiedControllerClassName); //$NON-NLS-1$
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/UIControlVisitor.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/UIControlVisitor.java
index c760484..9253af8 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/UIControlVisitor.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/UIControlVisitor.java
@@ -94,8 +94,9 @@ public class UIControlVisitor extends ASTVisitor {
return ridgetInterface;
}
} catch (final ClassNotFoundException e) {
- e.printStackTrace();
+ Util.logError(e);
} catch (final BindingException e) {
+ Util.logError(e);
return null;
}
return IRidget.class;
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/model/RCPView.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/model/RCPView.java
index f11e0f6..12f5655 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/model/RCPView.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/model/RCPView.java
@@ -20,6 +20,7 @@ public class RCPView {
private String viewClass;
private final boolean allowMultiple = true;
private final boolean restorable = false;
+ private BundleNode bundle;
public RCPView() {
}
@@ -60,11 +61,12 @@ public class RCPView {
this.viewClass = clazz;
}
- @Override
- public String toString() {
- return "RCPView [allowMultiple=" + allowMultiple + ", clazz=" + viewClass //$NON-NLS-1$ //$NON-NLS-2$
- + ", id=" + id + ", name=" + name + ", restorable=" //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
- + restorable + "]"; //$NON-NLS-1$
+ public BundleNode getBundle() {
+ return bundle;
+ }
+
+ public void setBundle(final BundleNode bundle) {
+ this.bundle = bundle;
}
@Override
@@ -96,4 +98,11 @@ public class RCPView {
}
return true;
}
+
+ @Override
+ public String toString() {
+ return "RCPView [id=" + id + ", name=" + name + ", viewClass=" + viewClass + ", allowMultiple=" + allowMultiple
+ + ", restorable=" + restorable + "]";
+ }
+
}
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/OpenClassLink.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/OpenClassLink.java
index b12230f..86a6356 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/OpenClassLink.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/OpenClassLink.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.riena.toolbox.assemblyeditor.ui;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
@@ -25,15 +26,15 @@ import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
+import org.eclipse.riena.toolbox.Util;
import org.eclipse.riena.toolbox.assemblyeditor.RidgetGenerator;
-import org.eclipse.riena.toolbox.assemblyeditor.model.SubModuleNode;
@SuppressWarnings("restriction")
public class OpenClassLink extends Composite {
- private Link lnk;
+ private final Link lnk;
private String className;
- private SubModuleNode subModule;
+ private IProject project;
public OpenClassLink(final Composite parent, final String text) {
super(parent, SWT.None);
@@ -45,20 +46,23 @@ public class OpenClassLink extends Composite {
lnk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
- if (subModule == null || className == null) {
+ if (project == null || className == null) {
+ Util.logWarning("OpenClassLink: no class or project found"); //$NON-NLS-1$
return;
}
- final RidgetGenerator gen = new RidgetGenerator(subModule.getBundle().getProject());
+ final RidgetGenerator gen = new RidgetGenerator(project);
try {
final ICompilationUnit unit = gen.findICompilationUnit(className);
if (null != unit) {
final IEditorPart part = EditorUtility.openInEditor(unit, false);
JavaUI.revealInEditor(part, (IJavaElement) unit);
+ } else {
+ Util.logWarning("ICompilationUnit not found " + className + " in " + project); //$NON-NLS-1$ //$NON-NLS-2$
}
} catch (final PartInitException pix) {
- pix.printStackTrace();
+ Util.logError(pix);
}
}
@@ -85,11 +89,11 @@ public class OpenClassLink extends Composite {
this.className = className;
}
- public SubModuleNode getSubModule() {
- return subModule;
+ public IProject getProject() {
+ return project;
}
- public void setSubModule(final SubModuleNode subModule) {
- this.subModule = subModule;
+ public void setProject(final IProject project) {
+ this.project = project;
}
}
diff --git a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/composites/SubModuleComposite.java b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/composites/SubModuleComposite.java
index 9d2460a..5feaea2 100644
--- a/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/composites/SubModuleComposite.java
+++ b/org.eclipse.riena.toolbox/src/org/eclipse/riena/toolbox/assemblyeditor/ui/composites/SubModuleComposite.java
@@ -23,6 +23,8 @@ import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
@@ -33,6 +35,7 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
+import org.eclipse.riena.core.util.StringUtils;
import org.eclipse.riena.toolbox.Activator;
import org.eclipse.riena.toolbox.Util;
import org.eclipse.riena.toolbox.assemblyeditor.model.RCPView;
@@ -84,13 +87,15 @@ public class SubModuleComposite extends AbstractDetailComposite<SubModuleNode> {
txtController.setControllerName(node.getController());
txtController.setProject(node.getBundle().getProject());
- lnkController.setSubModule(node);
+ lnkController.setProject(node.getBundle().getProject());
lnkController.setClassName(node.getController());
- lnkView.setSubModule(node);
-
+ lnkView.setProject(node.getBundle().getProject());
if (node.getRcpView() != null) {
lnkView.setClassName(node.getRcpView().getViewClass());
+ if (null != node.getRcpView() && null != node.getRcpView().getBundle()) {
+ lnkView.setProject(node.getRcpView().getBundle().getProject());
+ }
}
btnShared.setSelection(node.isSharedView());
@@ -117,6 +122,14 @@ public class SubModuleComposite extends AbstractDetailComposite<SubModuleNode> {
}
node.getRcpView().setId(txtView.getText().getText());
+
+ for (final RCPView view : Activator.getDefault().getAssemblyModel().getRcpViews()) {
+ if (view.getId().equals(node.getRcpView().getId())) {
+ node.setRcpView(view);
+ break;
+ }
+ }
+
node.setController(txtController.getText().getText());
node.setSharedView(btnShared.getSelection());
node.setIcon(txtIcon.getText().getText());
@@ -138,7 +151,7 @@ public class SubModuleComposite extends AbstractDetailComposite<SubModuleNode> {
}
// if the node already has a RCPView, don't update the nodeId
- if (Util.isGiven(node.getRcpView().getViewClass())) {
+ if (null != node.getRcpView() && Util.isGiven(node.getRcpView().getViewClass())) {
return;
}
@@ -166,6 +179,26 @@ public class SubModuleComposite extends AbstractDetailComposite<SubModuleNode> {
txtView = new IdSelectorText(parent, workareaBackground, "View Selection",
"Select a View (* = any string, ? = any char):", false);
+ txtView.getText().addModifyListener(new ModifyListener() {
+ public void modifyText(final ModifyEvent e) {
+ final String viewId = txtView.getText().getText();
+
+ if (!StringUtils.isGiven(viewId)) {
+ lnkView.setClassName(null);
+ lnkView.setProject(null);
+ return;
+ }
+
+ for (final RCPView view : Activator.getDefault().getAssemblyModel().getRcpViews()) {
+ if (viewId.equals(view.getId())) {
+ lnkView.setClassName(view.getViewClass());
+ lnkView.setProject(view.getBundle().getProject());
+ break;
+ }
+ }
+ }
+ });
+
// FIXME
// use
// RCPViews
@@ -179,7 +212,15 @@ public class SubModuleComposite extends AbstractDetailComposite<SubModuleNode> {
private void buildControllerSection(final Composite parent) {
lnkController = UIControlsFactory.createOpenClassLink(parent, "Controller");
- txtController = new BrowseControllerComposite(parent, workareaBackground);
+ txtController = new BrowseControllerComposite(parent, workareaBackground, lnkController);
+ txtController.getText().addModifyListener(new ModifyListener() {
+ public void modifyText(final ModifyEvent e) {
+ if (!StringUtils.isGiven(txtController.getText().getText())) {
+ lnkController.setClassName(null);
+ lnkController.setProject(null);
+ }
+ }
+ });
GridDataFactory.swtDefaults().applyTo(lnkController);
GridDataFactory.fillDefaults().grab(true, false).applyTo(txtController);
@@ -190,7 +231,7 @@ public class SubModuleComposite extends AbstractDetailComposite<SubModuleNode> {
private IProject project;
private String controllerName;
- public BrowseControllerComposite(final Composite parent, final Color background) {
+ public BrowseControllerComposite(final Composite parent, final Color background, final OpenClassLink link) {
super(parent, background, false);
getBrowseButton().addSelectionListener(new SelectionAdapter() {
@@ -219,6 +260,9 @@ public class SubModuleComposite extends AbstractDetailComposite<SubModuleNode> {
for (final Object obj : result) {
final SourceType source = (SourceType) obj;
getText().setText(source.getFullyQualifiedName());
+ link.setClassName(source.getFullyQualifiedName());
+ link.setProject(source.getJavaProject().getProject());
+
}
}
}
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 0ad8566..eaa538f 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
@@ -110,7 +110,6 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
private void initActions() {
final INodeFactory nodeFactory = Activator.getDefault().getNodeFactory();
-
addAssemblyAction = new AddAssemblyAction(nodeFactory);
addSubAppAction = new AddSubApplication(nodeFactory);
addModuleGroupAction = new AddModuleGroupAction(nodeFactory);
@@ -145,7 +144,6 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
getViewSite().getActionBars().getToolBarManager().add(refreshAction);
- //getViewSite().getActionBars().getToolBarManager().add(new DropDownAction());
getViewSite().getActionBars().getMenuManager().add(onlyShowProjectsWithAssembliesAction);
getViewSite().getActionBars().getMenuManager().add(linkWidthEditorAction);
@@ -570,7 +568,9 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
final ListSelectionDialog dia = new ListSelectionDialog(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell(), options, new ArrayContentProvider(), new LabelProvider(),
TITLE);
+ dia.setInitialElementSelections(Arrays.asList(options));
dia.open();
+
final List<Object> diaResult = Arrays.asList(dia.getResult());
boolean isBundleDirty = false;
@@ -600,6 +600,7 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
final ListSelectionDialog dia = new ListSelectionDialog(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getShell(), options, new ArrayContentProvider(), new LabelProvider(),
TITLE);
+ dia.setInitialElementSelections(Arrays.asList(options));
dia.open();
final Object[] result = dia.getResult();
@@ -822,19 +823,20 @@ public class AssemblyView extends ViewPart implements ISaveablePart {
if (null != rcpView) {
final String className = rcpView.getViewClass();
- final RidgetGenerator generator = new RidgetGenerator(selectedNode.getBundle().getProject());
+ final List<SwtControl> controls = new RidgetGenerator(rcpView.getBundle().getProject())
+ .findSwtControlsReflectionStyle(className);
- final List<SwtControl> controls = generator.findSwtControlsReflectionStyle(className);
- generator.generateConfigureRidgets(((SubModuleNode) selectedNode).getController(), controls);
+ new RidgetGenerator(selectedNode.getBundle().getProject()).generateConfigureRidgets(
+ ((SubModuleNode) selectedNode).getController(), controls);
if (Platform.inDebugMode()) {
for (final SwtControl control : controls) {
- System.out.println("DEBUG: found control: " + control.getSwtControlClassName()
- + " ridgetId: " + control.getRidgetId());
+ System.out.println("DEBUG: found control: " + control.getSwtControlClassName() //$NON-NLS-1$
+ + " ridgetId: " + control.getRidgetId()); //$NON-NLS-1$
}
}
} else {
- System.err.println("No ViewClass found for node: " + selectedNode);
+ System.err.println("No ViewClass found for node: " + selectedNode); //$NON-NLS-1$
}
}