Author: DartPeng
Date: 2009-04-09 05:45:28 -0400 (Thu, 09 Apr 2009)
New Revision: 14625
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java
Removed:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/edit/common/provider/AbstractAnyTypeItemProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
Log:
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/edit/common/provider/AbstractAnyTypeItemProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/edit/common/provider/AbstractAnyTypeItemProvider.java 2009-04-09
09:05:36 UTC (rev 14624)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/edit/common/provider/AbstractAnyTypeItemProvider.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -53,7 +53,6 @@
}
protected boolean isWrappingNeeded(Object object){
- wrappingNeeded = null;
return super.isWrappingNeeded(object);
}
/**
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-04-09
09:05:36 UTC (rev 14624)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -10,19 +10,14 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
/**
* @author Dart (dpeng(a)redhat.com)
@@ -47,23 +42,11 @@
}
public IResource getResource(EObject model) {
- final Resource resource = ((EObject) model).eResource();
- URI uri = resource.getURI();
- IResource workspaceResource = null;
- if (uri.isPlatformResource()) {
- String path = uri.toPlatformString(true);
- workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new
Path(path));
- }
- return workspaceResource;
+ return SmooksUIUtils.getResource(model);
}
public IJavaProject getJavaProject(EObject model) {
- IResource r = getResource(model);
- if (r != null) {
- IProject p = r.getProject();
- return JavaCore.create(p);
- }
- return null;
+ return SmooksUIUtils.getJavaProject(model);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java 2009-04-09
09:05:36 UTC (rev 14624)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -14,9 +14,11 @@
import java.util.Map;
import org.jboss.tools.smooks.configuration.editors.javabean.BindingsPropertyUICreator;
-import org.jboss.tools.smooks.configuration.editors.javabean.ValuePropertiesUICreator;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanValueUICreator;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanWiringUICreator;
import org.jboss.tools.smooks.model.javabean.impl.BindingsTypeImpl;
import org.jboss.tools.smooks.model.javabean.impl.ValueTypeImpl;
+import org.jboss.tools.smooks.model.javabean.impl.WiringTypeImpl;
/**
* @author Dart (dpeng(a)redhat.com)<p>
@@ -34,7 +36,8 @@
private void init() {
map.put(BindingsTypeImpl.class, new BindingsPropertyUICreator());
- map.put(ValueTypeImpl.class, new ValuePropertiesUICreator());
+ map.put(ValueTypeImpl.class, new JavabeanValueUICreator());
+ map.put(WiringTypeImpl.class, new JavabeanWiringUICreator());
}
public void registePropertyUICreator(Class<?> key,IPropertyUICreator creator){
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java 2009-04-09
09:05:36 UTC (rev 14624)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -11,12 +11,17 @@
package org.jboss.tools.smooks.configuration.editors;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.BasicFeatureMapEntry;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IWrapperItemProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
@@ -34,6 +39,8 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -47,6 +54,7 @@
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
/**
* @author Dart Peng (dpeng(a)redhat.com)
@@ -54,7 +62,7 @@
* Date Apr 1, 2009
*/
public class SmooksMasterDetailBlock extends MasterDetailsBlock implements
IMenuListener,
- ISelectionChangedListener {
+ ISelectionChangedListener {
private Section configurationSection;
private SectionPart sectionPart;
@@ -112,14 +120,15 @@
// provider.registePage(ResourceType.class, new
// SmooksStuffPropertyDetailPage());
detailsPart.registerPage(EObject.class, new SmooksStuffPropertyDetailPage(
- (SmooksMultiFormEditor) this.formEditor));
+ (SmooksMultiFormEditor) this.formEditor));
}
protected void createSmooksTreeViewer(FormToolkit tool, final IManagedForm managedForm,
- Composite rootMainControl) {
- configurationSection = tool.createSection(rootMainControl, Section.TITLE_BAR |
Section.DESCRIPTION);
+ Composite rootMainControl) {
+ configurationSection = tool.createSection(rootMainControl, Section.TITLE_BAR
+ | Section.DESCRIPTION);
configurationSection
- .setDescription("Define Smooks stuffes for configuration file in the following
section.");
+ .setDescription("Define Smooks stuffes for configuration file in the following
section.");
configurationSection.setText("All Smooks Stuffes");
sectionPart = new SectionPart(configurationSection);
managedForm.addPart(sectionPart);
@@ -140,8 +149,9 @@
smooksTreeViewer = new TreeViewer(tableComposite, SWT.NONE);
smooksTreeViewer.addSelectionChangedListener(this);
smooksTreeViewer.setContentProvider(new AdapterFactoryContentProvider(editingDomain
- .getAdapterFactory()));
- smooksTreeViewer.setLabelProvider(new
AdapterFactoryLabelProvider(editingDomain.getAdapterFactory()));
+ .getAdapterFactory()));
+ smooksTreeViewer.setLabelProvider(new AdapterFactoryLabelProvider(editingDomain
+ .getAdapterFactory()));
smooksTreeViewer.setFilters(new ViewerFilter[] { new TextEObjectModelFilter() });
Object smooksModel = ((SmooksMultiFormEditor) this.formEditor).getSmooksModel();
if (smooksModel != null) {
@@ -152,7 +162,7 @@
if (formEditor.getEditorSite().getActionBarContributor() instanceof
ISelectionChangedListener) {
smooksTreeViewer.addSelectionChangedListener((ISelectionChangedListener) formEditor
- .getEditorSite().getActionBarContributor());
+ .getEditorSite().getActionBarContributor());
}
smooksTreeViewer.addSelectionChangedListener(this);
@@ -181,8 +191,65 @@
downButton = tool.createButton(buttonComposite, "Down", SWT.NONE);
downButton.setLayoutData(gd);
+ // don't display button area
+ gd = new GridData(GridData.FILL_VERTICAL);
+ gd.widthHint = 0;
+ buttonComposite.setLayoutData(gd);
+ buttonComposite.setVisible(false);
+
+ hookButtons();
}
+ protected List<Object> getViewerSelections() {
+ IStructuredSelection selections = (IStructuredSelection)
smooksTreeViewer.getSelection();
+ List l = selections.toList();
+ List<Object> nl = new ArrayList<Object>();
+ for (Iterator<?> iterator = l.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ // object = AdapterFactoryEditingDomain.unwrap(object);
+ nl.add(object);
+ }
+ return l;
+ }
+
+ private void hookButtons() {
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ List<Object> list = getViewerSelections();
+ CompoundCommand ccommand = new CompoundCommand();
+ for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ Command command = DeleteCommand.create(editingDomain, object);
+ if (command.canExecute()) {
+ ccommand.append(command);
+ }
+ }
+
+ editingDomain.getCommandStack().execute(ccommand);
+ }
+ });
+
+ downButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ List<Object> list = getViewerSelections();
+ if(list.size() == 1){
+ Object obj = list.get(0);
+ EObject v = (EObject) AdapterFactoryEditingDomain.unwrap(obj);
+ EObject parent = v.eContainer();
+ int index = parent.eContents().indexOf(v);
+ Command command = MoveCommand.create(editingDomain, parent, null, obj, index + 1);
+ System.out.println(command.canExecute());
+ editingDomain.getCommandStack().execute(command);
+ }
+ }
+ });
+
+ upButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ }
+ });
+ }
+
private void createMenuForViewer(TreeViewer smooksTreeViewer2) {
MenuManager contextMenu = new MenuManager("#PopUp");
contextMenu.add(new Separator("additions"));
@@ -192,7 +259,7 @@
Menu menu = contextMenu.createContextMenu(smooksTreeViewer2.getControl());
smooksTreeViewer2.getControl().setMenu(menu);
formEditor.getSite().registerContextMenu(contextMenu,
- new UnwrappingSelectionProvider(smooksTreeViewer2));
+ new UnwrappingSelectionProvider(smooksTreeViewer2));
}
public TreeViewer getSmooksTreeViewer() {
@@ -204,7 +271,8 @@
}
public void menuAboutToShow(IMenuManager menuManager) {
- ((IMenuListener)
formEditor.getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
+ ((IMenuListener) formEditor.getEditorSite().getActionBarContributor())
+ .menuAboutToShow(menuManager);
}
private class TextEObjectModelFilter extends ViewerFilter {
@@ -217,7 +285,7 @@
if (obj instanceof BasicFeatureMapEntry) {
EStructuralFeature sf = ((BasicFeatureMapEntry) obj).getEStructuralFeature();
if (sf.equals(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT)
- || sf.equals(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__CDATA)) {
+ || sf.equals(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__CDATA)) {
return false;
}
}
@@ -233,6 +301,46 @@
}
}
+ /**
+ *
+ * @param selections
+ */
+ protected void updateButtons(List<?> selections) {
+ removeButton.setEnabled(true);
+ upButton.setEnabled(true);
+ downButton.setEnabled(true);
+ if (selections.size() >= 1) {
+ for (Iterator<?> iterator = selections.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ if (object instanceof SmooksResourceListType
+ || object instanceof org.jboss.tools.smooks10.model.smooks.SmooksResourceListType)
{
+ removeButton.setEnabled(false);
+ break;
+ }
+ }
+ }
+ if (selections.size() == 1) {
+ Object selection = selections.get(0);
+ if (selection instanceof SmooksResourceListType
+ || selection instanceof org.jboss.tools.smooks10.model.smooks.SmooksResourceListType)
{
+ upButton.setEnabled(false);
+ downButton.setEnabled(false);
+ } else {
+ if (selection instanceof EObject) {
+ EObject parent = ((EObject) selection).eContainer();
+ int index = parent.eContents().indexOf(selection);
+ if (index <= 0) {
+ upButton.setEnabled(false);
+ }
+ if (index >= parent.eContents().size() - 1) {
+ downButton.setEnabled(false);
+ }
+ }
+ }
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -250,11 +358,13 @@
objList.add(obj);
}
if (objList.isEmpty()) {
- sectionPart.getManagedForm().fireSelectionChanged(sectionPart,
event.getSelection());
+ sectionPart.getManagedForm()
+ .fireSelectionChanged(sectionPart, event.getSelection());
} else {
sectionPart.getManagedForm().fireSelectionChanged(sectionPart,
- new StructuredSelection(objList.toArray()));
+ new StructuredSelection(objList.toArray()));
}
+ updateButtons(objList);
}
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.javabean;
+
+import java.lang.reflect.Method;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.configuration.editors.uitls.IFieldDialog;
+import org.jboss.tools.smooks.configuration.editors.uitls.JavaPropertyUtils;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 9, 2009
+ */
+public class JavaMethodsSelectionDialog implements IFieldDialog {
+
+ private IJavaProject resource;
+
+ private Class<?> clazz;
+
+ public JavaMethodsSelectionDialog(IJavaProject resource, Class<?> clazz) {
+ super();
+ this.resource = resource;
+ this.clazz = clazz;
+ }
+
+ public Object open(Shell shell) {
+ if (resource != null && clazz != null) {
+ MethodSelectionDialog dialog = new MethodSelectionDialog(shell, resource, clazz);
+ if (dialog.open() == Dialog.OK) {
+ Method pd = (Method) dialog.getCurrentSelection();
+ return pd.getName();
+ }else{
+ return null;
+ }
+ }
+ MessageDialog.openInformation(shell, "Can't open dialog",
+ "Can't open java methods selection dialog.");
+ return null;
+ }
+
+ private class MethodSelectionDialog extends Dialog {
+
+ private TableViewer viewer;
+
+ private Class<?> clazz;
+
+ private Object currentSelection;
+
+
+
+ public MethodSelectionDialog(IShellProvider parentShell) {
+ super(parentShell);
+ }
+
+ public MethodSelectionDialog(Shell parentShell, IJavaProject project, Class<?>
clazz) {
+ super(parentShell);
+ this.clazz = clazz;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 400;
+ gd.widthHint = 400;
+ composite.setLayoutData(gd);
+ composite.setLayout(new FillLayout());
+ viewer = new TableViewer(composite, SWT.BORDER);
+ Table table = viewer.getTable();
+ TableColumn nameColumn = new TableColumn(table, SWT.NONE);
+ nameColumn.setWidth(100);
+ nameColumn.setText("Method Name");
+ TableColumn typeColumn = new TableColumn(table, SWT.NONE);
+ typeColumn.setWidth(200);
+ typeColumn.setText("Paramters Type");
+ table.setHeaderVisible(true);
+ viewer.setContentProvider(new MethodContentProvider());
+ viewer.setLabelProvider(new MethodLabelProvider());
+ Method[] settMethods = JavaPropertyUtils.getSetterMethods(clazz);
+ viewer.setInput(settMethods);
+ viewer.addDoubleClickListener(new IDoubleClickListener(){
+
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+
+ });
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ currentSelection = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ }
+
+ });
+ getShell().setText(clazz.getSimpleName() + "'s Setter Methods");
+ return composite;
+ }
+
+ public Object getCurrentSelection() {
+ return currentSelection;
+ }
+
+ public void setCurrentSelection(Object currentSelection) {
+ this.currentSelection = currentSelection;
+ }
+ }
+
+ private class MethodContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement.getClass().isArray()) {
+ return (Object[]) inputElement;
+ }
+ return new Object[] {};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ }
+
+ private class MethodLabelProvider extends LabelProvider implements ITableLabelProvider
{
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (columnIndex == 0) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.JAVA_PROPERTY_ICON);
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof Method) {
+ Method p = (Method) element;
+ switch (columnIndex) {
+ case 0:
+ return p.getName();
+ case 1:
+ Class<?>[] pts = p.getParameterTypes();
+ String paramtersName = "";
+ for (int i = 0; i < pts.length; i++,paramtersName+=",") {
+ String name = pts[i].getName();
+ if(pts[i].isArray()){
+ name = pts[i].getComponentType().getName() + "[]";
+ }
+ paramtersName += name;
+ }
+ if(paramtersName.endsWith(",")){
+ paramtersName = paramtersName.substring(0,paramtersName.length() - 1);
+ }
+ return paramtersName;
+ }
+ }
+ return getText(element);
+ }
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaMethodsSelectionDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java 2009-04-09
09:05:36 UTC (rev 14624)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -15,6 +15,8 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -74,8 +76,6 @@
private TableViewer viewer;
- private IJavaProject project;
-
private Class<?> clazz;
private Object currentSelection;
@@ -88,7 +88,6 @@
public PropertySelectionDialog(Shell parentShell, IJavaProject project, Class<?>
clazz) {
super(parentShell);
- this.project = project;
this.clazz = clazz;
}
@@ -113,13 +112,17 @@
viewer.setLabelProvider(new PropertyDescriptorLabelProvider());
PropertyDescriptor[] pds = JavaPropertyUtils.getPropertyDescriptor(clazz);
viewer.setInput(pds);
+ viewer.addDoubleClickListener(new IDoubleClickListener(){
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+ });
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
public void selectionChanged(SelectionChangedEvent event) {
currentSelection = ((IStructuredSelection) event.getSelection()).getFirstElement();
}
-
});
+ getShell().setText(clazz.getSimpleName() + "'s Properties");
return composite;
}
@@ -146,7 +149,6 @@
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // TODO Auto-generated method stub
}
Copied:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java
(from rev 14616,
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java)
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.javabean;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 9, 2009
+ */
+public class JavabeanValueUICreator extends
PropertiesAndSetterMethodSearchFieldEditorCreator {
+
+ @Override
+ protected boolean canCreatePropertiesSearchFieldEditor(EAttribute feature) {
+ if(feature == JavabeanPackage.eINSTANCE.getValueType_Property()){
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean canCreateMethodsSearchFieldEditor(EAttribute feature) {
+ if(feature == JavabeanPackage.eINSTANCE.getValueType_SetterMethod()){
+ return true;
+ }
+ return super.canCreateMethodsSearchFieldEditor(feature);
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanValueUICreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.javabean;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.model.javabean.BindingsType;
+import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
+import org.jboss.tools.smooks.model.smooks.AbstractResourceConfig;
+import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+
+/**
+ * @author Dart Peng (dpeng(a)redhat.com) Date Apr 9, 2009
+ */
+public class JavabeanWiringUICreator extends
PropertiesAndSetterMethodSearchFieldEditorCreator {
+
+ @Override
+ protected boolean canCreatePropertiesSearchFieldEditor(EAttribute feature) {
+ if (feature == JavabeanPackage.eINSTANCE.getWiringType_Property()) {
+ return true;
+ }
+ return false;
+ }
+
+
+
+ @Override
+ protected boolean canCreateMethodsSearchFieldEditor(EAttribute feature) {
+ if(feature == JavabeanPackage.eINSTANCE.getWiringType_SetterMethod()){
+ return true;
+ }
+ return super.canCreateMethodsSearchFieldEditor(feature);
+ }
+
+
+
+ @Override
+ public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ if (feature == JavabeanPackage.eINSTANCE.getWiringType_BeanIdRef()) {
+ if(model instanceof EObject){
+ SmooksResourceListType smooksResourceList = getSmooksResourceList((EObject)model);
+ if(smooksResourceList != null){
+ String displayName = propertyDescriptor.getDisplayName(model);
+ toolkit.createLabel(parent, displayName + " :");
+ final CCombo combo = new CCombo(parent,SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ combo.setLayoutData(gd);
+ Object editValue = SmooksUIUtils.getEditValue(propertyDescriptor, model);
+ if (editValue != null) {
+ combo.setText(editValue.toString());
+ }
+ List<String> list = getBeanIdList(smooksResourceList);
+ for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) {
+ String beanId = (String) iterator.next();
+ combo.add(beanId);
+ }
+ int selectIndex = list.indexOf(editValue);
+ if(selectIndex != -1){
+ combo.select(selectIndex);
+ }
+ final IItemPropertyDescriptor ip = propertyDescriptor;
+ final Object cmodel = model;
+ combo.addModifyListener(new ModifyListener(){
+ public void modifyText(ModifyEvent e) {
+ Object editValue = SmooksUIUtils.getEditValue(ip, cmodel);
+ if(combo.getText().equals(editValue)){
+ return;
+ }
+ ip.setPropertyValue(cmodel, combo.getText());
+ }
+ });
+ return combo;
+ }
+ }
+ }
+ return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature);
+ }
+
+ protected List<String> getBeanIdList(SmooksResourceListType resourceList){
+ List<AbstractResourceConfig> rlist = resourceList.getAbstractResourceConfig();
+ List<String> beanIdList = new ArrayList<String>();
+ for (Iterator<?> iterator = rlist.iterator(); iterator.hasNext();) {
+ AbstractResourceConfig abstractResourceConfig = (AbstractResourceConfig) iterator
+ .next();
+ if(abstractResourceConfig instanceof BindingsType){
+ String beanId = ((BindingsType)abstractResourceConfig).getBeanId();
+ if(beanId == null) continue;
+ beanIdList.add(beanId);
+ }
+ }
+ return beanIdList;
+ }
+
+ private SmooksResourceListType getSmooksResourceList(EObject model) {
+ EObject parent = model.eContainer();
+ while (parent != null && !(parent instanceof SmooksResourceListType)) {
+ parent = parent.eContainer();
+ }
+ if (parent instanceof SmooksResourceListType) {
+ return (SmooksResourceListType) parent;
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.javabean;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.model.javabean.BindingsType;
+
+/**
+ * @author Dart Peng (dpeng(a)redhat.com) Date Apr 9, 2009
+ */
+public class PropertiesAndSetterMethodSearchFieldEditorCreator extends PropertyUICreator
{
+
+ @Override
+ public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ if(canCreatePropertiesSearchFieldEditor(feature)){
+ return createPropertiesSearchFieldEditor(toolkit, parent, propertyDescriptor, model);
+ }
+ if(canCreateMethodsSearchFieldEditor(feature)){
+ return createMethodsSearchFieldEditor(toolkit, parent, propertyDescriptor, model);
+ }
+ return null;
+ }
+
+ protected boolean canCreatePropertiesSearchFieldEditor(EAttribute feature) {
+ return false;
+ }
+
+ protected boolean canCreateMethodsSearchFieldEditor(EAttribute feature) {
+ return false;
+ }
+
+ protected String getPropertiesSearchButtonName(){
+ return "Search property";
+ }
+
+ protected String getMethodsSearchButtonName(){
+ return "Search setter method";
+ }
+
+ protected Composite createPropertiesSearchFieldEditor(FormToolkit toolkit, Composite
parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model) {
+ if (model instanceof EObject) {
+ EObject container = ((EObject) model).eContainer();
+ if (container instanceof BindingsType) {
+ return SmooksUIUtils.createJavaPropertySearchFieldEditor((BindingsType) container,
+ parent, toolkit, propertyDescriptor, getPropertiesSearchButtonName(), (EObject)
model);
+ }
+ }
+ return null;
+ }
+
+ protected Composite createMethodsSearchFieldEditor(FormToolkit toolkit, Composite
parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model) {
+ if (model instanceof EObject) {
+ EObject container = ((EObject) model).eContainer();
+ if (container instanceof BindingsType) {
+ return SmooksUIUtils.createJavaMethodSearchFieldEditor((BindingsType) container,
+ parent, toolkit, propertyDescriptor, getMethodsSearchButtonName(), (EObject)
model);
+ }
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java 2009-04-09
09:05:36 UTC (rev 14624)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.smooks.configuration.editors.javabean;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.jboss.tools.smooks.configuration.editors.IPropertyUICreator;
-import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
-import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
-import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
-import org.jboss.tools.smooks.model.javabean.BindingsType;
-import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
-
-/**
- * @author Dart (dpeng(a)redhat.com)
- * <p>
- * Apr 9, 2009
- */
-public class ValuePropertiesUICreator extends PropertyUICreator implements
IPropertyUICreator {
-
- /*
- * (non-Javadoc)
- *
- * @seeorg.jboss.tools.smooks.configuration.editors.IPropertyUICreator#
- * createPropertyUI(org.eclipse.ui.forms.widgets.FormToolkit,
- * org.eclipse.swt.widgets.Composite,
- * org.eclipse.emf.edit.provider.IItemPropertyDescriptor, java.lang.Object,
- * org.eclipse.emf.ecore.EAttribute)
- */
- public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
- if (feature == JavabeanPackage.eINSTANCE.getValueType_Property()) {
- if (model instanceof EObject) {
- EObject container = ((EObject) model).eContainer();
- if (container instanceof BindingsType) {
- String classString = ((BindingsType) container).getClass_();
- IJavaProject project = getJavaProject(container);
- try {
- ProjectClassLoader classLoader = new ProjectClassLoader(project);
- Class<?> clazz = classLoader.loadClass(classString);
- JavaPropertiesSelectionDialog dialog = new JavaPropertiesSelectionDialog(project,
- clazz);
- return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor,
- "Select property", dialog, (EObject)model);
- } catch (JavaModelException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
- }
- return null;
- }
-
-}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java 2009-04-09
09:05:36 UTC (rev 14624)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -3,6 +3,9 @@
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
/**
*
@@ -21,6 +24,19 @@
return new PropertyDescriptor[]{};
}
}
+
+ public static Method[] getSetterMethods(Class<?> clazz){
+ Method[] methods = clazz.getMethods();
+ List<Method> mlist = new ArrayList<Method>();
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String methodName = method.getName();
+ if(methodName.startsWith("set")){
+ mlist.add(method);
+ }
+ }
+ return mlist.toArray(new Method[]{});
+ }
/**
*
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-09
09:05:36 UTC (rev 14624)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-09
09:45:28 UTC (rev 14625)
@@ -1,5 +1,6 @@
package org.jboss.tools.smooks.configuration.editors.uitls;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
@@ -8,6 +9,9 @@
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -15,29 +19,100 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavaMethodsSelectionDialog;
+import
org.jboss.tools.smooks.configuration.editors.javabean.JavaPropertiesSelectionDialog;
+import org.jboss.tools.smooks.model.javabean.BindingsType;
public class SmooksUIUtils {
public static Composite createJavaTypeSearchFieldEditor(Composite parent, FormToolkit
toolkit,
- final IItemPropertyDescriptor propertyDescriptor, final EObject model) {
+ final IItemPropertyDescriptor propertyDescriptor, final EObject model) {
if (model instanceof EObject) {
final Resource resource = ((EObject) model).eResource();
URI uri = resource.getURI();
IResource workspaceResource = null;
if (uri.isPlatformResource()) {
String path = uri.toPlatformString(true);
- workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new
Path(path));
+ workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(
+ new Path(path));
JavaTypeFieldDialog dialog = new JavaTypeFieldDialog(workspaceResource);
return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor,
- "Search Class", dialog, (EObject) model);
+ "Search Class", dialog, (EObject) model);
}
}
return null;
}
+ public static IResource getResource(EObject model) {
+ final Resource resource = ((EObject) model).eResource();
+ URI uri = resource.getURI();
+ IResource workspaceResource = null;
+ if (uri.isPlatformResource()) {
+ String path = uri.toPlatformString(true);
+ workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new
Path(path));
+ }
+ return workspaceResource;
+ }
+
+ public static IJavaProject getJavaProject(EObject model) {
+ IResource r = getResource(model);
+ if (r != null) {
+ IProject p = r.getProject();
+ return JavaCore.create(p);
+ }
+ return null;
+ }
+
+ public static Composite createJavaMethodSearchFieldEditor(BindingsType container,
+ Composite parent, FormToolkit toolkit, final IItemPropertyDescriptor
propertyDescriptor,
+ String buttonName, final EObject model) {
+ String classString = ((BindingsType) container).getClass_();
+ IJavaProject project = getJavaProject(container);
+ try {
+ ProjectClassLoader classLoader = new ProjectClassLoader(project);
+ Class<?> clazz = classLoader.loadClass(classString);
+ JavaMethodsSelectionDialog dialog = new JavaMethodsSelectionDialog(project, clazz);
+ return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor,
+ "Select method", dialog, (EObject) model);
+ } catch (JavaModelException e) {
+ // ignore
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ public static Composite createJavaPropertySearchFieldEditor(BindingsType container,
+ Composite parent, FormToolkit toolkit, final IItemPropertyDescriptor
propertyDescriptor,
+ String buttonName, final EObject model) {
+ String classString = ((BindingsType) container).getClass_();
+ IJavaProject project = getJavaProject(container);
+ try {
+ ProjectClassLoader classLoader = new ProjectClassLoader(project);
+ Class<?> clazz = classLoader.loadClass(classString);
+ JavaPropertiesSelectionDialog dialog = new JavaPropertiesSelectionDialog(project,
clazz);
+ return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor,
+ "Select property", dialog, (EObject) model);
+ } catch (JavaModelException e) {
+ // ignore
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ public static Object getEditValue(IItemPropertyDescriptor propertyDescriptor, Object
model) {
+ Object value = propertyDescriptor.getPropertyValue(model);
+ if (value != null && value instanceof PropertyValueWrapper) {
+ Object editValue = ((PropertyValueWrapper) value).getEditableValue(model);
+ return editValue;
+ }
+ return null;
+ }
+
public static Composite createDialogFieldEditor(Composite parent, FormToolkit toolkit,
- final IItemPropertyDescriptor propertyDescriptor, String buttonName, IFieldDialog
dialog,
- final EObject model) {
+ final IItemPropertyDescriptor propertyDescriptor, String buttonName, IFieldDialog
dialog,
+ final EObject model) {
String displayName = propertyDescriptor.getDisplayName(model);
toolkit.createLabel(parent, displayName + " :");
final Composite classTextComposite = toolkit.createComposite(parent);
@@ -47,14 +122,11 @@
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
classTextComposite.setLayout(fillLayout);
- final SearchComposite searchComposite = new SearchComposite(classTextComposite,
toolkit, buttonName,
- dialog, SWT.NONE);
- Object value = propertyDescriptor.getPropertyValue(model);
- if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value).getEditableValue(model);
- if (editValue != null) {
- searchComposite.getText().setText(editValue.toString());
- }
+ final SearchComposite searchComposite = new SearchComposite(classTextComposite,
toolkit,
+ buttonName, dialog, SWT.NONE);
+ Object editValue = getEditValue(propertyDescriptor, model);
+ if (editValue != null) {
+ searchComposite.getText().setText(editValue.toString());
}
searchComposite.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -63,10 +135,12 @@
Object editValue = ((PropertyValueWrapper) value).getEditableValue(model);
if (editValue != null) {
if (!editValue.equals(searchComposite.getText().getText())) {
- propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText()
+ .getText());
}
} else {
- propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText()
+ .getText());
}
} else {
propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());