JBoss Tools SVN: r16553 - trunk/archives/plugins/org.jboss.ide.eclipse.archives.core.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-13 15:53:45 -0400 (Mon, 13 Jul 2009)
New Revision: 16553
Modified:
trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml
Log:
JBIDE-4602 - old outdated extension
Modified: trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml
===================================================================
--- trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml 2009-07-13 19:47:43 UTC (rev 16552)
+++ trunk/archives/plugins/org.jboss.ide.eclipse.archives.core/plugin.xml 2009-07-13 19:53:45 UTC (rev 16553)
@@ -24,13 +24,6 @@
</builder>
</extension>
<extension
- point="org.jboss.ide.eclipse.archives.core.archiveTypes">
- <packageType
- class="org.jboss.ide.eclipse.archives.core.model.types.WorkspaceJARArchiveType"
- id="jar"
- label="JAR"/>
- </extension>
- <extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.jboss.ide.eclipse.archives.core.model.other.internal.WorkspacePreferenceManager"/>
</extension>
16 years, 9 months
JBoss Tools SVN: r16552 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-13 15:47:43 -0400 (Mon, 13 Jul 2009)
New Revision: 16552
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
Log:
JBIDE-4606 - partial revert... no reason to save at all.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2009-07-13 19:37:42 UTC (rev 16551)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2009-07-13 19:47:43 UTC (rev 16552)
@@ -199,10 +199,6 @@
jbs.setDeployLocationType(isAS5() ? IDeployableServer.DEPLOY_SERVER : IDeployableServer.DEPLOY_METADATA);
serverWC.setRuntime((IRuntime)getTaskModel().getObject(TaskModel.TASK_RUNTIME));
serverWC.setServerConfiguration(null); // no inside jboss folder
-
- IServer saved = serverWC.save(false, new NullProgressMonitor());
- IServerWorkingCopy copy = saved.createWorkingCopy();
- getTaskModel().putObject(TaskModel.TASK_SERVER, copy);
}
private IJBossServerRuntime getRuntime() {
16 years, 9 months
JBoss Tools SVN: r16551 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-07-13 15:37:42 -0400 (Mon, 13 Jul 2009)
New Revision: 16551
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
Log:
JBIDE-4606 - small class cast exception my fault
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2009-07-13 18:49:56 UTC (rev 16550)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossServerWizardFragment.java 2009-07-13 19:37:42 UTC (rev 16551)
@@ -201,7 +201,8 @@
serverWC.setServerConfiguration(null); // no inside jboss folder
IServer saved = serverWC.save(false, new NullProgressMonitor());
- getTaskModel().putObject(TaskModel.TASK_SERVER, saved);
+ IServerWorkingCopy copy = saved.createWorkingCopy();
+ getTaskModel().putObject(TaskModel.TASK_SERVER, copy);
}
private IJBossServerRuntime getRuntime() {
16 years, 9 months
JBoss Tools SVN: r16550 - in trunk/maven/plugins: org.jboss.tools.maven.core/META-INF and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2009-07-13 14:49:56 -0400 (Mon, 13 Jul 2009)
New Revision: 16550
Added:
trunk/maven/plugins/org.jboss.tools.maven.core/poms/
trunk/maven/plugins/org.jboss.tools.maven.core/poms/jsf-template11.xml
trunk/maven/plugins/org.jboss.tools.maven.core/poms/jsf-template12.xml
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/PluginUpdater.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectFacetsFactoryTester.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperationConfig.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderUninstallOperation.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/AutoResizeTableLayout.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/DependencyEditingSupport.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/ExclusionEditingSupport.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/MavenUserLibraryProviderInstallPanel.java
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.core/build.properties
trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/project/facet/MavenFacetInstallDelegate.java
trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java
trunk/maven/plugins/org.jboss.tools.maven.ui/META-INF/MANIFEST.MF
trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Activator.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4565 Adding WTP 3.1 Maven Library Provider
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/META-INF/MANIFEST.MF 2009-07-13 18:49:56 UTC (rev 16550)
@@ -18,9 +18,13 @@
org.eclipse.jst.j2ee;visibility:=reexport,
org.eclipse.jst.j2ee.web;visibility:=reexport,
org.jboss.tools.common;visibility:=reexport,
- org.eclipse.jdt.launching;visibility:=reexport
+ org.eclipse.jdt.launching;visibility:=reexport,
+ org.eclipse.ui.workbench;visibility:=reexport,
+ org.maven.ide.components.maven_model_edit;visibility:=reexport,
+ org.eclipse.core.expressions
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
Export-Package: org.jboss.tools.maven.core,
- org.jboss.tools.maven.core.internal.project.facet
+ org.jboss.tools.maven.core.internal.project.facet,
+ org.jboss.tools.maven.core.libprov
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/build.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/build.properties 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/build.properties 2009-07-13 18:49:56 UTC (rev 16550)
@@ -2,4 +2,5 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- plugin.xml
+ plugin.xml,\
+ poms/
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml 2009-07-13 18:49:56 UTC (rev 16550)
@@ -35,4 +35,64 @@
</supported>
</extension>
+ <extension point="org.eclipse.jst.common.project.facet.core.libraryProviders">
+ <provider id="maven-library-provider" abstract="true">
+ <label>Maven library provider</label>
+ <priority>500</priority>
+ <action type="INSTALL">
+ <config class="org.jboss.tools.maven.core.libprov.MavenLibraryProviderInstallOperationConfig"/>
+ <operation class="org.jboss.tools.maven.core.libprov.MavenLibraryProviderInstallOperation"/>
+ </action>
+
+ <action type="UNINSTALL">
+ <operation class="org.jboss.tools.maven.core.libprov.MavenLibraryProviderUninstallOperation"/>
+ </action>
+
+ </provider>
+ </extension>
+
+ <extension point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ namespace="org.jboss.tools.maven.core"
+ properties="projectFacets"
+ type="java.util.Collection"
+ class="org.jboss.tools.maven.core.ProjectFacetsFactoryTester"
+ id="org.jboss.tools.maven.core.ProjectFacetsFactoryTester">
+ </propertyTester>
+ </extension>
+
+ <extension point="org.eclipse.jst.common.project.facet.core.libraryProviders">
+ <provider id="jsf12-maven-library-provider" extends="maven-library-provider">
+ <label>Maven JSF 1.2 Libraries</label>
+ <param name="template" value="platform:/plugin/org.jboss.tools.maven.core/poms/jsf-template12.xml"/>
+ <enablement>
+ <and>
+ <with variable="projectFacets">
+ <test property="org.jboss.tools.maven.core.projectFacets" value="jst.jsf,jboss.m2" forcePluginActivation="true"/>
+ </with>
+ <with variable="requestingProjectFacet">
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jst.jsf:1.2" forcePluginActivation="true"/>
+ </with>
+ </and>
+ </enablement>
+ </provider>
+ </extension>
+
+ <extension point="org.eclipse.jst.common.project.facet.core.libraryProviders">
+ <provider id="jsf11-maven-library-provider" extends="maven-library-provider">
+ <label>Maven JSF 1.1 Libraries</label>
+ <param name="template" value="platform:/plugin/org.jboss.tools.maven.core/poms/jsf-template11.xml"/>
+ <enablement>
+ <and>
+ <with variable="projectFacets">
+ <test property="org.jboss.tools.maven.core.projectFacets" value="jst.jsf,jboss.m2" forcePluginActivation="true"/>
+ </with>
+ <with variable="requestingProjectFacet">
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jst.jsf:1.1" forcePluginActivation="true"/>
+ </with>
+ </and>
+ </enablement>
+ </provider>
+ </extension>
+
</plugin>
Added: trunk/maven/plugins/org.jboss.tools.maven.core/poms/jsf-template11.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/poms/jsf-template11.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/poms/jsf-template11.xml 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,25 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>template</groupId>
+ <artifactId>template</artifactId>
+ <packaging>pom</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.1_02</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.1_02</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.core/poms/jsf-template12.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/poms/jsf-template12.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/poms/jsf-template12.xml 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,25 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>template</groupId>
+ <artifactId>template</artifactId>
+ <packaging>pom</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.2-b19</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2-b19</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -1,6 +1,9 @@
package org.jboss.tools.maven.core;
+import java.io.File;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -23,20 +26,31 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework;
+import org.maven.ide.components.pom.Dependency;
+import org.maven.ide.components.pom.PomFactory;
+import org.maven.ide.components.pom.PropertyElement;
+import org.maven.ide.components.pom.Repository;
+import org.maven.ide.components.pom.util.PomResourceFactoryImpl;
+import org.maven.ide.components.pom.util.PomResourceImpl;
import org.maven.ide.eclipse.MavenPlugin;
import org.maven.ide.eclipse.core.IMavenConstants;
+import org.maven.ide.eclipse.embedder.IMavenConfiguration;
import org.maven.ide.eclipse.embedder.MavenModelManager;
import org.maven.ide.eclipse.jdt.BuildPathManager;
import org.maven.ide.eclipse.project.IProjectConfigurationManager;
@@ -57,8 +71,14 @@
public static final String BASEDIR = "${basedir}"; //$NON-NLS-1$
+ public static final String ENCODING = "UTF-8"; //$NON-NLS-1$
+
+ public static final List<LibraryProviderOperationConfig> libraryProviderOperationConfigs = new ArrayList<LibraryProviderOperationConfig>();
+
// The shared instance
private static MavenCoreActivator plugin;
+
+ private static PomResourceImpl resource;
/**
* The constructor
@@ -268,9 +288,10 @@
resolverConfiguration.setActiveProfiles(""); //$NON-NLS-1$
IProjectConfigurationManager configurationManager = MavenPlugin
.getDefault().getProjectConfigurationManager();
+ IMavenConfiguration mavenConfiguration = MavenPlugin.lookup(IMavenConfiguration.class);
configurationManager.updateProjectConfiguration(project,
resolverConfiguration, //
- MavenPlugin.getDefault().getMavenRuntimeManager()
+ mavenConfiguration
.getGoalOnUpdate(), new NullProgressMonitor());
}
@@ -435,4 +456,189 @@
String sourceDirectory = root.getProjectRelativePath().toString();
return sourceDirectory;
}
+
+ public static void mergeModel(org.maven.ide.components.pom.Model projectModel, org.maven.ide.components.pom.Model libraryModel) {
+ addProperties(projectModel,libraryModel);
+ addRepositories(projectModel,libraryModel);
+ addPlugins(projectModel,libraryModel);
+ addDependencies(projectModel,libraryModel);
+ }
+
+ private static void addDependencies(org.maven.ide.components.pom.Model projectModel, org.maven.ide.components.pom.Model libraryModel) {
+ List<org.maven.ide.components.pom.Dependency> projectDependencies = projectModel.getDependencies();
+ List<org.maven.ide.components.pom.Dependency> libraryDependencies = libraryModel.getDependencies();
+ for (Dependency dependency:libraryDependencies) {
+ if (!dependencyExists(dependency,projectDependencies)) {
+ Dependency newDependency = (Dependency) EcoreUtil.copy(dependency);
+ projectDependencies.add(newDependency);
+ }
+ }
+
+ }
+
+ private static boolean dependencyExists(Dependency dependency,
+ List<Dependency> projectDependencies) {
+ String groupId = dependency.getGroupId();
+ String artifactId = dependency.getArtifactId();
+ if (artifactId == null) {
+ return false;
+ }
+ for (Dependency projectDependency:projectDependencies) {
+ String projectGroupId = projectDependency.getGroupId();
+ String projectArtifactId = projectDependency.getArtifactId();
+ if (!artifactId.equals(projectArtifactId)) {
+ return false;
+ }
+ if (groupId == null && projectGroupId == null) {
+ return true;
+ }
+ if (groupId != null && groupId.equals(projectGroupId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void addPlugins(org.maven.ide.components.pom.Model projectModel, org.maven.ide.components.pom.Model libraryModel) {
+ org.maven.ide.components.pom.Build libraryBuild = libraryModel.getBuild();
+ if (libraryBuild == null) {
+ return;
+ }
+ List<org.maven.ide.components.pom.Plugin> libraryPlugins = projectModel.getBuild().getPlugins();
+ for (org.maven.ide.components.pom.Plugin plugin:libraryPlugins) {
+ org.maven.ide.components.pom.Build projectBuild = projectModel.getBuild();
+ if (projectBuild == null) {
+ projectBuild = PomFactory.eINSTANCE.createBuild();
+ projectModel.setBuild(projectBuild);
+ }
+ List<org.maven.ide.components.pom.Plugin> projectPlugins = projectBuild.getPlugins();
+ if (!pluginExists(plugin,projectPlugins)) {
+ org.maven.ide.components.pom.Plugin newPlugin = (org.maven.ide.components.pom.Plugin) EcoreUtil.copy(plugin);
+ projectPlugins.add(newPlugin);
+ }
+ }
+ }
+
+ private static boolean pluginExists(org.maven.ide.components.pom.Plugin plugin, List<org.maven.ide.components.pom.Plugin> projectPlugins) {
+ String groupId = plugin.getGroupId();
+ String artifactId = plugin.getArtifactId();
+ if (artifactId == null) {
+ return false;
+ }
+ for (org.maven.ide.components.pom.Plugin projectPlugin:projectPlugins) {
+ String projectGroupId = projectPlugin.getGroupId();
+ String projectArtifactId = projectPlugin.getArtifactId();
+ if (!artifactId.equals(projectArtifactId)) {
+ return false;
+ }
+ if (groupId == null && projectGroupId == null) {
+ return true;
+ }
+ if (groupId != null && groupId.equals(projectGroupId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void addRepositories(org.maven.ide.components.pom.Model projectModel, org.maven.ide.components.pom.Model libraryModel) {
+ List<Repository> projectRepositories = projectModel.getRepositories();
+ List<Repository> libraryRepositories = libraryModel.getRepositories();
+ for (Repository repository:libraryRepositories) {
+ if (!repositoryExists(repository,projectRepositories)) {
+ Repository newRepository = (Repository) EcoreUtil.copy(repository);
+ projectRepositories.add(newRepository);
+ }
+ }
+ }
+
+ private static boolean repositoryExists(Repository repository,
+ List<Repository> projectRepositories) {
+ String url = repository.getUrl();
+ if (url == null) {
+ return false;
+ }
+ for(Repository projectRepository:projectRepositories) {
+ if (url.equals(projectRepository.getUrl())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void addProperties(org.maven.ide.components.pom.Model projectModel, org.maven.ide.components.pom.Model libraryModel) {
+ List<PropertyElement> projectProperties = projectModel.getProperties();
+ List<PropertyElement> libraryProperties = libraryModel.getProperties();
+ for (PropertyElement libraryProperty:libraryProperties) {
+ String propertyName = libraryProperty.getName();
+ if (!propertyExists(propertyName,projectProperties)) {
+ PropertyElement newProperty = (PropertyElement) EcoreUtil.copy(libraryProperty);
+ projectProperties.add(newProperty);
+ }
+ }
+ }
+
+ private static boolean propertyExists(String propertyName,
+ List<PropertyElement> projectProperties) {
+ if (propertyName == null) {
+ return false;
+ }
+ for (PropertyElement propertyElement:projectProperties) {
+ if (propertyName.equals(propertyElement.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static void log(Throwable e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e.getLocalizedMessage(), e);
+ getDefault().getLog().log(status);
+ }
+
+ public static void log(String message) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message);
+ getDefault().getLog().log(status);
+ }
+
+ public static File getProviderFile(ILibraryProvider provider) {
+ String id = provider.getId();
+ IPath providerDir = MavenCoreActivator.getDefault().getStateLocation().append(id);
+ File providerDirFile = providerDir.toFile();
+ providerDirFile.mkdir();
+ File providerFile = new File(providerDirFile, "template.xml"); //$NON-NLS-1$
+ return providerFile;
+ }
+
+ public static PomResourceImpl loadResource(URL url) throws CoreException {
+ try {
+ URI uri = URI.createURI(url.toString());
+ org.eclipse.emf.ecore.resource.Resource resource = new PomResourceFactoryImpl()
+ .createResource(uri);
+ resource.load(Collections.EMPTY_MAP);
+ return (PomResourceImpl) resource;
+
+ } catch (Exception ex) {
+ log(ex);
+ throw new CoreException(new Status(IStatus.ERROR,
+ PLUGIN_ID, -1, ex.getMessage(), ex));
+ }
+ }
+
+ public static void addLibraryProviderOperationConfig(
+ LibraryProviderOperationConfig config) {
+ libraryProviderOperationConfigs.add(config);
+ }
+
+ public static List<LibraryProviderOperationConfig> getLibraryProviderOperationConfigs() {
+ return libraryProviderOperationConfigs;
+ }
+
+ public static PomResourceImpl getResource() {
+ return resource;
+ }
+
+ public static void setResource(PomResourceImpl resource2) {
+ resource = resource2;
+ }
}
Added: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/PluginUpdater.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/PluginUpdater.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/PluginUpdater.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,32 @@
+package org.jboss.tools.maven.core;
+
+
+import org.apache.maven.model.Plugin;
+import org.maven.ide.components.pom.Build;
+import org.maven.ide.components.pom.Model;
+import org.maven.ide.components.pom.PomFactory;
+import org.maven.ide.eclipse.embedder.ProjectUpdater;
+
+public class PluginUpdater extends ProjectUpdater {
+
+ private static final PomFactory POM_FACTORY = PomFactory.eINSTANCE;
+ private Plugin plugin;
+
+ public PluginUpdater(Plugin plugin) {
+ this.plugin = plugin;
+ }
+
+ public void update(Model model) {
+ Build build = model.getBuild();
+ if(build==null) {
+ build = POM_FACTORY.createBuild();
+ model.setBuild(build);
+ }
+ org.maven.ide.components.pom.Plugin newPlugin = POM_FACTORY.createPlugin();
+ newPlugin.setArtifactId(plugin.getArtifactId());
+ newPlugin.setGroupId(plugin.getGroupId());
+ newPlugin.setVersion(plugin.getVersion());
+ newPlugin.setExtensions(plugin.getExtensions());
+ // FIXME
+ }
+ }
Added: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectFacetsFactoryTester.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectFacetsFactoryTester.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/ProjectFacetsFactoryTester.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,44 @@
+package org.jboss.tools.maven.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.wst.common.project.facet.core.internal.ProjectFacetVersion;
+
+public class ProjectFacetsFactoryTester extends PropertyTester {
+
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue) {
+
+ if (! (receiver instanceof Collection)) {
+ return false;
+ }
+ if (! (expectedValue instanceof String)) {
+ return false;
+ }
+ String requiredFacets = (String) expectedValue;
+ Collection collection = (Collection) receiver;
+ List<String> facets = new ArrayList<String>();
+ for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
+ Object object = iterator.next();
+ if ( ! (object instanceof ProjectFacetVersion)) {
+ return false;
+ }
+ ProjectFacetVersion projectFacetVersion = (ProjectFacetVersion) object;
+ facets.add(projectFacetVersion.getProjectFacet().getId());
+ }
+ StringTokenizer tokenizer = new StringTokenizer(requiredFacets,",");
+ while (tokenizer.hasMoreTokens()) {
+ String requiredFacet = tokenizer.nextToken().trim();
+ if (!facets.contains(requiredFacet)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/project/facet/MavenFacetInstallDelegate.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/project/facet/MavenFacetInstallDelegate.java 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/internal/project/facet/MavenFacetInstallDelegate.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil;
import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants;
import org.eclipse.jst.j2ee.project.facet.IJ2EEFacetConstants;
@@ -26,6 +27,8 @@
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.jboss.tools.maven.core.MavenCoreActivator;
import org.jboss.tools.maven.core.IJBossMavenConstants;
+import org.jboss.tools.maven.core.libprov.MavenLibraryProviderInstallOperation;
+import org.jboss.tools.maven.core.libprov.MavenLibraryProviderInstallOperationConfig;
import org.maven.ide.eclipse.MavenPlugin;
import org.maven.ide.eclipse.core.IMavenConstants;
import org.maven.ide.eclipse.embedder.MavenModelManager;
@@ -106,6 +109,15 @@
if (!hasMavenNature) {
MavenCoreActivator.updateMavenProjectConfiguration(project);
}
+
+ List<LibraryProviderOperationConfig> configs = MavenCoreActivator.getLibraryProviderOperationConfigs();
+ if (configs.size() > 0) {
+ MavenLibraryProviderInstallOperation operation = new MavenLibraryProviderInstallOperation();
+ for (LibraryProviderOperationConfig libraryProviderOperationConfig:configs) {
+ operation.execute(libraryProviderOperationConfig, monitor);
+ }
+ }
+ configs.clear();
}
}
Added: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,106 @@
+package org.jboss.tools.maven.core.libprov;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperation;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase;
+import org.jboss.tools.maven.core.MavenCoreActivator;
+import org.maven.ide.components.pom.Model;
+import org.maven.ide.components.pom.util.PomResourceImpl;
+import org.maven.ide.eclipse.MavenPlugin;
+import org.maven.ide.eclipse.core.IMavenConstants;
+import org.maven.ide.eclipse.embedder.MavenModelManager;
+
+public class MavenLibraryProviderInstallOperation extends
+ LibraryProviderOperation {
+
+ @Override
+ public void execute(LibraryProviderOperationConfig config,
+ IProgressMonitor monitor) throws CoreException {
+ IFacetedProjectBase facetedProject = config.getFacetedProject();
+ IProject project = facetedProject.getProject();
+ IFile pom = project.getFile(IMavenConstants.POM_FILE_NAME);
+ MavenLibraryProviderInstallOperationConfig mavenConfig = (MavenLibraryProviderInstallOperationConfig) config;
+ if (pom.exists()) {
+ // JBoss Maven Integration facet has been executed
+ MavenModelManager modelManager = MavenPlugin.getDefault().getMavenModelManager();
+ PomResourceImpl resource = modelManager.loadResource(pom);
+ Model projectModel = resource.getModel();
+ Model libraryModel = mavenConfig.getModel();
+ MavenCoreActivator.mergeModel(projectModel, libraryModel);
+ try {
+ Map<String,String> options = new HashMap<String,String>();
+ options.put(XMIResource.OPTION_ENCODING, MavenCoreActivator.ENCODING);
+ resource.save(options);
+ } catch (IOException e) {
+ MavenCoreActivator.log(e);
+ } finally {
+ resource.unload();
+ }
+ ILibraryProvider provider = config.getLibraryProvider();
+ File providerFile = MavenCoreActivator.getProviderFile(provider);
+ URL url = null;
+ PomResourceImpl libraryResource = null;
+ URIConverter.WriteableOutputStream uws = null;
+ FileWriter fw = null;
+ try {
+ if (providerFile.exists()) {
+ url = providerFile.toURL();
+ } else {
+ Map<String, String> params = provider.getParams();
+ String pomURLString = params.get("template"); //$NON-NLS-1$
+ URL platformURL = new URL(pomURLString);
+ url = FileLocator.resolve(platformURL);
+ }
+ libraryResource = MavenCoreActivator.loadResource(url);
+ libraryResource.getContents().clear();
+ libraryResource.getContents().add(libraryModel);
+
+ Map<String, String> options = new HashMap<String, String>();
+ options.put(XMIResource.OPTION_ENCODING,
+ MavenCoreActivator.ENCODING);
+ fw = new FileWriter(providerFile);
+ uws = new URIConverter.WriteableOutputStream(
+ fw, MavenCoreActivator.ENCODING);
+ libraryResource.save(uws, options);
+ } catch (IOException e) {
+ MavenCoreActivator.log(e);
+ } finally {
+ if (uws != null) {
+ try {
+ uws.flush();
+ uws.close();
+ } catch (IOException ignore) {}
+ }
+ if (fw != null) {
+ try {
+ fw.close();
+ } catch (IOException ignore) {}
+ }
+ if (libraryResource != null) {
+ libraryResource.unload();
+ }
+ }
+
+ } else {
+ MavenCoreActivator.addLibraryProviderOperationConfig(config);
+ }
+
+ }
+
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperationConfig.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperationConfig.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperationConfig.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,21 @@
+package org.jboss.tools.maven.core.libprov;
+
+import org.eclipse.emf.ecore.resource.URIConverter.WriteableOutputStream;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderInstallOperationConfig;
+import org.maven.ide.components.pom.Model;
+import org.maven.ide.components.pom.util.PomResourceImpl;
+
+public class MavenLibraryProviderInstallOperationConfig extends
+ LibraryProviderInstallOperationConfig {
+
+ private Model model;
+
+ public void setModel(Model model) {
+ this.model = model;
+ }
+
+ public Model getModel() {
+ return model;
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderUninstallOperation.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderUninstallOperation.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderUninstallOperation.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,18 @@
+package org.jboss.tools.maven.core.libprov;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperation;
+import org.eclipse.jst.common.project.facet.core.libprov.LibraryProviderOperationConfig;
+
+public class MavenLibraryProviderUninstallOperation extends LibraryProviderOperation {
+
+ @Override
+ public void execute(LibraryProviderOperationConfig config,
+ IProgressMonitor monitor) throws CoreException {
+ // TODO Auto-generated method stub
+
+
+ }
+
+}
Modified: trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.seam/src/org/jboss/tools/maven/seam/MavenSeamActivator.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -2,6 +2,7 @@
import java.io.BufferedReader;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
@@ -733,12 +734,12 @@
private void configureParentProject(IDataModel m2FacetModel, IDataModel seamFacetModel) {
Bundle bundle = getDefault().getBundle();
URL parentPomEntryURL = bundle.getEntry("/poms/parent-pom.xml");
- Reader reader = null;
+ InputStream inputStream = null;
try {
URL resolvedURL = FileLocator.resolve(parentPomEntryURL);
MavenModelManager modelManager = MavenPlugin.getDefault().getMavenModelManager();
- reader = new BufferedReader(new InputStreamReader(resolvedURL.openStream()));
- Model model = modelManager.readMavenModel(reader);
+ inputStream = resolvedURL.openStream();
+ Model model = modelManager.readMavenModel(inputStream);
model.setArtifactId(parentArtifactId);
model.setGroupId(m2FacetModel.getStringProperty(IJBossMavenConstants.GROUP_ID));
String projectVersion = m2FacetModel.getStringProperty(IJBossMavenConstants.VERSION);
@@ -777,9 +778,9 @@
} catch (Exception e) {
log(e);
} finally {
- if (reader != null) {
+ if (inputStream != null) {
try {
- reader.close();
+ inputStream.close();
} catch (IOException ignore) {}
}
}
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/META-INF/MANIFEST.MF 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/META-INF/MANIFEST.MF 2009-07-13 18:49:56 UTC (rev 16550)
@@ -7,6 +7,7 @@
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.jst.common.project.facet.ui,
org.eclipse.wst.common.frameworks.ui,
org.eclipse.core.resources,
org.jboss.tools.maven.core
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/plugin.xml 2009-07-13 18:49:56 UTC (rev 16550)
@@ -9,4 +9,9 @@
</wizard-pages>
</extension>
+ <extension point="org.eclipse.jst.common.project.facet.ui.libraryProviderActionPanels">
+ <panel
+ provider="maven-library-provider"
+ class="org.jboss.tools.maven.ui.internal.libprov.MavenUserLibraryProviderInstallPanel"/>
+ </extension>
</plugin>
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Activator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Activator.java 2009-07-13 16:38:18 UTC (rev 16549)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/Activator.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -1,6 +1,16 @@
package org.jboss.tools.maven.ui;
+import java.net.URL;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.maven.ide.components.pom.util.PomResourceFactoryImpl;
+import org.maven.ide.components.pom.util.PomResourceImpl;
import org.osgi.framework.BundleContext;
/**
@@ -46,5 +56,15 @@
public static Activator getDefault() {
return plugin;
}
+
+ public static void log(Throwable e) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, e.getLocalizedMessage(), e);
+ getDefault().getLog().log(status);
+ }
+ public static void log(String message) {
+ IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, message);
+ getDefault().getLog().log(status);
+ }
+
}
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/AutoResizeTableLayout.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/AutoResizeTableLayout.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/AutoResizeTableLayout.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.tools.maven.ui.internal.libprov;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class AutoResizeTableLayout extends TableLayout implements
+ ControlListener {
+
+ private final Table table;
+ private List<ColumnLayoutData> columns = new ArrayList<ColumnLayoutData>();
+ private boolean autosizing = false;
+
+ public AutoResizeTableLayout(Table table) {
+ this.table = table;
+ table.addControlListener(this);
+ }
+
+ public void addColumnData(ColumnLayoutData data) {
+ columns.add(data);
+ super.addColumnData(data);
+ }
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ if (autosizing) {
+ return;
+ }
+ autosizing = true;
+ try {
+ autoSizeColumns();
+ } finally {
+ autosizing = false;
+ }
+ }
+
+ private void autoSizeColumns() {
+ int width = table.getClientArea().width;
+ if (width <= 1) {
+ return;
+ }
+
+ TableColumn[] tableColumns = table.getColumns();
+ int size =
+ Math.min(columns.size(), tableColumns.length);
+ int[] widths = new int[size];
+ int fixedWidth = 0;
+ int numberOfWeightColumns = 0;
+ int totalWeight = 0;
+
+ // First calc space occupied by fixed columns.
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnPixelData) {
+ int pixels = ((ColumnPixelData)col).width;
+ widths[i] = pixels;
+ fixedWidth += pixels;
+ } else if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ numberOfWeightColumns++;
+ int weight = cw.weight;
+ totalWeight += weight;
+ } else {
+ throw new IllegalStateException("Unknown column layout data");
+ }
+ }
+
+ // Do we have columns that have a weight?
+ if (numberOfWeightColumns > 0) {
+ // Now, distribute the rest
+ // to the columns with weight.
+ int rest = width - fixedWidth;
+ int totalDistributed = 0;
+ for (int i = 0; i < size; i++) {
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ColumnWeightData cw = (ColumnWeightData)col;
+ int weight = cw.weight;
+ int pixels = totalWeight == 0 ? 0 : weight * rest / totalWeight;
+ totalDistributed += pixels;
+ widths[i] = pixels;
+ }
+ }
+
+ // Distribute any remaining pixels
+ // to columns with weight.
+ int diff = rest - totalDistributed;
+ for (int i = 0; diff > 0; i++) {
+ if (i == size) {
+ i = 0;
+ }
+ ColumnLayoutData col = (ColumnLayoutData)columns.get(i);
+ if (col instanceof ColumnWeightData) {
+ ++widths[i];
+ --diff;
+ }
+ }
+ }
+
+ for (int i = 0; i < size; i++) {
+ if (tableColumns[i].getWidth() != widths[i]) {
+ tableColumns[i].setWidth(widths[i]);
+ }
+
+ }
+
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/DependencyEditingSupport.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/DependencyEditingSupport.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/DependencyEditingSupport.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,139 @@
+package org.jboss.tools.maven.ui.internal.libprov;
+
+import org.maven.ide.components.pom.Dependency;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+
+public class DependencyEditingSupport extends EditingSupport {
+
+ private static String[] scopes = {"","provided", "compile", "test", "runtime", "system","import"};
+ private static String[] types = {"","jar","war","rar","ear","par","ejb","ejb3","ejb-client","test-jar","java-source","javadoc","maven-plugin","pom"};
+
+ private CellEditor editor;
+ private int column;
+
+ public DependencyEditingSupport(ColumnViewer viewer, int column) {
+ super(viewer);
+ switch (column) {
+ case 3:
+ editor = new ComboBoxCellEditor(((TableViewer) viewer).getTable(),
+ scopes);
+ break;
+ case 4:
+ editor = new ComboBoxCellEditor(((TableViewer) viewer).getTable(),
+ types);
+ break;
+ default:
+ editor = new TextCellEditor(((TableViewer) viewer).getTable());
+ }
+
+
+ this.column = column;
+ }
+
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return editor;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ Dependency dependency = (Dependency) element;
+ String value = null;
+ switch (this.column) {
+ case 0:
+ value = dependency.getGroupId();
+ if (value == null) {
+ value = "";
+ }
+ return value;
+ case 1:
+ value = dependency.getArtifactId();
+ if (value == null) {
+ value = "";
+ }
+ return value;
+ case 2:
+ value = dependency.getVersion();
+ if (value == null) {
+ value = "";
+ }
+ return value;
+ case 3:
+ for (int i = 0; i < scopes.length; i++) {
+ if (scopes[i].equals(dependency.getScope())) {
+ return i;
+ }
+ }
+ return 0;
+ case 4:
+ for (int i = 0; i < types.length; i++) {
+ if (types[i].equals(dependency.getType())) {
+ return i;
+ }
+ }
+ return 0;
+ default:
+ break;
+ }
+ return null;
+
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ Dependency dependency = (Dependency) element;
+
+ String valueString = null;
+ int intValue = 0;
+ if (column < 3) {
+ if (value == null) {
+ valueString = null;
+ } else {
+ valueString = value.toString();
+ }
+ } else {
+ intValue = (Integer)value;
+ }
+ switch (this.column) {
+ case 0:
+ dependency.setGroupId(valueString);
+ break;
+ case 1:
+ dependency.setArtifactId(valueString);
+ break;
+ case 2:
+ dependency.setVersion(valueString);
+ break;
+ case 3:
+ if (intValue > scopes.length) {
+ intValue = 0;
+ }
+ dependency.setScope(scopes[intValue]);
+ break;
+ case 4:
+ if (intValue > types.length) {
+ intValue = 0;
+ }
+ dependency.setType(types[intValue]);
+ break;
+
+ default:
+ break;
+ }
+
+ getViewer().update(element, null);
+
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/ExclusionEditingSupport.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/ExclusionEditingSupport.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/ExclusionEditingSupport.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,76 @@
+package org.jboss.tools.maven.ui.internal.libprov;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.maven.ide.components.pom.Exclusion;
+
+public class ExclusionEditingSupport extends EditingSupport {
+
+ private CellEditor editor;
+ private int column;
+
+ public ExclusionEditingSupport(ColumnViewer viewer, int column) {
+ super(viewer);
+ editor = new TextCellEditor(((TableViewer) viewer).getTable());
+ this.column = column;
+ }
+
+ @Override
+ protected boolean canEdit(Object element) {
+ return true;
+ }
+
+ @Override
+ protected CellEditor getCellEditor(Object element) {
+ return editor;
+ }
+
+ @Override
+ protected Object getValue(Object element) {
+ Exclusion exclusion = (Exclusion) element;
+ String value = null;
+ switch (this.column) {
+ case 0:
+ value = exclusion.getGroupId();
+ if (value == null) {
+ value = "";
+ }
+ return value;
+ case 1:
+ value = exclusion.getArtifactId();
+ if (value == null) {
+ value = "";
+ }
+ return value;
+ }
+ return null;
+ }
+
+ @Override
+ protected void setValue(Object element, Object value) {
+ Exclusion exclusion = (Exclusion) element;
+
+ String valueString = null;
+ if (value == null) {
+ valueString = null;
+ } else {
+ valueString = value.toString();
+ }
+ switch (this.column) {
+ case 0:
+ exclusion.setGroupId(valueString);
+ break;
+ case 1:
+ exclusion.setArtifactId(valueString);
+ break;
+ default:
+ break;
+ }
+ getViewer().update(element, null);
+
+ }
+
+}
Added: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/MavenUserLibraryProviderInstallPanel.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/MavenUserLibraryProviderInstallPanel.java (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/MavenUserLibraryProviderInstallPanel.java 2009-07-13 18:49:56 UTC (rev 16550)
@@ -0,0 +1,497 @@
+package org.jboss.tools.maven.ui.internal.libprov;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
+import org.eclipse.jst.common.project.facet.ui.libprov.LibraryProviderOperationPanel;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+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.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.jboss.tools.maven.core.MavenCoreActivator;
+import org.jboss.tools.maven.core.libprov.MavenLibraryProviderInstallOperationConfig;
+import org.maven.ide.components.pom.Dependency;
+import org.maven.ide.components.pom.Exclusion;
+import org.maven.ide.components.pom.Model;
+import org.maven.ide.components.pom.PomFactory;
+import org.maven.ide.components.pom.util.PomResourceImpl;
+
+public class MavenUserLibraryProviderInstallPanel extends
+ LibraryProviderOperationPanel {
+
+ private TableViewer dependencyViewer;
+ protected ColumnLayoutData[] dependencyTableColumnLayouts= {
+ new ColumnWeightData(80,80),
+ new ColumnWeightData(80,80),
+ new ColumnWeightData(60,60),
+ new ColumnWeightData(60,60),
+ new ColumnWeightData(60,60)
+ };
+ protected ColumnLayoutData[] exclusionTableColumnLayouts= {
+ new ColumnWeightData(80,80),
+ new ColumnWeightData(60,60)
+ };
+ private List<Dependency> dependencies;
+ private TableViewer exclusionViewer;
+ private List exclusions;
+ private PomResourceImpl resource;
+
+ @Override
+ public Control createControl(final Composite parent) {
+ resource = MavenCoreActivator.getResource();
+ if (resource != null) {
+ resource.unload();
+ MavenCoreActivator.setResource(null);
+ }
+ MavenLibraryProviderInstallOperationConfig config = (MavenLibraryProviderInstallOperationConfig) getOperationConfig();
+ ILibraryProvider provider = config.getLibraryProvider();
+ File providerFile = MavenCoreActivator.getProviderFile(provider);
+ URL url = null;
+ try {
+ if (providerFile.exists()) {
+ url = providerFile.toURL();
+ } else {
+ Map<String, String> params = provider.getParams();
+ String pomURLString = params.get("template"); //$NON-NLS-1$
+ URL platformURL = new URL(pomURLString);
+ url = FileLocator.resolve(platformURL);
+ }
+
+ resource = MavenCoreActivator.loadResource(url);
+ MavenCoreActivator.setResource(resource);
+ Model model = resource.getModel();
+ dependencies = model.getDependencies();
+ config.setModel(model);
+ parent.addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ parent.removeDisposeListener(this);
+ resource.unload();
+ MavenCoreActivator.setResource(null);
+ }
+ });
+ } catch (CoreException e) {
+ MavenCoreActivator.log(e);
+ } catch (IOException e) {
+ MavenCoreActivator.log(e);
+ }
+
+ if (dependencies == null) {
+ dependencies = new ArrayList<Dependency>();
+ }
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Label dependencyLabel = new Label(composite, SWT.NONE);
+ dependencyLabel.setText("Dependencies:");
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan=2;
+ dependencyLabel.setLayoutData(gd);
+
+ createDependencyViewer(composite);
+ dependencyViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = event.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ if (object instanceof Dependency) {
+ Dependency dependency = (Dependency) object;
+ exclusions = dependency.getExclusions();
+ exclusionViewer.setInput(exclusions);
+ }
+ }
+ }
+ });
+
+ Label exclusionLabel = new Label(composite, SWT.NONE);
+ exclusionLabel.setText("Exclusions:");
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan=2;
+ exclusionLabel.setLayoutData(gd);
+
+ createExclusionViewer(composite);
+
+ if (dependencies.size() > 0) {
+ dependencyViewer.getTable().select(0);
+ exclusions = dependencies.get(0).getExclusions();
+ exclusionViewer.setInput(exclusions);
+ }
+ return composite;
+ }
+
+ private void createExclusionViewer(Composite parent) {
+ exclusionViewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 60;
+ exclusionViewer.getTable().setLayoutData(gd);
+ //viewer.setLabelProvider(new TableLabelProvider());
+ exclusionViewer.setContentProvider(new TableContentProvider());
+ Table table = exclusionViewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.setFont(parent.getFont());
+
+ String[] columnHeaders = {"GroupId","ArtifactId"};
+
+ for (int i = 0; i < columnHeaders.length; i++) {
+ TableViewerColumn column = new TableViewerColumn(exclusionViewer, SWT.NONE);
+ column.setLabelProvider(new ExclusionColumnLabelProvider(i));
+ column.getColumn().setText(columnHeaders[i]);
+ column.getColumn().setResizable(true);
+ column.getColumn().setMoveable(true);
+ column.setEditingSupport(new ExclusionEditingSupport(exclusionViewer, i));
+
+ }
+
+
+ TableLayout layout = new AutoResizeTableLayout(table);
+ for (int i = 0; i < exclusionTableColumnLayouts.length; i++) {
+ layout.addColumnData(exclusionTableColumnLayouts[i]);
+ }
+ exclusionViewer.getTable().setLayout(layout);
+
+ createExclusionButtons(parent);
+
+ }
+
+ private void createDependencyViewer(Composite parent) {
+ dependencyViewer = new TableViewer(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
+ | SWT.V_SCROLL | SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 80;
+ dependencyViewer.getTable().setLayoutData(gd);
+ //viewer.setLabelProvider(new TableLabelProvider());
+ dependencyViewer.setContentProvider(new TableContentProvider());
+ Table table = dependencyViewer.getTable();
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.setFont(parent.getFont());
+
+ String[] columnHeaders = {"GroupId","ArtifactId","Version","Scope","Type"};
+
+ for (int i = 0; i < columnHeaders.length; i++) {
+ TableViewerColumn column = new TableViewerColumn(dependencyViewer, SWT.NONE);
+ column.setLabelProvider(new DependencyColumnLabelProvider(i));
+ column.getColumn().setText(columnHeaders[i]);
+ column.getColumn().setResizable(true);
+ column.getColumn().setMoveable(true);
+ column.setEditingSupport(new DependencyEditingSupport(dependencyViewer, i));
+
+ }
+
+
+ TableLayout layout = new AutoResizeTableLayout(table);
+ for (int i = 0; i < dependencyTableColumnLayouts.length; i++) {
+ layout.addColumnData(dependencyTableColumnLayouts[i]);
+ }
+
+ dependencyViewer.getTable().setLayout(layout);
+ dependencyViewer.setInput(dependencies);
+ createDependencyButtons(parent);
+ }
+
+ private void createDependencyButtons(Composite parent) {
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ buttonComposite.setLayout(new GridLayout(1,false));
+ buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
+
+ Button addButton = new Button(buttonComposite, SWT.PUSH);
+ addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ addButton.setText("Add");
+ addButton.addSelectionListener(new SelectionListener(){
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ Dependency dependency = PomFactory.eINSTANCE.createDependency();
+ dependency.setGroupId("?");
+ dependency.setArtifactId("?");
+ dependencies.add(dependency);
+ dependencyViewer.refresh();
+ }
+
+ });
+
+ final Button removeButton = new Button(buttonComposite, SWT.PUSH);
+ removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeButton.setText("Remove");
+ removeButton.setEnabled(false);
+
+ removeButton.addSelectionListener(new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ ISelection sel = dependencyViewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ if (object instanceof Dependency) {
+ Dependency dependency = (Dependency) object;
+ boolean ok = MessageDialog.openQuestion(getShell(), "Remove dependency", "Are you sure you want to remove the '" + dependency.getGroupId() + ":" + dependency.getArtifactId() + "' artifact?");
+ if (ok) {
+ dependencies.remove(object);
+ dependencyViewer.refresh();
+ }
+ }
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ final Button restoreDefaults = new Button(buttonComposite, SWT.PUSH);
+ restoreDefaults.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ restoreDefaults.setText("Restore Defaults");
+
+ restoreDefaults.addSelectionListener(new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ resource.unload();
+ MavenLibraryProviderInstallOperationConfig config = (MavenLibraryProviderInstallOperationConfig) getOperationConfig();
+ ILibraryProvider provider = config.getLibraryProvider();
+ Map<String, String> params = provider.getParams();
+ String pomURLString = params.get("template"); //$NON-NLS-1$
+ try {
+ URL platformURL = new URL(pomURLString);
+ URL url = FileLocator.resolve(platformURL);
+ resource = MavenCoreActivator.loadResource(url);
+ Model model = resource.getModel();
+ dependencies = model.getDependencies();
+ dependencyViewer.setInput(dependencies);
+ config.setModel(model);
+ dependencyViewer.refresh();
+ if (dependencies.size() > 0) {
+ dependencyViewer.getTable().select(0);
+ exclusions = dependencies.get(0).getExclusions();
+ } else {
+ exclusions = null;
+ }
+ exclusionViewer.setInput(exclusions);
+ exclusionViewer.refresh();
+ } catch (MalformedURLException e1) {
+ MavenCoreActivator.log(e1);
+ } catch (IOException e1) {
+ MavenCoreActivator.log(e1);
+ } catch (CoreException e1) {
+ MavenCoreActivator.log(e1);
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+
+ dependencyViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = dependencyViewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ removeButton.setEnabled(object instanceof Dependency);
+ } else {
+ removeButton.setEnabled(false);
+ }
+ }
+ });
+ }
+
+ protected Shell getShell() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ private void createExclusionButtons(Composite parent) {
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ buttonComposite.setLayout(new GridLayout(1,false));
+ buttonComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
+
+ Button addButton = new Button(buttonComposite, SWT.PUSH);
+ addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ addButton.setText("Add");
+ addButton.addSelectionListener(new SelectionListener(){
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ Exclusion exclusion = PomFactory.eINSTANCE.createExclusion();
+ exclusion.setGroupId("?");
+ exclusion.setArtifactId("?");
+ if (exclusions == null) {
+ ISelection sel = dependencyViewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ if (object instanceof Dependency) {
+ exclusions = ((Dependency) object).getExclusions();
+ exclusionViewer.setInput(exclusions);
+ }
+ }
+ }
+ if (exclusions != null) {
+ exclusions.add(exclusion);
+ }
+ exclusionViewer.refresh();
+ }
+
+ });
+
+ final Button removeButton = new Button(buttonComposite, SWT.PUSH);
+ removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeButton.setText("Remove");
+ removeButton.setEnabled(false);
+
+ removeButton.addSelectionListener(new SelectionListener(){
+
+ public void widgetSelected(SelectionEvent e) {
+ ISelection sel = exclusionViewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ if (object instanceof Exclusion) {
+ Exclusion exclusion = (Exclusion) object;
+ boolean ok = MessageDialog.openQuestion(getShell(), "Remove exclusion", "Are you sure you want to remove the '" + exclusion.getGroupId() + ":" + exclusion.getArtifactId() + "' artifact?");
+ if (ok && exclusions != null) {
+ exclusions.remove(object);
+ }
+ }
+ exclusionViewer.refresh();
+ }
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+ });
+ exclusionViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = exclusionViewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Object object = selection.getFirstElement();
+ removeButton.setEnabled(object instanceof Exclusion);
+ } else {
+ removeButton.setEnabled(false);
+ }
+ }
+ });
+ }
+
+ private static class TableContentProvider implements
+ IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof Object[]) {
+ return (Object[]) inputElement;
+ }
+ if (inputElement instanceof Collection) {
+ return ((Collection) inputElement).toArray();
+ }
+ return new Object[0];
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+ }
+
+ private static class DependencyColumnLabelProvider extends ColumnLabelProvider {
+
+ private int columnIndex;
+
+ public DependencyColumnLabelProvider(int columnIndex) {
+ this.columnIndex = columnIndex;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof Dependency) {
+ Dependency dependency = (Dependency) element;
+ switch (columnIndex) {
+ case 0:
+ return dependency.getGroupId();
+ case 1:
+ return dependency.getArtifactId();
+ case 2:
+ return dependency.getVersion();
+ case 3:
+ return dependency.getScope();
+ case 4:
+ return dependency.getType();
+ }
+ }
+ return null;
+ }
+ }
+
+ private static class ExclusionColumnLabelProvider extends ColumnLabelProvider {
+
+ private int columnIndex;
+
+ public ExclusionColumnLabelProvider(int columnIndex) {
+ this.columnIndex = columnIndex;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof Exclusion) {
+ Exclusion exclusion = (Exclusion) element;
+ switch (columnIndex) {
+ case 0:
+ return exclusion.getGroupId();
+ case 1:
+ return exclusion.getArtifactId();
+ }
+ }
+ return null;
+ }
+ }
+}
16 years, 9 months
JBoss Tools SVN: r16549 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-13 12:38:18 -0400 (Mon, 13 Jul 2009)
New Revision: 16549
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1826
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java 2009-07-13 16:33:13 UTC (rev 16548)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/DialogCellEditorEx.java 2009-07-13 16:38:18 UTC (rev 16549)
@@ -271,7 +271,7 @@
}
}
- CPL2 popup = new CPL2();
+ protected CPL2 popup = new CPL2();
class CPL2 implements IContentProposalListener2 {
boolean isPopupOpened = false;
16 years, 9 months
JBoss Tools SVN: r16548 - in trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp: outline and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2009-07-13 12:33:13 -0400 (Mon, 13 Jul 2009)
New Revision: 16548
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1826
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-07-13 15:09:33 UTC (rev 16547)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-07-13 16:33:13 UTC (rev 16548)
@@ -726,7 +726,7 @@
}
}
- protected static class TextRegion {
+ public static class TextRegion {
private int startOffset;
private int offset;
private int length;
Added: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java (rev 0)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java 2009-07-13 16:33:13 UTC (rev 16548)
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ * 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.jst.jsp.contentassist;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IContentProposalProvider;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELUtil;
+import org.jboss.tools.common.el.core.parser.ELParser;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
+import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
+import org.jboss.tools.common.model.ui.ModelUIPlugin;
+import org.jboss.tools.common.text.TextProposal;
+import org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
+import org.jboss.tools.jst.web.kb.IPageContext;
+import org.jboss.tools.jst.web.kb.KbQuery;
+import org.jboss.tools.jst.web.kb.PageProcessor;
+import org.jboss.tools.jst.web.kb.KbQuery.Type;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class JSPDialogContentProposalProvider implements IContentProposalProvider {
+ Properties context;
+ String attributeName;
+ String nodeName;
+ int offset = 0;
+ JSPDialogContentAssistProcessor processor;
+ IPageContext pageContext = null;
+
+ public JSPDialogContentProposalProvider() {}
+
+ public void setContext(Properties context) {
+ this.context = context;
+ attributeName = Constants.EMPTY + context.getProperty("attributeName");
+ nodeName = Constants.EMPTY + context.getProperty("nodeName");
+ Node node = (Node)context.get("node");
+ if (node instanceof IDOMElement) {
+ offset = ((IDOMElement)node).getStartEndOffset(); //approximation, attribute may be not defined
+ }
+ processor = new JSPDialogContentAssistProcessor();
+ processor.computeCompletionProposals(getTextViewer(), offset);
+ pageContext = processor.getContext();
+ }
+
+ public IContentProposal[] getProposals(String contents, int position) {
+ List<IContentProposal> result = new ArrayList<IContentProposal>();
+ TextRegion prefix = getELPrefix(contents, position);
+ if (prefix == null || !prefix.isELStarted()) {
+ IContentProposal proposal = new ContentProposal("#{}", 0, "#{}", "New EL Expression");
+ result.add(proposal);
+ return result.toArray(new IContentProposal[0]);
+ }
+ String matchString = "#{" + prefix.getText();
+ String query = matchString;
+ if (query == null)
+ query = "";
+ String stringQuery = matchString;
+
+ int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
+
+ KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery, position);
+ TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery, pageContext);
+
+ if(proposals != null) for (TextProposal textProposal: proposals) {
+ int replacementOffset = beginChangeOffset;
+ int replacementLength = prefix.getLength();
+ String displayString = prefix.getText().substring(0, replacementLength) + textProposal.getReplacementString();
+ int cursorPosition = /*replacementOffset + */ textProposal.getReplacementString().length();
+
+ if(!prefix.isELClosed()) {
+ textProposal.setReplacementString(textProposal.getReplacementString() + "}");
+ }
+
+ Image image = textProposal.getImage();
+
+// IContextInformation contextInformation = null;
+// String additionalProposalInfo = textProposal.getContextInfo();
+// int relevance = textProposal.getRelevance() + 10000;
+
+ IContentProposal proposal = //new ContentProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo, relevance);
+ new ContentProposal(textProposal.getReplacementString(), cursorPosition, displayString, displayString);
+ result.add(proposal);
+ }
+
+ if (prefix.isELStarted() && !prefix.isELClosed()) {
+ IContentProposal proposal = new ContentProposal("}", 0, "}", "Close EL Expression");
+ result.add(proposal);
+ }
+
+ return result.toArray(new IContentProposal[0]);
+ }
+
+ class ContentProposal implements IContentProposal {
+ String content;
+ int pos;
+ String description = "";
+ String label;
+
+ public ContentProposal(String content, int pos, String label, String description) {
+ this.content = content;
+ this.pos = pos;
+ this.label = label;
+ this.description = description;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public int getCursorPosition() {
+ return pos;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ }
+
+ protected TextRegion getELPrefix(String text, int pos) {
+ int inValueOffset = pos;
+ if (text.length() < inValueOffset) { // probably, the attribute value ends before the document position
+ return null;
+ }
+ if (inValueOffset<0) {
+ return null;
+ }
+
+ String matchString = text.substring(0, inValueOffset);
+
+ ELParser p = ELParserUtil.getJbossFactory().createParser();
+ ELModel model = p.parse(text);
+
+ ELInstance is = ELUtil.findInstance(model, inValueOffset);// ELInstance
+ ELInvocationExpression ie = ELUtil.findExpression(model, inValueOffset);// ELExpression
+
+ boolean isELStarted = (model != null && is != null && (model.toString().startsWith("#{") ||
+ model.toString().startsWith("${")));
+ boolean isELClosed = (model != null && is != null && model.toString().endsWith("}"));
+
+// boolean insideEL = startOffset + model.toString().length()
+ TextRegion tr = new TextRegion(0, ie == null ? inValueOffset : ie.getStartPosition(), ie == null ? 0 : inValueOffset - ie.getStartPosition(), ie == null ? "" : ie.getText(), isELStarted, isELClosed);
+
+ return tr;
+ }
+
+ protected ELResolver[] getELResolvers(IResource resource) {
+ ELResolverFactoryManager elrfm = ELResolverFactoryManager.getInstance();
+ return elrfm.getResolvers(resource);
+ }
+
+ protected ITextViewer getTextViewer() {
+ IEditorPart editor = ModelUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editor == null) return null;
+ if (editor instanceof JSPMultiPageEditor) {
+ JSPMultiPageEditor jsp = (JSPMultiPageEditor)editor;
+ return jsp.getSourceEditor().getTextViewer();
+ }
+ return null;
+ }
+
+ protected KbQuery createKbQuery(Type type, String query, String stringQuery, int pos) {
+ KbQuery kbQuery = new KbQuery();
+
+ String prefix = processor.getTagPrefix();
+ String uri = processor.getTagUri();
+ String[] parentTags = processor.getParentTags(attributeName);
+ String parent = attributeName;
+ String queryValue = query;
+ String queryStringValue = stringQuery;
+
+ kbQuery.setPrefix(prefix);
+ kbQuery.setUri(uri);
+ kbQuery.setParentTags(parentTags);
+ kbQuery.setParent(parent);
+ kbQuery.setMask(true);
+ kbQuery.setType(type);
+ kbQuery.setOffset(pos);
+ kbQuery.setValue(queryValue);
+ kbQuery.setStringQuery(queryStringValue);
+
+ return kbQuery;
+ }
+
+ protected int getOffset() {
+ return offset;
+ }
+
+ static class JSPDialogContentAssistProcessor extends JspContentAssistProcessor {
+ public String getTagPrefix() {
+ return super.getTagPrefix();
+ }
+ public String getTagUri() {
+ return super.getTagUri();
+ }
+ protected String[] getParentTags(String attr) {
+ String[] result = super.getParentTags(true);
+ String[] result1 = new String[result.length + 1];
+ System.arraycopy(result, 0, result1, 0, result.length);
+ result1[result.length] = attr;
+ return result1;
+ }
+
+ }
+
+}
Property changes on: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JSPDialogContentProposalProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2009-07-13 15:09:33 UTC (rev 16547)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/outline/JSPDialogCellEditor.java 2009-07-13 16:33:13 UTC (rev 16548)
@@ -12,20 +12,28 @@
import java.util.Properties;
-import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
+import org.eclipse.jface.fieldassist.ContentProposalAdapter;
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.fieldassist.IContentProposal;
+import org.eclipse.jface.fieldassist.IControlContentAdapter;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.contentassist.ContentAssistHandler;
import org.jboss.tools.common.meta.key.WizardKeys;
+import org.jboss.tools.common.model.ui.attribute.AttributeContentProposalProviderFactory;
import org.jboss.tools.common.model.ui.attribute.editor.DialogCellEditorEx;
import org.jboss.tools.common.model.ui.objecteditor.AttributeWrapper;
import org.jboss.tools.common.model.ui.objecteditor.ExtendedCellEditorProvider;
import org.jboss.tools.jst.jsp.contentassist.FaceletsHtmlContentAssistProcessor;
-import org.jboss.tools.jst.jsp.contentassist.JSPDialogCellEditorContentAssistProcessor;
-import org.jboss.tools.jst.jsp.drop.treeviewer.model.RootElement;
+import org.jboss.tools.jst.jsp.contentassist.JSPDialogContentProposalProvider;
import org.jboss.tools.jst.jsp.outline.cssdialog.CSSStyleDialog;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.CSSConstants;
import org.jboss.tools.jst.jsp.outline.cssdialog.common.Constants;
@@ -38,8 +46,7 @@
Properties context;
// ValueHelper valueHelper;
- JSPDialogCellEditorContentAssistProcessor contentAssistentProcessor;
- ContentAssistHandler handler = null;
+// ContentAssistHandler handler = null;
boolean hasProposals = false;
/**
@@ -51,12 +58,7 @@
super(parent);
this.context = context;
- contentAssistentProcessor = new JSPDialogCellEditorContentAssistProcessor();
-
- contentAssistentProcessor.setContext(context);
-
- handler = ContentAssistHandler.createHandlerForText(getTextField(),
- ControlContentAssistHelper.createJavaContentAssistant(contentAssistentProcessor));
+ addContentAssist(getTextField());
}
public void activate() {
@@ -71,34 +73,25 @@
if (context == null) {
return;
}
-
- // valueHelper = (ValueHelper)context.get("valueHelper");
- // if(valueHelper == null) return;
- ValueHelper valueHelper = new ValueHelper();
+
String attributeName = Constants.EMPTY + context.getProperty("attributeName");
- String nodeName = Constants.EMPTY + context.getProperty("nodeName");
- String query = Constants.SLASH;
-
- if (valueHelper.isFacetets() && (nodeName.indexOf(':') < 0)) {
- query += FaceletsHtmlContentAssistProcessor.faceletHtmlPrefixStart;
+ if(attributeName.equalsIgnoreCase(CSSConstants.STYLE)
+ || attributeName.equalsIgnoreCase(CSSConstants.CLASS)) {
+ hasProposals = true;
+ return;
}
- query += (nodeName + "@" + attributeName);
-
- RootElement root = (RootElement) valueHelper.getInitalInput(query);
- hasProposals = ((root != null) && (root.getChildren().length > 0))
- || attributeName.equalsIgnoreCase(CSSConstants.STYLE)
- || attributeName.equalsIgnoreCase(CSSConstants.CLASS);
+ JSPDialogContentProposalProvider cpp = new JSPDialogContentProposalProvider();
+ cpp.setContext(context);
+ IContentProposal[] ps = cpp.getProposals("#{}", 2);
+ System.out.println(ps.length);
+ hasProposals = ((ps != null) && (ps.length > 0));
}
private void checkButtonEnablement() {
if (context == null) {
return;
}
-
-// valueHelper = (ValueHelper)context.get("valueHelper");
-// if(valueHelper == null) return;
-// ValueHelper valueHelper = new ValueHelper();
Button button = getButtonControl();
if ((button == null) || button.isDisposed()) {
@@ -106,7 +99,6 @@
}
button.setVisible(hasProposals);
- handler.setEnabled(hasProposals);
}
protected Object openDialogBox(Control cellEditorWindow) {
@@ -179,4 +171,47 @@
protected Text getTextField() {
return text;
}
+
+ protected Control createContents(Composite cell) {
+ super.createContents(cell);
+
+ return getTextControl();
+ }
+
+ protected void addContentAssist(Text text) {
+ IControlContentAdapter controlAdapter = new TextContentAdapter();
+ JSPDialogContentProposalProvider cpp = new JSPDialogContentProposalProvider();
+ cpp.setContext(context);
+
+ ContentProposalAdapter adapter = new ContentProposalAdapter(
+ text,
+ controlAdapter,
+ cpp,
+ AttributeContentProposalProviderFactory.getCtrlSpaceKeyStroke(),
+ null);
+ adapter.setPropagateKeys(true);
+ adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT);
+ if(popup != null) {
+ adapter.addContentProposalListener(popup);
+ }
+
+ int bits = SWT.TOP | SWT.LEFT;
+ ControlDecoration controlDecoration = new ControlDecoration(getTextControl(), bits) {
+ public Image getImage() {
+ return super.getImage();
+ }
+ };
+ // Configure text widget decoration
+ // No margin
+ controlDecoration.setMarginWidth(0);
+ // Custom hover tip text
+ controlDecoration.setDescriptionText("code assist" /*PDEUIMessages.PDEJavaHelper_msgContentAssistAvailable*/);
+ // Custom hover properties
+ controlDecoration.setShowHover(true);
+ controlDecoration.setShowOnlyOnFocus(true);
+ // Hover image to use
+ FieldDecoration contentProposalImage = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ controlDecoration.setImage(contentProposalImage.getImage());
+ }
+
}
16 years, 9 months
JBoss Tools SVN: r16547 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram: editors/actions and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-07-13 11:09:33 -0400 (Mon, 13 Jul 2009)
New Revision: 16547
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4017 - AutoLayoutAction, ExportImageAction - menu item translatable
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-07-13 14:54:44 UTC (rev 16546)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.java 2009-07-13 15:09:33 UTC (rev 16547)
@@ -24,6 +24,8 @@
public static String EditorActionContributor_refresh_visual_mapping;
public static String DiagramViewer_diagram_for;
+ public static String AutoLayoutAction_auto_layout;
+ public static String ExportImageAction_export_as_image;
public static String ExportImageAction_bmp_format;
public static String ExportImageAction_error;
public static String ExportImageAction_failed_to_export_image;
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-07-13 14:54:44 UTC (rev 16546)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/DiagramViewerMessages.properties 2009-07-13 15:09:33 UTC (rev 16547)
@@ -1,5 +1,7 @@
EditorActionContributor_refresh_visual_mapping=Refresh Visual Mapping
DiagramViewer_diagram_for=Diagram for
+AutoLayoutAction_auto_layout=Auto layout
+ExportImageAction_export_as_image=Export as Image
ExportImageAction_bmp_format=Bitmap format (*.bmp)
ExportImageAction_error=Error
ExportImageAction_failed_to_export_image=Failed to export image:
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java 2009-07-13 14:54:44 UTC (rev 16546)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/AutoLayoutAction.java 2009-07-13 15:09:33 UTC (rev 16547)
@@ -11,18 +11,19 @@
package org.jboss.tools.hibernate.ui.diagram.editors.actions;
import org.eclipse.jface.action.Action;
+import org.jboss.tools.hibernate.ui.diagram.DiagramViewerMessages;
import org.jboss.tools.hibernate.ui.diagram.editors.DiagramViewer;
public class AutoLayoutAction extends Action {
- public static final String ACTION_ID = "Auto layout"; //$NON-NLS-1$
+ public static final String ACTION_ID = "auto_layout_id"; //$NON-NLS-1$
private DiagramViewer editor;
public AutoLayoutAction(DiagramViewer editor) {
this.editor = editor;
setId(ACTION_ID);
- setText(ACTION_ID);
+ setText(DiagramViewerMessages.AutoLayoutAction_auto_layout);
//setImageDescriptor(ImageDescriptor.createFromFile(
// DiagramViewer.class, "icons/export.png"));
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java 2009-07-13 14:54:44 UTC (rev 16546)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/actions/ExportImageAction.java 2009-07-13 15:09:33 UTC (rev 16547)
@@ -35,7 +35,7 @@
public class ExportImageAction extends Action {
- public static final String ACTION_ID = "Export as Image"; //$NON-NLS-1$
+ public static final String ACTION_ID = "export_as_image_id"; //$NON-NLS-1$
public static final String[] dialogFilterExtensions = new String[] { "*.png", "*.jpg", "*.bmp" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
public static final String[] dialogFilterNames = new String[] { DiagramViewerMessages.ExportImageAction_png_format,
DiagramViewerMessages.ExportImageAction_jpg_format, DiagramViewerMessages.ExportImageAction_bmp_format };
@@ -46,7 +46,7 @@
public ExportImageAction(DiagramViewer editor) {
this.editor = editor;
setId(ACTION_ID);
- setText(ACTION_ID);
+ setText(DiagramViewerMessages.ExportImageAction_export_as_image);
setImageDescriptor(ImageDescriptor.createFromFile(
DiagramViewer.class,"icons/export.png")); //$NON-NLS-1$
}
16 years, 9 months
JBoss Tools SVN: r16546 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view.
by jbosstools-commits@lists.jboss.org
Author: vyemialyanchyk
Date: 2009-07-13 10:54:44 -0400 (Mon, 13 Jul 2009)
New Revision: 16546
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4017 - bugfix - correct images path
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java 2009-07-13 10:24:01 UTC (rev 16545)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmImageMap.java 2009-07-13 14:54:44 UTC (rev 16546)
@@ -56,7 +56,7 @@
} else if (obj instanceof PersistentClass) {
imageName = getImageName((PersistentClass)obj);
}
- return UiPlugin.getImageDescriptor(ImageBundle.getString(imageName));
+ return UiPlugin.getImageDescriptor("images/" + ImageBundle.getString(imageName)); //$NON-NLS-1$
}
/**
16 years, 9 months
JBoss Tools SVN: r16545 - in trunk/smooks/plugins: org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-07-13 06:24:01 -0400 (Mon, 13 Jul 2009)
New Revision: 16545
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.runtime/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java
Log:
JBIDE-4592
1.Remove useless plug-in dependence.
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.runtime/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.runtime/META-INF/MANIFEST.MF 2009-07-13 10:17:39 UTC (rev 16544)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.runtime/META-INF/MANIFEST.MF 2009-07-13 10:24:01 UTC (rev 16545)
@@ -5,13 +5,11 @@
Bundle-Version: 1.1.2
Require-Bundle: org.eclipse.core.runtime,
org.apache.commons.codec,
- org.apache.commons.jxpath,
org.apache.commons.lang,
org.apache.commons.logging,
org.apache.xerces,
org.apache.commons.httpclient,
- org.junit,
- org.w3c.css.sac
+ org.junit
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .,
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java 2009-07-13 10:17:39 UTC (rev 16544)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/edimap/models/EDIMappingNodeGraphModel.java 2009-07-13 10:24:01 UTC (rev 16545)
@@ -41,8 +41,6 @@
public boolean canLinkWithSource(Object model) {
return false;
}
-
-
/* (non-Javadoc)
* @see org.jboss.tools.smooks.gef.tree.model.TreeNodeModel#isLinkable()
@@ -70,6 +68,4 @@
}
return false;
}
-
-
}
16 years, 9 months
JBoss Tools SVN: r16544 - in trunk/hibernatetools/plugins: org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal and 6 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-07-13 06:17:39 -0400 (Mon, 13 Jul 2009)
New Revision: 16544
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/build.properties
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQuery.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryContainer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedQueryPropertyComposite.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4521
Hibernate @NamedNativeQuery/Queries support
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/build.properties
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/build.properties 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/build.properties 2009-07-13 10:17:39 UTC (rev 16544)
@@ -3,5 +3,4 @@
bin.includes = plugin.xml,\
META-INF/,\
.,\
- icons/,\
plugin.properties
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaAnnotationDefinitionProvider.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -15,9 +15,11 @@
import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider;
import org.eclipse.jpt.core.internal.platform.AbstractJpaAnnotationDefintionProvider;
import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryAnnotationDefinition;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.GenericGeneratorAnnotationImpl.GenericGeneratorAnnotationDefinition;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotationDefinition;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotationDefinition;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotationDefinition;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotationDefinition;
/**
* @author Dmitry Geraskov
@@ -51,6 +53,8 @@
definitions.add(GenericGeneratorAnnotationDefinition.instance());
definitions.add(HibernateNamedQueryAnnotationDefinition.instance());
definitions.add(HibernateNamedQueriesAnnotationDefinition.instance());
+ definitions.add(HibernateNamedNativeQueryAnnotationDefinition.instance());
+ definitions.add(HibernateNamedNativeQueriesAnnotationDefinition.instance());
}
@Override
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaFactory.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -22,8 +22,11 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaEntity;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaIdMapping;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaParameter;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaParameter;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaParameter;
@@ -57,6 +60,10 @@
public HibernateNamedQuery buildHibernateNamedQuery(JavaJpaContextNode parent) {
return new HibernateNamedQueryImpl(parent);
}
+
+ public HibernateNamedNativeQuery buildHibernateNamedNativeQuery(JavaJpaContextNode parent) {
+ return new HibernateNamedNativeQueryImpl(parent);
+ }
public JavaParameter buildJavaParameter(JavaGenericGeneratorImpl javaGenericGeneratorImpl) {
return new HibernateJavaParameter(javaGenericGeneratorImpl);
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * 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.jboss.tools.hibernate.jpt.core.internal;
-
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedQuery;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryAnnotation;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateNamedQueryImpl extends GenericJavaNamedQuery
- implements HibernateNamedQuery {
-
- private FlushModeType specifiedFlushMode;
-
- private CacheModeType specifiedCacheMode;
-
- private Boolean specifiedCacheable;
-
- private String specifiedCacheRegion;
-
- private Integer specifiedFetchSize;
-
- private Integer specifiedTimeout;
-
- private String specifiedComment;
-
- private Boolean specifiedReadOnly;
-
- /**
- * @param parent
- */
- public HibernateNamedQueryImpl(JavaJpaContextNode parent) {
- super(parent);
- }
-
- public void initialize(HibernateNamedQueryAnnotation resourceQuery) {
- this.specifiedFlushMode = this.getResourceFlushMode(resourceQuery);
- this.specifiedCacheMode = this.getResourceCacheMode(resourceQuery);
- this.specifiedCacheable = resourceQuery.isCacheable();
- this.specifiedCacheRegion = resourceQuery.getCacheRegion();
- this.specifiedFetchSize = resourceQuery.getFetchSize();
- this.specifiedTimeout = resourceQuery.getTimeout();
- this.specifiedComment = resourceQuery.getComment();
- this.specifiedReadOnly = resourceQuery.isReadOnly();
- super.initialize(resourceQuery);
- }
-
- public void update(HibernateNamedQueryAnnotation resourceQuery) {
- this.setFlushMode_(resourceQuery.getFlushMode());
- this.setCacheMode_ (resourceQuery.getCacheMode());
- this.setSpecifiedCacheable_(resourceQuery.isCacheable());
- this.setSpecifiedCacheRegion_(resourceQuery.getCacheRegion());
- this.setSpecifiedFetchSize_(resourceQuery.getFetchSize());
- this.setSpecifiedTimeout_(resourceQuery.getTimeout());
- this.setSpecifiedComment_(resourceQuery.getComment());
- this.setSpecifiedReadOnly_(resourceQuery.isReadOnly());
- super.update(resourceQuery);
- }
-
- private CacheModeType getResourceCacheMode(HibernateNamedQueryAnnotation resourceQuery) {
- return CacheModeType.fromJavaAnnotationValue(resourceQuery);
- }
-
- private FlushModeType getResourceFlushMode(HibernateNamedQueryAnnotation resourceQuery) {
- return FlushModeType.fromJavaAnnotationValue(resourceQuery);
- }
-
- @Override
- protected HibernateNamedQueryAnnotation getResourceQuery() {
- return (HibernateNamedQueryAnnotation) super.getResourceQuery();
- }
-
- // ****** flushMode
- public FlushModeType getFlushMode() {
- return getSpecifiedFlushMode() == null ? getDefaultFlushMode() : getSpecifiedFlushMode();
- }
-
- public FlushModeType getSpecifiedFlushMode() {
- return specifiedFlushMode;
- }
-
- public FlushModeType getDefaultFlushMode() {
- return HibernateNamedQuery.DEFAULT_FLUSH_MODE_TYPE;
- }
-
- public void setSpecifiedFlushMode(FlushModeType flushMode) {
- FlushModeType oldFlushMode = this.specifiedFlushMode;
- this.specifiedFlushMode = flushMode;
- getResourceQuery().setFlushMode(flushMode);
- firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
- }
-
- protected void setFlushMode_(FlushModeType flushMode) {
- FlushModeType oldFlushMode = this.specifiedFlushMode;
- this.specifiedFlushMode = flushMode;
- firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
- }
- // ****** cacheMode
- public CacheModeType getCacheMode() {
- return getSpecifiedCacheMode() == null ? getDefaultCacheMode() : getSpecifiedCacheMode();
- }
-
- public CacheModeType getDefaultCacheMode() {
- return HibernateNamedQuery.DEFAULT_CACHE_MODE_TYPE;
- }
-
- public CacheModeType getSpecifiedCacheMode() {
- return specifiedCacheMode;
- }
-
- public void setSpecifiedCacheMode(CacheModeType cacheMode) {
- CacheModeType oldCacheMode = this.specifiedCacheMode;
- this.specifiedCacheMode = cacheMode;
- getResourceQuery().setCacheMode(cacheMode);
- firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
- }
-
- public void setCacheMode_(CacheModeType cacheMode) {
- CacheModeType oldCacheMode = this.specifiedCacheMode;
- this.specifiedCacheMode = cacheMode;
- firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
- }
- //************************ cacheable *********************************
- public boolean isCacheable(){
- return (this.getSpecifiedCacheable() == null) ? this.isDefaultCacheable()
- : this.getSpecifiedCacheable().booleanValue();
- }
-
- public Boolean getSpecifiedCacheable(){
- return this.specifiedCacheable;
- }
-
- public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) {
- Boolean oldSpecifiedCacheable = this.specifiedCacheable;
- this.specifiedCacheable = newSpecifiedCacheable;
- this.getResourceQuery().setCacheable(newSpecifiedCacheable);
- firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable);
-
- }
-
- public void setSpecifiedCacheable_(Boolean newSpecifiedCacheable) {
- Boolean oldSpecifiedCacheable = this.specifiedCacheable;
- this.specifiedCacheable = newSpecifiedCacheable;
- firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable);
- }
-
- public boolean isDefaultCacheable() {
- return HibernateNamedQuery.DEFAULT_CACHEABLE;
- }
- //************************ cacheRegion *********************************
- public String getCacheRegion(){
- return (getSpecifiedCacheRegion() == null ? getDefaultCacheRegion()
- : getSpecifiedCacheRegion());
- }
- public String getSpecifiedCacheRegion(){
- return this.specifiedCacheRegion;
- }
-
- public void setSpecifiedCacheRegion(String cacheRegion){
- String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
- this.specifiedCacheRegion = cacheRegion;
- this.getResourceQuery().setCacheRegion(cacheRegion);
- firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion, cacheRegion);
- }
-
- public void setSpecifiedCacheRegion_(String cacheRegion){
- String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
- this.specifiedCacheRegion = cacheRegion;
- firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion, cacheRegion);
- }
-
- public String getDefaultCacheRegion(){
- return HibernateNamedQuery.DEFAULT_CACHE_REGION;
- }
- //************************ fetchSize *********************************
- public int getFetchSize(){
- return (getSpecifiedFetchSize() == null ? getDefaultFetchSize()
- : getSpecifiedFetchSize().intValue());
- }
-
- public Integer getSpecifiedFetchSize(){
- return this.specifiedFetchSize;
- }
-
- public void setSpecifiedFetchSize(Integer newSpecifiedFetchSize){
- Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
- this.specifiedFetchSize = newSpecifiedFetchSize;
- this.getResourceQuery().setFetchSize(newSpecifiedFetchSize);
- firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, newSpecifiedFetchSize);
- }
-
- public void setSpecifiedFetchSize_(Integer fetchSize){
- Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
- this.specifiedFetchSize = fetchSize;
- firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, fetchSize);
- }
-
- public int getDefaultFetchSize(){
- return HibernateNamedQuery.DEFAULT_FETCH_SIZE;
- }
- //************************ timeout *********************************
- public int getTimeout(){
- return (getSpecifiedTimeout() == null ? getDefaultTimeout()
- : getSpecifiedTimeout().intValue());
- }
-
- public Integer getSpecifiedTimeout(){
- return this.specifiedTimeout;
- }
-
- public void setSpecifiedTimeout(Integer newSpecifiedTimeout){
- Integer oldSpecifiedTimeout = this.specifiedTimeout;
- this.specifiedTimeout = newSpecifiedTimeout;
- this.getResourceQuery().setTimeout(newSpecifiedTimeout);
- firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, newSpecifiedTimeout);
- }
-
- public void setSpecifiedTimeout_(Integer timeout){
- Integer oldSpecifiedTimeout = this.specifiedTimeout;
- this.specifiedTimeout = timeout;
- firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, timeout);
- }
-
- public int getDefaultTimeout(){
- return HibernateNamedQuery.DEFAULT_TIMEOUT;
- }
- //************************ comment *********************************
- public String getComment(){
- return (getSpecifiedComment() == null ? getDefaultComment()
- : getSpecifiedComment());
- }
- public String getSpecifiedComment(){
- return this.specifiedComment;
- }
-
- public void setSpecifiedComment(String newSpecifiedComment){
- String oldSpecifiedComment = this.specifiedComment;
- this.specifiedComment = newSpecifiedComment;
- this.getResourceQuery().setComment(newSpecifiedComment);
- firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, newSpecifiedComment);
- }
-
- public void setSpecifiedComment_(String comment){
- String oldSpecifiedComment = this.specifiedComment;
- this.specifiedComment = comment;
- firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, comment);
- }
-
- public String getDefaultComment(){
- return HibernateNamedQuery.DEFAULT_COMMENT;
- }
-
- //************************ readOnly *********************************
- public boolean isReadOnly(){
- return (getSpecifiedReadOnly() == null ? isDefaultReadOnly()
- : getSpecifiedReadOnly().booleanValue());
- }
-
- public Boolean getSpecifiedReadOnly(){
- return this.specifiedReadOnly;
- }
-
- public void setSpecifiedReadOnly(Boolean newSpecifiedReadOnly){
- Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
- this.specifiedReadOnly = newSpecifiedReadOnly;
- this.getResourceQuery().setReadOnly(newSpecifiedReadOnly);
- firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, newSpecifiedReadOnly);
- }
-
- public void setSpecifiedReadOnly_(Boolean readOnly){
- Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
- this.specifiedReadOnly = readOnly;
- firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, readOnly);
- }
-
- public boolean isDefaultReadOnly(){
- return HibernateNamedQuery.DEFAULT_READ_ONLY;
- }
-}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnitProperties.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -163,7 +163,6 @@
* @param value -
* property value
*/
- @SuppressWarnings("unchecked")
protected void putProperty(String key, Object value) {
String elKey = this.hibernateKeyFor(key);
if (value == null)
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/basic/Hibernate.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -48,6 +48,25 @@
String NAMED_QUERIES = PACKAGE_ + "NamedQueries"; //$NON-NLS-1$
String NAMED_QUERIES__VALUE = "value"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY = PACKAGE_ + "NamedNativeQuery"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__NAME = "name"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__QUERY = "query"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__HINTS = "hints"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__FLUSH_MODE = "flushMode"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__CACHE_MODE = "cacheMode"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__CACHEABLE = "cacheable"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__CACHE_REGION = "cacheRegion"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__FETCH_SIZE = "fetchSize"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__TIMEOUT = "timeout"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__COMMENT = "comment"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__READ_ONLY = "readOnly"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__RESULT_CLASS = "resultClass"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__RESULT_SET_MAPPING = "resultSetMapping"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERY__CALLABLE = "callable"; //$NON-NLS-1$
+
+ String NAMED_NATIVE_QUERIES = PACKAGE_ + "NamedNativeQueries"; //$NON-NLS-1$
+ String NAMED_NATIVE_QUERIES__VALUE = "value"; //$NON-NLS-1$
+
String FLUSH_MODE_TYPE = PACKAGE_ + "FlushModeType"; //$NON-NLS-1$
String FLUSH_MODE_TYPE_ = FLUSH_MODE_TYPE + '.';
String FLUSH_MODE_TYPE__ALWAYS = FLUSH_MODE_TYPE_ + "ALWAYS"; //$NON-NLS-1$
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaEntity.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -31,7 +31,9 @@
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.hibernate.jpt.core.internal.HibernateJpaFactory;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueriesAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueriesAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
@@ -44,9 +46,12 @@
protected final List<HibernateNamedQuery> hibernateNamedQueries;
+ protected final List<HibernateNamedNativeQuery> hibernateNamedNativeQueries;
+
public HibernateJavaEntity(JavaPersistentType parent) {
super(parent);
this.hibernateNamedQueries = new ArrayList<HibernateNamedQuery>();
+ this.hibernateNamedNativeQueries = new ArrayList<HibernateNamedNativeQuery>();
}
@Override
@@ -54,6 +59,7 @@
super.initialize(resourcePersistentType);
this.initializeGenericGenerator();
this.initializeHibernateNamedQueries();
+ this.initializeHibernateNamedNativeQueries();
}
@Override
@@ -61,12 +67,16 @@
super.update(resourcePersistentType);
this.updateGenericGenerator();
this.updateHibernateNamedQueries();
+ this.updateHibernateNamedNativeQueries();
}
@SuppressWarnings("unchecked")
@Override
public Iterator<JavaQuery> queries() {
- return new CompositeIterator<JavaQuery>(super.queries(), this.hibernateNamedQueries());
+ return new CompositeIterator<JavaQuery>(
+ super.queries(),
+ this.hibernateNamedQueries(),
+ this.hibernateNamedNativeQueries());
}
// ********************* GenericGenerator **************
@@ -76,7 +86,9 @@
return new CompositeIterator<String>(
new ArrayIterator<String>(Hibernate.GENERIC_GENERATOR,
Hibernate.NAMED_QUERY,
- Hibernate.NAMED_QUERIES),
+ Hibernate.NAMED_QUERIES,
+ Hibernate.NAMED_NATIVE_QUERY,
+ Hibernate.NAMED_NATIVE_QUERIES),
super.correspondingAnnotationNames());
}
@@ -234,6 +246,88 @@
this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex, HibernateNamedQueriesAnnotation.ANNOTATION_NAME);
fireItemMoved(HIBERNATE_NAMED_QUERIES_LIST, targetIndex, sourceIndex);
}
+
+ // ********************* NamedNativeQuery **************
+ public ListIterator<HibernateNamedNativeQuery> hibernateNamedNativeQueries() {
+ return new CloneListIterator<HibernateNamedNativeQuery>(this.hibernateNamedNativeQueries);
+ }
+
+ public int hibernateNamedNativeQueriesSize() {
+ return this.hibernateNamedNativeQueries.size();
+ }
+
+ protected void initializeHibernateNamedNativeQueries() {
+ for (ListIterator<NestableAnnotation> stream = this.javaResourcePersistentType.supportingAnnotations(HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME, HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME); stream.hasNext(); ) {
+ this.hibernateNamedNativeQueries.add(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation) stream.next()));
+ }
+ }
+
+ protected HibernateNamedNativeQuery buildHibernateNamedNativeQuery(HibernateNamedNativeQueryAnnotation namedQueryResource) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery = getJpaFactory().buildHibernateNamedNativeQuery(this);
+ hibernateNamedNativeQuery.initialize(namedQueryResource);
+ return hibernateNamedNativeQuery;
+ }
+
+ protected void updateHibernateNamedNativeQueries() {
+ ListIterator<HibernateNamedNativeQuery> queries = hibernateNamedNativeQueries();
+ ListIterator<NestableAnnotation> resourceNamedNativeQueries = this.javaResourcePersistentType.supportingAnnotations(HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME, HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+
+ while (queries.hasNext()) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery = queries.next();
+ if (resourceNamedNativeQueries.hasNext()) {
+ hibernateNamedNativeQuery.update((HibernateNamedNativeQueryAnnotation) resourceNamedNativeQueries.next());
+ }
+ else {
+ removeHibernateNamedNativeQuery_(hibernateNamedNativeQuery);
+ }
+ }
+
+ while (resourceNamedNativeQueries.hasNext()) {
+ Object test = resourceNamedNativeQueries.next();
+ if (!(test instanceof HibernateNamedNativeQueryAnnotation)){
+ System.out.println("error!");//$NON-NLS-1$
+ }
+ addHibernateNamedNativeQuery(buildHibernateNamedNativeQuery((HibernateNamedNativeQueryAnnotation) test));
+ }
+ }
+
+ public HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index) {
+ HibernateNamedNativeQuery hibernateNamedNativeQuery = getJpaFactory().buildHibernateNamedNativeQuery(this);
+ this.hibernateNamedNativeQueries.add(index, hibernateNamedNativeQuery);
+ HibernateNamedNativeQueryAnnotation hibernateNamedNativeQueryAnnotation = (HibernateNamedNativeQueryAnnotation) this.javaResourcePersistentType
+ .addSupportingAnnotation(index, HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME, HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ hibernateNamedNativeQuery.initialize(hibernateNamedNativeQueryAnnotation);
+ fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, hibernateNamedNativeQuery);
+ return hibernateNamedNativeQuery;
+ }
+
+ protected void addHibernateNamedNativeQuery(int index, HibernateNamedNativeQuery hibernateNamedNativeQuery) {
+ addItemToList(index, hibernateNamedNativeQuery, this.hibernateNamedNativeQueries, HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
+ }
+
+ protected void addHibernateNamedNativeQuery(HibernateNamedNativeQuery hibernateNamedNativeQuery) {
+ this.addHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.size(), hibernateNamedNativeQuery);
+ }
+
+ public void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery hibernateNamedNativeQuery) {
+ removeHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.indexOf(hibernateNamedNativeQuery));
+ }
+
+ public void removeHibernateNamedNativeQuery(int index) {
+ HibernateNamedNativeQuery removedHibernateNamedNativeQuery = this.hibernateNamedNativeQueries.remove(index);
+ this.javaResourcePersistentType.removeSupportingAnnotation(index, HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME, HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ fireItemRemoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, removedHibernateNamedNativeQuery);
+ }
+
+ protected void removeHibernateNamedNativeQuery_(HibernateNamedNativeQuery hibernateNamedNativeQuery) {
+ removeItemFromList(hibernateNamedNativeQuery, this.hibernateNamedNativeQueries, HIBERNATE_NAMED_NATIVE_QUERIES_LIST);
+ }
+
+ public void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex) {
+ CollectionTools.move(this.hibernateNamedNativeQueries, targetIndex, sourceIndex);
+ this.javaResourcePersistentType.moveSupportingAnnotation(targetIndex, sourceIndex, HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME);
+ fireItemMoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex);
+ }
// ************************* validation ***********************
@Override
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaNamedNativeQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateNamedNativeQuery extends JavaNamedNativeQuery,
+ HibernateQuery {
+
+ String HIBERNATE_NAMED_NATIVE_QUERY="hibernateNamedNativeQuery"; //$NON-NLS-1$
+
+ //************************ callable *********************************
+ boolean isCallable();
+ Boolean getSpecifiedCallable();
+ void setSpecifiedCallable(Boolean value);
+ String SPECIFIED_CALLABLE_PROPERTY = "specifiedCallable"; //$NON-NLS-1$
+
+ boolean isDefaultCallable();
+ boolean DEFAULT_CALLABLE = false;
+ String DEFAULT_CALLABLE_PROPERTY = "defaultCallable"; //$NON-NLS-1$
+
+
+ void initialize(HibernateNamedNativeQueryAnnotation resourceNamedQuery);
+
+ void update(HibernateNamedNativeQueryAnnotation resourceNamedQuery);
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.resource.java.NestableNamedNativeQueryAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ * Corresponds to the Hibernate annotation
+ * org.hibernate.annotations.NamedNativeQuery
+ */
+public interface HibernateNamedNativeQueryAnnotation
+ extends NestableNamedNativeQueryAnnotation, HibernateQueryAnnotation {
+ //replace with Hibernate annotation
+ String ANNOTATION_NAME = Hibernate.NAMED_NATIVE_QUERY;
+
+ //************************ callable *********************************
+ Boolean isCallable();
+ void setCallable(Boolean value);
+ String CALLABLE_PROPERTY = "callable"; //$NON-NLS-1$
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,322 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedNativeQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedNativeQueryImpl extends GenericJavaNamedNativeQuery
+ implements HibernateNamedNativeQuery {
+
+ private FlushModeType specifiedFlushMode;
+
+ private CacheModeType specifiedCacheMode;
+
+ private Boolean specifiedCacheable;
+
+ private String specifiedCacheRegion;
+
+ private Integer specifiedFetchSize;
+
+ private Integer specifiedTimeout;
+
+ private String specifiedComment;
+
+ private Boolean specifiedReadOnly;
+
+ private Boolean specifiedCallable;
+
+ /**
+ * @param parent
+ */
+ public HibernateNamedNativeQueryImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ public void initialize(HibernateNamedNativeQueryAnnotation resourceQuery) {
+ this.specifiedFlushMode = this.getResourceFlushMode(resourceQuery);
+ this.specifiedCacheMode = this.getResourceCacheMode(resourceQuery);
+ this.specifiedCacheable = resourceQuery.isCacheable();
+ this.specifiedCacheRegion = resourceQuery.getCacheRegion();
+ this.specifiedFetchSize = resourceQuery.getFetchSize();
+ this.specifiedTimeout = resourceQuery.getTimeout();
+ this.specifiedComment = resourceQuery.getComment();
+ this.specifiedReadOnly = resourceQuery.isReadOnly();
+ this.specifiedCallable = resourceQuery.isCallable();
+ super.initialize(resourceQuery);
+ }
+
+ public void update(HibernateNamedNativeQueryAnnotation resourceQuery) {
+ this.setFlushMode_(resourceQuery.getFlushMode());
+ this.setCacheMode_ (resourceQuery.getCacheMode());
+ this.setSpecifiedCacheable_(resourceQuery.isCacheable());
+ this.setSpecifiedCacheRegion_(resourceQuery.getCacheRegion());
+ this.setSpecifiedFetchSize_(resourceQuery.getFetchSize());
+ this.setSpecifiedTimeout_(resourceQuery.getTimeout());
+ this.setSpecifiedComment_(resourceQuery.getComment());
+ this.setSpecifiedReadOnly_(resourceQuery.isReadOnly());
+ this.setSpecifiedCallable_(resourceQuery.isCallable());
+ super.update(resourceQuery);
+ }
+
+ private CacheModeType getResourceCacheMode(HibernateNamedNativeQueryAnnotation resourceQuery) {
+ return CacheModeType.fromJavaAnnotationValue(resourceQuery);
+ }
+
+ private FlushModeType getResourceFlushMode(HibernateNamedNativeQueryAnnotation resourceQuery) {
+ return FlushModeType.fromJavaAnnotationValue(resourceQuery);
+ }
+
+ @Override
+ protected HibernateNamedNativeQueryAnnotation getResourceQuery() {
+ return (HibernateNamedNativeQueryAnnotation) super.getResourceQuery();
+ }
+
+ // ****** flushMode
+ public FlushModeType getFlushMode() {
+ return getSpecifiedFlushMode() == null ? getDefaultFlushMode() : getSpecifiedFlushMode();
+ }
+
+ public FlushModeType getSpecifiedFlushMode() {
+ return specifiedFlushMode;
+ }
+
+ public FlushModeType getDefaultFlushMode() {
+ return HibernateNamedNativeQuery.DEFAULT_FLUSH_MODE_TYPE;
+ }
+
+ public void setSpecifiedFlushMode(FlushModeType flushMode) {
+ FlushModeType oldFlushMode = this.specifiedFlushMode;
+ this.specifiedFlushMode = flushMode;
+ getResourceQuery().setFlushMode(flushMode);
+ firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
+ }
+
+ protected void setFlushMode_(FlushModeType flushMode) {
+ FlushModeType oldFlushMode = this.specifiedFlushMode;
+ this.specifiedFlushMode = flushMode;
+ firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
+ }
+ // ****** cacheMode
+ public CacheModeType getCacheMode() {
+ return getSpecifiedCacheMode() == null ? getDefaultCacheMode() : getSpecifiedCacheMode();
+ }
+
+ public CacheModeType getDefaultCacheMode() {
+ return HibernateNamedNativeQuery.DEFAULT_CACHE_MODE_TYPE;
+ }
+
+ public CacheModeType getSpecifiedCacheMode() {
+ return specifiedCacheMode;
+ }
+
+ public void setSpecifiedCacheMode(CacheModeType cacheMode) {
+ CacheModeType oldCacheMode = this.specifiedCacheMode;
+ this.specifiedCacheMode = cacheMode;
+ getResourceQuery().setCacheMode(cacheMode);
+ firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
+ }
+
+ public void setCacheMode_(CacheModeType cacheMode) {
+ CacheModeType oldCacheMode = this.specifiedCacheMode;
+ this.specifiedCacheMode = cacheMode;
+ firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
+ }
+ //************************ cacheable *********************************
+ public boolean isCacheable(){
+ return (this.getSpecifiedCacheable() == null) ? this.isDefaultCacheable()
+ : this.getSpecifiedCacheable().booleanValue();
+ }
+
+ public Boolean getSpecifiedCacheable(){
+ return this.specifiedCacheable;
+ }
+
+ public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) {
+ Boolean oldSpecifiedCacheable = this.specifiedCacheable;
+ this.specifiedCacheable = newSpecifiedCacheable;
+ this.getResourceQuery().setCacheable(newSpecifiedCacheable);
+ firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable);
+
+ }
+
+ public void setSpecifiedCacheable_(Boolean newSpecifiedCacheable) {
+ Boolean oldSpecifiedCacheable = this.specifiedCacheable;
+ this.specifiedCacheable = newSpecifiedCacheable;
+ firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable);
+ }
+
+ public boolean isDefaultCacheable() {
+ return HibernateNamedNativeQuery.DEFAULT_CACHEABLE;
+ }
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return (getSpecifiedCacheRegion() == null ? getDefaultCacheRegion()
+ : getSpecifiedCacheRegion());
+ }
+ public String getSpecifiedCacheRegion(){
+ return this.specifiedCacheRegion;
+ }
+
+ public void setSpecifiedCacheRegion(String cacheRegion){
+ String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
+ this.specifiedCacheRegion = cacheRegion;
+ this.getResourceQuery().setCacheRegion(cacheRegion);
+ firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion, cacheRegion);
+ }
+
+ public void setSpecifiedCacheRegion_(String cacheRegion){
+ String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
+ this.specifiedCacheRegion = cacheRegion;
+ firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion, cacheRegion);
+ }
+
+ public String getDefaultCacheRegion(){
+ return HibernateNamedNativeQuery.DEFAULT_CACHE_REGION;
+ }
+ //************************ fetchSize *********************************
+ public int getFetchSize(){
+ return (getSpecifiedFetchSize() == null ? getDefaultFetchSize()
+ : getSpecifiedFetchSize().intValue());
+ }
+
+ public Integer getSpecifiedFetchSize(){
+ return this.specifiedFetchSize;
+ }
+
+ public void setSpecifiedFetchSize(Integer newSpecifiedFetchSize){
+ Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
+ this.specifiedFetchSize = newSpecifiedFetchSize;
+ this.getResourceQuery().setFetchSize(newSpecifiedFetchSize);
+ firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, newSpecifiedFetchSize);
+ }
+
+ public void setSpecifiedFetchSize_(Integer fetchSize){
+ Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
+ this.specifiedFetchSize = fetchSize;
+ firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, fetchSize);
+ }
+
+ public int getDefaultFetchSize(){
+ return HibernateNamedNativeQuery.DEFAULT_FETCH_SIZE;
+ }
+ //************************ timeout *********************************
+ public int getTimeout(){
+ return (getSpecifiedTimeout() == null ? getDefaultTimeout()
+ : getSpecifiedTimeout().intValue());
+ }
+
+ public Integer getSpecifiedTimeout(){
+ return this.specifiedTimeout;
+ }
+
+ public void setSpecifiedTimeout(Integer newSpecifiedTimeout){
+ Integer oldSpecifiedTimeout = this.specifiedTimeout;
+ this.specifiedTimeout = newSpecifiedTimeout;
+ this.getResourceQuery().setTimeout(newSpecifiedTimeout);
+ firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, newSpecifiedTimeout);
+ }
+
+ public void setSpecifiedTimeout_(Integer timeout){
+ Integer oldSpecifiedTimeout = this.specifiedTimeout;
+ this.specifiedTimeout = timeout;
+ firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, timeout);
+ }
+
+ public int getDefaultTimeout(){
+ return HibernateNamedNativeQuery.DEFAULT_TIMEOUT;
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return (getSpecifiedComment() == null ? getDefaultComment()
+ : getSpecifiedComment());
+ }
+ public String getSpecifiedComment(){
+ return this.specifiedComment;
+ }
+
+ public void setSpecifiedComment(String newSpecifiedComment){
+ String oldSpecifiedComment = this.specifiedComment;
+ this.specifiedComment = newSpecifiedComment;
+ this.getResourceQuery().setComment(newSpecifiedComment);
+ firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, newSpecifiedComment);
+ }
+
+ public void setSpecifiedComment_(String comment){
+ String oldSpecifiedComment = this.specifiedComment;
+ this.specifiedComment = comment;
+ firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, comment);
+ }
+
+ public String getDefaultComment(){
+ return HibernateNamedNativeQuery.DEFAULT_COMMENT;
+ }
+
+ //************************ readOnly *********************************
+ public boolean isReadOnly(){
+ return (getSpecifiedReadOnly() == null ? isDefaultReadOnly()
+ : getSpecifiedReadOnly().booleanValue());
+ }
+
+ public Boolean getSpecifiedReadOnly(){
+ return this.specifiedReadOnly;
+ }
+
+ public void setSpecifiedReadOnly(Boolean newSpecifiedReadOnly){
+ Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
+ this.specifiedReadOnly = newSpecifiedReadOnly;
+ this.getResourceQuery().setReadOnly(newSpecifiedReadOnly);
+ firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, newSpecifiedReadOnly);
+ }
+
+ public void setSpecifiedReadOnly_(Boolean readOnly){
+ Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
+ this.specifiedReadOnly = readOnly;
+ firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, readOnly);
+ }
+
+ public boolean isDefaultReadOnly(){
+ return HibernateNamedNativeQuery.DEFAULT_READ_ONLY;
+ }
+
+ //************************ callable *********************************
+ public boolean isCallable(){
+ return (getSpecifiedCallable() == null ? isDefaultCallable()
+ : getSpecifiedCallable().booleanValue());
+ }
+
+ public Boolean getSpecifiedCallable(){
+ return this.specifiedCallable;
+ }
+
+ public void setSpecifiedCallable(Boolean newSpecifiedCallable){
+ Boolean oldSpecifiedCallable = this.specifiedCallable;
+ this.specifiedCallable = newSpecifiedCallable;
+ this.getResourceQuery().setCallable(newSpecifiedCallable);
+ firePropertyChanged(SPECIFIED_CALLABLE_PROPERTY, oldSpecifiedCallable, newSpecifiedCallable);
+ }
+
+ public void setSpecifiedCallable_(Boolean callable){
+ Boolean oldSpecifiedCallable = this.specifiedCallable;
+ this.specifiedCallable = callable;
+ firePropertyChanged(SPECIFIED_CALLABLE_PROPERTY, oldSpecifiedCallable, callable);
+ }
+
+ public boolean isDefaultCallable(){
+ return HibernateNamedNativeQuery.DEFAULT_CALLABLE;
+ }
+
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedNativeQueryImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQuery.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQuery.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQuery.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -11,98 +11,16 @@
package org.jboss.tools.hibernate.jpt.core.internal.context.java;
import org.eclipse.jpt.core.context.java.JavaNamedQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
*
*/
-public interface HibernateNamedQuery extends JavaNamedQuery {
+public interface HibernateNamedQuery extends JavaNamedQuery, HibernateQuery {
String HIBERNATE_NAMED_QUERY="hibernateNamedQuery"; //$NON-NLS-1$
- // **************** flushMode ***************************************************
-
- FlushModeType getFlushMode();
- FlushModeType getSpecifiedFlushMode();
- String SPECIFIED_FLUSH_MODE_PROPERTY = "specifiedFlushMode"; //$NON-NLS-1$
- FlushModeType getDefaultFlushMode();
- String DEFAULT_FLUSH_MODE_PROPERTY = "defaultFlushMode"; //$NON-NLS-1$
- FlushModeType DEFAULT_FLUSH_MODE_TYPE = FlushModeType.AUTO;
-
- void setSpecifiedFlushMode(FlushModeType flushMode);
-
- //************************ cacheMode *********************************
-
- CacheModeType getCacheMode();
- CacheModeType getSpecifiedCacheMode();
- String SPECIFIED_CACHE_MODE_PROPERTY = "specifiedCacheMode"; //$NON-NLS-1$
- CacheModeType getDefaultCacheMode();
- String DEFAULT_CACHE_MODE_PROPERTY = "defaultCacheMode"; //$NON-NLS-1$
- CacheModeType DEFAULT_CACHE_MODE_TYPE = CacheModeType.NORMAL;
-
- void setSpecifiedCacheMode(CacheModeType cacheMode);
-
- //************************ cacheable *********************************
- boolean isCacheable();
- Boolean getSpecifiedCacheable();
- void setSpecifiedCacheable(Boolean value);
- String SPECIFIED_CACHEABLE_PROPERTY = "specifiedCacheable"; //$NON-NLS-1$
-
- boolean isDefaultCacheable();
- boolean DEFAULT_CACHEABLE = false;
- String DEFAULT_CACHEABLE_PROPERTY = "defaultCacheable"; //$NON-NLS-1$
- //************************ cacheRegion *********************************
- String getCacheRegion();
- String getSpecifiedCacheRegion();
- void setSpecifiedCacheRegion(String value);
- String SPECIFIED_CACHE_REGION_PROPERTY = "specifiedCacheRegion"; //$NON-NLS-1$
-
- String getDefaultCacheRegion();
- String DEFAULT_CACHE_REGION = ""; //$NON-NLS-1$
- String DEFAULT_CACHE_REGION_PROPERTY = "defaultCacheRegion"; //$NON-NLS-1$
-
- //************************ fetchSize *********************************
- int getFetchSize();
-
- Integer getSpecifiedFetchSize();
- void setSpecifiedFetchSize(Integer value);
- String SPECIFIED_FETCH_SIZE_PROPERTY = "specifiedFetchSize"; //$NON-NLS-1$
-
- int getDefaultFetchSize();
- int DEFAULT_FETCH_SIZE = -1;
- String DEFAULT_FETCH_SIZE_PROPERTY = "defaultFetchSize"; //$NON-NLS-1$
-
- //************************ timeout *********************************
- int getTimeout();
-
- Integer getSpecifiedTimeout();
- void setSpecifiedTimeout(Integer value);
- String SPECIFIED_TIMEOUT_PROPERTY = "specifiedTimeout"; //$NON-NLS-1$
-
- int getDefaultTimeout();
- int DEFAULT_TIMEOUT = -1;
- String DEFAULT_TIMEOUT_PROPERTY = "defaultTimeout"; //$NON-NLS-1$
-
- //************************ comment *********************************
- String getComment();
- String getSpecifiedComment();
- void setSpecifiedComment(String value);
- String SPECIFIED_COMMENT_PROPERTY = "specifiedComment"; //$NON-NLS-1$
-
- String getDefaultComment();
- String DEFAULT_COMMENT = ""; //$NON-NLS-1$
- String DEFAULT_COMMENT_PROPERTY = "defaultComment"; //$NON-NLS-1$
-
- //************************ readOnly *********************************
- boolean isReadOnly();
- Boolean getSpecifiedReadOnly();
- void setSpecifiedReadOnly(Boolean value);
- String SPECIFIED_READ_ONLY_PROPERTY = "specifiedReadOnly"; //$NON-NLS-1$
-
- boolean isDefaultReadOnly();
- boolean DEFAULT_READ_ONLY = false;
- String DEFAULT_READ_ONLY_PROPERTY = "defaultReadOnly"; //$NON-NLS-1$
-
void initialize(HibernateNamedQueryAnnotation resourceNamedQuery);
void update(HibernateNamedQueryAnnotation resourceNamedQuery);
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public interface HibernateNamedQueryAnnotation extends NestableNamedQueryAnnotation {
-
- //replace with Hibernate annotation
- String ANNOTATION_NAME = Hibernate.NAMED_QUERY;
-
- //************************ flushMode *********************************
-
- /**
- * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
- * Return null if the element does not exist in Java.
- */
- FlushModeType getFlushMode();
- String FLUSH_MODE_PROPERTY = "flushMode"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
- * Set to null to remove the element.
- */
- void setFlushMode(FlushModeType flushMode);
-
- /**
- * Return the {@link TextRange} for the 'flushMode' element. If element
- * does not exist return the {@link TextRange} for the *NamedQuery annotation.
- */
- TextRange getFlushModeTextRange(CompilationUnit astRoot);
-
- //************************ cacheMode *********************************
-
- /**
- * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
- * Return null if the element does not exist in Java.
- */
- CacheModeType getCacheMode();
- String CACHE_MODE_PROPERTY = "cacheMode"; //$NON-NLS-1$
-
- /**
- * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
- * Set to null to remove the element.
- */
- void setCacheMode(CacheModeType cacheMode);
-
- /**
- * Return the {@link TextRange} for the 'cacheMode' element. If element
- * does not exist return the {@link TextRange} for the *NamedQuery annotation.
- */
- TextRange getCacheModeTextRange(CompilationUnit astRoot);
-
- //************************ cacheable *********************************
- Boolean isCacheable();
- void setCacheable(Boolean value);
- String CACHEABLE_PROPERTY = "cacheable"; //$NON-NLS-1$
-
- //************************ cacheRegion *********************************
- String getCacheRegion();
- void setCacheRegion(String value);
- String CACHE_REGION_PROPERTY = "cacheRegion"; //$NON-NLS-1$
-
- //************************ fetchSize *********************************
- Integer getFetchSize();
- void setFetchSize(Integer value);
- String FETCH_SIZE_PROPERTY = "fetchSize"; //$NON-NLS-1$
-
- //************************ timeout *********************************
- Integer getTimeout();
- void setTimeout(Integer value);
- String TIMEOUT_PROPERTY = "timeout"; //$NON-NLS-1$
-
- //************************ comment *********************************
- String getComment();
- void setComment(String value);
- String COMMENT_PROPERTY = "comment"; //$NON-NLS-1$
-
- //************************ readOnly *********************************
- Boolean isReadOnly();
- void setReadOnly(Boolean value);
- String READ_ONLY_PROPERTY = "readOnly"; //$NON-NLS-1$
-}
Deleted: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.utility.jdt.Member;
-import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-
-
-/**
- * @author Dmitry Geraskov
- *
- */
-public class HibernateNamedQueryAnnotationDefinition implements AnnotationDefinition {
-
- // singleton
- private static final AnnotationDefinition INSTANCE = new HibernateNamedQueryAnnotationDefinition();
-
- /**
- * Return the singleton.
- */
- public static AnnotationDefinition instance() {
- return INSTANCE;
- }
-
- public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
- return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, member);
- }
-
- public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
- throw new UnsupportedOperationException();
- }
-
- public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
- //TODO return new BinaryNamedQueryAnnotation(parent, jdtAnnotation);
- throw new UnsupportedOperationException();
- }
-
- public String getAnnotationName() {
- return Hibernate.NAMED_QUERY;
- }
-}
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java (from rev 16518, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateNamedQueryImpl.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryImpl.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.core.internal.context.java.GenericJavaNamedQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedQueryImpl extends GenericJavaNamedQuery
+ implements HibernateNamedQuery {
+
+ private FlushModeType specifiedFlushMode;
+
+ private CacheModeType specifiedCacheMode;
+
+ private Boolean specifiedCacheable;
+
+ private String specifiedCacheRegion;
+
+ private Integer specifiedFetchSize;
+
+ private Integer specifiedTimeout;
+
+ private String specifiedComment;
+
+ private Boolean specifiedReadOnly;
+
+ /**
+ * @param parent
+ */
+ public HibernateNamedQueryImpl(JavaJpaContextNode parent) {
+ super(parent);
+ }
+
+ public void initialize(HibernateNamedQueryAnnotation resourceQuery) {
+ this.specifiedFlushMode = this.getResourceFlushMode(resourceQuery);
+ this.specifiedCacheMode = this.getResourceCacheMode(resourceQuery);
+ this.specifiedCacheable = resourceQuery.isCacheable();
+ this.specifiedCacheRegion = resourceQuery.getCacheRegion();
+ this.specifiedFetchSize = resourceQuery.getFetchSize();
+ this.specifiedTimeout = resourceQuery.getTimeout();
+ this.specifiedComment = resourceQuery.getComment();
+ this.specifiedReadOnly = resourceQuery.isReadOnly();
+ super.initialize(resourceQuery);
+ }
+
+ public void update(HibernateNamedQueryAnnotation resourceQuery) {
+ this.setFlushMode_(resourceQuery.getFlushMode());
+ this.setCacheMode_ (resourceQuery.getCacheMode());
+ this.setSpecifiedCacheable_(resourceQuery.isCacheable());
+ this.setSpecifiedCacheRegion_(resourceQuery.getCacheRegion());
+ this.setSpecifiedFetchSize_(resourceQuery.getFetchSize());
+ this.setSpecifiedTimeout_(resourceQuery.getTimeout());
+ this.setSpecifiedComment_(resourceQuery.getComment());
+ this.setSpecifiedReadOnly_(resourceQuery.isReadOnly());
+ super.update(resourceQuery);
+ }
+
+ private CacheModeType getResourceCacheMode(HibernateNamedQueryAnnotation resourceQuery) {
+ return CacheModeType.fromJavaAnnotationValue(resourceQuery);
+ }
+
+ private FlushModeType getResourceFlushMode(HibernateNamedQueryAnnotation resourceQuery) {
+ return FlushModeType.fromJavaAnnotationValue(resourceQuery);
+ }
+
+ @Override
+ protected HibernateNamedQueryAnnotation getResourceQuery() {
+ return (HibernateNamedQueryAnnotation) super.getResourceQuery();
+ }
+
+ // ****** flushMode
+ public FlushModeType getFlushMode() {
+ return getSpecifiedFlushMode() == null ? getDefaultFlushMode() : getSpecifiedFlushMode();
+ }
+
+ public FlushModeType getSpecifiedFlushMode() {
+ return specifiedFlushMode;
+ }
+
+ public FlushModeType getDefaultFlushMode() {
+ return HibernateNamedQuery.DEFAULT_FLUSH_MODE_TYPE;
+ }
+
+ public void setSpecifiedFlushMode(FlushModeType flushMode) {
+ FlushModeType oldFlushMode = this.specifiedFlushMode;
+ this.specifiedFlushMode = flushMode;
+ getResourceQuery().setFlushMode(flushMode);
+ firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
+ }
+
+ protected void setFlushMode_(FlushModeType flushMode) {
+ FlushModeType oldFlushMode = this.specifiedFlushMode;
+ this.specifiedFlushMode = flushMode;
+ firePropertyChanged(SPECIFIED_FLUSH_MODE_PROPERTY, oldFlushMode, flushMode);
+ }
+ // ****** cacheMode
+ public CacheModeType getCacheMode() {
+ return getSpecifiedCacheMode() == null ? getDefaultCacheMode() : getSpecifiedCacheMode();
+ }
+
+ public CacheModeType getDefaultCacheMode() {
+ return HibernateNamedQuery.DEFAULT_CACHE_MODE_TYPE;
+ }
+
+ public CacheModeType getSpecifiedCacheMode() {
+ return specifiedCacheMode;
+ }
+
+ public void setSpecifiedCacheMode(CacheModeType cacheMode) {
+ CacheModeType oldCacheMode = this.specifiedCacheMode;
+ this.specifiedCacheMode = cacheMode;
+ getResourceQuery().setCacheMode(cacheMode);
+ firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
+ }
+
+ public void setCacheMode_(CacheModeType cacheMode) {
+ CacheModeType oldCacheMode = this.specifiedCacheMode;
+ this.specifiedCacheMode = cacheMode;
+ firePropertyChanged(SPECIFIED_CACHE_MODE_PROPERTY, oldCacheMode, cacheMode);
+ }
+ //************************ cacheable *********************************
+ public boolean isCacheable(){
+ return (this.getSpecifiedCacheable() == null) ? this.isDefaultCacheable()
+ : this.getSpecifiedCacheable().booleanValue();
+ }
+
+ public Boolean getSpecifiedCacheable(){
+ return this.specifiedCacheable;
+ }
+
+ public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) {
+ Boolean oldSpecifiedCacheable = this.specifiedCacheable;
+ this.specifiedCacheable = newSpecifiedCacheable;
+ this.getResourceQuery().setCacheable(newSpecifiedCacheable);
+ firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable);
+
+ }
+
+ public void setSpecifiedCacheable_(Boolean newSpecifiedCacheable) {
+ Boolean oldSpecifiedCacheable = this.specifiedCacheable;
+ this.specifiedCacheable = newSpecifiedCacheable;
+ firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable);
+ }
+
+ public boolean isDefaultCacheable() {
+ return HibernateNamedQuery.DEFAULT_CACHEABLE;
+ }
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return (getSpecifiedCacheRegion() == null ? getDefaultCacheRegion()
+ : getSpecifiedCacheRegion());
+ }
+ public String getSpecifiedCacheRegion(){
+ return this.specifiedCacheRegion;
+ }
+
+ public void setSpecifiedCacheRegion(String cacheRegion){
+ String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
+ this.specifiedCacheRegion = cacheRegion;
+ this.getResourceQuery().setCacheRegion(cacheRegion);
+ firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion, cacheRegion);
+ }
+
+ public void setSpecifiedCacheRegion_(String cacheRegion){
+ String oldSpecifiedCacheRegion = this.specifiedCacheRegion;
+ this.specifiedCacheRegion = cacheRegion;
+ firePropertyChanged(SPECIFIED_CACHE_REGION_PROPERTY, oldSpecifiedCacheRegion, cacheRegion);
+ }
+
+ public String getDefaultCacheRegion(){
+ return HibernateNamedQuery.DEFAULT_CACHE_REGION;
+ }
+ //************************ fetchSize *********************************
+ public int getFetchSize(){
+ return (getSpecifiedFetchSize() == null ? getDefaultFetchSize()
+ : getSpecifiedFetchSize().intValue());
+ }
+
+ public Integer getSpecifiedFetchSize(){
+ return this.specifiedFetchSize;
+ }
+
+ public void setSpecifiedFetchSize(Integer newSpecifiedFetchSize){
+ Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
+ this.specifiedFetchSize = newSpecifiedFetchSize;
+ this.getResourceQuery().setFetchSize(newSpecifiedFetchSize);
+ firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, newSpecifiedFetchSize);
+ }
+
+ public void setSpecifiedFetchSize_(Integer fetchSize){
+ Integer oldSpecifiedFetchSize = this.specifiedFetchSize;
+ this.specifiedFetchSize = fetchSize;
+ firePropertyChanged(SPECIFIED_FETCH_SIZE_PROPERTY, oldSpecifiedFetchSize, fetchSize);
+ }
+
+ public int getDefaultFetchSize(){
+ return HibernateNamedQuery.DEFAULT_FETCH_SIZE;
+ }
+ //************************ timeout *********************************
+ public int getTimeout(){
+ return (getSpecifiedTimeout() == null ? getDefaultTimeout()
+ : getSpecifiedTimeout().intValue());
+ }
+
+ public Integer getSpecifiedTimeout(){
+ return this.specifiedTimeout;
+ }
+
+ public void setSpecifiedTimeout(Integer newSpecifiedTimeout){
+ Integer oldSpecifiedTimeout = this.specifiedTimeout;
+ this.specifiedTimeout = newSpecifiedTimeout;
+ this.getResourceQuery().setTimeout(newSpecifiedTimeout);
+ firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, newSpecifiedTimeout);
+ }
+
+ public void setSpecifiedTimeout_(Integer timeout){
+ Integer oldSpecifiedTimeout = this.specifiedTimeout;
+ this.specifiedTimeout = timeout;
+ firePropertyChanged(SPECIFIED_TIMEOUT_PROPERTY, oldSpecifiedTimeout, timeout);
+ }
+
+ public int getDefaultTimeout(){
+ return HibernateNamedQuery.DEFAULT_TIMEOUT;
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return (getSpecifiedComment() == null ? getDefaultComment()
+ : getSpecifiedComment());
+ }
+ public String getSpecifiedComment(){
+ return this.specifiedComment;
+ }
+
+ public void setSpecifiedComment(String newSpecifiedComment){
+ String oldSpecifiedComment = this.specifiedComment;
+ this.specifiedComment = newSpecifiedComment;
+ this.getResourceQuery().setComment(newSpecifiedComment);
+ firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, newSpecifiedComment);
+ }
+
+ public void setSpecifiedComment_(String comment){
+ String oldSpecifiedComment = this.specifiedComment;
+ this.specifiedComment = comment;
+ firePropertyChanged(SPECIFIED_COMMENT_PROPERTY, oldSpecifiedComment, comment);
+ }
+
+ public String getDefaultComment(){
+ return HibernateNamedQuery.DEFAULT_COMMENT;
+ }
+
+ //************************ readOnly *********************************
+ public boolean isReadOnly(){
+ return (getSpecifiedReadOnly() == null ? isDefaultReadOnly()
+ : getSpecifiedReadOnly().booleanValue());
+ }
+
+ public Boolean getSpecifiedReadOnly(){
+ return this.specifiedReadOnly;
+ }
+
+ public void setSpecifiedReadOnly(Boolean newSpecifiedReadOnly){
+ Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
+ this.specifiedReadOnly = newSpecifiedReadOnly;
+ this.getResourceQuery().setReadOnly(newSpecifiedReadOnly);
+ firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, newSpecifiedReadOnly);
+ }
+
+ public void setSpecifiedReadOnly_(Boolean readOnly){
+ Boolean oldSpecifiedReadOnly = this.specifiedReadOnly;
+ this.specifiedReadOnly = readOnly;
+ firePropertyChanged(SPECIFIED_READ_ONLY_PROPERTY, oldSpecifiedReadOnly, readOnly);
+ }
+
+ public boolean isDefaultReadOnly(){
+ return HibernateNamedQuery.DEFAULT_READ_ONLY;
+ }
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.core.context.Query;
+import org.eclipse.jpt.utility.model.Model;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateQuery extends Query, Model {
+
+ // **************** flushMode ***************************************************
+
+ FlushModeType getFlushMode();
+ FlushModeType getSpecifiedFlushMode();
+ String SPECIFIED_FLUSH_MODE_PROPERTY = "specifiedFlushMode"; //$NON-NLS-1$
+ FlushModeType getDefaultFlushMode();
+ String DEFAULT_FLUSH_MODE_PROPERTY = "defaultFlushMode"; //$NON-NLS-1$
+ FlushModeType DEFAULT_FLUSH_MODE_TYPE = FlushModeType.AUTO;
+
+ void setSpecifiedFlushMode(FlushModeType flushMode);
+
+ //************************ cacheMode *********************************
+
+ CacheModeType getCacheMode();
+ CacheModeType getSpecifiedCacheMode();
+ String SPECIFIED_CACHE_MODE_PROPERTY = "specifiedCacheMode"; //$NON-NLS-1$
+ CacheModeType getDefaultCacheMode();
+ String DEFAULT_CACHE_MODE_PROPERTY = "defaultCacheMode"; //$NON-NLS-1$
+ CacheModeType DEFAULT_CACHE_MODE_TYPE = CacheModeType.NORMAL;
+
+ void setSpecifiedCacheMode(CacheModeType cacheMode);
+
+ //************************ cacheable *********************************
+ boolean isCacheable();
+ Boolean getSpecifiedCacheable();
+ void setSpecifiedCacheable(Boolean value);
+ String SPECIFIED_CACHEABLE_PROPERTY = "specifiedCacheable"; //$NON-NLS-1$
+
+ boolean isDefaultCacheable();
+ boolean DEFAULT_CACHEABLE = false;
+ String DEFAULT_CACHEABLE_PROPERTY = "defaultCacheable"; //$NON-NLS-1$
+
+ //************************ cacheRegion *********************************
+ String getCacheRegion();
+ String getSpecifiedCacheRegion();
+ void setSpecifiedCacheRegion(String value);
+ String SPECIFIED_CACHE_REGION_PROPERTY = "specifiedCacheRegion"; //$NON-NLS-1$
+
+ String getDefaultCacheRegion();
+ String DEFAULT_CACHE_REGION = ""; //$NON-NLS-1$
+ String DEFAULT_CACHE_REGION_PROPERTY = "defaultCacheRegion"; //$NON-NLS-1$
+
+ //************************ fetchSize *********************************
+ int getFetchSize();
+
+ Integer getSpecifiedFetchSize();
+ void setSpecifiedFetchSize(Integer value);
+ String SPECIFIED_FETCH_SIZE_PROPERTY = "specifiedFetchSize"; //$NON-NLS-1$
+
+ int getDefaultFetchSize();
+ int DEFAULT_FETCH_SIZE = -1;
+ String DEFAULT_FETCH_SIZE_PROPERTY = "defaultFetchSize"; //$NON-NLS-1$
+
+ //************************ timeout *********************************
+ int getTimeout();
+
+ Integer getSpecifiedTimeout();
+ void setSpecifiedTimeout(Integer value);
+ String SPECIFIED_TIMEOUT_PROPERTY = "specifiedTimeout"; //$NON-NLS-1$
+
+ int getDefaultTimeout();
+ int DEFAULT_TIMEOUT = -1;
+ String DEFAULT_TIMEOUT_PROPERTY = "defaultTimeout"; //$NON-NLS-1$
+
+ //************************ comment *********************************
+ String getComment();
+ String getSpecifiedComment();
+ void setSpecifiedComment(String value);
+ String SPECIFIED_COMMENT_PROPERTY = "specifiedComment"; //$NON-NLS-1$
+
+ String getDefaultComment();
+ String DEFAULT_COMMENT = ""; //$NON-NLS-1$
+ String DEFAULT_COMMENT_PROPERTY = "defaultComment"; //$NON-NLS-1$
+
+ //************************ readOnly *********************************
+ boolean isReadOnly();
+ Boolean getSpecifiedReadOnly();
+ void setSpecifiedReadOnly(Boolean value);
+ String SPECIFIED_READ_ONLY_PROPERTY = "specifiedReadOnly"; //$NON-NLS-1$
+
+ boolean isDefaultReadOnly();
+ boolean DEFAULT_READ_ONLY = false;
+ String DEFAULT_READ_ONLY_PROPERTY = "defaultReadOnly"; //$NON-NLS-1$
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQuery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.utility.TextRange;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ * Interface contains Hibernate specific attributes.
+ */
+public interface HibernateQueryAnnotation {
+
+ //************************ flushMode *********************************
+
+ /**
+ * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
+ * Return null if the element does not exist in Java.
+ */
+ FlushModeType getFlushMode();
+ String FLUSH_MODE_PROPERTY = "flushMode"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'flushMode' element of the *NamedQuery annotation.
+ * Set to null to remove the element.
+ */
+ void setFlushMode(FlushModeType flushMode);
+
+ /**
+ * Return the {@link TextRange} for the 'flushMode' element. If element
+ * does not exist return the {@link TextRange} for the *NamedQuery annotation.
+ */
+ TextRange getFlushModeTextRange(CompilationUnit astRoot);
+
+ //************************ cacheMode *********************************
+
+ /**
+ * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
+ * Return null if the element does not exist in Java.
+ */
+ CacheModeType getCacheMode();
+ String CACHE_MODE_PROPERTY = "cacheMode"; //$NON-NLS-1$
+
+ /**
+ * Corresponds to the 'cacheMode' element of the *NamedQuery annotation.
+ * Set to null to remove the element.
+ */
+ void setCacheMode(CacheModeType cacheMode);
+
+ /**
+ * Return the {@link TextRange} for the 'cacheMode' element. If element
+ * does not exist return the {@link TextRange} for the *NamedQuery annotation.
+ */
+ TextRange getCacheModeTextRange(CompilationUnit astRoot);
+
+ //************************ cacheable *********************************
+ Boolean isCacheable();
+ void setCacheable(Boolean value);
+ String CACHEABLE_PROPERTY = "cacheable"; //$NON-NLS-1$
+
+ //************************ cacheRegion *********************************
+ String getCacheRegion();
+ void setCacheRegion(String value);
+ String CACHE_REGION_PROPERTY = "cacheRegion"; //$NON-NLS-1$
+
+ //************************ fetchSize *********************************
+ Integer getFetchSize();
+ void setFetchSize(Integer value);
+ String FETCH_SIZE_PROPERTY = "fetchSize"; //$NON-NLS-1$
+
+ //************************ timeout *********************************
+ Integer getTimeout();
+ void setTimeout(Integer value);
+ String TIMEOUT_PROPERTY = "timeout"; //$NON-NLS-1$
+
+ //************************ comment *********************************
+ String getComment();
+ void setComment(String value);
+ String COMMENT_PROPERTY = "comment"; //$NON-NLS-1$
+
+ //************************ readOnly *********************************
+ Boolean isReadOnly();
+ void setReadOnly(Boolean value);
+ String READ_ONLY_PROPERTY = "readOnly"; //$NON-NLS-1$
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryContainer.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryContainer.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateQueryContainer.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -21,6 +21,8 @@
public interface HibernateQueryContainer extends QueryContainer {
String HIBERNATE_NAMED_QUERIES_LIST = "hibernateNamedQueries"; //$NON-NLS-1$
+
+ String HIBERNATE_NAMED_NATIVE_QUERIES_LIST = "hibernateNamedNativeQueries"; //$NON-NLS-1$
// ********** named queries **********
/**
@@ -53,5 +55,39 @@
* Move the named query from the source index to the target index.
*/
void moveHibernateNamedQuery(int targetIndex, int sourceIndex);
+
+ // ********** named native queries **********
+ /**
+ * Return a list iterator of the specified named native queries.
+ * This will not be null.
+ */
+ <T extends HibernateNamedNativeQuery> ListIterator<T> hibernateNamedNativeQueries();
+
+ /**
+ * Return the number of named native queries.
+ */
+ int hibernateNamedNativeQueriesSize();
+
+ /**
+ * Add a named native query to the entity return the object representing it.
+ */
+ HibernateNamedNativeQuery addHibernateNamedNativeQuery(int index);
+
+ /**
+ * Remove the named native query at the index from the entity.
+ */
+ void removeHibernateNamedNativeQuery(int index);
+
+ /**
+ * Remove the named native query at from the entity.
+ */
+ void removeHibernateNamedNativeQuery(HibernateNamedNativeQuery namedNativeQuery);
+
+ /**
+ * Move the named native query from the source index to the target index.
+ */
+ void moveHibernateNamedNativeQuery(int targetIndex, int sourceIndex);
+
+
}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,613 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.MemberIndexedAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.resource.java.NestableAnnotation;
+import org.eclipse.jpt.core.resource.java.NestableQueryHintAnnotation;
+import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
+import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateSourceNamedNativeQueryAnnotation extends SourceAnnotation<Member> implements
+ HibernateNamedNativeQueryAnnotation {
+
+ public static final SimpleDeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
+ private final AnnotationElementAdapter<String> nameAdapter;
+ private String name;
+
+ private final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter;
+ private final AnnotationElementAdapter<String> queryAdapter;
+ private String query;
+
+ private final DeclarationAnnotationElementAdapter<String> flushModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> flushModeAdapter;
+ private FlushModeType flushMode;
+
+ private final DeclarationAnnotationElementAdapter<String> cacheModeDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheModeAdapter;
+ private CacheModeType cacheMode;
+
+ private final DeclarationAnnotationElementAdapter<Boolean> cacheableDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> cacheableAdapter;
+ private Boolean cacheable;
+
+ private final DeclarationAnnotationElementAdapter<String> cacheRegionDeclarationAdapter;
+ private final AnnotationElementAdapter<String> cacheRegionAdapter;
+ private String cacheRegion;
+
+ private final DeclarationAnnotationElementAdapter<Integer> fetchSizeDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> fetchSizeAdapter;
+ private Integer fetchSize;
+
+ private final DeclarationAnnotationElementAdapter<Integer> timeoutDeclarationAdapter;
+ private final AnnotationElementAdapter<Integer> timeoutAdapter;
+ private Integer timeout;
+
+ private final DeclarationAnnotationElementAdapter<String> commentDeclarationAdapter;
+ private final AnnotationElementAdapter<String> commentAdapter;
+ private String comment;
+
+ private final DeclarationAnnotationElementAdapter<Boolean> readOnlyDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> readOnlyAdapter;
+ private Boolean readOnly;
+
+ private final DeclarationAnnotationElementAdapter<Boolean> callableDeclarationAdapter;
+ private final AnnotationElementAdapter<Boolean> callableAdapter;
+ private Boolean callable;
+
+ private final DeclarationAnnotationElementAdapter<String> resultClassDeclarationAdapter;
+ private final AnnotationElementAdapter<String> resultClassAdapter;
+ private String resultClass;
+
+ private String fullyQualifiedResultClassName;
+
+ private final DeclarationAnnotationElementAdapter<String> resultSetMappingDeclarationAdapter;
+ private final AnnotationElementAdapter<String> resultSetMappingAdapter;
+ private String resultSetMapping;
+
+ HibernateSourceNamedNativeQueryAnnotation(JavaResourceNode parent, Member member,DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
+ super(parent, member, daa, annotationAdapter);
+ this.nameDeclarationAdapter = this.buildNameAdapter(daa);
+ this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
+ this.queryDeclarationAdapter = this.buildQueryAdapter(daa);
+ this.queryAdapter = this.buildAdapter(this.queryDeclarationAdapter);
+ this.flushModeDeclarationAdapter = this.buildFlushModeAdapter(daa);
+ this.flushModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, flushModeDeclarationAdapter);
+ this.cacheModeDeclarationAdapter = this.buildCacheModeAdapter(daa);
+ this.cacheModeAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, cacheModeDeclarationAdapter);
+ this.cacheableDeclarationAdapter = this.buildCacheableAdapter(daa);
+ this.cacheableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, cacheableDeclarationAdapter);
+ this.cacheRegionDeclarationAdapter = this.buildCacheRegionAdapter(daa);
+ this.cacheRegionAdapter = this.buildAdapter(this.cacheRegionDeclarationAdapter);
+ this.fetchSizeDeclarationAdapter = this.buildFetchSizeAdapter(daa);
+ this.fetchSizeAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, fetchSizeDeclarationAdapter);
+ this.timeoutDeclarationAdapter = this.buildTimeoutAdapter(daa);
+ this.timeoutAdapter = new ShortCircuitAnnotationElementAdapter<Integer>(member, timeoutDeclarationAdapter);
+ this.commentDeclarationAdapter = this.buildCommentAdapter(daa);
+ this.commentAdapter = new ShortCircuitAnnotationElementAdapter<String>(member, commentDeclarationAdapter);
+ this.readOnlyDeclarationAdapter = this.buildReadOnlyAdapter(daa);
+ this.readOnlyAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, readOnlyDeclarationAdapter);
+ this.callableDeclarationAdapter = this.buildReadOnlyAdapter(daa);
+ this.callableAdapter = new ShortCircuitAnnotationElementAdapter<Boolean>(member, callableDeclarationAdapter);
+ this.resultClassDeclarationAdapter = this.buildResultClassAdapter(daa);
+ this.resultClassAdapter = this.buildAdapter(this.resultClassDeclarationAdapter);
+ this.resultSetMappingDeclarationAdapter = this.buildResultSetMappingAdapter(daa);
+ this.resultSetMappingAdapter = this.buildAdapter(this.resultSetMappingDeclarationAdapter);
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ this.name = this.buildName(astRoot);
+ this.query = this.buildQuery(astRoot);
+ this.flushMode = this.buildFlushMode(astRoot);
+ this.cacheMode = this.buildCacheMode(astRoot);
+ this.cacheable = this.buildCacheable(astRoot);
+ this.cacheRegion = this.buildCacheRegion(astRoot);
+ this.fetchSize = this.buildFetchSize(astRoot);
+ this.timeout = this.buildTimeout(astRoot);
+ this.comment = this.buildComment(astRoot);
+ this.readOnly = this.buildReadOnly(astRoot);
+ this.callable = this.buildCallable(astRoot);
+ this.resultClass = this.buildResultClass(astRoot);
+ this.fullyQualifiedResultClassName = this.buildFullyQualifiedResultClassName(astRoot);
+ this.resultSetMapping = this.buildResultSetMapping(astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ this.setName(this.buildName(astRoot));
+ this.setQuery(this.buildQuery(astRoot));
+ this.setFlushMode(this.buildFlushMode(astRoot));
+ this.setCacheMode(this.buildCacheMode(astRoot));
+ this.setCacheable(this.buildCacheable(astRoot));
+ this.setCacheRegion(this.buildCacheRegion(astRoot));
+ this.setFetchSize(this.buildFetchSize(astRoot));
+ this.setTimeout(this.buildTimeout(astRoot));
+ this.setComment(this.buildComment(astRoot));
+ this.setReadOnly(this.buildReadOnly(astRoot));
+ this.setCallable(this.buildCallable(astRoot));
+ this.setResultClass(this.buildResultClass(astRoot));
+ this.setFullyQualifiedResultClassName(this.buildFullyQualifiedResultClassName(astRoot));
+ this.setResultSetMapping(this.buildResultSetMapping(astRoot));
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ /**
+ * convenience method
+ */
+ AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) {
+ return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea);
+ }
+
+ // ********** BaseNamedNativeQueryAnnotation implementation **********
+
+ // ***** name
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ if (this.attributeValueHasNotChanged(this.name, name)) {
+ return;
+ }
+ String old = this.name;
+ this.name = name;
+ this.nameAdapter.setValue(name);
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ private String buildName(CompilationUnit astRoot) {
+ return this.nameAdapter.getValue(astRoot);
+ }
+
+ public TextRange getNameTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.nameDeclarationAdapter, astRoot);
+ }
+
+ // ***** query
+ public String getQuery() {
+ return this.query;
+ }
+
+ public void setQuery(String query) {
+ if (this.attributeValueHasNotChanged(this.query, query)) {
+ return;
+ }
+ String old = this.query;
+ this.query = query;
+ this.queryAdapter.setValue(query);
+ this.firePropertyChanged(QUERY_PROPERTY, old, query);
+ }
+
+ private String buildQuery(CompilationUnit astRoot) {
+ return this.queryAdapter.getValue(astRoot);
+ }
+
+ public TextRange getQueryTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.queryDeclarationAdapter, astRoot);
+ }
+
+ String getQueryElementName() {
+ return Hibernate.NAMED_NATIVE_QUERY__QUERY;
+ }
+
+ // ***** hints
+ public ListIterator<QueryHintAnnotation> hints() {
+ return EmptyListIterator.instance();
+ }
+
+ ListIterator<NestableQueryHintAnnotation> nestableHints() {
+ return EmptyListIterator.instance();
+ }
+
+ public int hintsSize() {
+ return 0;
+ }
+
+ public NestableQueryHintAnnotation hintAt(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public int indexOfHint(QueryHintAnnotation queryHint) {
+ return -1;
+ }
+
+ public NestableQueryHintAnnotation addHint(int index) {
+ return null;
+ }
+
+ public void moveHint(int targetIndex, int sourceIndex) {
+ //AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.hintsContainer);
+ }
+
+ public void removeHint(int index) {
+ //AnnotationContainerTools.removeNestedAnnotation(index, this.hintsContainer);
+ }
+
+ // ******************** HibernateNamedNativeQueryAnnotation implementation *************
+ // ***** flushMode
+
+ public FlushModeType getFlushMode() {
+ return flushMode;
+ }
+
+ public void setFlushMode(FlushModeType flushMode) {
+ if (this.attributeValueHasNotChanged(this.flushMode, flushMode)) {
+ return;
+ }
+ FlushModeType old = this.flushMode;
+ this.flushMode = flushMode;
+ this.flushModeAdapter.setValue(FlushModeType.toJavaAnnotationValue(flushMode));
+ this.firePropertyChanged(FLUSH_MODE_PROPERTY, old, flushMode);
+ }
+
+ private FlushModeType buildFlushMode(CompilationUnit astRoot) {
+ return FlushModeType.fromJavaAnnotationValue(this.flushModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getFlushModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(flushModeDeclarationAdapter, astRoot);
+ }
+
+ // ***** caheMode
+
+ public CacheModeType getCacheMode() {
+ return cacheMode;
+ }
+
+ public void setCacheMode(CacheModeType cacheMode) {
+ if (this.attributeValueHasNotChanged(this.cacheMode, cacheMode)) {
+ return;
+ }
+ CacheModeType old = this.cacheMode;
+ this.cacheMode = cacheMode;
+ this.cacheModeAdapter.setValue(CacheModeType.toJavaAnnotationValue(cacheMode));
+ this.firePropertyChanged(CACHE_MODE_PROPERTY, old, cacheMode);
+ }
+
+ private CacheModeType buildCacheMode(CompilationUnit astRoot) {
+ return CacheModeType.fromJavaAnnotationValue(this.cacheModeAdapter.getValue(astRoot));
+ }
+
+ public TextRange getCacheModeTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(cacheModeDeclarationAdapter, astRoot);
+ }
+
+ //************************ cacheable *********************************
+ public Boolean isCacheable(){
+ return this.cacheable;
+ }
+
+ public void setCacheable(Boolean cacheable){
+ if (this.attributeValueHasNotChanged(this.cacheable, cacheable)) {
+ return;
+ }
+ Boolean old = this.cacheable;
+ this.cacheable = cacheable;
+ this.cacheableAdapter.setValue(cacheable);
+ this.firePropertyChanged(CACHEABLE_PROPERTY, old, cacheable);
+ }
+
+ private Boolean buildCacheable(CompilationUnit astRoot) {
+ return this.cacheableAdapter.getValue(astRoot);
+ }
+
+ //************************ cacheRegion *********************************
+ public String getCacheRegion(){
+ return this.cacheRegion;
+ }
+
+ public void setCacheRegion(String cacheRegion){
+ if (this.attributeValueHasNotChanged(this.cacheRegion, cacheRegion)) {
+ return;
+ }
+ String old = this.cacheRegion;
+ this.cacheRegion = cacheRegion;
+ this.cacheRegionAdapter.setValue(cacheRegion);
+ this.firePropertyChanged(CACHE_REGION_PROPERTY, old, cacheRegion);
+ }
+
+ private String buildCacheRegion(CompilationUnit astRoot) {
+ return this.cacheRegionAdapter.getValue(astRoot);
+ }
+ //************************ fetchSize *********************************
+ public Integer getFetchSize(){
+ return this.fetchSize;
+ }
+
+ public void setFetchSize(Integer fetchSize){
+ if (this.attributeValueHasNotChanged(this.fetchSize, fetchSize)) {
+ return;
+ }
+ Integer old = this.fetchSize;
+ this.fetchSize = fetchSize;
+ this.fetchSizeAdapter.setValue(fetchSize);
+ this.firePropertyChanged(FETCH_SIZE_PROPERTY, old, fetchSize);
+ }
+
+ private Integer buildFetchSize(CompilationUnit astRoot) {
+ return this.fetchSizeAdapter.getValue(astRoot);
+ }
+ //************************ timeout *********************************
+ public Integer getTimeout(){
+ return this.timeout;
+ }
+ public void setTimeout(Integer timeout){
+ if (this.attributeValueHasNotChanged(this.timeout, timeout)) {
+ return;
+ }
+ Integer old = this.timeout;
+ this.timeout = timeout;
+ this.timeoutAdapter.setValue(timeout);
+ this.firePropertyChanged(TIMEOUT_PROPERTY, old, timeout);
+ }
+
+ private Integer buildTimeout(CompilationUnit astRoot) {
+ return this.timeoutAdapter.getValue(astRoot);
+ }
+ //************************ comment *********************************
+ public String getComment(){
+ return this.comment;
+ }
+
+ public void setComment(String comment){
+ if (this.attributeValueHasNotChanged(this.comment, comment)) {
+ return;
+ }
+ String old = this.comment;
+ this.comment = comment;
+ this.commentAdapter.setValue(comment);
+ this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
+ }
+
+ private String buildComment(CompilationUnit astRoot) {
+ return this.commentAdapter.getValue(astRoot);
+ }
+ //************************ readOnly *********************************
+ public Boolean isReadOnly(){
+ return this.readOnly;
+ }
+
+ public void setReadOnly(Boolean readOnly){
+ if (this.attributeValueHasNotChanged(this.readOnly, readOnly)) {
+ return;
+ }
+ Boolean old = this.readOnly;
+ this.readOnly = readOnly;
+ this.readOnlyAdapter.setValue(readOnly);
+ this.firePropertyChanged(READ_ONLY_PROPERTY, old, readOnly);
+ }
+
+ private Boolean buildReadOnly(CompilationUnit astRoot) {
+ return this.readOnlyAdapter.getValue(astRoot);
+ }
+ //************************ callable *********************************
+ public Boolean isCallable(){
+ return this.callable;
+ }
+
+ public void setCallable(Boolean callable){
+ if (this.attributeValueHasNotChanged(this.callable, callable)) {
+ return;
+ }
+ Boolean old = this.callable;
+ this.callable = callable;
+ this.callableAdapter.setValue(callable);
+ this.firePropertyChanged(CALLABLE_PROPERTY, old, callable);
+ }
+
+ private Boolean buildCallable(CompilationUnit astRoot) {
+ return this.callableAdapter.getValue(astRoot);
+ }
+ // ***** result class
+ public String getResultClass() {
+ return this.resultClass;
+ }
+
+ public void setResultClass(String resultClass) {
+ if (this.attributeValueHasNotChanged(this.resultClass, resultClass)) {
+ return;
+ }
+ String old = this.resultClass;
+ this.resultClass = resultClass;
+ this.resultClassAdapter.setValue(resultClass);
+ this.firePropertyChanged(RESULT_CLASS_PROPERTY, old, resultClass);
+ }
+
+ private String buildResultClass(CompilationUnit astRoot) {
+ return this.resultClassAdapter.getValue(astRoot);
+ }
+
+ public TextRange getResultClassTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.resultClassDeclarationAdapter, astRoot);
+ }
+
+ // ***** fully-qualified result class name
+ public String getFullyQualifiedResultClassName() {
+ return this.fullyQualifiedResultClassName;
+ }
+
+ private void setFullyQualifiedResultClassName(String name) {
+ String old = this.fullyQualifiedResultClassName;
+ this.fullyQualifiedResultClassName = name;
+ this.firePropertyChanged(FULLY_QUALIFIED_RESULT_CLASS_NAME_PROPERTY, old, name);
+ }
+
+ private String buildFullyQualifiedResultClassName(CompilationUnit astRoot) {
+ return (this.resultClass == null) ? null : JDTTools.resolveFullyQualifiedName(this.resultClassAdapter.getExpression(astRoot));
+ }
+
+ // ***** result set mapping
+ public String getResultSetMapping() {
+ return this.resultSetMapping;
+ }
+
+ public void setResultSetMapping(String resultSetMapping) {
+ if (this.attributeValueHasNotChanged(this.resultSetMapping, resultSetMapping)) {
+ return;
+ }
+ String old = this.resultSetMapping;
+ this.resultSetMapping = resultSetMapping;
+ this.resultSetMappingAdapter.setValue(resultSetMapping);
+ this.firePropertyChanged(RESULT_SET_MAPPING_PROPERTY, old, resultSetMapping);
+ }
+
+ private String buildResultSetMapping(CompilationUnit astRoot) {
+ return this.resultSetMappingAdapter.getValue(astRoot);
+ }
+
+ public TextRange getResultSetMappingTextRange(CompilationUnit astRoot) {
+ return this.getElementTextRange(this.resultSetMappingDeclarationAdapter, astRoot);
+ }
+ // ********** NestableAnnotation implementation **********
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void initializeFrom(NestableAnnotation oldAnnotation) {
+ HibernateSourceNamedNativeQueryAnnotation oldQuery = (HibernateSourceNamedNativeQueryAnnotation) oldAnnotation;
+ this.setName(oldQuery.getName());
+ this.setQuery(oldQuery.getQuery());
+ this.setFlushMode(oldQuery.getFlushMode());
+ this.setCacheMode(oldQuery.getCacheMode());
+ this.setCacheable(oldQuery.isCacheable());
+ this.setComment(oldQuery.getComment());
+ this.setFetchSize(oldQuery.getFetchSize());
+ this.setTimeout(oldQuery.getTimeout());
+ this.setCacheRegion(oldQuery.getCacheRegion());
+ this.setReadOnly(oldQuery.isReadOnly());
+ this.setCallable(oldQuery.isCallable());
+ this.setResultClass(oldQuery.getResultClass());
+ this.setResultSetMapping(oldQuery.getResultSetMapping());
+ }
+
+ /**
+ * convenience implementation of method from NestableAnnotation interface
+ * for subclasses
+ */
+ public void moveAnnotation(int newIndex) {
+ this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
+ }
+
+ private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
+ return (IndexedAnnotationAdapter) this.annotationAdapter;
+ }
+
+ public static HibernateNamedNativeQueryAnnotation createNamedNativeQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildNameAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__NAME);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildQueryAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__QUERY);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildFlushModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_NATIVE_QUERY__FLUSH_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCacheModeAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new EnumDeclarationAnnotationElementAdapter(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHE_MODE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean> buildCacheableAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHEABLE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCacheRegionAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CACHE_REGION);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer> buildFetchSizeAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_NATIVE_QUERY__FETCH_SIZE);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Integer> buildTimeoutAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forNumbers(daAdapter, Hibernate.NAMED_NATIVE_QUERY__TIMEOUT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<String> buildCommentAdapter(DeclarationAnnotationAdapter daAdapter){
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__COMMENT);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean> buildReadOnlyAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__READ_ONLY);
+ }
+
+ protected DeclarationAnnotationElementAdapter<Boolean> buildCallableAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forBooleans(daAdapter, Hibernate.NAMED_NATIVE_QUERY__CALLABLE);
+ }
+
+
+ private DeclarationAnnotationElementAdapter<String> buildResultClassAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return new ConversionDeclarationAnnotationElementAdapter<String>(daAdapter, Hibernate.NAMED_NATIVE_QUERY__RESULT_CLASS, SimpleTypeStringExpressionConverter.instance());
+ }
+
+ private DeclarationAnnotationElementAdapter<String> buildResultSetMappingAdapter(DeclarationAnnotationAdapter daAdapter) {
+ return ConversionDeclarationAnnotationElementAdapter.forStrings(daAdapter, Hibernate.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+
+ // ********** static methods **********
+
+ public static HibernateSourceNamedNativeQueryAnnotation createHibernateNamedNativeQuery(JavaResourceNode parent, Member member) {
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new MemberAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER));
+ }
+
+ public static HibernateSourceNamedNativeQueryAnnotation createNestedHibernateNamedNativeQuery(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
+ IndexedDeclarationAnnotationAdapter idaa = buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
+ IndexedAnnotationAdapter annotationAdapter = new MemberIndexedAnnotationAdapter(member, idaa);
+ return new HibernateSourceNamedNativeQueryAnnotation(parent, member, idaa, annotationAdapter);
+ }
+
+ private static IndexedDeclarationAnnotationAdapter buildNestedHibernateDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter hibernateNamedNativeQueriesAdapter) {
+ return new NestedIndexedDeclarationAnnotationAdapter(hibernateNamedNativeQueriesAdapter, index, Hibernate.NAMED_NATIVE_QUERY);
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedNativeQueryAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateSourceNamedQueryAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -35,6 +35,7 @@
import org.eclipse.jpt.core.utility.jdt.Member;
import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jpt.core.resource.java.ContainerAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernateNamedNativeQueriesAnnotation extends
+ ContainerAnnotation<HibernateNamedNativeQueryAnnotation> {
+
+ String ANNOTATION_NAME = Hibernate.NAMED_NATIVE_QUERIES;
+
+ String HIBERNATE_NAMED_NATIVE_QUERIES_LIST = "hibernateNamedNativeQueries"; //$NON-NLS-1$
+
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.Member;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedNativeQueriesAnnotationDefinition implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new HibernateNamedNativeQueriesAnnotationDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Ensure single instance.
+ */
+ private HibernateNamedNativeQueriesAnnotationDefinition() {
+ super();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return new HibernateSourceNamedNativeQueriesAnnotation(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return HibernateNamedNativeQueriesAnnotation.ANNOTATION_NAME;
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedNativeQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedNativeQueryAnnotationDefinition implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new HibernateNamedNativeQueryAnnotationDefinition();
+
+ /**
+ * Ensure single instance.
+ */
+ private HibernateNamedNativeQueryAnnotationDefinition() {
+ super();
+ }
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return HibernateSourceNamedNativeQueryAnnotation.createNamedNativeQuery(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ //TODO return new HibernateBinaryNamedQueryAnnotation(parent, jdtAnnotation);
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return Hibernate.NAMED_NATIVE_QUERY;
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotation.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -12,7 +12,6 @@
import org.eclipse.jpt.core.resource.java.ContainerAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryAnnotation;
/**
* @author Dmitry Geraskov
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java (from rev 16518, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotation.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ * Corresponds to the Hibernate annotation
+ * org.hibernate.annotations.NamedQuery
+ */
+public interface HibernateNamedQueryAnnotation extends NestableNamedQueryAnnotation,
+HibernateQueryAnnotation {
+ //replace with Hibernate annotation
+ String ANNOTATION_NAME = Hibernate.NAMED_QUERY;
+}
Copied: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java (from rev 16282, trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateNamedQueryAnnotationDefinition.java)
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jpt.core.resource.java.Annotation;
+import org.eclipse.jpt.core.resource.java.AnnotationDefinition;
+import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedQueryAnnotation;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedQueryAnnotationDefinition implements AnnotationDefinition {
+
+ // singleton
+ private static final AnnotationDefinition INSTANCE = new HibernateNamedQueryAnnotationDefinition();
+
+
+ /**
+ * Ensure single instance.
+ */
+ private HibernateNamedQueryAnnotationDefinition() {
+ super();
+ }
+
+ /**
+ * Return the singleton.
+ */
+ public static AnnotationDefinition instance() {
+ return INSTANCE;
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, Member member) {
+ return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, member);
+ }
+
+ public Annotation buildNullAnnotation(JavaResourcePersistentMember parent) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Annotation buildAnnotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) {
+ //TODO return new BinaryNamedQueryAnnotation(parent, jdtAnnotation);
+ throw new UnsupportedOperationException();
+ }
+
+ public String getAnnotationName() {
+ return Hibernate.NAMED_QUERY;
+ }
+}
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.core.internal.resource.java;
+
+import java.util.ListIterator;
+import java.util.Vector;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools;
+import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation;
+import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.resource.java.JavaResourceNode;
+import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter;
+import org.eclipse.jpt.core.utility.jdt.Member;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryAnnotation;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedNativeQueryAnnotation;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateSourceNamedNativeQueriesAnnotation extends SourceAnnotation<Member> implements
+ HibernateNamedNativeQueriesAnnotation {
+
+ public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
+
+ private final Vector<HibernateNamedNativeQueryAnnotation> hibernateNamedNativeQueries = new Vector<HibernateNamedNativeQueryAnnotation>();
+
+
+ public HibernateSourceNamedNativeQueriesAnnotation(JavaResourceNode parent, Member member) {
+ super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
+ }
+
+ public String getAnnotationName() {
+ return ANNOTATION_NAME;
+ }
+
+ public void initialize(CompilationUnit astRoot) {
+ AnnotationContainerTools.initialize(this, astRoot);
+ }
+
+ public void update(CompilationUnit astRoot) {
+ AnnotationContainerTools.update(this, astRoot);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.hibernateNamedNativeQueries);
+ }
+
+ // ********** AnnotationContainer implementation **********
+
+ public String getContainerAnnotationName() {
+ return this.getAnnotationName();
+ }
+
+ public org.eclipse.jdt.core.dom.Annotation getContainerJdtAnnotation(CompilationUnit astRoot) {
+ return this.getJdtAnnotation(astRoot);
+ }
+
+ public String getElementName() {
+ return Hibernate.NAMED_NATIVE_QUERIES__VALUE;
+ }
+
+ public String getNestableAnnotationName() {
+ return HibernateNamedNativeQueryAnnotation.ANNOTATION_NAME;
+ }
+
+ public ListIterator<HibernateNamedNativeQueryAnnotation> nestedAnnotations() {
+ return new CloneListIterator<HibernateNamedNativeQueryAnnotation>(this.hibernateNamedNativeQueries);
+ }
+
+ public int nestedAnnotationsSize() {
+ return this.hibernateNamedNativeQueries.size();
+ }
+
+ public HibernateNamedNativeQueryAnnotation addNestedAnnotationInternal() {
+ HibernateNamedNativeQueryAnnotation namedQuery = this.buildHibernateNamedNativeQuery(this.hibernateNamedNativeQueries.size());
+ this.hibernateNamedNativeQueries.add(namedQuery);
+ return namedQuery;
+ }
+
+ private HibernateNamedNativeQueryAnnotation buildHibernateNamedNativeQuery(int index) {
+ return HibernateSourceNamedNativeQueryAnnotation.createNestedHibernateNamedNativeQuery(this, member, index, this.daa);
+ }
+
+ public void nestedAnnotationAdded(int index, HibernateNamedNativeQueryAnnotation nestedAnnotation) {
+ this.fireItemAdded(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, nestedAnnotation);
+ }
+
+ public HibernateNamedNativeQueryAnnotation moveNestedAnnotationInternal(int targetIndex, int sourceIndex) {
+ return CollectionTools.move(this.hibernateNamedNativeQueries, targetIndex, sourceIndex).get(targetIndex);
+ }
+
+ public void nestedAnnotationMoved(int targetIndex, int sourceIndex) {
+ this.fireItemMoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, targetIndex, sourceIndex);
+ }
+
+ public HibernateNamedNativeQueryAnnotation removeNestedAnnotationInternal(int index) {
+ return this.hibernateNamedNativeQueries.remove(index);
+ }
+
+ public void nestedAnnotationRemoved(int index, HibernateNamedNativeQueryAnnotation nestedAnnotation) {
+ this.fireItemRemoved(HIBERNATE_NAMED_NATIVE_QUERIES_LIST, index, nestedAnnotation);
+ }
+
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -23,7 +23,6 @@
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateSourceNamedQueryAnnotation;
/**
@@ -115,5 +114,4 @@
this.fireItemRemoved(HIBERNATE_NAMED_QUERIES_LIST, index, nestedAnnotation);
}
-
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/java/details/HibernateJavaEntityComposite.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -14,8 +14,10 @@
import org.eclipse.jpt.ui.WidgetFactory;
import org.eclipse.jpt.ui.internal.java.details.JavaEntityComposite;
import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryContainer;
import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateGeneratorsComposite;
import org.jboss.tools.hibernate.jpt.ui.internal.mapping.details.HibernateQueriesComposite;
@@ -35,6 +37,7 @@
super(subjectHolder, parent, widgetFactory);
}
+ @SuppressWarnings("unchecked")
@Override
protected void initializeQueriesPane(Composite container) {
container = addCollapsableSection(
@@ -42,7 +45,7 @@
JptUiMappingsMessages.EntityComposite_queries
);
- new HibernateQueriesComposite(this, container);
+ new HibernateQueriesComposite((Pane<? extends HibernateQueryContainer>) this, container);
}
@Override
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateAddQueryDialog.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -29,6 +29,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
/**
@@ -136,7 +137,7 @@
queryTypes.add(Query.NAMED_QUERY);
queryTypes.add(Query.NAMED_NATIVE_QUERY);
queryTypes.add(HibernateNamedQuery.HIBERNATE_NAMED_QUERY);
-
+ queryTypes.add(HibernateNamedNativeQuery.HIBERNATE_NAMED_NATIVE_QUERY);
return new StaticListValueModel<String>(queryTypes);
}
@@ -152,6 +153,9 @@
if (value == HibernateNamedQuery.HIBERNATE_NAMED_QUERY) {
return HibernateUIMappingMessages.HibernateAddQueryDialog_hibernateNamedQuery;
}
+ if (value == HibernateNamedNativeQuery.HIBERNATE_NAMED_NATIVE_QUERY) {
+ return HibernateUIMappingMessages.HibernateAddQueryDialog_hibernateNamedNativeQuery;
+ }
return value;
}
};
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
+
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.widgets.ClassChooserPane;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateNamedNativeQueryPropertyComposite extends
+ HibernateQueryPropertyComposite<HibernateNamedNativeQuery> {
+
+ private ClassChooserPane<HibernateNamedNativeQuery> resultClassChooserPane;
+
+ /**
+ * Creates a new <code>HibernateNamedNativeQueryPropertyComposite</code>.
+ *
+ * @param parentPane The parent container of this one
+ * @param subjectHolder The holder of this pane's subject
+ * @param parent The parent container
+ */
+ public HibernateNamedNativeQueryPropertyComposite(Pane<?> parentPane,
+ PropertyValueModel<? extends HibernateNamedNativeQuery> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent);
+ }
+
+ private ClassChooserPane<HibernateNamedNativeQuery> addClassChooser(Composite container) {
+
+ return new ClassChooserPane<HibernateNamedNativeQuery>(this, container) {
+
+ @Override
+ protected WritablePropertyValueModel<String> buildTextHolder() {
+ return new PropertyAspectAdapter<HibernateNamedNativeQuery, String>(getSubjectHolder(), HibernateNamedNativeQuery.RESULT_CLASS_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getResultClass();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ this.subject.setResultClass(value);
+ }
+ };
+ }
+
+ @Override
+ protected String getClassName() {
+ return getSubject().getResultClass();
+ }
+
+ @Override
+ protected String getLabelText() {
+ return JptUiMappingsMessages.NamedNativeQueryPropertyComposite_resultClass;
+ }
+
+ @Override
+ protected JpaProject getJpaProject() {
+ return getSubject().getJpaProject();
+ }
+
+ @Override
+ protected void setClassName(String className) {
+ getSubject().setResultClass(className);
+ }
+
+ @Override
+ protected char getEnclosingTypeSeparator() {
+ return getSubject().getResultClassEnclosingTypeSeparator();
+ }
+ };
+ }
+
+
+ @Override
+ public void enableWidgets(boolean enabled) {
+ super.enableWidgets(enabled);
+ this.resultClassChooserPane.enableWidgets(enabled);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ super.initializeLayout(container);
+
+ // Result class chooser
+ this.resultClassChooserPane = addClassChooser(container);
+
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedNativeQueryPropertyComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedQueryPropertyComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedQueryPropertyComposite.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateNamedQueryPropertyComposite.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -10,33 +10,16 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
-import java.util.Collection;
-
-import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
-import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
-import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
import org.eclipse.jpt.ui.internal.widgets.Pane;
-import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
-import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
/**
* @author Dmitry Geraskov
*
*/
-public class HibernateNamedQueryPropertyComposite extends Pane<HibernateNamedQuery> {
+public class HibernateNamedQueryPropertyComposite extends HibernateQueryPropertyComposite<HibernateNamedQuery> {
/**
* Creates a new <code>HibernateNamedQueryPropertyComposite</code>.
@@ -52,439 +35,4 @@
super(parentPane, subjectHolder, parent);
}
- @Override
- protected void initializeLayout(Composite container) {
-
- addLabeledText(
- container,
- JptUiMappingsMessages.NamedQueryComposite_nameTextLabel,
- buildNameTextHolder());
-
- // Query text area
- addLabeledMultiLineText(
- container,
- JptUiMappingsMessages.NamedQueryPropertyComposite_query,
- buildQueryHolder(),
- 4,
- null
- );
-
- // ReadOnly tri-state check box
- addTriStateCheckBoxWithDefault(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnly,
- buildReadOnlyHolder(),
- buildReadOnlyStringHolder(),
- null//TODO help
- );
-
- //Flush Mode combobox
- addLabeledComposite(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_flushMode,
- addFlushModeTypeCombo(container),
- null//TODO help
- );
-
- // Cacheable tri-state check box
- addTriStateCheckBoxWithDefault(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheable,
- buildCacheableHolder(),
- buildCacheableStringHolder(),
- null//TODO help
- );
-
- //Cache Mode combobox
- addLabeledComposite(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheMode,
- addCacheModeTypeCombo(container),
- null//TODO help
- );
-
- addLabeledText(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheRegion,
- buildCacheRegionTextHolder());
-
- // Fetch size widgets
- Spinner fetchSizeSpinner = addLabeledSpinner(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_fetchSize,
- buildFetchSizeHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultFetchSizeLabel(container),
- JpaHelpContextIds.MAPPING_COLUMN_LENGTH
- );
-
- updateGridData(container, fetchSizeSpinner);
-
- // Timeout size widgets
- Spinner timeoutSpinner = addLabeledSpinner(
- container,
- HibernateUIMappingMessages.NamedQueryPropertyComposite_timeout,
- buildTimeoutHolder(),
- -1,
- -1,
- Integer.MAX_VALUE,
- addDefaultFetchSizeLabel(container),
- JpaHelpContextIds.MAPPING_COLUMN_LENGTH
- );
-
- updateGridData(container, timeoutSpinner);
-
- }
-
- private Control addDefaultFetchSizeLabel(Composite container) {
-
- Label label = addLabel(
- container,
- JptUiMappingsMessages.DefaultEmpty
- );
-
- new LabeledControlUpdater(
- new LabeledLabel(label),
- buildDefaultFetchSizeLabelHolder()
- );
-
- return label;
- }
-
- private PropertyValueModel<String> buildDefaultFetchSizeLabelHolder() {
-
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultFetchSizeHolder()) {
-
- @Override
- protected String transform(Integer value) {
-
- int defaultValue = (getSubject() != null) ? getSubject().getDefaultFetchSize() :
- HibernateNamedQuery.DEFAULT_FETCH_SIZE;
-
- return NLS.bind(
- JptUiMappingsMessages.DefaultWithOneParam,
- Integer.valueOf(defaultValue)
- );
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildDefaultFetchSizeHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, Integer>(getSubjectHolder(), HibernateNamedQuery.DEFAULT_FETCH_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return Integer.valueOf(this.subject.getDefaultFetchSize());
- }
-
- @Override
- protected synchronized void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Integer.MIN_VALUE, newValue);
- }
- }
- };
- }
-
- protected WritablePropertyValueModel<String> buildNameTextHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, String>(
- getSubjectHolder(), HibernateNamedQuery.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- this.subject.setName(value);
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildQueryHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, String>(getSubjectHolder(), HibernateNamedQuery.QUERY_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getQuery();
- }
-
- @Override
- protected void setValue_(String value) {
- this.subject.setQuery(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildCacheableHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, Boolean>(
- getSubjectHolder(),
- HibernateNamedQuery.DEFAULT_CACHEABLE_PROPERTY,
- HibernateNamedQuery.SPECIFIED_CACHEABLE_PROPERTY)
- {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSpecifiedCacheable();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setSpecifiedCacheable(value);
- }
-
- @Override
- protected synchronized void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildCacheableStringHolder() {
-
- return new TransformationPropertyValueModel<Boolean, String>(buildCacheableHolder()) {
-
- @Override
- protected String transform(Boolean value) {
-
- if ((getSubject() != null) && (value == null)) {
- boolean defaultValue = getSubject().isDefaultCacheable();
-
- String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
- JptUiMappingsMessages.Boolean_False;
-
- return NLS.bind(
- HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheableWithDefault,
- defaultStringValue
- );
- }
-
- return HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheable;
- }
- };
- }
-
- private WritablePropertyValueModel<Boolean> buildReadOnlyHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, Boolean>(
- getSubjectHolder(),
- HibernateNamedQuery.DEFAULT_READ_ONLY_PROPERTY,
- HibernateNamedQuery.SPECIFIED_READ_ONLY_PROPERTY)
- {
- @Override
- protected Boolean buildValue_() {
- return this.subject.getSpecifiedReadOnly();
- }
-
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setSpecifiedReadOnly(value);
- }
-
- @Override
- protected synchronized void subjectChanged() {
- Object oldValue = this.getValue();
- super.subjectChanged();
- Object newValue = this.getValue();
-
- // Make sure the default value is appended to the text
- if (oldValue == newValue && newValue == null) {
- this.fireAspectChange(Boolean.TRUE, newValue);
- }
- }
- };
- }
-
- private PropertyValueModel<String> buildReadOnlyStringHolder() {
-
- return new TransformationPropertyValueModel<Boolean, String>(buildReadOnlyHolder()) {
-
- @Override
- protected String transform(Boolean value) {
-
- if ((getSubject() != null) && (value == null)) {
- boolean defaultValue = getSubject().isDefaultReadOnly();
-
- String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
- JptUiMappingsMessages.Boolean_False;
-
- return NLS.bind(
- HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnlyWithDefault,
- defaultStringValue
- );
- }
-
- return HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnly;
- }
- };
- }
-
- private EnumFormComboViewer<HibernateNamedQuery, FlushModeType> addFlushModeTypeCombo(Composite container) {
-
- return new EnumFormComboViewer<HibernateNamedQuery, FlushModeType>(this, container) {
-
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(HibernateNamedQuery.DEFAULT_FLUSH_MODE_PROPERTY);
- propertyNames.add(HibernateNamedQuery.SPECIFIED_FLUSH_MODE_PROPERTY);
- }
-
- @Override
- protected FlushModeType[] getChoices() {
- return FlushModeType.values();
- }
-
- @Override
- protected FlushModeType getDefaultValue() {
- return getSubject().getDefaultFlushMode();
- }
-
- @Override
- protected String displayString(FlushModeType value) {
- return value.toString();
-
- }
-
- @Override
- protected FlushModeType getValue() {
- return getSubject().getSpecifiedFlushMode();
- }
-
- @Override
- protected void setValue(FlushModeType value) {
- getSubject().setSpecifiedFlushMode(value);
- }
- };
- }
-
- private EnumFormComboViewer<HibernateNamedQuery, CacheModeType> addCacheModeTypeCombo(Composite container) {
-
- return new EnumFormComboViewer<HibernateNamedQuery, CacheModeType>(this, container) {
-
- @Override
- protected void addPropertyNames(Collection<String> propertyNames) {
- super.addPropertyNames(propertyNames);
- propertyNames.add(HibernateNamedQuery.DEFAULT_CACHE_MODE_PROPERTY);
- propertyNames.add(HibernateNamedQuery.SPECIFIED_CACHE_MODE_PROPERTY);
- }
-
- @Override
- protected CacheModeType[] getChoices() {
- return CacheModeType.values();
- }
-
- @Override
- protected CacheModeType getDefaultValue() {
- return getSubject().getDefaultCacheMode();
- }
-
- @Override
- protected String displayString(CacheModeType value) {
- return value.toString();
-
- }
-
- @Override
- protected CacheModeType getValue() {
- return getSubject().getSpecifiedCacheMode();
- }
-
- @Override
- protected void setValue(CacheModeType value) {
- getSubject().setSpecifiedCacheMode(value);
- }
- };
- }
-
- private WritablePropertyValueModel<String> buildCacheRegionTextHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, String>(
- getSubjectHolder(),
- HibernateNamedQuery.DEFAULT_CACHE_REGION_PROPERTY,
- HibernateNamedQuery.SPECIFIED_CACHE_REGION_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getSpecifiedCacheRegion();
- }
-
- @Override
- protected void setValue_(String value) {
- if (value.length() == 0) {
- value = null;
- }
- this.subject.setSpecifiedCacheRegion(value);
- }
- };
- }
-
- private WritablePropertyValueModel<Integer> buildFetchSizeHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, Integer>(getSubjectHolder(), HibernateNamedQuery.SPECIFIED_FETCH_SIZE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedFetchSize();
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value.intValue() == -1) {
- value = null;
- }
- this.subject.setSpecifiedFetchSize(value);
- }
- };
- }
-
-
-
- private WritablePropertyValueModel<Integer> buildTimeoutHolder() {
- return new PropertyAspectAdapter<HibernateNamedQuery, Integer>(getSubjectHolder(), HibernateNamedQuery.SPECIFIED_TIMEOUT_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return this.subject.getSpecifiedTimeout();
- }
-
- @Override
- protected void setValue_(Integer value) {
- if (value.intValue() == -1) {
- value = null;
- }
- this.subject.setSpecifiedTimeout(value);
- }
- };
- }
-
- private void updateGridData(Composite container, Spinner spinner) {
-
- // It is possible the spinner's parent is not the container of the
- // label, spinner and right control (a pane is sometimes required for
- // painting the spinner's border)
- Composite paneContainer = spinner.getParent();
-
- while (container != paneContainer.getParent()) {
- paneContainer = paneContainer.getParent();
- }
-
- Control[] controls = paneContainer.getChildren();
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.BEGINNING;
- controls[1].setLayoutData(gridData);
-
- controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- removeAlignRight(controls[2]);
- }
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java 2009-07-13 08:56:40 UTC (rev 16543)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueriesComposite.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -46,6 +46,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.part.PageBook;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQueryContainer;
@@ -53,12 +54,13 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateQueriesComposite extends Pane<QueryContainer> {
+public class HibernateQueriesComposite extends Pane<HibernateQueryContainer> {
private AddRemoveListPane<QueryContainer> listPane;
private NamedNativeQueryPropertyComposite namedNativeQueryPane;
private NamedQueryPropertyComposite namedQueryPane;
private HibernateNamedQueryPropertyComposite hibernateNamedQueryPane;
+ private HibernateNamedNativeQueryPropertyComposite hibernateNamedNativeQueryPane;
private WritablePropertyValueModel<Query> queryHolder;
/**
@@ -67,7 +69,7 @@
* @param parentPane The parent controller of this one
* @param parent The parent container
*/
- public HibernateQueriesComposite(Pane<? extends QueryContainer> parentPane,
+ public HibernateQueriesComposite(Pane<? extends HibernateQueryContainer> parentPane,
Composite parent) {
super(parentPane, parent, false);
@@ -87,16 +89,18 @@
}
String queryType = hibernateAddQueryDialog.getQueryType();
Query query;
- HibernateQueryContainer subj = (HibernateQueryContainer)this.getSubject();
if (queryType == Query.NAMED_QUERY) {
query = this.getSubject().addNamedQuery(getSubject().namedQueriesSize());
}
else if (queryType == Query.NAMED_NATIVE_QUERY) {
- query = subj.addNamedNativeQuery(subj.namedNativeQueriesSize());
+ query = this.getSubject().addNamedNativeQuery(this.getSubject().namedNativeQueriesSize());
}
else if (queryType == HibernateNamedQuery.HIBERNATE_NAMED_QUERY) {
- query = subj.addHibernateNamedQuery(subj.hibernateNamedQueriesSize());
+ query = this.getSubject().addHibernateNamedQuery(this.getSubject().hibernateNamedQueriesSize());
}
+ else if (queryType == HibernateNamedNativeQuery.HIBERNATE_NAMED_NATIVE_QUERY) {
+ query = this.getSubject().addHibernateNamedNativeQuery(this.getSubject().hibernateNamedNativeQueriesSize());
+ }
else {
throw new IllegalArgumentException();
}
@@ -166,7 +170,24 @@
}
};
}
+
+ private ListValueModel<HibernateNamedNativeQuery> buildHibernateNamedNativeQueriesListHolder() {
+ return new ListAspectAdapter<QueryContainer, HibernateNamedNativeQuery>(
+ getSubjectHolder(),
+ HibernateQueryContainer.HIBERNATE_NAMED_NATIVE_QUERIES_LIST)
+ {
+ @Override
+ protected ListIterator<HibernateNamedNativeQuery> listIterator_() {
+ return ((HibernateQueryContainer)this.subject).hibernateNamedNativeQueries();
+ }
+ @Override
+ protected int size_() {
+ return ((HibernateQueryContainer)this.subject).hibernateNamedNativeQueriesSize();
+ }
+ };
+ }
+
private ListValueModel<NamedQuery> buildNamedQueriesListHolder() {
return new ListAspectAdapter<QueryContainer, NamedQuery>(
getSubjectHolder(),
@@ -201,6 +222,15 @@
}
};
}
+
+ private PropertyValueModel<HibernateNamedNativeQuery> buildHibernateNamedNativeQueryHolder() {
+ return new TransformationPropertyValueModel<Query, HibernateNamedNativeQuery>(this.queryHolder) {
+ @Override
+ protected HibernateNamedNativeQuery transform_(Query value) {
+ return (value instanceof HibernateNamedNativeQuery) ? (HibernateNamedNativeQuery) value : null;
+ }
+ };
+ }
private Transformer<Query, Control> buildPaneTransformer() {
return new Transformer<Query, Control>() {
@@ -213,6 +243,10 @@
if (query instanceof HibernateNamedQuery) {
return HibernateQueriesComposite.this.hibernateNamedQueryPane.getControl();
}
+
+ if (query instanceof HibernateNamedNativeQuery){
+ return HibernateQueriesComposite.this.hibernateNamedNativeQueryPane.getControl();
+ }
if (query instanceof NamedNativeQuery) {
return HibernateQueriesComposite.this.namedNativeQueryPane.getControl();
@@ -234,7 +268,9 @@
public void removeSelectedItems(ObjectListSelectionModel listSelectionModel) {
for (Object item : listSelectionModel.selectedValues()) {
if (item instanceof HibernateNamedQuery) {
- ((HibernateQueryContainer)getSubject()).removeHibernateNamedQuery((HibernateNamedQuery)item);
+ getSubject().removeHibernateNamedQuery((HibernateNamedQuery)item);
+ } else if (item instanceof HibernateNamedNativeQuery) {
+ getSubject().removeHibernateNamedNativeQuery((HibernateNamedNativeQuery)item);
} else if (item instanceof NamedQuery) {
getSubject().removeNamedQuery((NamedQuery) item);
} else {
@@ -248,6 +284,7 @@
private ListValueModel<Query> buildQueriesListHolder() {
List<ListValueModel<? extends Query>> list = new ArrayList<ListValueModel<? extends Query>>();
list.add(buildHibernateNamedQueriesListHolder());
+ list.add(buildHibernateNamedNativeQueriesListHolder());
list.add(buildNamedQueriesListHolder());
list.add(buildNamedNativeQueriesListHolder());
return new CompositeListValueModel<ListValueModel<? extends Query>, Query>(list);
@@ -264,7 +301,9 @@
int index = -1;
if (query instanceof HibernateNamedQuery) {
- index = CollectionTools.indexOf(((HibernateQueryContainer)getSubject()).hibernateNamedQueries(), query);
+ index = CollectionTools.indexOf(getSubject().hibernateNamedQueries(), query);
+ } else if (query instanceof HibernateNamedNativeQuery) {
+ index = CollectionTools.indexOf(getSubject().hibernateNamedNativeQueries(), query);
} else if (query instanceof NamedQuery) {
index = CollectionTools.indexOf(getSubject().namedQueries(), query);
} else {
@@ -305,13 +344,20 @@
PageBook pageBook = new PageBook(container, SWT.NULL);
pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // Named Query property pane
+ // Hibernate Named Query property pane
this.hibernateNamedQueryPane = new HibernateNamedQueryPropertyComposite(
this,
buildHibernateNamedQueryHolder(),
pageBook
);
+ // Hibernate Named Native Query property pane
+ this.hibernateNamedNativeQueryPane = new HibernateNamedNativeQueryPropertyComposite(
+ this,
+ buildHibernateNamedNativeQueryHolder(),
+ pageBook
+ );
+
// Named Query property pane
this.namedQueryPane = new NamedQueryPropertyComposite(
this,
Added: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java (rev 0)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java 2009-07-13 10:17:39 UTC (rev 16544)
@@ -0,0 +1,485 @@
+/*******************************************************************************
+ * 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.jboss.tools.hibernate.jpt.ui.internal.mapping.details;
+
+import java.util.Collection;
+
+import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
+import org.eclipse.jpt.ui.internal.mappings.JptUiMappingsMessages;
+import org.eclipse.jpt.ui.internal.util.LabeledControlUpdater;
+import org.eclipse.jpt.ui.internal.util.LabeledLabel;
+import org.eclipse.jpt.ui.internal.widgets.EnumFormComboViewer;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
+import org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.utility.internal.model.value.TransformationPropertyValueModel;
+import org.eclipse.jpt.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.CacheModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.FlushModeType;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQuery;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateQuery;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateQueryPropertyComposite<T extends HibernateQuery> extends Pane<T> {
+
+ public HibernateQueryPropertyComposite(Pane<?> parentPane,
+ PropertyValueModel<? extends T> subjectHolder,
+ Composite parent) {
+
+ super(parentPane, subjectHolder, parent);
+ }
+
+ @Override
+ protected void initializeLayout(Composite container) {
+
+ addLabeledText(
+ container,
+ JptUiMappingsMessages.NamedQueryComposite_nameTextLabel,
+ buildNameTextHolder());
+
+ // Query text area
+ addLabeledMultiLineText(
+ container,
+ JptUiMappingsMessages.NamedQueryPropertyComposite_query,
+ buildQueryHolder(),
+ 4,
+ null
+ );
+
+ // ReadOnly tri-state check box
+ addTriStateCheckBoxWithDefault(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnly,
+ buildReadOnlyHolder(),
+ buildReadOnlyStringHolder(),
+ null//TODO help
+ );
+
+ //Flush Mode combobox
+ addLabeledComposite(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_flushMode,
+ addFlushModeTypeCombo(container),
+ null//TODO help
+ );
+
+ // Cacheable tri-state check box
+ addTriStateCheckBoxWithDefault(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheable,
+ buildCacheableHolder(),
+ buildCacheableStringHolder(),
+ null//TODO help
+ );
+
+ //Cache Mode combobox
+ addLabeledComposite(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheMode,
+ addCacheModeTypeCombo(container),
+ null//TODO help
+ );
+
+ addLabeledText(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheRegion,
+ buildCacheRegionTextHolder());
+
+ // Fetch size widgets
+ Spinner fetchSizeSpinner = addLabeledSpinner(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_fetchSize,
+ buildFetchSizeHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ addDefaultFetchSizeLabel(container),
+ JpaHelpContextIds.MAPPING_COLUMN_LENGTH
+ );
+
+ updateGridData(container, fetchSizeSpinner);
+
+ // Timeout size widgets
+ Spinner timeoutSpinner = addLabeledSpinner(
+ container,
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_timeout,
+ buildTimeoutHolder(),
+ -1,
+ -1,
+ Integer.MAX_VALUE,
+ addDefaultFetchSizeLabel(container),
+ JpaHelpContextIds.MAPPING_COLUMN_LENGTH
+ );
+
+ updateGridData(container, timeoutSpinner);
+
+ }
+
+ private Control addDefaultFetchSizeLabel(Composite container) {
+
+ Label label = addLabel(
+ container,
+ JptUiMappingsMessages.DefaultEmpty
+ );
+
+ new LabeledControlUpdater(
+ new LabeledLabel(label),
+ buildDefaultFetchSizeLabelHolder()
+ );
+
+ return label;
+ }
+
+ private PropertyValueModel<String> buildDefaultFetchSizeLabelHolder() {
+
+ return new TransformationPropertyValueModel<Integer, String>(buildDefaultFetchSizeHolder()) {
+
+ @Override
+ protected String transform(Integer value) {
+
+ int defaultValue = (getSubject() != null) ? getSubject().getDefaultFetchSize() :
+ HibernateNamedQuery.DEFAULT_FETCH_SIZE;
+
+ return NLS.bind(
+ JptUiMappingsMessages.DefaultWithOneParam,
+ Integer.valueOf(defaultValue)
+ );
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Integer> buildDefaultFetchSizeHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Integer>(getSubjectHolder(), HibernateQuery.DEFAULT_FETCH_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return Integer.valueOf(this.subject.getDefaultFetchSize());
+ }
+
+ @Override
+ protected synchronized void subjectChanged() {
+ Object oldValue = this.getValue();
+ super.subjectChanged();
+ Object newValue = this.getValue();
+
+ // Make sure the default value is appended to the text
+ if (oldValue == newValue && newValue == null) {
+ this.fireAspectChange(Integer.MIN_VALUE, newValue);
+ }
+ }
+ };
+ }
+
+ protected WritablePropertyValueModel<String> buildNameTextHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, String>(
+ getSubjectHolder(), HibernateQuery.NAME_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getName();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ this.subject.setName(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildQueryHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, String>(getSubjectHolder(), HibernateQuery.QUERY_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getQuery();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ this.subject.setQuery(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildCacheableHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Boolean>(
+ getSubjectHolder(),
+ HibernateQuery.DEFAULT_CACHEABLE_PROPERTY,
+ HibernateQuery.SPECIFIED_CACHEABLE_PROPERTY)
+ {
+ @Override
+ protected Boolean buildValue_() {
+ return this.subject.getSpecifiedCacheable();
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ this.subject.setSpecifiedCacheable(value);
+ }
+
+ @Override
+ protected synchronized void subjectChanged() {
+ Object oldValue = this.getValue();
+ super.subjectChanged();
+ Object newValue = this.getValue();
+
+ // Make sure the default value is appended to the text
+ if (oldValue == newValue && newValue == null) {
+ this.fireAspectChange(Boolean.TRUE, newValue);
+ }
+ }
+ };
+ }
+
+ private PropertyValueModel<String> buildCacheableStringHolder() {
+
+ return new TransformationPropertyValueModel<Boolean, String>(buildCacheableHolder()) {
+
+ @Override
+ protected String transform(Boolean value) {
+
+ if ((getSubject() != null) && (value == null)) {
+ boolean defaultValue = getSubject().isDefaultCacheable();
+
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
+
+ return NLS.bind(
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheableWithDefault,
+ defaultStringValue
+ );
+ }
+
+ return HibernateUIMappingMessages.NamedQueryPropertyComposite_cacheable;
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Boolean> buildReadOnlyHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Boolean>(
+ getSubjectHolder(),
+ HibernateQuery.DEFAULT_READ_ONLY_PROPERTY,
+ HibernateQuery.SPECIFIED_READ_ONLY_PROPERTY)
+ {
+ @Override
+ protected Boolean buildValue_() {
+ return this.subject.getSpecifiedReadOnly();
+ }
+
+ @Override
+ protected void setValue_(Boolean value) {
+ this.subject.setSpecifiedReadOnly(value);
+ }
+
+ @Override
+ protected synchronized void subjectChanged() {
+ Object oldValue = this.getValue();
+ super.subjectChanged();
+ Object newValue = this.getValue();
+
+ // Make sure the default value is appended to the text
+ if (oldValue == newValue && newValue == null) {
+ this.fireAspectChange(Boolean.TRUE, newValue);
+ }
+ }
+ };
+ }
+
+ private PropertyValueModel<String> buildReadOnlyStringHolder() {
+
+ return new TransformationPropertyValueModel<Boolean, String>(buildReadOnlyHolder()) {
+
+ @Override
+ protected String transform(Boolean value) {
+
+ if ((getSubject() != null) && (value == null)) {
+ boolean defaultValue = getSubject().isDefaultReadOnly();
+
+ String defaultStringValue = defaultValue ? JptUiMappingsMessages.Boolean_True :
+ JptUiMappingsMessages.Boolean_False;
+
+ return NLS.bind(
+ HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnlyWithDefault,
+ defaultStringValue
+ );
+ }
+
+ return HibernateUIMappingMessages.NamedQueryPropertyComposite_readOnly;
+ }
+ };
+ }
+
+ private EnumFormComboViewer<HibernateQuery, FlushModeType> addFlushModeTypeCombo(Composite container) {
+
+ return new EnumFormComboViewer<HibernateQuery, FlushModeType>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(HibernateQuery.DEFAULT_FLUSH_MODE_PROPERTY);
+ propertyNames.add(HibernateQuery.SPECIFIED_FLUSH_MODE_PROPERTY);
+ }
+
+ @Override
+ protected FlushModeType[] getChoices() {
+ return FlushModeType.values();
+ }
+
+ @Override
+ protected FlushModeType getDefaultValue() {
+ return getSubject().getDefaultFlushMode();
+ }
+
+ @Override
+ protected String displayString(FlushModeType value) {
+ return value.toString();
+
+ }
+
+ @Override
+ protected FlushModeType getValue() {
+ return getSubject().getSpecifiedFlushMode();
+ }
+
+ @Override
+ protected void setValue(FlushModeType value) {
+ getSubject().setSpecifiedFlushMode(value);
+ }
+ };
+ }
+
+ private EnumFormComboViewer<HibernateQuery, CacheModeType> addCacheModeTypeCombo(Composite container) {
+
+ return new EnumFormComboViewer<HibernateQuery, CacheModeType>(this, container) {
+
+ @Override
+ protected void addPropertyNames(Collection<String> propertyNames) {
+ super.addPropertyNames(propertyNames);
+ propertyNames.add(HibernateQuery.DEFAULT_CACHE_MODE_PROPERTY);
+ propertyNames.add(HibernateQuery.SPECIFIED_CACHE_MODE_PROPERTY);
+ }
+
+ @Override
+ protected CacheModeType[] getChoices() {
+ return CacheModeType.values();
+ }
+
+ @Override
+ protected CacheModeType getDefaultValue() {
+ return getSubject().getDefaultCacheMode();
+ }
+
+ @Override
+ protected String displayString(CacheModeType value) {
+ return value.toString();
+
+ }
+
+ @Override
+ protected CacheModeType getValue() {
+ return getSubject().getSpecifiedCacheMode();
+ }
+
+ @Override
+ protected void setValue(CacheModeType value) {
+ getSubject().setSpecifiedCacheMode(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<String> buildCacheRegionTextHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, String>(
+ getSubjectHolder(),
+ HibernateQuery.DEFAULT_CACHE_REGION_PROPERTY,
+ HibernateQuery.SPECIFIED_CACHE_REGION_PROPERTY) {
+ @Override
+ protected String buildValue_() {
+ return this.subject.getSpecifiedCacheRegion();
+ }
+
+ @Override
+ protected void setValue_(String value) {
+ if (value.length() == 0) {
+ value = null;
+ }
+ this.subject.setSpecifiedCacheRegion(value);
+ }
+ };
+ }
+
+ private WritablePropertyValueModel<Integer> buildFetchSizeHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Integer>(getSubjectHolder(), HibernateQuery.SPECIFIED_FETCH_SIZE_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedFetchSize();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ if (value.intValue() == -1) {
+ value = null;
+ }
+ this.subject.setSpecifiedFetchSize(value);
+ }
+ };
+ }
+
+
+
+ private WritablePropertyValueModel<Integer> buildTimeoutHolder() {
+ return new PropertyAspectAdapter<HibernateQuery, Integer>(getSubjectHolder(), HibernateQuery.SPECIFIED_TIMEOUT_PROPERTY) {
+ @Override
+ protected Integer buildValue_() {
+ return this.subject.getSpecifiedTimeout();
+ }
+
+ @Override
+ protected void setValue_(Integer value) {
+ if (value.intValue() == -1) {
+ value = null;
+ }
+ this.subject.setSpecifiedTimeout(value);
+ }
+ };
+ }
+
+ protected void updateGridData(Composite container, Spinner spinner) {
+
+ // It is possible the spinner's parent is not the container of the
+ // label, spinner and right control (a pane is sometimes required for
+ // painting the spinner's border)
+ Composite paneContainer = spinner.getParent();
+
+ while (container != paneContainer.getParent()) {
+ paneContainer = paneContainer.getParent();
+ }
+
+ Control[] controls = paneContainer.getChildren();
+
+ GridData gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = false;
+ gridData.horizontalAlignment = GridData.BEGINNING;
+ controls[1].setLayoutData(gridData);
+
+ controls[2].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ removeAlignRight(controls[2]);
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/mapping/details/HibernateQueryPropertyComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
16 years, 9 months