Author: DartPeng
Date: 2009-04-08 13:24:26 -0400 (Wed, 08 Apr 2009)
New Revision: 14611
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SearchComposite.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
Removed:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/presentations/
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/BindingsPropertyUICreator.java
Log:
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-04-08
16:37:50 UTC (rev 14610)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -2,7 +2,9 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
import org.osgi.framework.BundleContext;
/**
@@ -15,7 +17,7 @@
// The shared instance
private static SmooksConfigurationActivator plugin;
-
+
/**
* The constructor
*/
@@ -24,7 +26,10 @@
/*
* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
*/
public void start(BundleContext context) throws Exception {
super.start(context);
@@ -33,7 +38,10 @@
/*
* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
@@ -42,22 +50,30 @@
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static SmooksConfigurationActivator getDefault() {
return plugin;
}
-
- public void log(Throwable e){
+
+ public void log(Throwable e) {
getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.ERROR, "Error", e));
}
+ @Override
+ protected void initializeImageRegistry(ImageRegistry reg) {
+ super.initializeImageRegistry(reg);
+ reg.put(GraphicsConstants.JAVA_PROPERTY_ICON,
+ getImageDescriptor(GraphicsConstants.JAVA_PROPERTY_ICON_PATH));
+ }
+
/**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path
- *
- * @param path the path
+ * Returns an image descriptor for the image file at the given plug-in
+ * relative path
+ *
+ * @param path
+ * the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,6 @@
+package org.jboss.tools.smooks.configuration.editors;
+
+public final class GraphicsConstants {
+ public static final String JAVA_PROPERTY_ICON_PATH =
"icons/full/obj16/att_obj.gif";
+ public static final String JAVA_PROPERTY_ICON = JAVA_PROPERTY_ICON_PATH;
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java 2009-04-08
16:37:50 UTC (rev 14610)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -21,8 +21,6 @@
* Apr 7, 2009
*/
public interface IPropertyUICreator {
- public void createPropertyUI(FormToolkit toolkit, Composite parent,
+ public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature);
-
- public boolean canCreate(IItemPropertyDescriptor itemPropertyDescriptor, Object model,
EAttribute feature);
}
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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;
+
+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;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 9, 2009
+ */
+public class 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) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ 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;
+ }
+
+ public IJavaProject getJavaProject(EObject model) {
+ IResource r = getResource(model);
+ if (r != null) {
+ IProject p = r.getProject();
+ return JavaCore.create(p);
+ }
+ return null;
+ }
+
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java 2009-04-08
16:37:50 UTC (rev 14610)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -14,7 +14,9 @@
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.model.javabean.impl.BindingsTypeImpl;
+import org.jboss.tools.smooks.model.javabean.impl.ValueTypeImpl;
/**
* @author Dart (dpeng(a)redhat.com)<p>
@@ -32,6 +34,7 @@
private void init() {
map.put(BindingsTypeImpl.class, new BindingsPropertyUICreator());
+ map.put(ValueTypeImpl.class, new ValuePropertiesUICreator());
}
public void registePropertyUICreator(Class<?> key,IPropertyUICreator creator){
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-04-08
16:37:50 UTC (rev 14610)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -110,11 +110,15 @@
final IItemPropertyDescriptor itemPropertyDescriptor = (IItemPropertyDescriptor)
iterator
.next();
EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(getModel());
- if (creator != null && creator.canCreate(itemPropertyDescriptor,
- getModel(), feature)) {
- creator.createPropertyUI(formToolkit, propertyComposite, itemPropertyDescriptor,
- getModel(), feature);
- } else {
+ boolean createDefault = true;
+ if (creator != null) {
+ Composite composite = creator.createPropertyUI(formToolkit, propertyComposite,
+ itemPropertyDescriptor, getModel(), feature);
+ if (composite != null) {
+ createDefault = false;
+ }
+ }
+ if (createDefault) {
EClassifier typeClazz = feature.getEType();
if (typeClazz instanceof EEnum) {
createEnumFieldEditor(propertyComposite, (EEnum) typeClazz, formToolkit,
@@ -169,7 +173,8 @@
public void widgetSelected(SelectionEvent e) {
try {
Object value = itemPropertyDescriptor.getPropertyValue(getModel());
- Method method = typeClass.getInstanceClass().getMethod("get", new
Class<?>[]{String.class});
+ Method method = typeClass.getInstanceClass().getMethod("get",
+ new Class<?>[] { String.class });
// it's static method
Object v = method.invoke(null, combo.getText());
if (value != null && value instanceof PropertyValueWrapper) {
@@ -177,13 +182,13 @@
if (editValue != null) {
if (!editValue.equals(v)) {
- itemPropertyDescriptor.setPropertyValue(getModel(),v);
+ itemPropertyDescriptor.setPropertyValue(getModel(), v);
}
} else {
- itemPropertyDescriptor.setPropertyValue(getModel(),v);
+ itemPropertyDescriptor.setPropertyValue(getModel(), v);
}
} else {
- itemPropertyDescriptor.setPropertyValue(getModel(),v);
+ itemPropertyDescriptor.setPropertyValue(getModel(), v);
}
} catch (Throwable t) {
SmooksConfigurationActivator.getDefault().log(t);
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/BindingsPropertyUICreator.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/BindingsPropertyUICreator.java 2009-04-08
16:37:50 UTC (rev 14610)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/BindingsPropertyUICreator.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -10,42 +10,13 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.javabean;
-import org.eclipse.core.resources.IFile;
-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.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
-import org.eclipse.jdt.ui.IJavaElementSearchConstants;
-import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-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.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.SelectionDialog;
import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.IPropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
/**
@@ -79,131 +50,17 @@
* org.eclipse.emf.edit.provider.IItemPropertyDescriptor, java.lang.Object,
* org.eclipse.emf.ecore.EAttribute)
*/
- public void createPropertyUI(FormToolkit toolkit, Composite parent,
+ public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
- String displayName = propertyDescriptor.getDisplayName(model);
- toolkit.createLabel(parent, displayName + " :");
- createBeanClassTextWithButton(parent, toolkit, propertyDescriptor, model);
+ if (feature == JavabeanPackage.eINSTANCE.getBindingsType_Class()) {
+ return createBeanClassTextWithButton(parent, toolkit, propertyDescriptor, model);
+ }
+ return null;
}
- protected void createBeanClassTextWithButton(Composite composite, FormToolkit toolkit,
+ protected Composite createBeanClassTextWithButton(Composite composite, FormToolkit
toolkit,
final IItemPropertyDescriptor propertyDescriptor, final Object model) {
- final Resource resource = ((EObject) model).eResource();
- final Composite classTextComposite = toolkit.createComposite(composite);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- classTextComposite.setLayoutData(gd);
- GridLayout gl = new GridLayout();
- gl.marginWidth = 2;
- gl.numColumns = 2;
- gl.makeColumnsEqualWidth = false;
- gl.marginHeight = 2;
- classTextComposite.setLayout(gl);
-
- final Text text = toolkit.createText(classTextComposite, "");
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- text.setLayoutData(gd);
- Object value = propertyDescriptor.getPropertyValue(model);
- if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value).getEditableValue(model);
- if (editValue != null) {
- text.setText(editValue.toString());
- }
- }
- text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Object value = propertyDescriptor.getPropertyValue(model);
- if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value).getEditableValue(model);
- if (editValue != null) {
- if (!editValue.equals(text.getText())) {
- propertyDescriptor.setPropertyValue(model, text.getText());
- }
- } else {
- propertyDescriptor.setPropertyValue(model, text.getText());
- }
- } else {
- propertyDescriptor.setPropertyValue(model, text.getText());
- }
- }
- });
- Button search = toolkit.createButton(classTextComposite, "Search",
SWT.NONE);
- search.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
-
- if (resource != null && resource.getURI() != null) {
- URI uri = resource.getURI();
- if (uri.isPlatformResource()) {
- String path = uri.toPlatformString(true);
- IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(
- new Path(path));
- if (workspaceResource != null && workspaceResource instanceof IFile) {
- IProject project = ((IFile) workspaceResource).getProject();
- IJavaProject jp = JavaCore.create(project);
- if (jp != null) {
- String className = openJavaTypeDialog(classTextComposite.getShell(), jp);
- if (className != null) {
- text.setText(className);
- }
- return;
- }
- }
- }
- }
- MessageDialog.openInformation(classTextComposite.getShell(), "Can't open
dialog",
- "Can't open java type search dialog.");
- }
- });
- gd = new GridData(GridData.END);
- search.setLayoutData(gd);
- toolkit.paintBordersFor(classTextComposite);
+ return SmooksUIUtils.createJavaTypeSearchFieldEditor(composite, toolkit,
propertyDescriptor, (EObject)model);
}
- protected String openJavaTypeDialog(Shell shell, IJavaProject javaProject) {
- IJavaSearchScope scope = null;
- String className = null;
- if (javaProject == null) {
- scope = JavaSearchScopeFactory.getInstance().createWorkspaceScope(true);
- } else {
- String[] requiredProjects = null;
- try {
- requiredProjects = javaProject.getRequiredProjectNames();
- } catch (Exception e) {
- }
- if (requiredProjects == null) {
- requiredProjects = new String[] { javaProject.getElementName() };
- } else {
- String[] temp = new String[requiredProjects.length + 1];
- temp[0] = javaProject.getElementName();
- System.arraycopy(requiredProjects, 0, temp, 1, requiredProjects.length);
- requiredProjects = temp;
- }
- scope =
JavaSearchScopeFactory.getInstance().createJavaProjectSearchScope(requiredProjects,
true);
- }
- SelectionDialog dialog;
- try {
- dialog = JavaUI.createTypeDialog(shell,
SmooksConfigurationActivator.getDefault().getWorkbench()
- .getActiveWorkbenchWindow(), scope,
- IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false);
- dialog.setMessage("Search Java Type");
- dialog.setTitle("Search Java Type");
- if (dialog.open() == Window.OK) {
- Object[] results = dialog.getResult();
- if (results.length > 0) {
- Object result = results[0];
- String packageFullName = JavaModelUtil.getTypeContainerName((IType) result);
- if (packageFullName == null || packageFullName.length() <= 0) {
- className = ((IType) result).getElementName();
- } else {
- className = packageFullName + "." //$NON-NLS-1$
- + ((IType) result).getElementName();
- }
- return className;
- }
- }
- } catch (Throwable t) {
- SmooksConfigurationActivator.getDefault().log(t);
- }
- return className;
- }
}
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * 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.beans.PropertyDescriptor;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+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 JavaPropertiesSelectionDialog implements IFieldDialog {
+
+ private IJavaProject resource;
+
+ private Class<?> clazz;
+
+ public JavaPropertiesSelectionDialog(IJavaProject resource, Class<?> clazz) {
+ super();
+ this.resource = resource;
+ this.clazz = clazz;
+ }
+
+ public Object open(Shell shell) {
+ if (resource != null && clazz != null) {
+ PropertySelectionDialog dialog = new PropertySelectionDialog(shell, resource, clazz);
+ if (dialog.open() == Dialog.OK) {
+ PropertyDescriptor pd = (PropertyDescriptor) dialog.getCurrentSelection();
+ return pd.getName();
+ }else{
+ return null;
+ }
+ }
+ MessageDialog.openInformation(shell, "Can't open dialog",
+ "Can't open java properties selection dialog.");
+ return null;
+ }
+
+ private class PropertySelectionDialog extends Dialog {
+
+ private TableViewer viewer;
+
+ private IJavaProject project;
+
+ private Class<?> clazz;
+
+ private Object currentSelection;
+
+
+
+ public PropertySelectionDialog(IShellProvider parentShell) {
+ super(parentShell);
+ }
+
+ public PropertySelectionDialog(Shell parentShell, IJavaProject project, Class<?>
clazz) {
+ super(parentShell);
+ this.project = project;
+ 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("Name");
+ TableColumn typeColumn = new TableColumn(table, SWT.NONE);
+ typeColumn.setWidth(200);
+ typeColumn.setText("Type");
+ table.setHeaderVisible(true);
+ viewer.setContentProvider(new PropertyDescriptorContentProvider());
+ viewer.setLabelProvider(new PropertyDescriptorLabelProvider());
+ PropertyDescriptor[] pds = JavaPropertyUtils.getPropertyDescriptor(clazz);
+ viewer.setInput(pds);
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ currentSelection = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ }
+
+ });
+ return composite;
+ }
+
+ public Object getCurrentSelection() {
+ return currentSelection;
+ }
+
+ public void setCurrentSelection(Object currentSelection) {
+ this.currentSelection = currentSelection;
+ }
+ }
+
+ private class PropertyDescriptorContentProvider 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) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ private class PropertyDescriptorLabelProvider 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 PropertyDescriptor) {
+ PropertyDescriptor p = (PropertyDescriptor) element;
+ switch (columnIndex) {
+ case 0:
+ return p.getName();
+ case 1:
+ Class<?> cla = p.getPropertyType();
+ if(cla.isArray()){
+ return cla.getComponentType().getName() + "[]";
+ }
+ return cla.getName();
+ }
+ }
+ return getText(element);
+ }
+ }
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaPropertiesSelectionDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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;
+ }
+
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/ValuePropertiesUICreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.uitls;
+
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)<p>
+ * Apr 8, 2009
+ */
+public interface IFieldDialog {
+ Object open(Shell shell);
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,45 @@
+package org.jboss.tools.smooks.configuration.editors.uitls;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+
+/**
+ *
+ * @author Dart Peng<br>
+ * Date : Sep 10, 2008
+ */
+public class JavaPropertyUtils {
+
+ private static JavaPropertyUtils instace = null;
+
+ public static PropertyDescriptor[] getPropertyDescriptor(Class clazz) {
+ try {
+ return getInstace().getPropertyDescriptorArray(clazz);
+ } catch (Exception e) {
+ // ignore
+ return new PropertyDescriptor[]{};
+ }
+ }
+
+ /**
+ *
+ * @param clazz
+ * @return
+ * @throws IntrospectionException
+ */
+ public PropertyDescriptor[] getPropertyDescriptorArray(Class clazz)
+ throws IntrospectionException {
+ // TODO should improve (use some catch to store the BeanInfo , right?)
+ return Introspector
+ .getBeanInfo(clazz, Introspector.IGNORE_ALL_BEANINFO)
+ .getPropertyDescriptors();
+ }
+
+ public static JavaPropertyUtils getInstace() {
+ if (instace == null) {
+ instace = new JavaPropertyUtils();
+ }
+ return instace;
+ }
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * 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.uitls;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
+import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)<p>
+ * Apr 8, 2009
+ */
+public class JavaTypeFieldDialog implements IFieldDialog {
+
+ IResource workspaceResource = null;
+
+ public JavaTypeFieldDialog(IResource resource) {
+ super();
+ workspaceResource = resource;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.configuration.editors.uitls.IFieldDialog#open()
+ */
+ public Object open(Shell shell) {
+ if (workspaceResource != null && workspaceResource instanceof IFile) {
+ IProject project = ((IFile) workspaceResource).getProject();
+ IJavaProject jp = JavaCore.create(project);
+ if (jp != null) {
+ return openJavaTypeDialog(shell, jp);
+ }
+ }
+ MessageDialog.openInformation(shell, "Can't open dialog",
+ "Can't open java type search dialog.");
+ return null;
+ }
+
+ protected String openJavaTypeDialog(Shell shell, IJavaProject javaProject) {
+ IJavaSearchScope scope = null;
+ String className = null;
+ if (javaProject == null) {
+ scope = JavaSearchScopeFactory.getInstance().createWorkspaceScope(true);
+ } else {
+ String[] requiredProjects = null;
+ try {
+ requiredProjects = javaProject.getRequiredProjectNames();
+ } catch (Exception e) {
+ }
+ if (requiredProjects == null) {
+ requiredProjects = new String[] { javaProject.getElementName() };
+ } else {
+ String[] temp = new String[requiredProjects.length + 1];
+ temp[0] = javaProject.getElementName();
+ System.arraycopy(requiredProjects, 0, temp, 1, requiredProjects.length);
+ requiredProjects = temp;
+ }
+ scope =
JavaSearchScopeFactory.getInstance().createJavaProjectSearchScope(requiredProjects,
true);
+ }
+ SelectionDialog dialog;
+ try {
+ dialog = JavaUI.createTypeDialog(shell,
SmooksConfigurationActivator.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow(), scope,
+ IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false);
+ dialog.setMessage("Search Java Type");
+ dialog.setTitle("Search Java Type");
+ if (dialog.open() == Window.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length > 0) {
+ Object result = results[0];
+ String packageFullName = JavaModelUtil.getTypeContainerName((IType) result);
+ if (packageFullName == null || packageFullName.length() <= 0) {
+ className = ((IType) result).getElementName();
+ } else {
+ className = packageFullName + "." //$NON-NLS-1$
+ + ((IType) result).getElementName();
+ }
+ return className;
+ }
+ }
+ } catch (Throwable t) {
+ SmooksConfigurationActivator.getDefault().log(t);
+ }
+ return className;
+ }
+
+
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,110 @@
+package org.jboss.tools.smooks.configuration.editors.uitls;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+
+/**
+ * This class code comes from HibernateSynchronizer
+ *
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 21, 2008
+ */
+public class ProjectClassLoader extends URLClassLoader {
+
+ public ProjectClassLoader(IJavaProject project) throws JavaModelException {
+ super(getURLSFromProject(project, null, true), Thread.currentThread()
+ .getContextClassLoader());
+ }
+
+ public ProjectClassLoader(IJavaProject project, URL[] extraUrls)
+ throws JavaModelException {
+ super(getURLSFromProject(project, extraUrls, true), Thread
+ .currentThread().getContextClassLoader());
+ }
+
+ private static URL[] getURLSFromProject(IJavaProject project,
+ URL[] extraUrls, boolean cludeRequiredProject)
+ throws JavaModelException {
+ List<URL> list = new ArrayList<URL>();
+ if (null != extraUrls) {
+ for (int i = 0; i < extraUrls.length; i++) {
+ list.add(extraUrls[i]);
+ }
+ }
+
+ IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
+ if (cludeRequiredProject) {
+ String[] requiredProjectNames = project.getRequiredProjectNames();
+ for (int i = 0; i < requiredProjectNames.length; i++) {
+ String requiredProjectName = requiredProjectNames[i];
+ IProject requiredProject = ResourcesPlugin.getWorkspace()
+ .getRoot().getProject(requiredProjectName);
+ if (requiredProject != null && requiredProject.isOpen()) {
+ IJavaProject jp = JavaCore.create(requiredProject);
+ if (jp == null)
+ continue;
+ URL[] requeiredURL = getURLSFromProject(jp, extraUrls,
+ false);
+ if (requeiredURL == null)
+ continue;
+ for (int j = 0; j < requeiredURL.length; j++) {
+ list.add(requeiredURL[j]);
+ }
+ }
+ }
+ }
+ IPath installPath = ResourcesPlugin.getWorkspace().getRoot()
+ .getLocation();
+ for (int i = 0; i < roots.length; i++) {
+ try {
+ if (roots[i].isArchive()) {
+ File f = new File(FileLocator.resolve(
+ installPath.append(roots[i].getPath()).toFile()
+ .toURL()).getFile());
+ if (!f.exists()) {
+ f = new File(FileLocator.resolve(
+ roots[i].getPath().makeAbsolute().toFile()
+ .toURL()).getFile());
+ }
+ list.add(f.toURL());
+ } else {
+ IPath path = roots[i].getJavaProject().getOutputLocation();
+ if (path.segmentCount() > 1) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace()
+ .getRoot();
+ path = root.getFolder(path).getLocation();
+ list.add(path.toFile().toURL());
+ } else {
+ path = roots[i].getJavaProject().getProject()
+ .getLocation();
+ list.add(path.toFile().toURL());
+ }
+ }
+ } catch (Exception e) {
+ }
+
+ }
+
+ URL[] urls = new URL[list.size()];
+ int index = 0;
+ for (Iterator i = list.iterator(); i.hasNext(); index++) {
+ urls[index] = (URL) i.next();
+ }
+ return urls;
+ }
+}
\ No newline at end of file
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SearchComposite.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SearchComposite.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SearchComposite.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.uitls;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 8, 2009
+ */
+public class SearchComposite extends Composite {
+
+ protected Text text;
+ protected Button searchButton;
+
+ public SearchComposite(Composite parent, FormToolkit toolkit, String
searchName,IFieldDialog dialog, int style) {
+ super(parent, style);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ GridLayout gl = new GridLayout();
+ gl.marginWidth = 2;
+ gl.numColumns = 2;
+ gl.makeColumnsEqualWidth = false;
+ gl.marginHeight = 2;
+ this.setLayout(gl);
+ if (toolkit != null) {
+ text = toolkit.createText(this, "");
+ } else {
+ text = new Text(this, SWT.BORDER);
+ }
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ text.setLayoutData(gd);
+ if (toolkit != null) {
+ searchButton = toolkit.createButton(this, searchName, SWT.NONE);
+ } else {
+ searchButton = new Button(this, SWT.BORDER);
+ searchButton.setText(searchName);
+ }
+ final IFieldDialog fieldDialog = dialog;
+ searchButton.addSelectionListener(new SelectionAdapter(){
+
+ public void widgetSelected(SelectionEvent e) {
+ Object value = fieldDialog.open(getShell());
+ if(value != null){
+ text.setText(getDialogResultText(value));
+ }
+ }
+
+ });
+ gd = new GridData(GridData.END);
+ searchButton.setLayoutData(gd);
+ if (toolkit != null) {
+ toolkit.paintBordersFor(this);
+ }
+ }
+
+ public String getDialogResultText(Object value){
+ return value.toString();
+ }
+
+ public void addModifyListener(ModifyListener listener) {
+ if (text != null) {
+ text.addModifyListener(listener);
+ }
+ }
+
+ public void addSelectionListener(SelectionListener listener) {
+ if (searchButton != null) {
+ searchButton.addSelectionListener(listener);
+ }
+ }
+
+ public Text getText() {
+ return text;
+ }
+
+ public Button getSearchButton() {
+ return searchButton;
+ }
+
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SearchComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-08
17:24:26 UTC (rev 14611)
@@ -0,0 +1,79 @@
+package org.jboss.tools.smooks.configuration.editors.uitls;
+
+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.EObject;
+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.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class SmooksUIUtils {
+
+ public static Composite createJavaTypeSearchFieldEditor(Composite parent, FormToolkit
toolkit,
+ 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));
+ JavaTypeFieldDialog dialog = new JavaTypeFieldDialog(workspaceResource);
+ return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor,
+ "Search Class", dialog, (EObject) model);
+ }
+ }
+ return null;
+ }
+
+ public static Composite createDialogFieldEditor(Composite parent, FormToolkit toolkit,
+ 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);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ classTextComposite.setLayoutData(gd);
+ FillLayout fillLayout = new FillLayout();
+ 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());
+ }
+ }
+ searchComposite.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ Object value = propertyDescriptor.getPropertyValue(model);
+ if (value != null && value instanceof PropertyValueWrapper) {
+ Object editValue = ((PropertyValueWrapper) value).getEditableValue(model);
+ if (editValue != null) {
+ if (!editValue.equals(searchComposite.getText().getText())) {
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
+ }
+ } else {
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
+ }
+ } else {
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
+ }
+ }
+ });
+ toolkit.paintBordersFor(classTextComposite);
+ return classTextComposite;
+ }
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain