JBoss Tools SVN: r19032 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/impl and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-12-03 12:35:51 -0500 (Thu, 03 Dec 2009)
New Revision: 19032
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIBuilderDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4943
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2009-12-03 17:29:43 UTC (rev 19031)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2009-12-03 17:35:51 UTC (rev 19032)
@@ -32,7 +32,9 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.internal.core.scanner.CDIBuilderDelegate;
+import org.jboss.tools.cdi.internal.core.scanner.FileSet;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.project.ProjectHome;
@@ -161,7 +163,10 @@
protected void fullBuild(final IProgressMonitor monitor)
throws CoreException {
try {
- getProject().accept(getResourceVisitor());
+ CDIResourceVisitor rv = getResourceVisitor();
+ getProject().accept(rv);
+ FileSet fs = rv.fileSet;
+
} catch (CoreException e) {
CDICorePlugin.getDefault().logError(e);
}
@@ -169,7 +174,10 @@
protected void incrementalBuild(IResourceDelta delta,
IProgressMonitor monitor) throws CoreException {
+ CDIResourceVisitor rv = getResourceVisitor();
delta.accept(new SampleDeltaVisitor());
+ FileSet fs = rv.fileSet;
+ builderDelegate.build(fs, getCDICoreNature());
}
protected void clean(IProgressMonitor monitor) throws CoreException {
@@ -199,6 +207,7 @@
}
class CDIResourceVisitor implements IResourceVisitor {
+ FileSet fileSet = new FileSet();
IPath[] outs = new IPath[0];
IPath[] srcs = new IPath[0];
IPath webinf = null;
@@ -249,14 +258,21 @@
if(srcs[i].isPrefixOf(path)) {
if(f.getName().endsWith(".java")) {
ICompilationUnit unit = EclipseUtil.getCompilationUnit(f);
- builderDelegate.build(f, unit, getCDICoreNature());
+ IType[] ts = unit.getTypes();
+ if(ts == null || ts.length == 0) {
+ fileSet.getNonModelFiles().add(f);
+ } else if(findPublicAnnotation(ts) != null) {
+ fileSet.getAnnotations().put(f, unit);
+ } else if(findPublicInterface(ts) != null) {
+ fileSet.getInterfaces().put(f, unit);
+ }
}
return false;
}
}
if(webinf != null && webinf.isPrefixOf(path)) {
if(f.getName().equals("beans.xml")) {
- //TODO
+ fileSet.setBeanXML(f);
}
}
}
@@ -288,5 +304,21 @@
}
+ static IType findPublicAnnotation(IType[] ts) throws JavaModelException {
+ for (IType t: ts) {
+ if(t.isAnnotation()) {
+ return t;
+ }
+ }
+ return null;
+ }
+ static IType findPublicInterface(IType[] ts) throws JavaModelException {
+ for (IType t: ts) {
+ if(t.isInterface()) {
+ return t;
+ }
+ }
+ return null;
+ }
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIBuilderDelegate.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIBuilderDelegate.java 2009-12-03 17:29:43 UTC (rev 19031)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/ICDIBuilderDelegate.java 2009-12-03 17:35:51 UTC (rev 19032)
@@ -10,9 +10,8 @@
******************************************************************************/
package org.jboss.tools.cdi.core;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.core.ICompilationUnit;
+import org.jboss.tools.cdi.internal.core.scanner.FileSet;
/**
* Builder delegate performs build for specific kind of cdi project.
@@ -30,7 +29,6 @@
public Class<? extends ICDIProject> getProjectImplementationClass();
- public void build(IFile file, ICompilationUnit unit, CDICoreNature projectNature);
- public void build(IFile file, CDICoreNature projectNature);
-
+ public void build(FileSet fileSet, CDICoreNature projectNature);
+
}
Added: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java 2009-12-03 17:35:51 UTC (rev 19032)
@@ -0,0 +1,37 @@
+package org.jboss.tools.cdi.internal.core.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+
+public class AnnotatedTypeDeclaration {
+ List<AnnotationDeclaration> annotations = new ArrayList<AnnotationDeclaration>();
+ String qualifiedName;
+ IType type;
+
+ public AnnotatedTypeDeclaration() {
+ }
+
+ public void setType(IType type) {
+ this.type = type;
+ try {
+ init();
+ } catch (CoreException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ }
+
+ void init() throws CoreException {
+ qualifiedName = type.getFullyQualifiedName();
+ IAnnotation[] ts = type.getAnnotations();
+ for (int i = 0; i < annotations.size(); i++) {
+ AnnotationDeclaration a = new AnnotationDeclaration();
+ a.setDeclaration(ts[i], type);
+ annotations.add(a);
+ }
+ }
+}
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotatedTypeDeclaration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java 2009-12-03 17:35:51 UTC (rev 19032)
@@ -0,0 +1,56 @@
+package org.jboss.tools.cdi.internal.core.impl;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.ISourceRange;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+
+public class AnnotationDeclaration implements IAnnotationDeclaration {
+ IAnnotation annotation;
+ int startPosition = -1;
+ int length = 0;
+ String annotationTypeName = null;
+
+ public AnnotationDeclaration() {}
+
+ public void setDeclaration(IAnnotation annotation, IType declaringType) {
+ this.annotation = annotation;
+ try {
+ ISourceRange range = annotation.getSourceRange();
+ if(range != null) {
+ startPosition = range.getOffset();
+ length = range.getLength();
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ String name = annotation.getElementName();
+ annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name);
+ }
+
+ public IAnnotation getDeclaration() {
+ return annotation;
+ }
+
+ public IMember getParentMember() {
+ return (IMember)annotation.getParent();
+ }
+
+ public IType getType() {
+ return getParentMember().getDeclaringType();
+ }
+
+ public int getLength() {
+ return length;
+ }
+
+ public int getStartPosition() {
+ return startPosition;
+ }
+
+}
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java 2009-12-03 17:29:43 UTC (rev 19031)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/CDIBuilderDelegate.java 2009-12-03 17:35:51 UTC (rev 19032)
@@ -1,5 +1,7 @@
package org.jboss.tools.cdi.internal.core.scanner;
+import java.util.Map;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IAnnotation;
@@ -10,7 +12,6 @@
import org.jboss.tools.cdi.core.ICDIBuilderDelegate;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
public class CDIBuilderDelegate implements ICDIBuilderDelegate {
@@ -27,33 +28,21 @@
return CDIProject.class;
}
- public void build(IFile file, CDICoreNature projectNature) {
- IProject project = projectNature.getProject();
+ public void build(FileSet fileSet, CDICoreNature projectNature) {
+ Map<IFile, ICompilationUnit> as = fileSet.getAnnotations();
+ for (IFile f: as.keySet()) {
+
+ }
-
- }
-
- public void build(IFile file, ICompilationUnit unit, CDICoreNature projectNature) {
- if(unit != null) {
- try {
- IType[] types = unit.getTypes();
- if(types != null) {
- for (IType type: types) {
- if(type.isAnnotation()) {
- IAnnotation[] as = type.getAnnotations();
- for (IAnnotation a: as) {
- String name = a.getElementName();
- String qName = EclipseJavaUtil.resolveType(type, name);
- System.out.println(qName);
- }
- }
- }
- }
- } catch (JavaModelException e) {
- e.printStackTrace();
- }
- } else {
+ Map<IFile, ICompilationUnit> is = fileSet.getInterfaces();
+ for (IFile f: is.keySet()) {
}
+
+ Map<IFile, ICompilationUnit> cs = fileSet.getClasses();
+ for (IFile f: cs.keySet()) {
+
+ }
+
}
}
Added: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java 2009-12-03 17:35:51 UTC (rev 19032)
@@ -0,0 +1,41 @@
+package org.jboss.tools.cdi.internal.core.scanner;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.ICompilationUnit;
+
+public class FileSet {
+ Set<IFile> nonmodel = new HashSet<IFile>();
+ Map<IFile, ICompilationUnit> annotations = new HashMap<IFile, ICompilationUnit>();
+ Map<IFile, ICompilationUnit> interfaces = new HashMap<IFile, ICompilationUnit>();
+ Map<IFile, ICompilationUnit> classes = new HashMap<IFile, ICompilationUnit>();
+ IFile beansXML = null;
+
+ public Set<IFile> getNonModelFiles() {
+ return nonmodel;
+ }
+
+ public Map<IFile, ICompilationUnit> getAnnotations() {
+ return annotations;
+ }
+
+ public Map<IFile, ICompilationUnit> getInterfaces() {
+ return interfaces;
+ }
+
+ public Map<IFile, ICompilationUnit> getClasses() {
+ return classes;
+ }
+
+ public IFile getBeanXML() {
+ return beansXML;
+ }
+
+ public void setBeanXML(IFile f) {
+ beansXML = f;
+ }
+}
Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
JBoss Tools SVN: r19031 - in trunk/hibernatetools/plugins: org.hibernate.eclipse/src/org/hibernate/console/execution and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-12-03 12:29:43 -0500 (Thu, 03 Dec 2009)
New Revision: 19031
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CloseConfigAction.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfigClassLoader.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/viewers/xpl/MTreeViewer.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1012 & http://opensource.atlassian.com/projects/hibernate/browse/HBX-936 - fix
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfigClassLoader.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfigClassLoader.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfigClassLoader.java 2009-12-03 17:29:43 UTC (rev 19031)
@@ -0,0 +1,286 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.console;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.jar.JarFile;
+
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * Workaround for jdk disgrace with open jar files & native libs,
+ * which is a reason of locked, "undelete" files.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ConsoleConfigClassLoader extends URLClassLoader {
+
+ protected HashSet<String> setJarFileNames2Close = new HashSet<String>();
+
+ public ConsoleConfigClassLoader(URL[] urls, ClassLoader parent) {
+ super(urls, parent);
+ }
+
+ public void close() {
+ setJarFileNames2Close.clear();
+ closeClassLoader(this);
+ finalizeNativeLibs(this);
+ cleanupJarFileFactory();
+ }
+
+ /**
+ * cleanup jar file factory cache
+ */
+ @SuppressWarnings({ "nls", "unchecked" })
+ public boolean cleanupJarFileFactory()
+ {
+ boolean res = false;
+ Class classJarURLConnection = null;
+ try {
+ classJarURLConnection = ReflectHelper.classForName("sun.net.www.protocol.jar.JarURLConnection");
+ } catch (ClassNotFoundException e) {
+ //ignore
+ }
+ if (classJarURLConnection == null) {
+ return res;
+ }
+ Field f = null;
+ try {
+ f = classJarURLConnection.getDeclaredField("factory");
+ } catch (NoSuchFieldException e) {
+ //ignore
+ }
+ if (f == null) {
+ return res;
+ }
+ f.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = f.get(null);
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ if (obj == null) {
+ return res;
+ }
+ Class classJarFileFactory = obj.getClass();
+ //
+ HashMap fileCache = null;
+ try {
+ f = classJarFileFactory.getDeclaredField("fileCache");
+ f.setAccessible(true);
+ obj = f.get(null);
+ if (obj instanceof HashMap) {
+ fileCache = (HashMap)obj;
+ }
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ HashMap urlCache = null;
+ try {
+ f = classJarFileFactory.getDeclaredField("urlCache");
+ f.setAccessible(true);
+ obj = f.get(null);
+ if (obj instanceof HashMap) {
+ urlCache = (HashMap)obj;
+ }
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ if (urlCache != null) {
+ HashMap urlCacheTmp = (HashMap)urlCache.clone();
+ Iterator it = urlCacheTmp.keySet().iterator();
+ while (it.hasNext()) {
+ obj = it.next();
+ if (!(obj instanceof JarFile)) {
+ continue;
+ }
+ JarFile jarFile = (JarFile)obj;
+ if (setJarFileNames2Close.contains(jarFile.getName())) {
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ if (fileCache != null) {
+ fileCache.remove(urlCache.get(jarFile));
+ }
+ urlCache.remove(jarFile);
+ }
+ }
+ res = true;
+ } else if (fileCache != null) {
+ // urlCache := null
+ HashMap fileCacheTmp = (HashMap)fileCache.clone();
+ Iterator it = fileCacheTmp.keySet().iterator();
+ while (it.hasNext()) {
+ Object key = it.next();
+ obj = fileCache.get(key);
+ if (!(obj instanceof JarFile)) {
+ continue;
+ }
+ JarFile jarFile = (JarFile)obj;
+ if (setJarFileNames2Close.contains(jarFile.getName())) {
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ fileCache.remove(key);
+ }
+ }
+ res = true;
+ }
+ setJarFileNames2Close.clear();
+ return res;
+ }
+
+ /**
+ * close jar files of cl
+ * @param cl
+ * @return
+ */
+ @SuppressWarnings( { "nls", "unchecked" })
+ public boolean closeClassLoader(ClassLoader cl) {
+ boolean res = false;
+ if (cl == null) {
+ return res;
+ }
+ Class classURLClassLoader = URLClassLoader.class;
+ Field f = null;
+ try {
+ f = classURLClassLoader.getDeclaredField("ucp");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = f.get(cl);
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ if (obj != null) {
+ final Object ucp = obj;
+ f = null;
+ try {
+ f = ucp.getClass().getDeclaredField("loaders");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ ArrayList loaders = null;
+ try {
+ loaders = (ArrayList) f.get(ucp);
+ res = true;
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ for (int i = 0; loaders != null && i < loaders.size(); i++) {
+ obj = loaders.get(i);
+ f = null;
+ try {
+ f = obj.getClass().getDeclaredField("jar");
+ } catch (NoSuchFieldException e) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ try {
+ obj = f.get(obj);
+ } catch (IllegalAccessException e1) {
+ // ignore
+ }
+ if (obj instanceof JarFile) {
+ final JarFile jarFile = (JarFile)obj;
+ setJarFileNames2Close.add(jarFile.getName());
+ //try {
+ // jarFile.getManifest().clear();
+ //} catch (IOException e) {
+ // // ignore
+ //}
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return res;
+ }
+
+ /**
+ * finalize native libraries
+ * @param cl
+ * @return
+ */
+ @SuppressWarnings({ "nls", "unchecked" })
+ public boolean finalizeNativeLibs(ClassLoader cl) {
+ boolean res = false;
+ Class classClassLoader = ClassLoader.class;
+ java.lang.reflect.Field nativeLibraries = null;
+ try {
+ nativeLibraries = classClassLoader.getDeclaredField("nativeLibraries");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (nativeLibraries == null) {
+ return res;
+ }
+ nativeLibraries.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = nativeLibraries.get(cl);
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ if (!(obj instanceof Vector)) {
+ return res;
+ }
+ res = true;
+ Vector java_lang_ClassLoader_NativeLibrary = (Vector)obj;
+ for (Object lib : java_lang_ClassLoader_NativeLibrary) {
+ java.lang.reflect.Method finalize = null;
+ try {
+ finalize = lib.getClass().getDeclaredMethod("finalize", new Class[0]);
+ } catch (NoSuchMethodException e) {
+ //ignore
+ }
+ if (finalize != null) {
+ finalize.setAccessible(true);
+ try {
+ finalize.invoke(lib, new Object[0]);
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
+ //ignore
+ }
+ }
+ }
+ return res;
+ }
+}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2009-12-03 17:29:10 UTC (rev 19030)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2009-12-03 17:29:43 UTC (rev 19031)
@@ -29,7 +29,8 @@
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Driver;
@@ -37,6 +38,7 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -74,6 +76,7 @@
public class ConsoleConfiguration implements ExecutionContextHolder {
private ExecutionContext executionContext;
+ private ConsoleConfigClassLoader classLoader = null;
private Map<String, FakeDelegatingDriver> fakeDrivers = new HashMap<String, FakeDelegatingDriver>();
@@ -106,8 +109,38 @@
// reseting state
configuration = null;
closeSessionFactory();
+ if (executionContext != null) {
+ executionContext.execute(new ExecutionContext.Command() {
+
+ public Object execute() {
+ Iterator<FakeDelegatingDriver> it = fakeDrivers.values().iterator();
+ while (it.hasNext()) {
+ try {
+ DriverManager.deregisterDriver(it.next());
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ return null;
+ }
+ });
+ }
+ fakeDrivers.clear();
+ cleanUpClassLoader();
+ executionContext = null;
}
+ public void cleanUpClassLoader() {
+ ClassLoader classLoaderTmp = classLoader;
+ while (classLoaderTmp != null) {
+ if (classLoaderTmp instanceof ConsoleConfigClassLoader) {
+ ((ConsoleConfigClassLoader)classLoaderTmp).close();
+ }
+ classLoaderTmp = classLoaderTmp.getParent();
+ }
+ classLoader = null;
+ }
+
public void build() {
configuration = buildWith(null, true);
fireConfigurationBuilt();
@@ -237,39 +270,51 @@
}
return customClassPathURLs;
}
+
+ protected ConsoleConfigClassLoader createClassLoader() {
+ final URL[] customClassPathURLs = getCustomClassPathURLs();
+ ConsoleConfigClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ConsoleConfigClassLoader>() {
+ public ConsoleConfigClassLoader run() {
+ return new ConsoleConfigClassLoader(customClassPathURLs, getParentClassLoader()) {
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ try {
+ return super.findClass(name);
+ } catch (ClassNotFoundException cnfe) {
+ throw cnfe;
+ }
+ }
+
+ protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ try {
+ return super.loadClass(name, resolve);
+ } catch (ClassNotFoundException cnfe) {
+ throw cnfe;
+ }
+ }
+
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
+ try {
+ return super.loadClass(name);
+ } catch (ClassNotFoundException cnfe) {
+ throw cnfe;
+ }
+ }
+ };
+ }
+ });
+ return classLoader;
+ }
/**
* @return
*
*/
public Configuration buildWith(final Configuration cfg, final boolean includeMappings) {
- URL[] customClassPathURLs = getCustomClassPathURLs();
- executionContext = new DefaultExecutionContext( getName(), new URLClassLoader( customClassPathURLs, getParentClassLoader() ) {
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- try {
- return super.findClass( name );
- } catch(ClassNotFoundException cnfe) {
- throw cnfe;
- }
- }
+ if (classLoader == null) {
+ classLoader = createClassLoader();
+ }
+ executionContext = new DefaultExecutionContext(getName(), classLoader);
- protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- try {
- return super.loadClass( name, resolve );
- } catch(ClassNotFoundException cnfe) {
- throw cnfe;
- }
- }
-
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- try {
- return super.loadClass( name );
- } catch(ClassNotFoundException cnfe) {
- throw cnfe;
- }
- }
- });
-
Configuration result = (Configuration) executionContext.execute(new ExecutionContext.Command() {
public Object execute() {
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java 2009-12-03 17:29:10 UTC (rev 19030)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java 2009-12-03 17:29:43 UTC (rev 19031)
@@ -21,7 +21,6 @@
*/
package org.hibernate.console.execution;
-import java.net.URLClassLoader;
import java.util.Map;
import java.util.WeakHashMap;
@@ -31,13 +30,13 @@
public class DefaultExecutionContext implements ExecutionContext {
- final private URLClassLoader configurationClassLoader;
+ final private ClassLoader configurationClassLoader;
private volatile int installs;
private Map<Thread, ClassLoader> previousLoaders = new WeakHashMap<Thread, ClassLoader>();
final String key;
- public DefaultExecutionContext(String key, URLClassLoader loader) {
+ public DefaultExecutionContext(String key, ClassLoader loader) {
configurationClassLoader = loader;
this.key = key;
}
@@ -45,7 +44,7 @@
/* (non-Javadoc)
* @see org.hibernate.console.IExecutionContext#installLoader()
*/
- public void installLoader() {
+ public synchronized void installLoader() {
installs++;
if(configurationClassLoader!=null && Thread.currentThread().getContextClassLoader() != configurationClassLoader) {
previousLoaders.put(Thread.currentThread(), Thread.currentThread().getContextClassLoader() );
@@ -57,7 +56,7 @@
/* (non-Javadoc)
* @see org.hibernate.console.IExecutionContext#execute(org.hibernate.console.ExecutionContext.Command)
*/
- public Object execute(Command c) {
+ public synchronized Object execute(Command c) {
try {
CurrentContext.push( key );
installLoader();
@@ -72,7 +71,7 @@
/* (non-Javadoc)
* @see org.hibernate.console.IExecutionContext#uninstallLoader()
*/
- public void uninstallLoader() {
+ public synchronized void uninstallLoader() {
installs--; // TODO: make more safe (synchronized) bookkeeping of the classloader installation.
if(installs==0) {
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-12-03 17:29:10 UTC (rev 19030)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-12-03 17:29:43 UTC (rev 19031)
@@ -49,6 +49,7 @@
public static String ConsoleConfigurationBasedAction_problem_while_executing;
public static String CriteriaEditorAction_hibernate_criteria_editor;
public static String CriteriaEditorAction_open_hibernate_criteria_editor;
+ public static String CloseConfigAction_close_config;
public static String DeleteConfigurationAction_delete_config;
public static String DeleteConfigurationAction_delete_console_config;
public static String DeleteConfigurationAction_do_you_wish_del_selected_config;
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-12-03 17:29:10 UTC (rev 19030)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-12-03 17:29:43 UTC (rev 19031)
@@ -42,6 +42,7 @@
ConsoleConfigurationBasedAction_problem_while_executing=Problem while executing {0} ({1})
CriteriaEditorAction_hibernate_criteria_editor=Hibernate Criteria Editor
CriteriaEditorAction_open_hibernate_criteria_editor=Open Hibernate Criteria Editor
+CloseConfigAction_close_config=Close Configuration
DeleteConfigurationAction_delete_config=Delete Configuration
DeleteConfigurationAction_delete_console_config=Delete console configuration
DeleteConfigurationAction_do_you_wish_del_selected_config=Do you wish to delete the selected console configuration
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CloseConfigAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CloseConfigAction.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CloseConfigAction.java 2009-12-03 17:29:43 UTC (rev 19031)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.console.viewers.xpl.MTreeViewer;
+
+/**
+ * @author Vitali Yemialyanchyk
+ */
+public class CloseConfigAction extends SelectionListenerAction {
+
+ public static final String CLOSECONFIG_ACTIONID = "actionid.closeconfig"; //$NON-NLS-1$
+
+ private StructuredViewer viewer;
+
+ public CloseConfigAction(StructuredViewer sv) {
+ super(HibernateConsoleMessages.CloseConfigAction_close_config);
+ setEnabled(false);
+ this.viewer = sv;
+ setText(HibernateConsoleMessages.CloseConfigAction_close_config);
+ setImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.CLOSE));
+ setId(CLOSECONFIG_ACTIONID);
+ }
+
+ public void run() {
+ doCloseConfig();
+ }
+
+ protected void doCloseConfig() {
+ for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext();) {
+ Object node = i.next();
+ if (!(node instanceof ConsoleConfiguration)) {
+ continue;
+ }
+ ConsoleConfiguration config = (ConsoleConfiguration) node;
+ ((MTreeViewer)viewer).clearChildren(null);
+ config.reset();
+ viewer.refresh(node);
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ boolean res = false;
+ for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext();) {
+ Object node = i.next();
+ if (!(node instanceof ConsoleConfiguration)) {
+ continue;
+ }
+ ConsoleConfiguration config = (ConsoleConfiguration) node;
+ if (config.hasConfiguration()) {
+ res = true;
+ }
+ }
+ //return res;
+ return true;
+ }
+}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/viewers/xpl/MTreeViewer.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/viewers/xpl/MTreeViewer.java 2009-12-03 17:29:10 UTC (rev 19030)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/viewers/xpl/MTreeViewer.java 2009-12-03 17:29:43 UTC (rev 19031)
@@ -19,6 +19,7 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
/**
@@ -46,6 +47,17 @@
super(parent, style);
}
+ public void clearChildren(Object node) {
+ Widget[] items = getChildren(node == null ? getTree() : (Widget)node);
+ for (int j = 0; j < items.length; j++) {
+ clearChildren(items[j]);
+ if (items[j] instanceof TreeItem) {
+ ((TreeItem)items[j]).setExpanded(false);
+ ((TreeItem)items[j]).clearAll(true);
+ }
+ }
+ }
+
/**
* Adds the given child elements to this viewer as children of the given
* parent element. If this viewer does not have a sorter, the elements are
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java 2009-12-03 17:29:10 UTC (rev 19030)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java 2009-12-03 17:29:43 UTC (rev 19031)
@@ -34,6 +34,7 @@
import org.eclipse.ui.actions.SelectionListenerAction;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.actions.AddConfigurationAction;
+import org.hibernate.eclipse.console.actions.CloseConfigAction;
import org.hibernate.eclipse.console.actions.CriteriaEditorAction;
import org.hibernate.eclipse.console.actions.DeleteConfigurationAction;
import org.hibernate.eclipse.console.actions.EditConsoleConfiguration;
@@ -76,6 +77,7 @@
public static final String GROUP_OTHER_EDITORS_LAST = "group.otherEditors.last"; //$NON-NLS-1$
private Action addConfigurationAction;
+ private SelectionListenerAction closeConfigAction;
private SelectionListenerAction deleteConfigurationAction;
private SelectionListenerAction refreshAction;
//private SelectionListenerAction connectAction;
@@ -93,6 +95,9 @@
this.selectionProvider = selectionProvider;
addConfigurationAction = new AddConfigurationAction(part);
+ closeConfigAction = new CloseConfigAction(selectionProvider);
+ selectionProvider.addSelectionChangedListener(closeConfigAction);
+
deleteConfigurationAction = new DeleteConfigurationAction(selectionProvider);
selectionProvider.addSelectionChangedListener(deleteConfigurationAction);
IActionBars actionBars= part.getViewSite().getActionBars();
@@ -133,6 +138,7 @@
public void dispose() {
super.dispose();
+ selectionProvider.removeSelectionChangedListener(closeConfigAction);
selectionProvider.removeSelectionChangedListener(deleteConfigurationAction);
selectionProvider.removeSelectionChangedListener(refreshAction);
selectionProvider.removeSelectionChangedListener(reloadConfigurationAction);
@@ -160,6 +166,7 @@
if (first instanceof ConsoleConfiguration) {
menu.appendToGroup(GROUP_CONSOLE_CONFIG, reloadConfigurationAction);
menu.appendToGroup(GROUP_CONSOLE_CONFIG, editConfigurationAction);
+ menu.appendToGroup(GROUP_CONSOLE_CONFIG, closeConfigAction);
menu.appendToGroup(GROUP_CONSOLE_CONFIG, deleteConfigurationAction);
}
menu.add(new GroupMarker(GROUP_CONSOLE_CONFIG_LAST));
15 years, 1 month
JBoss Tools SVN: r19030 - in branches/jbosstools-3.1.0.RC1/hibernatetools/plugins: org.hibernate.eclipse/src/org/hibernate/console/execution and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-12-03 12:29:10 -0500 (Thu, 03 Dec 2009)
New Revision: 19030
Added:
branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CloseConfigAction.java
branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfigClassLoader.java
Modified:
branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/viewers/xpl/MTreeViewer.java
branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java
branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1012 & http://opensource.atlassian.com/projects/hibernate/browse/HBX-936 - fix
Added: branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfigClassLoader.java
===================================================================
--- branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfigClassLoader.java (rev 0)
+++ branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfigClassLoader.java 2009-12-03 17:29:10 UTC (rev 19030)
@@ -0,0 +1,286 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.console;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.jar.JarFile;
+
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * Workaround for jdk disgrace with open jar files & native libs,
+ * which is a reason of locked, "undelete" files.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ConsoleConfigClassLoader extends URLClassLoader {
+
+ protected HashSet<String> setJarFileNames2Close = new HashSet<String>();
+
+ public ConsoleConfigClassLoader(URL[] urls, ClassLoader parent) {
+ super(urls, parent);
+ }
+
+ public void close() {
+ setJarFileNames2Close.clear();
+ closeClassLoader(this);
+ finalizeNativeLibs(this);
+ cleanupJarFileFactory();
+ }
+
+ /**
+ * cleanup jar file factory cache
+ */
+ @SuppressWarnings({ "nls", "unchecked" })
+ public boolean cleanupJarFileFactory()
+ {
+ boolean res = false;
+ Class classJarURLConnection = null;
+ try {
+ classJarURLConnection = ReflectHelper.classForName("sun.net.www.protocol.jar.JarURLConnection");
+ } catch (ClassNotFoundException e) {
+ //ignore
+ }
+ if (classJarURLConnection == null) {
+ return res;
+ }
+ Field f = null;
+ try {
+ f = classJarURLConnection.getDeclaredField("factory");
+ } catch (NoSuchFieldException e) {
+ //ignore
+ }
+ if (f == null) {
+ return res;
+ }
+ f.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = f.get(null);
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ if (obj == null) {
+ return res;
+ }
+ Class classJarFileFactory = obj.getClass();
+ //
+ HashMap fileCache = null;
+ try {
+ f = classJarFileFactory.getDeclaredField("fileCache");
+ f.setAccessible(true);
+ obj = f.get(null);
+ if (obj instanceof HashMap) {
+ fileCache = (HashMap)obj;
+ }
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ HashMap urlCache = null;
+ try {
+ f = classJarFileFactory.getDeclaredField("urlCache");
+ f.setAccessible(true);
+ obj = f.get(null);
+ if (obj instanceof HashMap) {
+ urlCache = (HashMap)obj;
+ }
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ if (urlCache != null) {
+ HashMap urlCacheTmp = (HashMap)urlCache.clone();
+ Iterator it = urlCacheTmp.keySet().iterator();
+ while (it.hasNext()) {
+ obj = it.next();
+ if (!(obj instanceof JarFile)) {
+ continue;
+ }
+ JarFile jarFile = (JarFile)obj;
+ if (setJarFileNames2Close.contains(jarFile.getName())) {
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ if (fileCache != null) {
+ fileCache.remove(urlCache.get(jarFile));
+ }
+ urlCache.remove(jarFile);
+ }
+ }
+ res = true;
+ } else if (fileCache != null) {
+ // urlCache := null
+ HashMap fileCacheTmp = (HashMap)fileCache.clone();
+ Iterator it = fileCacheTmp.keySet().iterator();
+ while (it.hasNext()) {
+ Object key = it.next();
+ obj = fileCache.get(key);
+ if (!(obj instanceof JarFile)) {
+ continue;
+ }
+ JarFile jarFile = (JarFile)obj;
+ if (setJarFileNames2Close.contains(jarFile.getName())) {
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ fileCache.remove(key);
+ }
+ }
+ res = true;
+ }
+ setJarFileNames2Close.clear();
+ return res;
+ }
+
+ /**
+ * close jar files of cl
+ * @param cl
+ * @return
+ */
+ @SuppressWarnings( { "nls", "unchecked" })
+ public boolean closeClassLoader(ClassLoader cl) {
+ boolean res = false;
+ if (cl == null) {
+ return res;
+ }
+ Class classURLClassLoader = URLClassLoader.class;
+ Field f = null;
+ try {
+ f = classURLClassLoader.getDeclaredField("ucp");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = f.get(cl);
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ if (obj != null) {
+ final Object ucp = obj;
+ f = null;
+ try {
+ f = ucp.getClass().getDeclaredField("loaders");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ ArrayList loaders = null;
+ try {
+ loaders = (ArrayList) f.get(ucp);
+ res = true;
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ for (int i = 0; loaders != null && i < loaders.size(); i++) {
+ obj = loaders.get(i);
+ f = null;
+ try {
+ f = obj.getClass().getDeclaredField("jar");
+ } catch (NoSuchFieldException e) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ try {
+ obj = f.get(obj);
+ } catch (IllegalAccessException e1) {
+ // ignore
+ }
+ if (obj instanceof JarFile) {
+ final JarFile jarFile = (JarFile)obj;
+ setJarFileNames2Close.add(jarFile.getName());
+ //try {
+ // jarFile.getManifest().clear();
+ //} catch (IOException e) {
+ // // ignore
+ //}
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return res;
+ }
+
+ /**
+ * finalize native libraries
+ * @param cl
+ * @return
+ */
+ @SuppressWarnings({ "nls", "unchecked" })
+ public boolean finalizeNativeLibs(ClassLoader cl) {
+ boolean res = false;
+ Class classClassLoader = ClassLoader.class;
+ java.lang.reflect.Field nativeLibraries = null;
+ try {
+ nativeLibraries = classClassLoader.getDeclaredField("nativeLibraries");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (nativeLibraries == null) {
+ return res;
+ }
+ nativeLibraries.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = nativeLibraries.get(cl);
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ if (!(obj instanceof Vector)) {
+ return res;
+ }
+ res = true;
+ Vector java_lang_ClassLoader_NativeLibrary = (Vector)obj;
+ for (Object lib : java_lang_ClassLoader_NativeLibrary) {
+ java.lang.reflect.Method finalize = null;
+ try {
+ finalize = lib.getClass().getDeclaredMethod("finalize", new Class[0]);
+ } catch (NoSuchMethodException e) {
+ //ignore
+ }
+ if (finalize != null) {
+ finalize.setAccessible(true);
+ try {
+ finalize.invoke(lib, new Object[0]);
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
+ //ignore
+ }
+ }
+ }
+ return res;
+ }
+}
Modified: branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
--- branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2009-12-03 17:06:59 UTC (rev 19029)
+++ branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2009-12-03 17:29:10 UTC (rev 19030)
@@ -29,7 +29,8 @@
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Driver;
@@ -37,6 +38,7 @@
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -74,6 +76,7 @@
public class ConsoleConfiguration implements ExecutionContextHolder {
private ExecutionContext executionContext;
+ private ConsoleConfigClassLoader classLoader = null;
private Map<String, FakeDelegatingDriver> fakeDrivers = new HashMap<String, FakeDelegatingDriver>();
@@ -106,8 +109,38 @@
// reseting state
configuration = null;
closeSessionFactory();
+ if (executionContext != null) {
+ executionContext.execute(new ExecutionContext.Command() {
+
+ public Object execute() {
+ Iterator<FakeDelegatingDriver> it = fakeDrivers.values().iterator();
+ while (it.hasNext()) {
+ try {
+ DriverManager.deregisterDriver(it.next());
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ return null;
+ }
+ });
+ }
+ fakeDrivers.clear();
+ cleanUpClassLoader();
+ executionContext = null;
}
+ public void cleanUpClassLoader() {
+ ClassLoader classLoaderTmp = classLoader;
+ while (classLoaderTmp != null) {
+ if (classLoaderTmp instanceof ConsoleConfigClassLoader) {
+ ((ConsoleConfigClassLoader)classLoaderTmp).close();
+ }
+ classLoaderTmp = classLoaderTmp.getParent();
+ }
+ classLoader = null;
+ }
+
public void build() {
configuration = buildWith(null, true);
fireConfigurationBuilt();
@@ -237,39 +270,51 @@
}
return customClassPathURLs;
}
+
+ protected ConsoleConfigClassLoader createClassLoader() {
+ final URL[] customClassPathURLs = getCustomClassPathURLs();
+ ConsoleConfigClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ConsoleConfigClassLoader>() {
+ public ConsoleConfigClassLoader run() {
+ return new ConsoleConfigClassLoader(customClassPathURLs, getParentClassLoader()) {
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ try {
+ return super.findClass(name);
+ } catch (ClassNotFoundException cnfe) {
+ throw cnfe;
+ }
+ }
+
+ protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ try {
+ return super.loadClass(name, resolve);
+ } catch (ClassNotFoundException cnfe) {
+ throw cnfe;
+ }
+ }
+
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
+ try {
+ return super.loadClass(name);
+ } catch (ClassNotFoundException cnfe) {
+ throw cnfe;
+ }
+ }
+ };
+ }
+ });
+ return classLoader;
+ }
/**
* @return
*
*/
public Configuration buildWith(final Configuration cfg, final boolean includeMappings) {
- URL[] customClassPathURLs = getCustomClassPathURLs();
- executionContext = new DefaultExecutionContext( getName(), new URLClassLoader( customClassPathURLs, getParentClassLoader() ) {
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- try {
- return super.findClass( name );
- } catch(ClassNotFoundException cnfe) {
- throw cnfe;
- }
- }
+ if (classLoader == null) {
+ classLoader = createClassLoader();
+ }
+ executionContext = new DefaultExecutionContext(getName(), classLoader);
- protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- try {
- return super.loadClass( name, resolve );
- } catch(ClassNotFoundException cnfe) {
- throw cnfe;
- }
- }
-
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- try {
- return super.loadClass( name );
- } catch(ClassNotFoundException cnfe) {
- throw cnfe;
- }
- }
- });
-
Configuration result = (Configuration) executionContext.execute(new ExecutionContext.Command() {
public Object execute() {
Modified: branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java
===================================================================
--- branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java 2009-12-03 17:06:59 UTC (rev 19029)
+++ branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/execution/DefaultExecutionContext.java 2009-12-03 17:29:10 UTC (rev 19030)
@@ -21,7 +21,6 @@
*/
package org.hibernate.console.execution;
-import java.net.URLClassLoader;
import java.util.Map;
import java.util.WeakHashMap;
@@ -31,13 +30,13 @@
public class DefaultExecutionContext implements ExecutionContext {
- final private URLClassLoader configurationClassLoader;
+ final private ClassLoader configurationClassLoader;
private volatile int installs;
private Map<Thread, ClassLoader> previousLoaders = new WeakHashMap<Thread, ClassLoader>();
final String key;
- public DefaultExecutionContext(String key, URLClassLoader loader) {
+ public DefaultExecutionContext(String key, ClassLoader loader) {
configurationClassLoader = loader;
this.key = key;
}
@@ -45,7 +44,7 @@
/* (non-Javadoc)
* @see org.hibernate.console.IExecutionContext#installLoader()
*/
- public void installLoader() {
+ public synchronized void installLoader() {
installs++;
if(configurationClassLoader!=null && Thread.currentThread().getContextClassLoader() != configurationClassLoader) {
previousLoaders.put(Thread.currentThread(), Thread.currentThread().getContextClassLoader() );
@@ -57,7 +56,7 @@
/* (non-Javadoc)
* @see org.hibernate.console.IExecutionContext#execute(org.hibernate.console.ExecutionContext.Command)
*/
- public Object execute(Command c) {
+ public synchronized Object execute(Command c) {
try {
CurrentContext.push( key );
installLoader();
@@ -72,7 +71,7 @@
/* (non-Javadoc)
* @see org.hibernate.console.IExecutionContext#uninstallLoader()
*/
- public void uninstallLoader() {
+ public synchronized void uninstallLoader() {
installs--; // TODO: make more safe (synchronized) bookkeeping of the classloader installation.
if(installs==0) {
Modified: branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
--- branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-12-03 17:06:59 UTC (rev 19029)
+++ branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-12-03 17:29:10 UTC (rev 19030)
@@ -49,6 +49,7 @@
public static String ConsoleConfigurationBasedAction_problem_while_executing;
public static String CriteriaEditorAction_hibernate_criteria_editor;
public static String CriteriaEditorAction_open_hibernate_criteria_editor;
+ public static String CloseConfigAction_close_config;
public static String DeleteConfigurationAction_delete_config;
public static String DeleteConfigurationAction_delete_console_config;
public static String DeleteConfigurationAction_do_you_wish_del_selected_config;
Modified: branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
--- branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-12-03 17:06:59 UTC (rev 19029)
+++ branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-12-03 17:29:10 UTC (rev 19030)
@@ -42,6 +42,7 @@
ConsoleConfigurationBasedAction_problem_while_executing=Problem while executing {0} ({1})
CriteriaEditorAction_hibernate_criteria_editor=Hibernate Criteria Editor
CriteriaEditorAction_open_hibernate_criteria_editor=Open Hibernate Criteria Editor
+CloseConfigAction_close_config=Close Configuration
DeleteConfigurationAction_delete_config=Delete Configuration
DeleteConfigurationAction_delete_console_config=Delete console configuration
DeleteConfigurationAction_do_you_wish_del_selected_config=Do you wish to delete the selected console configuration
Added: branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CloseConfigAction.java
===================================================================
--- branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CloseConfigAction.java (rev 0)
+++ branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/actions/CloseConfigAction.java 2009-12-03 17:29:10 UTC (rev 19030)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.console.viewers.xpl.MTreeViewer;
+
+/**
+ * @author Vitali Yemialyanchyk
+ */
+public class CloseConfigAction extends SelectionListenerAction {
+
+ public static final String CLOSECONFIG_ACTIONID = "actionid.closeconfig"; //$NON-NLS-1$
+
+ private StructuredViewer viewer;
+
+ public CloseConfigAction(StructuredViewer sv) {
+ super(HibernateConsoleMessages.CloseConfigAction_close_config);
+ setEnabled(false);
+ this.viewer = sv;
+ setText(HibernateConsoleMessages.CloseConfigAction_close_config);
+ setImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.CLOSE));
+ setId(CLOSECONFIG_ACTIONID);
+ }
+
+ public void run() {
+ doCloseConfig();
+ }
+
+ protected void doCloseConfig() {
+ for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext();) {
+ Object node = i.next();
+ if (!(node instanceof ConsoleConfiguration)) {
+ continue;
+ }
+ ConsoleConfiguration config = (ConsoleConfiguration) node;
+ ((MTreeViewer)viewer).clearChildren(null);
+ config.reset();
+ viewer.refresh(node);
+ }
+ }
+
+ @Override
+ public boolean isEnabled() {
+ boolean res = false;
+ for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext();) {
+ Object node = i.next();
+ if (!(node instanceof ConsoleConfiguration)) {
+ continue;
+ }
+ ConsoleConfiguration config = (ConsoleConfiguration) node;
+ if (config.hasConfiguration()) {
+ res = true;
+ }
+ }
+ //return res;
+ return true;
+ }
+}
Modified: branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/viewers/xpl/MTreeViewer.java
===================================================================
--- branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/viewers/xpl/MTreeViewer.java 2009-12-03 17:06:59 UTC (rev 19029)
+++ branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/viewers/xpl/MTreeViewer.java 2009-12-03 17:29:10 UTC (rev 19030)
@@ -19,6 +19,7 @@
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;
/**
@@ -46,6 +47,17 @@
super(parent, style);
}
+ public void clearChildren(Object node) {
+ Widget[] items = getChildren(node == null ? getTree() : (Widget)node);
+ for (int j = 0; j < items.length; j++) {
+ clearChildren(items[j]);
+ if (items[j] instanceof TreeItem) {
+ ((TreeItem)items[j]).setExpanded(false);
+ ((TreeItem)items[j]).clearAll(true);
+ }
+ }
+ }
+
/**
* Adds the given child elements to this viewer as children of the given
* parent element. If this viewer does not have a sorter, the elements are
Modified: branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java
===================================================================
--- branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java 2009-12-03 17:06:59 UTC (rev 19029)
+++ branches/jbosstools-3.1.0.RC1/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConfigurationsViewActionGroup.java 2009-12-03 17:29:10 UTC (rev 19030)
@@ -34,6 +34,7 @@
import org.eclipse.ui.actions.SelectionListenerAction;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.eclipse.console.actions.AddConfigurationAction;
+import org.hibernate.eclipse.console.actions.CloseConfigAction;
import org.hibernate.eclipse.console.actions.CriteriaEditorAction;
import org.hibernate.eclipse.console.actions.DeleteConfigurationAction;
import org.hibernate.eclipse.console.actions.EditConsoleConfiguration;
@@ -76,6 +77,7 @@
public static final String GROUP_OTHER_EDITORS_LAST = "group.otherEditors.last"; //$NON-NLS-1$
private Action addConfigurationAction;
+ private SelectionListenerAction closeConfigAction;
private SelectionListenerAction deleteConfigurationAction;
private SelectionListenerAction refreshAction;
//private SelectionListenerAction connectAction;
@@ -93,6 +95,9 @@
this.selectionProvider = selectionProvider;
addConfigurationAction = new AddConfigurationAction(part);
+ closeConfigAction = new CloseConfigAction(selectionProvider);
+ selectionProvider.addSelectionChangedListener(closeConfigAction);
+
deleteConfigurationAction = new DeleteConfigurationAction(selectionProvider);
selectionProvider.addSelectionChangedListener(deleteConfigurationAction);
IActionBars actionBars= part.getViewSite().getActionBars();
@@ -133,6 +138,7 @@
public void dispose() {
super.dispose();
+ selectionProvider.removeSelectionChangedListener(closeConfigAction);
selectionProvider.removeSelectionChangedListener(deleteConfigurationAction);
selectionProvider.removeSelectionChangedListener(refreshAction);
selectionProvider.removeSelectionChangedListener(reloadConfigurationAction);
@@ -160,6 +166,7 @@
if (first instanceof ConsoleConfiguration) {
menu.appendToGroup(GROUP_CONSOLE_CONFIG, reloadConfigurationAction);
menu.appendToGroup(GROUP_CONSOLE_CONFIG, editConfigurationAction);
+ menu.appendToGroup(GROUP_CONSOLE_CONFIG, closeConfigAction);
menu.appendToGroup(GROUP_CONSOLE_CONFIG, deleteConfigurationAction);
}
menu.add(new GroupMarker(GROUP_CONSOLE_CONFIG_LAST));
15 years, 1 month
JBoss Tools SVN: r19029 - in trunk: vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mareshkau
Date: 2009-12-03 12:06:59 -0500 (Thu, 03 Dec 2009)
New Revision: 19029
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/resources/faceletsTest/WebContent/pages/components/compositionWithoutTaglibs.xhtml.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5352
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/resources/faceletsTest/WebContent/pages/components/compositionWithoutTaglibs.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/resources/faceletsTest/WebContent/pages/components/compositionWithoutTaglibs.xhtml.xml 2009-12-03 16:58:35 UTC (rev 19028)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.facelets.test/resources/faceletsTest/WebContent/pages/components/compositionWithoutTaglibs.xhtml.xml 2009-12-03 17:06:59 UTC (rev 19029)
@@ -5,52 +5,27 @@
</SPAN>
</test>
<test id="id3">
-<DIV STYLE="-moz-user-modify: read-only;">
-<DIV STYLE="-moz-user-modify: read-only;">
-<DIV STYLE="display: none; -moz-user-modify: read-only;">
-<H1 STYLE="-moz-user-modify: read-only;">
-</H1>
+<DIV CLASS="__any__tag__caption" STYLE="border: 1px solid green; -moz-user-modify: read-only;">
+ui:composition
+<DIV CLASS="__any__tag__caption" STYLE="border: 1px solid green; -moz-user-modify: read-only;">
+ui:define
+<SPAN CLASS="vpe-text">
+Greeting to User
+</SPAN>
</DIV>
-<DIV STYLE="-moz-user-modify: read-only;">
-<TABLE WIDTH="400" CELLSPACING="0" CELLPADDING="0" BORDER="0" ALIGN="center" STYLE="border: 1px solid rgb(202, 214, 224); -moz-user-modify: read-only;">
-<TBODY STYLE="-moz-user-modify: read-only;">
-<TR STYLE="-moz-user-modify: read-only;">
-<TD WIDTH="100%" VALIGN="middle" HEIGHT="42" BGCOLOR="#e4ebeb" ALIGN="center" CLASS="header" STYLE="-moz-user-modify: read-only;">
+<DIV CLASS="__any__tag__caption" STYLE="border: 1px solid green; -moz-user-modify: read-only;">
+ui:define
<SPAN CLASS="vpe-text">
Greeting Page
</SPAN>
-</TD>
-</TR>
-<TR STYLE="-moz-user-modify: read-only;">
-<TD WIDTH="100%" HEIGHT="1" BGCOLOR="#cad6e0" ALIGN="center" STYLE="-moz-user-modify: read-only;">
-<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
-#{user}
-</SPAN>
-</TD>
-</TR>
-<TR STYLE="-moz-user-modify: read-only;">
-<TD WIDTH="100%" COLSPAN="2" STYLE="-moz-user-modify: read-only;">
-<TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0" BORDER="0" ALIGN="left" STYLE="height: 150px; -moz-user-modify: read-only;">
-<TBODY STYLE="-moz-user-modify: read-only;">
-<TR STYLE="-moz-user-modify: read-only;">
-<TD WIDTH="100%" VALIGN="middle" ALIGN="center" STYLE="-moz-user-modify: read-only;">
+</DIV>
+<DIV CLASS="__any__tag__caption" STYLE="border: 1px solid green; -moz-user-modify: read-only;">
+ui:define
<SPAN CLASS="vpe-text">
Hello #{person.name}!
</SPAN>
-</TD>
-</TR>
-</TBODY>
-</TABLE>
-</TD>
-</TR>
-<TR STYLE="-moz-user-modify: read-only;">
-<TD WIDTH="100%" VALIGN="bottom" HEIGHT="1" BGCOLOR="#cad6e0" COLSPAN="2" STYLE="-moz-user-modify: read-only;">
-</TD>
-</TR>
-</TBODY>
-</TABLE>
</DIV>
</DIV>
-</DIV>
</test>
-</tests>
\ No newline at end of file
+</tests>
+
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-12-03 16:58:35 UTC (rev 19028)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-12-03 17:06:59 UTC (rev 19029)
@@ -386,7 +386,7 @@
TaglibData sourceNodeTaglib = XmlUtil.getTaglibForPrefix(sourcePrefix, taglibs);
if(sourceNodeTaglib == null) {
- return sourceNode.getNodeName();
+ return sourceNode.getLocalName();
}
String sourceNodeUri = sourceNodeTaglib.getUri();
15 years, 1 month
JBoss Tools SVN: r19027 - trunk/hibernatetools/docs/reference/en/modules.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2009-12-03 11:42:52 -0500 (Thu, 03 Dec 2009)
New Revision: 19027
Modified:
trunk/hibernatetools/docs/reference/en/modules/plugins.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-970 mention in hibernate guide about possibility to create an empty hbm.xml file is added
Modified: trunk/hibernatetools/docs/reference/en/modules/plugins.xml
===================================================================
--- trunk/hibernatetools/docs/reference/en/modules/plugins.xml 2009-12-03 15:14:54 UTC (rev 19026)
+++ trunk/hibernatetools/docs/reference/en/modules/plugins.xml 2009-12-03 16:42:52 UTC (rev 19027)
@@ -37,7 +37,7 @@
<property>.hbm.xml</property>
</emphasis> files, Hibernate Tools provide a basic wizard which you can bring up by navigating <emphasis>
<property>New > Hibernate XML mapping file</property>.</emphasis></para>
- <para>At first you'll be asked to select a package or multiple individual classes to map.</para>
+ <para>At first you'll be asked to select a package or multiple individual classes to map. It's also possible to create an empty file, don't select any packages or classes and an empty .hbm will be created in the specified location</para>
<figure>
<title>Hibernate XML Mapping File Wizard</title>
15 years, 1 month
JBoss Tools SVN: r19026 - in trunk/esb/docs/esb_ref_guide/en: modules and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: smukhina
Date: 2009-12-03 10:14:54 -0500 (Thu, 03 Dec 2009)
New Revision: 19026
Added:
trunk/esb/docs/esb_ref_guide/en/images/esb_editor/06a_esb_filter.png
Modified:
trunk/esb/docs/esb_ref_guide/en/modules/esb_editor.xml
Log:
https://jira.jboss.org/jira/browse/JBDS-958 Directory pickup is added in JBoss ESB Editor/FS Message Filter - screen is added
Added: trunk/esb/docs/esb_ref_guide/en/images/esb_editor/06a_esb_filter.png
===================================================================
(Binary files differ)
Property changes on: trunk/esb/docs/esb_ref_guide/en/images/esb_editor/06a_esb_filter.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/esb/docs/esb_ref_guide/en/modules/esb_editor.xml
===================================================================
--- trunk/esb/docs/esb_ref_guide/en/modules/esb_editor.xml 2009-12-03 15:03:00 UTC (rev 19025)
+++ trunk/esb/docs/esb_ref_guide/en/modules/esb_editor.xml 2009-12-03 15:14:54 UTC (rev 19026)
@@ -89,7 +89,7 @@
</imageobject>
</mediaobject>
</figure>
-
+
<para>The same way you can create a listener for service and other elements of ESB:</para>
<figure>
<title>Adding New Listener for Service</title>
@@ -102,6 +102,17 @@
<para>The same actions can be done in the right part of <property>Tree view</property> tab
(Form editor) using <property>Add</property>, <property>Edit</property> and
<property>Remove</property> buttons.</para>
+
+ <para>Filter can be also edited this way</para>
+
+ <figure>
+ <title>Editing Filter</title>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/esb_editor/06a_esb_filter.png"/>
+ </imageobject>
+ </mediaobject>
+ </figure>
<para>In order to add a new generic Action to your ESB XML file you should select the
15 years, 1 month
JBoss Tools SVN: r19025 - trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2009-12-03 10:03:00 -0500 (Thu, 03 Dec 2009)
New Revision: 19025
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE5218Test.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5218, test class was commited
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE5218Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE5218Test.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE5218Test.java 2009-12-03 15:03:00 UTC (rev 19025)
@@ -0,0 +1,171 @@
+package org.jboss.tools.jsf.vpe.jsf.test.jbide;
+
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+
+/**
+ * Checks f:view's locale workflow.
+ *
+ * @author dmaliarevich
+ */
+public class JBIDE5218Test extends VpeTest {
+
+ private static final String DEFAULT_LOCALE_PAGE = "defaultLocale.jsp"; //$NON-NLS-1$
+ private static final String LOCALE_ATTRIBUTE_PAGE = "JBIDE/5218/localeAttribute.jsp"; //$NON-NLS-1$
+ private static final String LOCALE_ATTRIBUTE_WITH_DEFAULT_LOCALE_PAGE = "localeAndDefault.jsp"; //$NON-NLS-1$
+ private static final String SEVERAL_FVIEWS_PAGE = "JBIDE/5218/severalFViews.jsp"; //$NON-NLS-1$
+ private static final String CHANGE_LOCALE_AND_REFRESH_PAGE = "JBIDE/5218/changeLocaleAndRefresh.jsp"; //$NON-NLS-1$
+
+ private static final String HELLO_DE = "Guten Tag!"; //$NON-NLS-1$
+ private static final String HELLO2_DE = "German Hello"; //$NON-NLS-1$
+ private static final String HELLO_EN = "Hello"; //$NON-NLS-1$
+ private static final String HELLO_EN_US = "US Hello"; //$NON-NLS-1$
+ private static final String HELLO_EN_GB = "Great Britain Hello"; //$NON-NLS-1$
+
+ private static final String LOCALE_TEXT_ID = "localeText"; //$NON-NLS-1$
+ private static final String LOCALE_TEXT1_ID = "localeText1"; //$NON-NLS-1$
+ private static final String LOCALE_TEXT2_ID = "localeText2"; //$NON-NLS-1$
+ private static final String FVIEW_ID = "fviewid"; //$NON-NLS-1$
+
+
+ public JBIDE5218Test(String name) {
+ super(name);
+ }
+
+ /**
+ * Tests that the dafault locale is applied by default,
+ * f:view has no locale attribute in this case.
+ *
+ * @throws Throwable
+ */
+ public void testDefaultLocale() throws Throwable {
+ VpeController controller = openInVpe(
+ JsfAllTests.IMPORT_I18N_PROJECT_NAME, DEFAULT_LOCALE_PAGE);
+ nsIDOMDocument doc = controller.getXulRunnerEditor().getDOMDocument();
+ nsIDOMElement localeText = doc.getElementById(LOCALE_TEXT_ID);
+ String localizedText = getLocalizedText(localeText);
+ assertTrue("Text is '"+localizedText+"', but should be in Deutch", HELLO_DE.equalsIgnoreCase(localizedText)); //$NON-NLS-1$ //$NON-NLS-2$
+ closeEditors();
+ }
+
+ /**
+ * f:view has a locale attribute defined,
+ * which should be applied.
+ * Default locale is empty in this case.
+ *
+ * @throws Throwable
+ */
+ public void testLocaleAttribute() throws Throwable {
+ VpeController controller = openInVpe(
+ JsfAllTests.IMPORT_JSF_20_PROJECT_NAME, LOCALE_ATTRIBUTE_PAGE);
+ nsIDOMDocument doc = controller.getXulRunnerEditor().getDOMDocument();
+ nsIDOMElement localeText = doc.getElementById(LOCALE_TEXT_ID);
+ String localizedText = getLocalizedText(localeText);
+ assertTrue("Text is '"+localizedText+"', but should be should be in German", HELLO2_DE.equalsIgnoreCase(localizedText)); //$NON-NLS-1$ //$NON-NLS-2$
+ closeEditors();
+ }
+
+ /**
+ * The default locale is defined,
+ * f:view has a locale attribute defined also,
+ * The default locale in this case should take an advantage.
+ *
+ * @throws Throwable
+ */
+ public void testLocaleAttributeWithDefaultLocale() throws Throwable {
+ VpeController controller = openInVpe(
+ JsfAllTests.IMPORT_I18N_PROJECT_NAME,
+ LOCALE_ATTRIBUTE_WITH_DEFAULT_LOCALE_PAGE);
+ nsIDOMDocument doc = controller.getXulRunnerEditor().getDOMDocument();
+ nsIDOMElement localeText = doc.getElementById(LOCALE_TEXT_ID);
+ String localizedText = getLocalizedText(localeText);
+ assertTrue("Text is '"+localizedText+"', but should be in Deutch", HELLO_DE.equalsIgnoreCase(localizedText)); //$NON-NLS-1$ //$NON-NLS-2$
+ closeEditors();
+ }
+
+ /**
+ * If there are several f:views on the page.
+ * Only the last f:view one should be applied on server,
+ * but each f:view should have its own locale.
+ *
+ * @throws Throwable
+ */
+ public void testSeveralFViewsWithLocales() throws Throwable {
+ VpeController controller = openInVpe(
+ JsfAllTests.IMPORT_JSF_20_PROJECT_NAME, SEVERAL_FVIEWS_PAGE);
+ nsIDOMDocument doc = controller.getXulRunnerEditor().getDOMDocument();
+ nsIDOMElement localeText = doc.getElementById(LOCALE_TEXT1_ID);
+ String localizedText = getLocalizedText(localeText);
+ assertTrue("Text is '"+localizedText+"', but should be in 'de' locale", HELLO2_DE.equalsIgnoreCase(localizedText)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ localeText = doc.getElementById(LOCALE_TEXT2_ID);
+ localizedText = getLocalizedText(localeText);
+ assertTrue("Text is '"+localizedText+"', but should be in default locale", HELLO_EN.equalsIgnoreCase(localizedText)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ localeText = doc.getElementById(LOCALE_TEXT_ID);
+ localizedText = getLocalizedText(localeText);
+ assertTrue("Text is '"+localizedText+"', but should be in 'en_US' locale", HELLO_EN_US.equalsIgnoreCase(localizedText)); //$NON-NLS-1$ //$NON-NLS-2$
+ closeEditors();
+ }
+
+ /**
+ * After the locale attribute value has been changed and
+ * Refresh button is clicked - the correct locale should be applied,
+ * bundle messages should be updated and showed in the correct locale.
+ *
+ * @throws Throwable
+ */
+ public void testChangeLocaleAndRefresh() throws Throwable {
+ VpeController controller = openInVpe(
+ JsfAllTests.IMPORT_JSF_20_PROJECT_NAME,
+ CHANGE_LOCALE_AND_REFRESH_PAGE);
+ nsIDOMDocument doc = controller.getXulRunnerEditor().getDOMDocument();
+ nsIDOMElement localeText = doc.getElementById(LOCALE_TEXT_ID);
+ String localizedText = getLocalizedText(localeText);
+ assertTrue("Text is '"+localizedText+"', but should be in German", HELLO2_DE.equalsIgnoreCase(localizedText)); //$NON-NLS-1$ //$NON-NLS-2$
+ /*
+ * Change the locale
+ */
+ Element fViewElement = controller.getSourceBuilder().getSourceDocument().getElementById(FVIEW_ID);
+ assertTrue("Previous locale should be 'de'", "de".equalsIgnoreCase(fViewElement.getAttribute("locale"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ fViewElement.setAttribute("locale", "en_GB"); //$NON-NLS-1$ //$NON-NLS-2$
+ /*
+ * Wait until new value is applied and children are refreshed.
+ */
+ TestUtil.waitForIdle();
+ assertTrue("Current locale should be 'en_GB'", "en_GB".equalsIgnoreCase(fViewElement.getAttribute("locale"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ doc = controller.getXulRunnerEditor().getDOMDocument();
+ localeText = doc.getElementById(LOCALE_TEXT_ID);
+ localizedText = getLocalizedText(localeText);
+ /*
+ * Check the new localized message.
+ */
+ assertTrue("Text is '"+localizedText+"', but should be in en_GB", HELLO_EN_GB.equalsIgnoreCase(localizedText)); //$NON-NLS-1$ //$NON-NLS-2$
+ closeEditors();
+ }
+
+ /**
+ * Gets the text value from the container.
+ * Contaner should be a simple tag like div or span.
+ * The text node in the VPE is initially wrapped in a span element,
+ * thus to get its value two child elements should be skipped.
+ *
+ * @param textContainer - the tag with text
+ * @return localized by VPE string
+ */
+ private String getLocalizedText(nsIDOMElement textContainer) {
+ String text = ""; //$NON-NLS-1$
+ if ((textContainer.getFirstChild() != null) && (textContainer.getFirstChild().getFirstChild() != null)
+ && HTML.TAG_SPAN.equalsIgnoreCase(textContainer.getFirstChild().getNodeName())) {
+ text = textContainer.getFirstChild().getFirstChild().getNodeValue();
+ }
+ return text;
+ }
+
+}
15 years, 1 month
JBoss Tools SVN: r19024 - in trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources: i18nTest/WebContent/pages and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2009-12-03 09:04:32 -0500 (Thu, 03 Dec 2009)
New Revision: 19024
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_en.properties
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/defaultLocale.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/localeAndDefault.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/changeLocaleAndRefresh.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/localeAttribute.jsp
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/severalFViews.jsp
Log:
https://jira.jboss.org/jira/browse/JBIDE-5218, test pages were added
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_en.properties
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_en.properties (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_en.properties 2009-12-03 14:04:32 UTC (rev 19024)
@@ -0,0 +1 @@
+hello_message=English Good afternoon!
Property changes on: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/JavaSource/demo/Messages_en.properties
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/defaultLocale.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/defaultLocale.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/defaultLocale.jsp 2009-12-03 14:04:32 UTC (rev 19024)
@@ -0,0 +1,12 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages" />
+
+<html>
+ <body>
+ <f:view>
+ <span id="localeText">#{Message.hello_message}</span>
+ </f:view>
+ </body>
+</html>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/localeAndDefault.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/localeAndDefault.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/i18nTest/WebContent/pages/localeAndDefault.jsp 2009-12-03 14:04:32 UTC (rev 19024)
@@ -0,0 +1,12 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages" />
+
+<html>
+ <body>
+ <f:view locale="en">
+ <span id="localeText">#{Message.hello_message}</span>
+ </f:view>
+ </body>
+</html>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/changeLocaleAndRefresh.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/changeLocaleAndRefresh.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/changeLocaleAndRefresh.jsp 2009-12-03 14:04:32 UTC (rev 19024)
@@ -0,0 +1,17 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+<head>
+
+</head>
+
+<body>
+<f:view locale="de" id="fviewid">
+<div id="localeText">#{Message.hello_message}</div>
+</f:view>
+</body>
+
+</html>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/localeAttribute.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/localeAttribute.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/localeAttribute.jsp 2009-12-03 14:04:32 UTC (rev 19024)
@@ -0,0 +1,17 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+<head>
+
+</head>
+
+<body>
+<f:view locale="de">
+<div id="localeText">#{Message.hello_message}</div>
+</f:view>
+</body>
+
+</html>
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/severalFViews.jsp
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/severalFViews.jsp (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsf2test/WebContent/pages/JBIDE/5218/severalFViews.jsp 2009-12-03 14:04:32 UTC (rev 19024)
@@ -0,0 +1,23 @@
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages"/>
+
+<html>
+<head>
+
+</head>
+
+<body>
+<f:view locale="de">
+<div id="localeText1">#{Message.hello_message}</div>
+</f:view>
+<f:view>
+<div id="localeText2">#{Message.hello_message}</div>
+</f:view>
+<f:view locale="en_US">
+<div id="localeText">#{Message.hello_message}</div>
+</f:view>
+</body>
+
+</html>
15 years, 1 month
JBoss Tools SVN: r19023 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks: graphical/editors/commands and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: tfennelly
Date: 2009-12-03 08:43:07 -0500 (Thu, 03 Dec 2009)
New Revision: 19023
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5365
Auto-expanded bean models should have concrete class implementations where a bean property is an Interface/Abstract
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java 2009-12-03 13:41:45 UTC (rev 19022)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java 2009-12-03 13:43:07 UTC (rev 19023)
@@ -21,8 +21,12 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
import org.jboss.tools.smooks.configuration.editors.uitls.JavaPropertyUtils;
@@ -225,7 +229,7 @@
JavaBeanModel(Class beanClass, String beanName, PropertyDescriptor propertyDescriptor, Class parentClass,
boolean lazyLoadProperties) {
this.lazyLoadProperties = lazyLoadProperties;
- this.beanClass = beanClass;
+ this.beanClass = toConcreteImpl(beanClass);
this.name = beanName;
if (beanClass == null)
return;
@@ -287,6 +291,23 @@
this(beanClass, null, null, null, lazyLoadProperties);
}
+ private Class<? extends Object> toConcreteImpl(Class declaredType) {
+
+ // Intentionally not doing an isAssignableFrom test... want to know is it the
+ // the exact class...
+ if(declaredType == List.class) {
+ return ArrayList.class;
+ } else if(declaredType == Set.class) {
+ return LinkedHashSet.class;
+ } else if(declaredType == Collection.class) {
+ return ArrayList.class;
+ } else if(declaredType == Map.class) {
+ return LinkedHashMap.class;
+ }
+
+ return declaredType;
+ }
+
public boolean isPrimitive() {
Class<?> beanType = getBeanClass();
if (beanType == null)
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java 2009-12-03 13:41:45 UTC (rev 19022)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/commands/CreateJavaBeanModelCommand.java 2009-12-03 13:43:07 UTC (rev 19023)
@@ -115,24 +115,22 @@
((BeanType) parent).setClass(parentBeanModel.getBeanClassString());
if (properties != null && properties.length > 0) {
for (int i = 0; i < properties.length; i++) {
- Object pro = properties[i];
- if (pro instanceof JavaBeanModel && belongsToMe(parentBeanModel, (JavaBeanModel) pro)) {
- if (((JavaBeanModel) pro).isPrimitive()) {
+ Object beanPropertyObj = properties[i];
+ if (beanPropertyObj instanceof JavaBeanModel && belongsToMe(parentBeanModel, (JavaBeanModel) beanPropertyObj)) {
+ JavaBeanModel beanProperty = (JavaBeanModel) beanPropertyObj;
+ if (beanProperty.isPrimitive()) {
ValueType value = Javabean12Factory.eINSTANCE.createValueType();
- value.setProperty(((JavaBeanModel) pro).getName());
+ value.setProperty(beanProperty.getName());
((BeanType) parent).getValue().add(value);
} else {
WiringType value = Javabean12Factory.eINSTANCE.createWiringType();
- if (((JavaBeanModel) parentBeanModel).isArray()
- || ((JavaBeanModel) parentBeanModel).isList()) {
-
- } else {
- value.setProperty(((JavaBeanModel) pro).getName());
+ if (!parentBeanModel.isArray() && !parentBeanModel.isList()) {
+ value.setProperty(beanProperty.getName());
}
- String refID = generateBeanID((JavaBeanModel) pro, resourceListType, ids);
+ String refID = generateBeanID(beanProperty, resourceListType, ids);
value.setBeanIdRef(refID);
((BeanType) parent).getWiring().add(value);
- creationObject.addAll(createJavaBeanModel(type, (JavaBeanModel) pro, properties,
+ creationObject.addAll(createJavaBeanModel(type, beanProperty, properties,
resourceListType, ids));
}
}
15 years, 1 month