JBoss Tools SVN: r14611 - in workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration: editors and 2 other directories.
by jbosstools-commits@lists.jboss.org
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
15 years, 8 months
JBoss Tools SVN: r14610 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-04-08 12:37:50 -0400 (Wed, 08 Apr 2009)
New Revision: 14610
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-04-08 15:46:17 UTC (rev 14609)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-04-08 16:37:50 UTC (rev 14610)
@@ -347,20 +347,20 @@
private void scanProperties(IFile file, String content){
//System.out.println("ScanProperties "+file.getName());
- try{
- FileInputStream fis = new FileInputStream(new File(file.getLocationURI()));
- PropertyResourceBundle rb = new PropertyResourceBundle(fis);
- for(String key : rb.keySet()){
- //System.out.println("Key - "+key+" Val - "+rb.getString(key));
- String value = rb.getString(key);
- if(value.indexOf('{')>-1)
- scanString(file, value, 0);
- }
- }catch(FileNotFoundException ex){
- SeamCorePlugin.getDefault().logError(ex);
- }catch(IOException ex){
- SeamCorePlugin.getDefault().logError(ex);
- }
+// try{
+// FileInputStream fis = new FileInputStream(new File(file.getLocationURI()));
+// PropertyResourceBundle rb = new PropertyResourceBundle(fis);
+// for(String key : rb.keySet()){
+// //System.out.println("Key - "+key+" Val - "+rb.getString(key));
+// String value = rb.getString(key);
+// if(value.indexOf('{')>-1)
+// scanString(file, value, 0);
+// }
+// }catch(FileNotFoundException ex){
+// SeamCorePlugin.getDefault().logError(ex);
+// }catch(IOException ex){
+// SeamCorePlugin.getDefault().logError(ex);
+// }
}
/*
15 years, 8 months
JBoss Tools SVN: r14609 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-04-08 11:46:17 -0400 (Wed, 08 Apr 2009)
New Revision: 14609
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-04-08 15:21:35 UTC (rev 14608)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-04-08 15:46:17 UTC (rev 14609)
@@ -10,9 +10,13 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.refactoring;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.PropertyResourceBundle;
import java.util.Set;
import org.eclipse.core.resources.IFile;
@@ -256,7 +260,7 @@
if (model instanceof IDOMModel) {
IDOMModel domModel = (IDOMModel) model;
IDOMDocument document = domModel.getDocument();
- validateChildNodes(file, document);
+ scanChildNodes(file, document);
}
} catch (CoreException e) {
SeamCorePlugin.getDefault().logError(e);
@@ -269,20 +273,20 @@
}
}
- private void validateChildNodes(IFile file, Node parent) {
+ private void scanChildNodes(IFile file, Node parent) {
NodeList children = parent.getChildNodes();
for(int i=0; i<children.getLength(); i++) {
Node curentValidatedNode = children.item(i);
if(Node.ELEMENT_NODE == curentValidatedNode.getNodeType()) {
- validateNodeContent(file, ((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(), DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE);
+ scanNodeContent(file, ((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(), DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE);
} else if(Node.TEXT_NODE == curentValidatedNode.getNodeType()) {
- validateNodeContent(file, ((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(), DOMRegionContext.XML_CONTENT);
+ scanNodeContent(file, ((IDOMNode)curentValidatedNode).getFirstStructuredDocumentRegion(), DOMRegionContext.XML_CONTENT);
}
- validateChildNodes(file, curentValidatedNode);
+ scanChildNodes(file, curentValidatedNode);
}
}
- private void validateNodeContent(IFile file, IStructuredDocumentRegion node, String regionType) {
+ private void scanNodeContent(IFile file, IStructuredDocumentRegion node, String regionType) {
ITextRegionList regions = node.getRegions();
for(int i=0; i<regions.size(); i++) {
ITextRegion region = regions.get(i);
@@ -342,7 +346,21 @@
}
private void scanProperties(IFile file, String content){
-
+ //System.out.println("ScanProperties "+file.getName());
+ try{
+ FileInputStream fis = new FileInputStream(new File(file.getLocationURI()));
+ PropertyResourceBundle rb = new PropertyResourceBundle(fis);
+ for(String key : rb.keySet()){
+ //System.out.println("Key - "+key+" Val - "+rb.getString(key));
+ String value = rb.getString(key);
+ if(value.indexOf('{')>-1)
+ scanString(file, value, 0);
+ }
+ }catch(FileNotFoundException ex){
+ SeamCorePlugin.getDefault().logError(ex);
+ }catch(IOException ex){
+ SeamCorePlugin.getDefault().logError(ex);
+ }
}
/*
15 years, 8 months
JBoss Tools SVN: r14608 - in trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2009-04-08 11:21:35 -0400 (Wed, 08 Apr 2009)
New Revision: 14608
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/Seam.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4109, style and styleClass attributes were added.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java 2009-04-08 14:58:51 UTC (rev 14607)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java 2009-04-08 15:21:35 UTC (rev 14608)
@@ -1,20 +1,46 @@
package org.jboss.tools.jsf.vpe.seam.template;
+import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
+import org.jboss.tools.jsf.vpe.seam.template.util.Seam;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate;
+import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class SeamDecorateTemplate extends VpeDefineContainerTemplate {
- private final String ATTR_TEMPLATE = "template"; //$NON-NLS-1$
-
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- String fileName = ((Element) sourceNode).getAttribute(ATTR_TEMPLATE);
- return createTemplate(fileName, pageContext, sourceNode, visualDocument);
+
+ Element sourceElement = (Element) sourceNode;
+
+ /*
+ * Reading attributes
+ */
+ String fileName = sourceElement.getAttribute(Seam.ATTR_TEMPLATE);
+ String styleClass = sourceElement.getAttribute(Seam.ATTR_STYLE_CLASS);
+ String style = sourceElement.getAttribute(HTML.ATTR_STYLE);
+
+ /*
+ * Creating template
+ */
+ VpeCreationData creationData = createTemplate(fileName, pageContext, sourceNode, visualDocument);
+
+ /*
+ * Setting style and class attributes
+ */
+ if (ComponentUtil.isNotBlank(style)) {
+ ((nsIDOMElement)creationData.getNode()).setAttribute(HTML.ATTR_STYLE, style);
+ }
+ if (ComponentUtil.isNotBlank(styleClass)) {
+ ((nsIDOMElement)creationData.getNode()).setAttribute(HTML.ATTR_CLASS, styleClass);
+ }
+
+ return creationData;
}
}
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/Seam.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/Seam.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/Seam.java 2009-04-08 15:21:35 UTC (rev 14608)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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.jsf.vpe.seam.template.util;
+
+/**
+ * Class contains Seam tags and general attributes.
+ *
+ * @author dmaliarevich
+ *
+ */
+public class Seam {
+
+ public static final String ATTR_TEMPLATE = "template"; //$NON-NLS-1$
+ public static final String ATTR_STYLE_CLASS = "styleClass"; //$NON-NLS-1$
+
+}
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/util/Seam.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
15 years, 8 months
JBoss Tools SVN: r14607 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-04-08 10:58:51 -0400 (Wed, 08 Apr 2009)
New Revision: 14607
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java
Log:
JBIDE-4132
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java 2009-04-08 14:14:43 UTC (rev 14606)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/SourceEditorPageContext.java 2009-04-08 14:58:51 UTC (rev 14607)
@@ -40,6 +40,8 @@
* Contains information about taglibs on edited page
*/
private List<TaglibData> taglibs = null;
+
+ private IDocument iDocument;
/**
* Kb connector
*/
@@ -70,6 +72,7 @@
setConnector(null);
setReferenceNode(null);
setPageContext(null);
+ iDocument = null;
}
/**
@@ -89,16 +92,18 @@
* @param iDocument
*/
public void setDocument(IDocument iDocument, Node refNode) {
+ this.iDocument = iDocument;
if(refNode != null) {
referenceNode = null; //TODO study when we really need refresh
setReferenceNode(refNode);
} else {
- List<TaglibData> taglibs = XmlUtil.getTaglibsForJSPDocument(iDocument, getIncludeTaglibs());
+ List<TaglibData> taglibs = getIncludeTaglibs();
//if we on jsp page we will set taglibs
//TODO Max Areshkau Find other possibility to check if we on jsp page
// FIX FOR https://jira.jboss.org/jira/browse/JBIDE-3888
// in some cases list of taglibs is not refreshed
- if(taglibs != null /*&& taglibs.size()>0*/) {
+// if(taglibs != null /*&& taglibs.size()>0*/) {
+ if(taglibs != null && taglibs.size()>0) {
setTaglibs(taglibs);
}
}
@@ -217,11 +222,16 @@
}
public List<TaglibData> getIncludeTaglibs() {
+ List<TaglibData> result = null;
if(getPageContext() != null) {
- return getPageContext().getIncludeTaglibs();
+ result = getPageContext().getIncludeTaglibs();
} else {
- return new ArrayList<TaglibData>();
+ result = new ArrayList<TaglibData>();
}
+ if(iDocument != null) {
+ result = XmlUtil.getTaglibsForJSPDocument(iDocument, result);
+ }
+ return result;
}
}
15 years, 8 months
JBoss Tools SVN: r14606 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.jstl/META-INF and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2009-04-08 10:14:43 -0400 (Wed, 08 Apr 2009)
New Revision: 14606
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDecorateTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlImportTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates/vpe-templates-seam.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4109, VpeDefineContainerTemplate was moved from Facelts plugin to org.jboss.tools.vpe.editor.template, c:import, s:decorate, ui:decorate templates were updated.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java 2009-04-08 13:51:05 UTC (rev 14605)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java 2009-04-08 14:14:43 UTC (rev 14606)
@@ -14,6 +14,7 @@
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -27,7 +28,7 @@
Attr attr = ((Element)sourceNode).getAttributeNode(Facelets.ATTR_TEMPLATE);
if (attr != null) {
- return super.create(pageContext, sourceNode, visualDocument);
+ return super.createTemplate(attr.getNodeValue(), pageContext, sourceNode, visualDocument);
} else {
nsIDOMElement composition = visualDocument.createElement(HTML.TAG_DIV);
return new VpeCreationData(composition);
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDecorateTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDecorateTemplate.java 2009-04-08 13:51:05 UTC (rev 14605)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDecorateTemplate.java 2009-04-08 14:14:43 UTC (rev 14606)
@@ -10,44 +10,18 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.facelets.template;
-import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
-import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.jsf.vpe.facelets.template.util.Facelets;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-public class VpeDecorateTemplate extends VpeDefineContainerTemplate {
+public class VpeDecorateTemplate extends org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate{
- protected VpeCreationData createStub(String fileName, Node sourceElement, nsIDOMDocument visualDocument) {
- nsIDOMElement container = visualDocument.createElement(HTML.TAG_DIV);
- container.setAttribute("style", "border: 1px dashed #2A7F00");
- VpeVisualDomBuilder.markIncludeElement(container);
-
- nsIDOMElement title = visualDocument.createElement(HTML.TAG_DIV);
- nsIDOMElement tag = visualDocument.createElement(HTML.TAG_SPAN);
- tag.setAttribute("class", "__any__tag__caption");
- tag.appendChild(visualDocument.createTextNode(sourceElement.getNodeName()));
- title.appendChild(tag);
- if (fileName != null) {
- title.appendChild(visualDocument.createTextNode(fileName));
- }
- container.appendChild(title);
-
- VpeCreationData creationData = new VpeCreationData(container);
-
- VpeChildrenInfo childrenInfo = new VpeChildrenInfo(container);
- NodeList sourceChildren = sourceElement.getChildNodes();
- int len = sourceChildren.getLength();
- for (int i = 0; i < len; i++) {
- Node sourceChild = sourceChildren.item(i);
- if (sourceChild.getNodeType() == Node.ELEMENT_NODE && "define".equals(sourceChild.getLocalName())) {
- childrenInfo.addSourceChild(sourceChild);
- }
- }
- creationData.addChildrenInfo(childrenInfo);
- return creationData;
+ public VpeCreationData create(VpePageContext pageContext,
+ Node sourceNode, nsIDOMDocument visualDocument) {
+ String fileName = ((Element)sourceNode).getAttribute(Facelets.ATTR_TEMPLATE);
+ return createTemplate(fileName, pageContext, sourceNode, visualDocument);
}
}
Deleted: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java 2009-04-08 13:51:05 UTC (rev 14605)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java 2009-04-08 14:14:43 UTC (rev 14606)
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jsf.vpe.facelets.template;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.core.resources.IFile;
-import org.jboss.tools.jsf.vpe.facelets.template.util.Facelets;
-import org.jboss.tools.vpe.editor.VpeIncludeInfo;
-import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
-import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
-import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
-import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
-import org.jboss.tools.vpe.editor.template.VpeTemplate;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.FileUtil;
-import org.jboss.tools.vpe.editor.util.HTML;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNamedNodeMap;
-import org.mozilla.interfaces.nsIDOMNode;
-import org.mozilla.interfaces.nsIDOMNodeList;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public abstract class VpeDefineContainerTemplate extends VpeAbstractTemplate {
- int count = 0;
- private static Set<Node> defineContainer = new HashSet<Node>();
-
- @Override
- protected void init(Element templateElement) {
- children = true;
- modify = false;
- initTemplateSections(templateElement, false, true, false, false, false);
- }
-
-
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument) {
- String fileName = ((Element)sourceNode).getAttribute(Facelets.ATTR_TEMPLATE);
- VpeCreationData creationData = createTemplate(fileName, pageContext, sourceNode, visualDocument);
- if (null != creationData) {
- return creationData;
- }
- creationData = createStub(fileName, (Element)sourceNode, visualDocument);
- creationData.setData(null);
- return creationData;
- }
-
- public VpeCreationData createTemplate(String fileName, VpePageContext pageContext,
- Node sourceNode, nsIDOMDocument visualDocument) {
- if (fileName != null && fileName.trim().length() > 0) {
- IFile file = VpeCreatorUtil.getFile(fileName, pageContext);
- if (file != null) {
- if (!pageContext.getVisualBuilder().isFileInIncludeStack(file)) {
- registerDefine(pageContext, sourceNode);
- Document document = pageContext.getVisualBuilder()
- .getIncludeDocuments().get(file);
- if (document == null) {
- document = VpeCreatorUtil.getDocumentForRead(file);
- if (document != null)
- pageContext.getVisualBuilder()
- .getIncludeDocuments().put(file, document);
- }
- // Document document =
- // VpeCreatorUtil.getDocumentForRead(file, pageContext);
- if (document != null) {
- VpeCreationData creationData = createInclude(document,
- visualDocument);
- creationData.setData(new TemplateFileInfo(file));
- pageContext.getVisualBuilder().pushIncludeStack(
- new VpeIncludeInfo((Element) sourceNode, file,
- document));
- // we should add only real nodem, sourceNode can be a
- // proxy
- // so
- if (sourceNode.getFirstChild() != null) {
- defineContainer.add(sourceNode.getFirstChild()
- .getParentNode());
- }
- return creationData;
- }
- }
- }
- }
- return null;
- }
-
- private String replacePattern(String origStr, String target,
- String replacement) {
- StringBuilder sb = new StringBuilder();
- String word = "((\\w+)([\\.\\[\\]]*))";
- Matcher m;
- String variable;
- String signs;
- m = Pattern.compile(word).matcher(origStr);
-
- // everything must be found here
- int endIndex = 0;
- int startIndex = 0;
- while (m.find()) {
- variable = m.group(2);
- signs = m.group(3);
- startIndex = m.start(2);
-
- if ((startIndex != 0) && (endIndex != 0)
- && (endIndex != startIndex)) {
- sb.append(origStr.substring(endIndex, startIndex));
- }
-
- if (target.equals(variable)) {
- sb.append(replacement);
- } else {
- sb.append(variable);
- }
- sb.append(signs);
- endIndex = m.end(3);
- }
-
- // append the tail
- if (endIndex != origStr.length()) {
- sb.append(origStr.substring(endIndex, origStr.length()));
- }
-
- if (!"".equals(sb.toString())) {
- return sb.toString();
- }
- return origStr;
- }
-
- private void updateNodeValue(nsIDOMNode node, Map<String, String> paramsMap) {
- Set<String> keys = paramsMap.keySet();
- if (null != node) {
- String nodeValue = node.getNodeValue();
- String curlyBracketResultPattern = "(" + Pattern.quote("#")
- + "\\{(.+?)\\})+?";
- int matcherGroupWithVariable = 2;
-
- if ((null != nodeValue) && (!"".equals(nodeValue))) {
- for (String key : keys) {
- Matcher curlyBracketMatcher = Pattern.compile(
- curlyBracketResultPattern).matcher(nodeValue);
-
- String replacement = paramsMap.get(key);
- if (replacement.startsWith("#{")
- && replacement.endsWith("}")) {
- // remove first 2 signs '#{'
- replacement = replacement.substring(2);
- // remove last '}' sign
- replacement = replacement.substring(0, replacement
- .length() - 1);
- }
-
- int lastPos = 0;
- StringBuilder sb = new StringBuilder();
- lastPos = 0;
- sb = new StringBuilder();
- curlyBracketMatcher.reset(nodeValue);
- boolean firstFind = false;
- boolean find = curlyBracketMatcher.find();
- while (find) {
- if (!firstFind) {
- firstFind = true;
- }
- int start = curlyBracketMatcher
- .start(matcherGroupWithVariable);
- int end = curlyBracketMatcher
- .end(matcherGroupWithVariable);
- String group = replacePattern(curlyBracketMatcher
- .group(matcherGroupWithVariable), key,
- replacement);
- sb.append(nodeValue.substring(lastPos, start));
- sb.append(group);
- lastPos = end;
- find = curlyBracketMatcher.find();
- }
- if (firstFind) {
- sb.append(nodeValue.substring(lastPos, nodeValue
- .length()));
- nodeValue = sb.toString();
- node.setNodeValue(nodeValue);
- }
- }
- }
- }
- }
-
- private void insertParam(nsIDOMNode node, Map<String, String> paramsMap) {
-
- // update current node value
- updateNodeValue(node, paramsMap);
-
- nsIDOMNamedNodeMap attributes = node.getAttributes();
- if (null != attributes) {
- long len = attributes.getLength();
- for (int i = 0; i < len; i++) {
- nsIDOMNode item = attributes.item(i);
- // update attributes node
- updateNodeValue(item, paramsMap);
- }
- }
-
- nsIDOMNodeList children = node.getChildNodes();
- if (null != children) {
- long len = children.getLength();
- for (int i = 0; i < len; i++) {
- nsIDOMNode child = children.item(i);
- // update child node
- insertParam(child, paramsMap);
- }
- }
- }
-
- @Override
- public void validate(VpePageContext pageContext, Node sourceNode, nsIDOMDocument visualDocument, VpeCreationData creationData) {
-
- Map<String, String> paramsMap = new HashMap<String, String>();
- NodeList sourceChildren = sourceNode.getChildNodes();
- int len = sourceChildren.getLength();
- for (int i = 0; i < len; i++) {
- Node sourceChild = sourceChildren.item(i);
- if (sourceChild.getNodeType() == Node.ELEMENT_NODE && Facelets.TAG_PARAM.equals(sourceChild.getLocalName())) {
- String name = ((Element)sourceChild).getAttribute(Facelets.ATTR_NAME);
- String value = ((Element)sourceChild).getAttribute(Facelets.ATTR_VALUE);
- paramsMap.put(name, value);
- }
- }
- nsIDOMNode node = creationData.getNode();
- insertParam(node, paramsMap);
-
- TemplateFileInfo templateFileInfo = (TemplateFileInfo)creationData.getData();
- if (templateFileInfo != null) {
- VpeIncludeInfo includeInfo = pageContext.getVisualBuilder().popIncludeStack();
- if (includeInfo != null) {
- // VpeCreatorUtil.releaseDocumentFromRead(includeInfo.getDocument());
- }
- }
- defineContainer.remove(sourceNode);
- }
- @Override
- public void beforeRemove(VpePageContext pageContext, Node sourceNode, nsIDOMNode visualNode, Object data) {
- TemplateFileInfo templateFileInfo = (TemplateFileInfo)data;
- if (templateFileInfo != null && templateFileInfo.templateFile != null) {
- pageContext.getEditPart().getController().getIncludeList().removeIncludeModel(templateFileInfo.templateFile);
- }
- }
- @Override
- public boolean recreateAtAttrChange(VpePageContext pageContext, Element sourceElement, nsIDOMDocument visualDocument, nsIDOMElement visualNode, Object data, String name, String value) {
-
- return true;
- }
-
- private void registerDefine(VpePageContext pageContext, Node defineContainer) {
- VpeTemplate template = null;
- NodeList sourceChildren = defineContainer.getChildNodes();
- int len = sourceChildren.getLength();
- for (int i = 0; i < len; i++) {
- Node sourceChild = sourceChildren.item(i);
- if (sourceChild.getNodeType() == Node.ELEMENT_NODE && Facelets.TAG_DEFINE.equals(sourceChild.getLocalName())) {
- if (template == null) {
- VpeTemplateManager templateManager = pageContext.getVisualBuilder().getTemplateManager();
- template = templateManager.getTemplate(pageContext, (Element)sourceChild, null);
- if (template == null) {
- break;
- }
- }
- pageContext.getVisualBuilder().registerNodes(new VpeElementMapping((Element)sourceChild, null, null, template, null, null));
- }
- }
- }
-
- private VpeCreationData createInclude(Document sourceDocument, nsIDOMDocument visualDocument) {
- nsIDOMElement visualNewElement = visualDocument.createElement(HTML.TAG_DIV);
- VpeVisualDomBuilder.markIncludeElement(visualNewElement);
- VpeCreationData creationData = new VpeCreationData(visualNewElement);
- VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualNewElement);
- NodeList sourceChildren = sourceDocument.getChildNodes();
- int len = sourceChildren.getLength();
- for (int i = 0; i < len; i++) {
- childrenInfo.addSourceChild(sourceChildren.item(i));
- }
- creationData.addChildrenInfo(childrenInfo);
- return creationData;
- }
- @Override
- public boolean containsText() {
- return false;
- }
-
- public static boolean isDefineContainer(Node sourceNode) {
-
- //FIX https://jira.jboss.org/jira/browse/JBIDE-3187 by sdzmitrovich
- //TODO: it is necessary to refactor facelet templates
-// return defineContainer.contains(sourceNode);
- while (sourceNode != null) {
- if (defineContainer.contains(sourceNode))
- return true;
-
- sourceNode = sourceNode.getParentNode();
- }
-
- return false;
-
- }
-
- @Override
- public void openIncludeEditor(VpePageContext pageContext,
- Element sourceElement, Object data) {
-
- if (data instanceof TemplateFileInfo) {
- FileUtil.openEditor(((TemplateFileInfo) data).getTemplateFile());
- }
- }
-
- protected abstract VpeCreationData createStub(String fileName, Node sourceElement, nsIDOMDocument visualDocument);
-
- static class TemplateFileInfo {
- private IFile templateFile;
-
- TemplateFileInfo(IFile templateFile) {
- this.templateFile = templateFile;
- }
-
- public IFile getTemplateFile() {
- return templateFile;
- }
-
- public void setTemplateFile(IFile templateFile) {
- this.templateFile = templateFile;
- }
- }
-}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java 2009-04-08 13:51:05 UTC (rev 14605)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java 2009-04-08 14:14:43 UTC (rev 14606)
@@ -13,6 +13,7 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate;
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/META-INF/MANIFEST.MF 2009-04-08 13:51:05 UTC (rev 14605)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/META-INF/MANIFEST.MF 2009-04-08 14:14:43 UTC (rev 14606)
@@ -15,8 +15,7 @@
org.eclipse.jst.jsp.core,
org.eclipse.wst.html.core,
org.jboss.tools.vpe.html,
- org.jboss.tools.jsf.vpe.jsf;bundle-version="2.1.0",
- org.jboss.tools.jsf.vpe.facelets;bundle-version="2.1.0"
+ org.jboss.tools.jsf.vpe.jsf;bundle-version="2.1.0"
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.jsf.vpe.jstl.template
Bundle-Localization: plugin
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlImportTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlImportTemplate.java 2009-04-08 13:51:05 UTC (rev 14605)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlImportTemplate.java 2009-04-08 14:14:43 UTC (rev 14606)
@@ -10,26 +10,20 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jstl.template;
-import org.jboss.tools.jsf.vpe.facelets.template.VpeDecorateTemplate;
import org.jboss.tools.jsf.vpe.jstl.template.util.Jstl;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate;
import org.mozilla.interfaces.nsIDOMDocument;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-public class JstlImportTemplate extends VpeDecorateTemplate {
+public class JstlImportTemplate extends VpeDefineContainerTemplate {
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
String fileName = ((Element)sourceNode).getAttribute(Jstl.ATTR_URL);
- VpeCreationData creationData = createTemplate(fileName, pageContext, sourceNode, visualDocument);
- if (null != creationData) {
- return creationData;
- }
- creationData = createStub(fileName, (Element)sourceNode, visualDocument);
- creationData.setData(null);
- return creationData;
+ return createTemplate(fileName, pageContext, sourceNode, visualDocument);
}
}
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java 2009-04-08 14:14:43 UTC (rev 14606)
@@ -0,0 +1,20 @@
+package org.jboss.tools.jsf.vpe.seam.template;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class SeamDecorateTemplate extends VpeDefineContainerTemplate {
+
+ private final String ATTR_TEMPLATE = "template"; //$NON-NLS-1$
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ String fileName = ((Element) sourceNode).getAttribute(ATTR_TEMPLATE);
+ return createTemplate(fileName, pageContext, sourceNode, visualDocument);
+ }
+
+}
Property changes on: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates/vpe-templates-seam.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates/vpe-templates-seam.xml 2009-04-08 13:51:05 UTC (rev 14605)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/templates/vpe-templates-seam.xml 2009-04-08 14:14:43 UTC (rev 14606)
@@ -101,7 +101,8 @@
</vpe:tag>
<vpe:tag name="s:decorate" case-sensitive="yes">
- <vpe:template children="yes" modify="yes" namespaceIdentifier="org.jboss.tools.jsf.vpe.facelets" class="org.jboss.tools.jsf.vpe.facelets.template.VpeDecorateTemplate">
+ <vpe:template children="yes" modify="yes"
+ class="org.jboss.tools.jsf.vpe.seam.template.SeamDecorateTemplate">
</vpe:template>
</vpe:tag>
Added: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java (rev 0)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java 2009-04-08 14:14:43 UTC (rev 14606)
@@ -0,0 +1,395 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.template;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.vpe.editor.VpeIncludeInfo;
+import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
+import org.jboss.tools.vpe.editor.template.VpeTemplate;
+import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.FileUtil;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNamedNodeMap;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public abstract class VpeDefineContainerTemplate extends VpeAbstractTemplate {
+ int count = 0;
+ private static Set<Node> defineContainer = new HashSet<Node>();
+
+ @Override
+ protected void init(Element templateElement) {
+ children = true;
+ modify = false;
+ initTemplateSections(templateElement, false, true, false, false, false);
+ }
+
+ public VpeCreationData createTemplate(String includedFileName,
+ VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ VpeCreationData creationData = null;
+ if (includedFileName != null && includedFileName.trim().length() > 0) {
+ IFile file = VpeCreatorUtil.getFile(includedFileName, pageContext);
+ if (file != null) {
+ if (!pageContext.getVisualBuilder().isFileInIncludeStack(file)) {
+ registerDefine(pageContext, sourceNode);
+ Document document = pageContext.getVisualBuilder()
+ .getIncludeDocuments().get(file);
+ if (document == null) {
+ document = VpeCreatorUtil.getDocumentForRead(file);
+ if (document != null)
+ pageContext.getVisualBuilder()
+ .getIncludeDocuments().put(file, document);
+ }
+ // Document document =
+ // VpeCreatorUtil.getDocumentForRead(file, pageContext);
+ if (document != null) {
+ creationData = createInclude(document, visualDocument);
+ creationData.setData(new TemplateFileInfo(file));
+ pageContext.getVisualBuilder().pushIncludeStack(
+ new VpeIncludeInfo((Element) sourceNode, file,
+ document));
+ /*
+ * we should add only real node, sourceNode can be a
+ * proxy so
+ */
+ if (sourceNode.getFirstChild() != null) {
+ defineContainer.add(sourceNode.getFirstChild()
+ .getParentNode());
+ }
+ return creationData;
+ }
+ }
+ }
+ }
+ /*
+ * Create a stub when creationData is null.
+ */
+ creationData = createStub(includedFileName, (Element) sourceNode,
+ visualDocument);
+ creationData.setData(null);
+ return creationData;
+ }
+
+ private String replacePattern(String origStr, String target,
+ String replacement) {
+ StringBuilder sb = new StringBuilder();
+ String word = "((\\w+)([\\.\\[\\]]*))";
+ Matcher m;
+ String variable;
+ String signs;
+ m = Pattern.compile(word).matcher(origStr);
+
+ // everything must be found here
+ int endIndex = 0;
+ int startIndex = 0;
+ while (m.find()) {
+ variable = m.group(2);
+ signs = m.group(3);
+ startIndex = m.start(2);
+
+ if ((startIndex != 0) && (endIndex != 0)
+ && (endIndex != startIndex)) {
+ sb.append(origStr.substring(endIndex, startIndex));
+ }
+
+ if (target.equals(variable)) {
+ sb.append(replacement);
+ } else {
+ sb.append(variable);
+ }
+ sb.append(signs);
+ endIndex = m.end(3);
+ }
+
+ // append the tail
+ if (endIndex != origStr.length()) {
+ sb.append(origStr.substring(endIndex, origStr.length()));
+ }
+
+ if (!"".equals(sb.toString())) {
+ return sb.toString();
+ }
+ return origStr;
+ }
+
+ private void updateNodeValue(nsIDOMNode node, Map<String, String> paramsMap) {
+ Set<String> keys = paramsMap.keySet();
+ if (null != node) {
+ String nodeValue = node.getNodeValue();
+ String curlyBracketResultPattern = "(" + Pattern.quote("#")
+ + "\\{(.+?)\\})+?";
+ int matcherGroupWithVariable = 2;
+
+ if ((null != nodeValue) && (!"".equals(nodeValue))) {
+ for (String key : keys) {
+ Matcher curlyBracketMatcher = Pattern.compile(
+ curlyBracketResultPattern).matcher(nodeValue);
+
+ String replacement = paramsMap.get(key);
+ if (replacement.startsWith("#{")
+ && replacement.endsWith("}")) {
+ // remove first 2 signs '#{'
+ replacement = replacement.substring(2);
+ // remove last '}' sign
+ replacement = replacement.substring(0, replacement
+ .length() - 1);
+ }
+
+ int lastPos = 0;
+ StringBuilder sb = new StringBuilder();
+ lastPos = 0;
+ sb = new StringBuilder();
+ curlyBracketMatcher.reset(nodeValue);
+ boolean firstFind = false;
+ boolean find = curlyBracketMatcher.find();
+ while (find) {
+ if (!firstFind) {
+ firstFind = true;
+ }
+ int start = curlyBracketMatcher
+ .start(matcherGroupWithVariable);
+ int end = curlyBracketMatcher
+ .end(matcherGroupWithVariable);
+ String group = replacePattern(curlyBracketMatcher
+ .group(matcherGroupWithVariable), key,
+ replacement);
+ sb.append(nodeValue.substring(lastPos, start));
+ sb.append(group);
+ lastPos = end;
+ find = curlyBracketMatcher.find();
+ }
+ if (firstFind) {
+ sb.append(nodeValue.substring(lastPos, nodeValue
+ .length()));
+ nodeValue = sb.toString();
+ node.setNodeValue(nodeValue);
+ }
+ }
+ }
+ }
+ }
+
+ private void insertParam(nsIDOMNode node, Map<String, String> paramsMap) {
+
+ // update current node value
+ updateNodeValue(node, paramsMap);
+
+ nsIDOMNamedNodeMap attributes = node.getAttributes();
+ if (null != attributes) {
+ long len = attributes.getLength();
+ for (int i = 0; i < len; i++) {
+ nsIDOMNode item = attributes.item(i);
+ // update attributes node
+ updateNodeValue(item, paramsMap);
+ }
+ }
+
+ nsIDOMNodeList children = node.getChildNodes();
+ if (null != children) {
+ long len = children.getLength();
+ for (int i = 0; i < len; i++) {
+ nsIDOMNode child = children.item(i);
+ // update child node
+ insertParam(child, paramsMap);
+ }
+ }
+ }
+
+ @Override
+ public void validate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData creationData) {
+
+ Map<String, String> paramsMap = new HashMap<String, String>();
+ NodeList sourceChildren = sourceNode.getChildNodes();
+ int len = sourceChildren.getLength();
+ for (int i = 0; i < len; i++) {
+ Node sourceChild = sourceChildren.item(i);
+ if (sourceChild.getNodeType() == Node.ELEMENT_NODE
+ && "param".equals(sourceChild.getLocalName())) {
+ String name = ((Element) sourceChild)
+ .getAttribute(HTML.ATTR_NAME);
+ String value = ((Element) sourceChild)
+ .getAttribute(HTML.ATTR_VALUE);
+ paramsMap.put(name, value);
+ }
+ }
+ nsIDOMNode node = creationData.getNode();
+ insertParam(node, paramsMap);
+
+ TemplateFileInfo templateFileInfo = (TemplateFileInfo) creationData
+ .getData();
+ if (templateFileInfo != null) {
+ VpeIncludeInfo includeInfo = pageContext.getVisualBuilder()
+ .popIncludeStack();
+ if (includeInfo != null) {
+ // VpeCreatorUtil.releaseDocumentFromRead(includeInfo.getDocument());
+ }
+ }
+ defineContainer.remove(sourceNode);
+ }
+
+ @Override
+ public void beforeRemove(VpePageContext pageContext, Node sourceNode,
+ nsIDOMNode visualNode, Object data) {
+ TemplateFileInfo templateFileInfo = (TemplateFileInfo) data;
+ if (templateFileInfo != null && templateFileInfo.templateFile != null) {
+ pageContext.getEditPart().getController().getIncludeList()
+ .removeIncludeModel(templateFileInfo.templateFile);
+ }
+ }
+
+ @Override
+ public boolean recreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+
+ return true;
+ }
+
+ private void registerDefine(VpePageContext pageContext, Node defineContainer) {
+ VpeTemplate template = null;
+ NodeList sourceChildren = defineContainer.getChildNodes();
+ int len = sourceChildren.getLength();
+ for (int i = 0; i < len; i++) {
+ Node sourceChild = sourceChildren.item(i);
+ if (sourceChild.getNodeType() == Node.ELEMENT_NODE
+ && "define".equals(sourceChild.getLocalName())) {
+ if (template == null) {
+ VpeTemplateManager templateManager = pageContext
+ .getVisualBuilder().getTemplateManager();
+ template = templateManager.getTemplate(pageContext,
+ (Element) sourceChild, null);
+ if (template == null) {
+ break;
+ }
+ }
+ pageContext.getVisualBuilder().registerNodes(
+ new VpeElementMapping((Element) sourceChild, null,
+ null, template, null, null));
+ }
+ }
+ }
+
+ private VpeCreationData createInclude(Document sourceDocument,
+ nsIDOMDocument visualDocument) {
+ nsIDOMElement visualNewElement = visualDocument
+ .createElement(HTML.TAG_DIV);
+ VpeVisualDomBuilder.markIncludeElement(visualNewElement);
+ VpeCreationData creationData = new VpeCreationData(visualNewElement);
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(visualNewElement);
+ NodeList sourceChildren = sourceDocument.getChildNodes();
+ int len = sourceChildren.getLength();
+ for (int i = 0; i < len; i++) {
+ childrenInfo.addSourceChild(sourceChildren.item(i));
+ }
+ creationData.addChildrenInfo(childrenInfo);
+ return creationData;
+ }
+
+ @Override
+ public boolean containsText() {
+ return false;
+ }
+
+ public static boolean isDefineContainer(Node sourceNode) {
+
+ // FIX https://jira.jboss.org/jira/browse/JBIDE-3187 by sdzmitrovich
+ // TODO: it is necessary to refactor facelet templates
+ // return defineContainer.contains(sourceNode);
+ while (sourceNode != null) {
+ if (defineContainer.contains(sourceNode))
+ return true;
+
+ sourceNode = sourceNode.getParentNode();
+ }
+
+ return false;
+
+ }
+
+ @Override
+ public void openIncludeEditor(VpePageContext pageContext,
+ Element sourceElement, Object data) {
+
+ if (data instanceof TemplateFileInfo) {
+ FileUtil.openEditor(((TemplateFileInfo) data).getTemplateFile());
+ }
+ }
+
+ protected VpeCreationData createStub(String fileName,
+ Node sourceElement, nsIDOMDocument visualDocument) {
+
+ nsIDOMElement container = visualDocument.createElement(HTML.TAG_DIV);
+ container.setAttribute("style", "border: 1px dashed #2A7F00");
+ VpeVisualDomBuilder.markIncludeElement(container);
+
+ nsIDOMElement title = visualDocument.createElement(HTML.TAG_DIV);
+ nsIDOMElement tag = visualDocument.createElement(HTML.TAG_SPAN);
+ tag.setAttribute("class", "__any__tag__caption");
+ tag.appendChild(visualDocument.createTextNode(sourceElement.getNodeName()));
+ title.appendChild(tag);
+ if (fileName != null) {
+ title.appendChild(visualDocument.createTextNode(fileName));
+ }
+ container.appendChild(title);
+
+ VpeCreationData creationData = new VpeCreationData(container);
+
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(container);
+ NodeList sourceChildren = sourceElement.getChildNodes();
+ int len = sourceChildren.getLength();
+ for (int i = 0; i < len; i++) {
+ Node sourceChild = sourceChildren.item(i);
+ if (sourceChild.getNodeType() == Node.ELEMENT_NODE
+ && "define".equals(sourceChild.getLocalName())) {
+ childrenInfo.addSourceChild(sourceChild);
+ }
+ }
+ creationData.addChildrenInfo(childrenInfo);
+ return creationData;
+ }
+
+ static class TemplateFileInfo {
+ private IFile templateFile;
+
+ TemplateFileInfo(IFile templateFile) {
+ this.templateFile = templateFile;
+ }
+
+ public IFile getTemplateFile() {
+ return templateFile;
+ }
+
+ public void setTemplateFile(IFile templateFile) {
+ this.templateFile = templateFile;
+ }
+ }
+}
Property changes on: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
15 years, 8 months
JBoss Tools SVN: r14605 - trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2009-04-08 09:51:05 -0400 (Wed, 08 Apr 2009)
New Revision: 14605
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssClassNewWizardTest.java
Log:
test has been corrected
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssClassNewWizardTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssClassNewWizardTest.java 2009-04-08 13:14:17 UTC (rev 14604)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/ui/test/CssClassNewWizardTest.java 2009-04-08 13:51:05 UTC (rev 14605)
@@ -1,11 +1,13 @@
package org.jboss.tools.jsf.ui.test;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
@@ -19,7 +21,7 @@
private static String CSS_FILE_PATH="WebContent/pages/main.css"; //$NON-NLS-1$
public CssClassNewWizardTest(){
- super("org.jboss.tools.jst.web.ui.wizards.newfile.NewCSSClassWizard");
+ super("org.jboss.tools.jst.web.ui.wizards.newfile.NewCSSClassWizard"); //$NON-NLS-1$
}
public void testCssClassNewWizardTestIsCreated() {
@@ -32,7 +34,7 @@
boolean canFinish = wizard.canFinish();
- assertFalse("Finish button is enabled at first wizard page.", canFinish);
+ assertFalse("Finish button is enabled at first wizard page.", canFinish); //$NON-NLS-1$
}
public void testCssClassNewWizardValidation2() {
@@ -41,7 +43,7 @@
boolean canFinish = wizard.canFinish();
// Assert Finish button is enabled by default if wizard is called on Project
- assertFalse("Finish button is disabled at first wizard page.", canFinish);
+ assertFalse("Finish button is disabled at first wizard page.", canFinish); //$NON-NLS-1$
// Assert Finish button is disabled and error is present if
// Folder field is empty
@@ -79,11 +81,45 @@
.getActiveWorkbenchWindow().getShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.open();
+
+ assertFalse("Finish button is not disabled.", wizard.canFinish()); //$NON-NLS-1$
+ assertFalse("Next button is not disabled.", wizard.getContainer().getCurrentPage().canFlipToNextPage()); //$NON-NLS-1$
+
+ try {
+
- boolean canFinish = wizard.canFinish();
+ Field selectFileTextField = wizard.getContainer().getCurrentPage()
+ .getClass().getDeclaredField("selectFileText"); //$NON-NLS-1$
+ selectFileTextField.setAccessible(true);
+ Text selectFileText = (Text) selectFileTextField.get(wizard
+ .getContainer().getCurrentPage());
+ selectFileText.setText(cssFile.getFullPath().toString());
+ Field classNameTextField = wizard.getContainer().getCurrentPage()
+ .getClass().getDeclaredField("classNameText"); //$NON-NLS-1$
+ classNameTextField.setAccessible(true);
+ Text classNameTextText = (Text) classNameTextField.get(wizard
+ .getContainer().getCurrentPage());
+ classNameTextText.setText("newCSS"); //$NON-NLS-1$
+
+
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
- assertTrue("Finish button is disabled.", canFinish); //$NON-NLS-1$
-
+ assertTrue("Next button is disabled.", wizard.getContainer().getCurrentPage().canFlipToNextPage()); //$NON-NLS-1$
+ assertFalse("Finish button is not disabled.", wizard.canFinish()); //$NON-NLS-1$
+ wizard.getContainer().showPage(wizard.getNextPage(wizard.getContainer().getCurrentPage()));
+ assertTrue("Finish button is disabled.", wizard.canFinish()); //$NON-NLS-1$
wizard.performFinish();
}
15 years, 8 months
JBoss Tools SVN: r14604 - trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-04-08 09:14:17 -0400 (Wed, 08 Apr 2009)
New Revision: 14604
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java
Log:
JBIDE-4138 - close fis in ResourcesUtils.findLineInFile - cosmetic change - cause this is never call function
Modified: trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java
===================================================================
--- trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java 2009-04-08 13:13:30 UTC (rev 14603)
+++ trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ResourcesUtils.java 2009-04-08 13:14:17 UTC (rev 14604)
@@ -36,7 +36,6 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
-import org.jboss.tools.tests.ImportBean;
import org.jboss.tools.tests.ImportProvider;
import org.osgi.framework.Bundle;
@@ -111,16 +110,37 @@
}
public static boolean findLineInFile(IFile file, String pattern) throws CoreException, IOException {
- InputStream content = file.getContents(true);
- LineNumberReader contentReader = new LineNumberReader(new InputStreamReader(content));
- String line;
+ InputStream content = null;
+ InputStreamReader isr = null;
boolean patternIsFound = false;
- do {
- line = contentReader.readLine();
- if(line!=null && !patternIsFound) {
- patternIsFound = line.trim().matches(pattern);
+ try {
+ content = file.getContents(true);
+ isr = new InputStreamReader(content);
+ LineNumberReader contentReader = new LineNumberReader(isr);
+ String line;
+ do {
+ line = contentReader.readLine();
+ if(line!=null && !patternIsFound) {
+ patternIsFound = line.trim().matches(pattern);
+ }
+ } while (line != null && !patternIsFound);
+ }
+ finally {
+ if (isr != null) {
+ try {
+ isr.close();
+ } catch (IOException e) {
+ // ignore
+ }
}
- } while (line != null && !patternIsFound);
+ if (content != null) {
+ try {
+ content.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
return patternIsFound;
}
@@ -164,9 +184,9 @@
return oldAutoBuilding;
}
- static public void importProjectIntoWorkspace(ImportBean bean) {
- importProjectIntoWorkspace(bean);
- }
+ //static public void importProjectIntoWorkspace(ImportBean bean) {
+ // importProjectIntoWorkspace(bean);
+ //}
private static final long IMPORT_DELAY = 50;
15 years, 8 months
JBoss Tools SVN: r14603 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-04-08 09:13:30 -0400 (Wed, 08 Apr 2009)
New Revision: 14603
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-04-08 12:59:32 UTC (rev 14602)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/refactoring/RenameComponentProcessor.java 2009-04-08 13:13:30 UTC (rev 14603)
@@ -43,6 +43,7 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.wst.sse.core.StructuredModelManager;
@@ -294,6 +295,8 @@
}
}
}
+
+ TextFileChange lastChange = null;
private void scanString(IFile file, String string, int offset) {
int startEl = string.indexOf("#{"); //$NON-NLS-1$
@@ -304,10 +307,14 @@
for(ELInvocationExpression ie : instance.getExpression().getInvocations()){
ELPropertyInvocation pi = findComponentReference(ie);
if(pi != null){
- TextFileChange change = new TextFileChange(file.getName(), file);
- TextEdit edit = new ReplaceEdit(offset+pi.getStartPosition(), pi.getEndPosition()-pi.getStartPosition(), newName);
- change.setEdit(edit);
- changes.add(change);
+ if(lastChange == null || lastChange.getFile() != file){
+ lastChange = new TextFileChange(file.getName(), file);
+ MultiTextEdit root = new MultiTextEdit();
+ lastChange.setEdit(root);
+ changes.add(lastChange);
+ }
+ TextEdit edit = new ReplaceEdit(offset+pi.getStartPosition(), pi.getName().getStart()+pi.getName().getLength()-pi.getStartPosition(), newName);
+ lastChange.addEdit(edit);
}
}
}
@@ -318,7 +325,7 @@
ELInvocationExpression invExp = invocationExpression;
while(invExp != null){
if(invExp instanceof ELPropertyInvocation){
- if(((ELPropertyInvocation)invExp).getQualifiedName().equals(component.getName()))
+ if(((ELPropertyInvocation)invExp).getQualifiedName() != null && ((ELPropertyInvocation)invExp).getQualifiedName().equals(component.getName()))
return (ELPropertyInvocation)invExp;
else
invExp = invExp.getLeft();
15 years, 8 months
JBoss Tools SVN: r14602 - in trunk/hibernatetools: tests/org.hibernate.eclipse.console.test/res and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-04-08 08:59:32 -0400 (Wed, 08 Apr 2009)
New Revision: 14602
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/LaunchCC.properties
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/EclipseLaunchConsoleConfigurationPreferencesTest.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java
Log:
JBIDE-4138 - close fis in EclipseLaunchConsoleConfigurationPreferences.getProperties and unit test
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java 2009-04-08 12:46:39 UTC (rev 14601)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/EclipseLaunchConsoleConfigurationPreferences.java 2009-04-08 12:59:32 UTC (rev 14602)
@@ -164,14 +164,25 @@
public Properties getProperties() {
File propFile = getPropertyFile();
if(propFile==null) return null;
+ Properties p = new Properties();
+ FileInputStream fis = null;
try {
- Properties p = new Properties();
- p.load(new FileInputStream(propFile) );
- return p;
+ fis = new FileInputStream(propFile);
+ p.load(fis);
}
catch(IOException io) {
throw new HibernateConsoleRuntimeException(HibernateConsoleMessages.EclipseLaunchConsoleConfigurationPreferences_could_not_load_property_file + propFile, io);
}
+ finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ return p;
}
public File getPropertyFile() {
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/LaunchCC.properties
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/LaunchCC.properties (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/LaunchCC.properties 2009-04-08 12:59:32 UTC (rev 14602)
@@ -0,0 +1 @@
+org.hibernate.test = testValue
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/EclipseLaunchConsoleConfigurationPreferencesTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/EclipseLaunchConsoleConfigurationPreferencesTest.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/EclipseLaunchConsoleConfigurationPreferencesTest.java 2009-04-08 12:59:32 UTC (rev 14602)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.test;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.hibernate.eclipse.console.EclipseLaunchConsoleConfigurationPreferences;
+import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
+import org.osgi.framework.Bundle;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class EclipseLaunchConsoleConfigurationPreferencesTest extends TestCase {
+
+ public Mockery context = new Mockery() {{
+ setImposteriser(ClassImposteriser.INSTANCE);
+ }};
+
+ static public String getPropertiesFilePath() {
+ Bundle bundle = HibernateConsoleTestPlugin.getDefault().getBundle();
+ String resPath = null;
+ try {
+ URL url = FileLocator.resolve(bundle.getEntry("/res/LaunchCC.properties")); //$NON-NLS-1$
+ resPath = url.getPath();
+ } catch (IOException e) {
+ //ignore
+ }
+ return resPath;
+ }
+
+ /**
+ * test method for eclipseLaunchConsoleConfigurationPreferences.getProperties
+ * @throws CoreException
+ */
+ public void testCloseStream() throws CoreException {
+
+ final ILaunchConfiguration launchConfiguration = context.mock(ILaunchConfiguration.class);
+
+ final EclipseLaunchConsoleConfigurationPreferences eclipseLaunchConsoleConfigurationPreferences =
+ new EclipseLaunchConsoleConfigurationPreferences(launchConfiguration);
+ final String propertiesFilePath = getPropertiesFilePath();
+
+ context.checking(new Expectations() {{
+
+ allowing(launchConfiguration).getAttribute(IConsoleConfigurationLaunchConstants.PROPERTY_FILE, (String)null);
+ will(returnValue(propertiesFilePath));
+ }});
+ Properties properties = eclipseLaunchConsoleConfigurationPreferences.getProperties();
+ assertNotNull(properties);
+ assertTrue(properties.size() == 1);
+ context.assertIsSatisfied();
+
+ }
+
+}
15 years, 8 months