Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2012-04-03 11:35:18 -0400
committerbvosburgh2012-04-03 11:35:18 -0400
commitb7e53c0b7bf55ba278e9b63f8b232ac45c89c049 (patch)
treec35cf00f59e367de5128938eeefc8e87a4d38e44
parente37fe558e61f33ed18c7a38c268b995d984b8f9d (diff)
downloadwebtools.dali-b7e53c0b7bf55ba278e9b63f8b232ac45c89c049.tar.gz
webtools.dali-b7e53c0b7bf55ba278e9b63f8b232ac45c89c049.tar.xz
webtools.dali-b7e53c0b7bf55ba278e9b63f8b232ac45c89c049.zip
[353149] metadata conversion UI
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/WorkspaceRunnableAdapter.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/RunnableWithProgressAdapter.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java144
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_core.properties10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptCoreMessages.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java84
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedNativeQuery.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java27
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedNativeQuery.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_jpa_eclipselink_core.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/JptJpaEclipseLinkCorePlugin.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java255
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptJpaEclipseLinkCoreMessages.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkObjectTypeConverter.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/JavaConverterConversionHandler.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/JpaJavaConverterMetadataConversionHandler.java)11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/AbstractEclipseLinkJpaPlatformUi.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink1_0JpaPlatformUi.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink2_0JpaPlatformUi.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaConverterMetadataConvertor.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaGeneratorMetadataConvertor.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaQueryMetadataConvertor.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EmbeddedEclipseLinkMappingFileWizard.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/SelectEclipseLinkMappingFileDialog.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/SelectEcliplseLinkMappingFileDialog.java)19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaConverterConversionWizardPage.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaGeneratorConversionWizardPage.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaMetadataConversionWizardPage.java130
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaQueryConversionWizardPage.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaConverterMetadataConversionWizard.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaConverterMetadataConversionWizardPage.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGeneratorMetadataConversionWizard.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGlobalMetadataConversionWizard.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGlobalMetadataConversionWizardPage.java113
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaQueryMetadataConversionWizard.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaQueryMetadataConversionWizardPage.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/gen/DynamicDefaultTableGenerationWizardPage.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties47
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java57
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AbstractJavaMetadataConversionHandler.java93
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AbstractJpaJavaMetadataConversionHandler.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JavaGeneratorConversionHandler.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JpaJavaQueryMetadataConversionHandler.java)10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JavaQueryConversionHandler.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JpaJavaGeneratorMetadataConversionHandler.java)12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractJpaJavaGlobalMetadataConvertor.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractJpaPlatformUi.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/BaseJpaPlatformUi.java)55
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/GenericJpaJavaGeneratorMetadataConvertor.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/GenericJpaJavaQueryMetadataConvertor.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUi.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizardPage.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJPAProjectWizardPage.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectMappingFileDialog.java (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java)30
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaGeneratorConversionWizardPage.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaMetadataConversionWizardPage.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaQueryConversionWizardPage.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGeneratorMetadataConversionWizard.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGeneratorMetadataConversionWizardPage.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGlobalMetadataConversionWizard.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGlobalMetadataConversionWizardPage.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaQueryMetadataConversionWizard.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaQueryMetadataConversionWizardPage.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JavaMetadataConversionWizard.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JavaMetadataConversionWizardPage.java625
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JpaJavaGlobalMetadataConversionWizard.java144
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JpaJavaGlobalMetadataConversionWizardPage.java422
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityClassWizardPage.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/EmbeddedMappingFileWizard.java35
82 files changed, 1946 insertions, 2253 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/WorkspaceRunnableAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/WorkspaceRunnableAdapter.java
new file mode 100644
index 0000000000..2958fe42aa
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/WorkspaceRunnableAdapter.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.core.internal.utility;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+
+/**
+ * Convenience implementation of {@link IWorkspaceRunnable}.
+ */
+public class WorkspaceRunnableAdapter
+ implements IWorkspaceRunnable
+{
+ public void run(IProgressMonitor monitor) throws CoreException {
+ // NOP
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/RunnableWithProgressAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/RunnableWithProgressAdapter.java
new file mode 100644
index 0000000000..c32a0fa584
--- /dev/null
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/RunnableWithProgressAdapter.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.common.ui.internal.jface;
+
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+
+/**
+ * Convenience implementation of {@link IRunnableWithProgress}.
+ */
+public class RunnableWithProgressAdapter
+ implements IRunnableWithProgress
+{
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ // NOP
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java
index accfe6bd28..eaa395c23d 100644
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java
+++ b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java
@@ -17,6 +17,7 @@ import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
@@ -24,7 +25,6 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.widgets.ScrolledForm;
@@ -43,7 +43,7 @@ public class SWTUtil {
* @see #execute(Runnable)
*/
public static void asyncExec(Runnable runnable) {
- getStandardDisplay().asyncExec(runnable);
+ getDisplay().asyncExec(runnable);
}
/**
@@ -53,7 +53,7 @@ public class SWTUtil {
* @see #execute(Runnable)
*/
public static void syncExec(Runnable runnable) {
- getStandardDisplay().syncExec(runnable);
+ getDisplay().syncExec(runnable);
}
/**
@@ -72,7 +72,7 @@ public class SWTUtil {
* @see #execute(Runnable)
*/
public static void timerExec(int milliseconds, Runnable runnable) {
- getStandardDisplay().timerExec(milliseconds, runnable);
+ getDisplay().timerExec(milliseconds, runnable);
}
/**
@@ -153,21 +153,6 @@ public class SWTUtil {
}
/**
- * Tweaks the given <code>Combo</code> to remove the default value when the
- * widget receives the focus and to show the default when the widget loses
- * the focus.
- *
- * @param combo The widget having a default value that is always at the
- * beginning of the list
- */
- public static void attachDefaultValueHandler(Combo combo) {
- ComboHandler handler = new ComboHandler();
- combo.addFocusListener(handler);
- combo.addModifyListener(handler);
- }
-
-
- /**
* Convenience method for getting the current shell. If the current thread is
* not the UI thread, then an invalid thread access exception will be thrown.
*
@@ -175,27 +160,131 @@ public class SWTUtil {
*/
public static Shell getShell() {
// Retrieve the active shell, which can be the shell from any window
- Shell shell = getStandardDisplay().getActiveShell();
+ Shell shell = getDisplay().getActiveShell();
if (shell != null) {
return shell;
}
// No shell could be found, revert back to the active workbench window
- shell = getWorkbench().getActiveWorkbenchWindow().getShell();
+ shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
return (shell != null) ? shell : new Shell();
}
/**
- * Return the "standard" {@link Display display}. Return the
+ * Return the most appropriate {@link Display display}; i.e. return the
* {@link Display#getCurrent() display associated with the current thread}
* if it is present; otherwise return the
* {@link Display#getDefault() default display}.
*/
- public static Display getStandardDisplay() {
+ public static Display getDisplay() {
Display display = Display.getCurrent();
return (display != null) ? display : Display.getDefault();
}
+ /**
+ * Center the specified shell within its display.
+ * <p>
+ * <strong>NB:</strong> This will not look too good on a dual monitor system.
+ */
+ public static void center(Shell shell) {
+ shell.setBounds(calculateCenteredBounds(shell.getBounds(), shell.getDisplay().getBounds()));
+ }
+
+ /**
+ * Center the specified shell within the specified parent shell.
+ */
+ public static void center(Shell shell, Shell parentShell) {
+ shell.setBounds(calculateCenteredBounds(shell.getBounds(), parentShell.getBounds()));
+ }
+
+ /**
+ * Calculate the bounds (within the second specified rectangle's coordinate
+ * system) that would center the first specified rectangle
+ * with respect to the second specified rectangle.
+ */
+ public static Rectangle calculateCenteredBounds(Rectangle rectangle1, Rectangle rectangle2) {
+ return calculateCenteredBounds(rectangle1.width, rectangle1.height, rectangle2.x, rectangle2.y, rectangle2.width, rectangle2.height);
+ }
+
+ /**
+ * Calculate the bounds (within the second specified rectangle's coordinate
+ * system) that would center the first specified rectangle
+ * with respect to the second specified rectangle.
+ */
+ public static Rectangle calculateCenteredBounds(Point size1, Point size2) {
+ return calculateCenteredBounds(size1.x, size1.y, size2.x, size2.y);
+ }
+
+ /**
+ * Calculate the point (within the second specified rectangle's coordinate
+ * system) that would center the first specified rectangle
+ * with respect to the second specified rectangle.
+ */
+ public static Rectangle calculateCenteredBounds(int width1, int height1, int width2, int height2) {
+ return calculateCenteredBounds(width1, height1, 0, 0, width2, height2);
+ }
+
+
+ /**
+ * Calculate the point (within the second specified rectangle's coordinate
+ * system) that would center the first specified rectangle
+ * with respect to the second specified rectangle.
+ */
+ public static Rectangle calculateCenteredBounds(int width1, int height1, int x2, int y2, int width2, int height2) {
+ return new Rectangle(x2 + ((width2 - width1) / 2), y2 + ((height2 - height1) / 2), width1, height1);
+ }
+
+ /**
+ * Calculate the point (within the second specified rectangle's coordinate
+ * system) that would center the first specified rectangle
+ * with respect to the second specified rectangle.
+ */
+ public static Point calculateCenteredPosition(Rectangle rectangle1, Rectangle rectangle2) {
+ return calculateCenteredPosition(rectangle1.width, rectangle1.height, rectangle2.x, rectangle2.y, rectangle2.width, rectangle2.height);
+ }
+
+ /**
+ * Calculate the point (within the second specified rectangle's coordinate
+ * system) that would center the first specified rectangle
+ * with respect to the second specified rectangle.
+ */
+ public static Point calculateCenteredPosition(Point size1, Point size2) {
+ return calculateCenteredPosition(size1.x, size1.y, size2.x, size2.y);
+ }
+
+ /**
+ * Calculate the point (within the second specified rectangle's coordinate
+ * system) that would center the first specified rectangle
+ * with respect to the second specified rectangle.
+ */
+ public static Point calculateCenteredPosition(int width1, int height1, int width2, int height2) {
+ return calculateCenteredPosition(width1, height1, 0, 0, width2, height2);
+ }
+
+ /**
+ * Calculate the point (within the second specified rectangle's coordinate
+ * system) that would center the first specified rectangle
+ * with respect to the second specified rectangle.
+ */
+ public static Point calculateCenteredPosition(int width1, int height1, int x2, int y2, int width2, int height2) {
+ return new Point(x2 + ((width2 - width1) / 2), y2 + ((height2 - height1) / 2));
+ }
+
+ /**
+ * Tweaks the given <code>Combo</code> to remove the default value when the
+ * widget receives the focus and to show the default when the widget loses
+ * the focus.
+ *
+ * @param combo The widget having a default value that is always at the
+ * beginning of the list
+ */
+ public static void attachDefaultValueHandler(Combo combo) {
+ ComboHandler handler = new ComboHandler();
+ combo.addFocusListener(handler);
+ combo.addModifyListener(handler);
+ }
+
+
public static int getTableHeightHint(Table table, int rows) {
if (table.getFont().equals(JFaceResources.getDefaultFont()))
table.setFont(JFaceResources.getDialogFont());
@@ -205,15 +294,6 @@ public class SWTUtil {
return result;
}
- /**
- * Returns the Platform UI workbench.
- *
- * @return The workbench for this plug-in
- */
- public static IWorkbench getWorkbench() {
- return PlatformUI.getWorkbench();
- }
-
/**
* Relays out the parents of the <code>Control</code>. This was taken from
* the widget <code>Section</code>.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_core.properties b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_core.properties
index aecaa3f292..cf3229a74a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_core.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpa_core.properties
@@ -57,8 +57,8 @@ PLATFORM_ID_DOES_NOT_EXIST=No JPA platform exists for the id: ''{0}''. The JPA p
PREFERENCES_FLUSH_JOB_NAME=Flush Preferences: {0}
OSGI_BUNDLES_LIBRARY_VALIDATOR__BUNDLE_NOT_FOUND=The bundle ''{0}'' could not be found.
OSGI_BUNDLES_LIBRARY_VALIDATOR__IMPROPER_BUNDLE_VERSION=The version of bundle ''{0}'' does not meet platform requirements.
-JPA_METADATA_CONVERSION_CONVERTING=Converting in progress...
-JPA_METADATA_CONVERSION_CONVERT_GENERATOR=Converting JPA Java generator ''{0}''
-JPA_METADATA_CONVERSION_CONVERT_QUERY=Converting JPA Java query ''{0}''
-JPA_METADATA_CONVERSION_OPERATION_CANCELED=JPA metadata conversion operation canceled: check for malformated metadata.
-JPA_METADATA_CONVERSION_OPERATION_COMPLETE=Conversion Completed. Open the mapping file... \ No newline at end of file
+JAVA_METADATA_CONVERSION_IN_PROGRESS=Java metadata conversion in progress...
+JAVA_METADATA_CONVERSION_CONVERT_GENERATOR=Converting Java generator ''{0}''
+JAVA_METADATA_CONVERSION_CONVERT_QUERY=Converting Java query ''{0}''
+JAVA_METADATA_CONVERSION_CANCELED=Java metadata conversion operation canceled. Check for inconsistent metadata.
+JAVA_METADATA_CONVERSION_COMPLETE=Java metadata conversion complete. Open the mapping file...
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptCoreMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptCoreMessages.java
index b05cf8e435..55172de479 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptCoreMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/JptCoreMessages.java
@@ -16,7 +16,12 @@ import org.eclipse.osgi.util.NLS;
*/
// TODO bjv rename...
public class JptCoreMessages {
-
+ private static final String BUNDLE_NAME = "jpa_core"; //$NON-NLS-1$
+ private static final Class<?> BUNDLE_CLASS = JptCoreMessages.class;
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
+ }
+
public static String NONE;
public static String BUILD_JPA_PROJECTS_JOB_NAME;
@@ -66,17 +71,11 @@ public class JptCoreMessages {
public static String PREFERENCES_FLUSH_JOB_NAME;
public static String OSGI_BUNDLES_LIBRARY_VALIDATOR__BUNDLE_NOT_FOUND;
public static String OSGI_BUNDLES_LIBRARY_VALIDATOR__IMPROPER_BUNDLE_VERSION;
- public static String JPA_METADATA_CONVERSION_CONVERTING;
- public static String JPA_METADATA_CONVERSION_CONVERT_GENERATOR;
- public static String JPA_METADATA_CONVERSION_CONVERT_QUERY;
- public static String JPA_METADATA_CONVERSION_OPERATION_CANCELED;
- public static String JPA_METADATA_CONVERSION_OPERATION_COMPLETE;
-
- private static final String BUNDLE_NAME = "jpa_core"; //$NON-NLS-1$
- private static final Class<?> BUNDLE_CLASS = JptCoreMessages.class;
- static {
- NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
- }
+ public static String JAVA_METADATA_CONVERSION_IN_PROGRESS;
+ public static String JAVA_METADATA_CONVERSION_CONVERT_GENERATOR;
+ public static String JAVA_METADATA_CONVERSION_CONVERT_QUERY;
+ public static String JAVA_METADATA_CONVERSION_CANCELED;
+ public static String JAVA_METADATA_CONVERSION_COMPLETE;
private JptCoreMessages() {
throw new UnsupportedOperationException();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java
index c5a43be97f..591de582cc 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java
@@ -191,7 +191,7 @@ public abstract class AbstractJavaGenerator<A extends GeneratorAnnotation>
public boolean isEquivalentTo(JpaNamedContextNode node) {
return (this != node) &&
(this.getType() == node.getType()) &&
- this.isEquivalentTo((Generator)node);
+ this.isEquivalentTo((Generator) node);
}
protected boolean isEquivalentTo(Generator generator) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java
index 98d92f3d5b..9c0e210eab 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java
@@ -9,9 +9,11 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.context.java;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
@@ -43,7 +45,7 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation>
protected String query;
- protected final ContextListContainer<JavaQueryHint, QueryHintAnnotation> queryHintContainer;
+ protected final ContextListContainer<JavaQueryHint, QueryHintAnnotation> hintContainer;
protected AbstractJavaQuery(JavaJpaContextNode parent, A queryAnnotation) {
@@ -51,7 +53,7 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation>
this.queryAnnotation = queryAnnotation;
this.name = queryAnnotation.getName();
this.query = queryAnnotation.getQuery();
- this.queryHintContainer = this.buildHintContainer();
+ this.hintContainer = this.buildHintContainer();
}
@@ -111,11 +113,11 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation>
// ********** hints **********
public ListIterable<JavaQueryHint> getHints() {
- return this.queryHintContainer.getContextElements();
+ return this.hintContainer.getContextElements();
}
public int getHintsSize() {
- return this.queryHintContainer.getContextElementsSize();
+ return this.hintContainer.getContextElementsSize();
}
public JavaQueryHint addHint() {
@@ -124,25 +126,25 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation>
public JavaQueryHint addHint(int index) {
QueryHintAnnotation annotation = this.queryAnnotation.addHint(index);
- return this.queryHintContainer.addContextElement(index, annotation);
+ return this.hintContainer.addContextElement(index, annotation);
}
public void removeHint(QueryHint hint) {
- this.removeHint(this.queryHintContainer.indexOfContextElement((JavaQueryHint) hint));
+ this.removeHint(this.hintContainer.indexOfContextElement((JavaQueryHint) hint));
}
public void removeHint(int index) {
this.queryAnnotation.removeHint(index);
- this.queryHintContainer.removeContextElement(index);
+ this.hintContainer.removeContextElement(index);
}
public void moveHint(int targetIndex, int sourceIndex) {
this.queryAnnotation.moveHint(targetIndex, sourceIndex);
- this.queryHintContainer.moveContextElement(targetIndex, sourceIndex);
+ this.hintContainer.moveContextElement(targetIndex, sourceIndex);
}
public JavaQueryHint getHint(int index) {
- return this.queryHintContainer.get(index);
+ return this.hintContainer.get(index);
}
protected JavaQueryHint buildHint(QueryHintAnnotation hintAnnotation) {
@@ -150,7 +152,7 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation>
}
protected void syncHints() {
- this.queryHintContainer.synchronizeWithResourceModel();
+ this.hintContainer.synchronizeWithResourceModel();
}
protected ListIterable<QueryHintAnnotation> getHintAnnotations() {
@@ -239,29 +241,31 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation>
public boolean isEquivalentTo(JpaNamedContextNode node) {
return (this != node) &&
(this.getType() == node.getType()) &&
- this.isEquivalentTo((Query)node);
+ this.isEquivalentTo((Query) node);
}
protected boolean isEquivalentTo(Query other) {
return Tools.valuesAreEqual(this.name, other.getName()) &&
Tools.valuesAreEqual(this.query, other.getQuery()) &&
- hintsAreEquivalentTo(other);
+ this.hintsAreEquivalentTo(other);
}
protected boolean hintsAreEquivalentTo(Query other) {
- if (this.getHintsSize() != other.getHintsSize()) {
+ // get fixed lists of the hints
+ ArrayList<JavaQueryHint> hints1 = CollectionTools.list(this.getHints());
+ ArrayList<? extends QueryHint> hints2 = CollectionTools.list(other.getHints());
+ if (hints1.size() != hints2.size()) {
return false;
}
-
- for (int i=0; i<this.getHintsSize(); i++) {
- if (! this.queryHintContainer.get(i).isEquivalentTo(other.getHint(i))) {
+ for (int i = 0; i < hints1.size(); i++) {
+ if ( ! hints1.get(i).isEquivalentTo(hints2.get(i))) {
return false;
}
}
-
return true;
}
+
// ********** misc **********
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java
index 57fc8fbc0c..f2f0a7f8e1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java
@@ -15,7 +15,7 @@ import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
+import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.SequenceGenerator;
import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
import org.eclipse.jpt.jpa.core.context.java.JavaSequenceGenerator;
@@ -143,14 +143,13 @@ public abstract class AbstractJavaSequenceGenerator<A extends SequenceGeneratorA
// ********** validation **********
@Override
- public boolean isEquivalentTo(JpaNamedContextNode node) {
- return super.isEquivalentTo(node)
- && this.isEquivalentTo((SequenceGenerator) node);
+ protected boolean isEquivalentTo(Generator generator) {
+ return super.isEquivalentTo(generator)
+ && this.isEquivalentTo((SequenceGenerator) generator);
}
protected boolean isEquivalentTo(SequenceGenerator generator) {
- return super.isEquivalentTo(generator) &&
- Tools.valuesAreEqual(this.specifiedSequenceName, generator.getSpecifiedSequenceName());
+ return Tools.valuesAreEqual(this.specifiedSequenceName, generator.getSpecifiedSequenceName());
}
// ********** metadata conversion **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
index cd00f7f11f..6ff23b0e88 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
@@ -193,7 +193,7 @@ public abstract class AbstractOrmGenerator<X extends XmlGenerator>
public boolean isEquivalentTo(JpaNamedContextNode node) {
return (this != node) &&
(this.getType() == node.getType()) &&
- this.isEquivalentTo((Generator)node);
+ this.isEquivalentTo((Generator) node);
}
protected boolean isEquivalentTo(Generator generator) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java
index de9dc96d39..888ed8dd1b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.context.orm;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
@@ -47,7 +48,7 @@ public abstract class AbstractOrmQuery<X extends XmlQuery>
protected String query;
- protected final ContextListContainer<OrmQueryHint, XmlQueryHint> queryHintContainer;
+ protected final ContextListContainer<OrmQueryHint, XmlQueryHint> hintContainer;
protected AbstractOrmQuery(XmlContextNode parent, X xmlQuery) {
@@ -55,7 +56,7 @@ public abstract class AbstractOrmQuery<X extends XmlQuery>
this.xmlQuery = xmlQuery;
this.name = xmlQuery.getName();
this.query = this.getUnescapedQuery();
- this.queryHintContainer = this.buildHintContainer();
+ this.hintContainer = this.buildHintContainer();
}
// ********** synchronize/update **********
@@ -122,11 +123,11 @@ public abstract class AbstractOrmQuery<X extends XmlQuery>
// ********** hints **********
public ListIterable<OrmQueryHint> getHints() {
- return this.queryHintContainer.getContextElements();
+ return this.hintContainer.getContextElements();
}
public int getHintsSize() {
- return this.queryHintContainer.getContextElementsSize();
+ return this.hintContainer.getContextElementsSize();
}
public OrmQueryHint addHint() {
@@ -135,7 +136,7 @@ public abstract class AbstractOrmQuery<X extends XmlQuery>
public OrmQueryHint addHint(int index) {
XmlQueryHint xmlHint = this.buildXmlQueryHint();
- OrmQueryHint hint = this.queryHintContainer.addContextElement(index, xmlHint);
+ OrmQueryHint hint = this.hintContainer.addContextElement(index, xmlHint);
this.xmlQuery.getHints().add(index, xmlHint);
return hint;
}
@@ -145,21 +146,21 @@ public abstract class AbstractOrmQuery<X extends XmlQuery>
}
public void removeHint(QueryHint hint) {
- this.removeHint(this.queryHintContainer.indexOfContextElement((OrmQueryHint) hint));
+ this.removeHint(this.hintContainer.indexOfContextElement((OrmQueryHint) hint));
}
public void removeHint(int index) {
- this.queryHintContainer.removeContextElement(index);
+ this.hintContainer.removeContextElement(index);
this.xmlQuery.getHints().remove(index);
}
public void moveHint(int targetIndex, int sourceIndex) {
- this.queryHintContainer.moveContextElement(targetIndex, sourceIndex);
+ this.hintContainer.moveContextElement(targetIndex, sourceIndex);
this.xmlQuery.getHints().move(targetIndex, sourceIndex);
}
public OrmQueryHint getHint(int index) {
- return this.queryHintContainer.get(index);
+ return this.hintContainer.get(index);
}
protected OrmQueryHint buildHint(XmlQueryHint xmlHint) {
@@ -167,7 +168,7 @@ public abstract class AbstractOrmQuery<X extends XmlQuery>
}
protected void syncHints() {
- this.queryHintContainer.synchronizeWithResourceModel();
+ this.hintContainer.synchronizeWithResourceModel();
}
protected ListIterable<XmlQueryHint> getXmlHints() {
@@ -272,29 +273,31 @@ public abstract class AbstractOrmQuery<X extends XmlQuery>
public boolean isEquivalentTo(JpaNamedContextNode node) {
return (this != node) &&
(this.getType() == node.getType()) &&
- this.isEquivalentTo((Query)node);
+ this.isEquivalentTo((Query) node);
}
protected boolean isEquivalentTo(Query other) {
return Tools.valuesAreEqual(this.name, other.getName()) &&
Tools.valuesAreEqual(this.query, other.getQuery()) &&
- hintsAreEquivalentTo(other);
+ this.hintsAreEquivalentTo(other);
}
protected boolean hintsAreEquivalentTo(Query other) {
- if (this.getHintsSize() != CollectionTools.size(other.getHints())) {
+ // get fixed lists of the hints
+ ArrayList<OrmQueryHint> hints1 = CollectionTools.list(this.getHints());
+ ArrayList<? extends QueryHint> hints2 = CollectionTools.list(other.getHints());
+ if (hints1.size() != hints2.size()) {
return false;
}
-
- for (int i=0; i<this.getHintsSize(); i++) {
- if (! this.queryHintContainer.get(i).isEquivalentTo(other.getHint(i))) {
+ for (int i = 0; i < hints1.size(); i++) {
+ if ( ! hints1.get(i).isEquivalentTo(hints2.get(i))) {
return false;
}
}
-
return true;
}
+
// ********** misc **********
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java
index 9679885f9b..f8cf7cfdea 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java
@@ -11,7 +11,7 @@ package org.eclipse.jpt.jpa.core.internal.context.orm;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
+import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.SequenceGenerator;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.context.java.JavaSequenceGenerator;
@@ -103,14 +103,13 @@ public abstract class AbstractOrmSequenceGenerator
// ********** validation **********
@Override
- public boolean isEquivalentTo(JpaNamedContextNode node) {
- return super.isEquivalentTo(node)
- && this.isEquivalentTo((SequenceGenerator) node);
+ protected boolean isEquivalentTo(Generator generator) {
+ return super.isEquivalentTo(generator)
+ && this.isEquivalentTo((SequenceGenerator) generator);
}
protected boolean isEquivalentTo(SequenceGenerator generator) {
- return super.isEquivalentTo(generator) &&
- Tools.valuesAreEqual(this.specifiedSequenceName, generator.getSpecifiedSequenceName());
+ return Tools.valuesAreEqual(this.specifiedSequenceName, generator.getSpecifiedSequenceName());
}
// ********** metadata conversion **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
index 6124e4f515..d70b2ec418 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -1550,18 +1550,18 @@ public abstract class AbstractPersistenceUnit
public void convertJavaGenerators(EntityMappings entityMappings, IProgressMonitor monitor) {
ArrayList<JavaGenerator> convertibleJavaGenerators = this.getConvertibleJavaGenerators();
- SubMonitor subMonitor = SubMonitor.convert(monitor, JptCoreMessages.JPA_METADATA_CONVERSION_CONVERTING, convertibleJavaGenerators.size());
+ SubMonitor subMonitor = SubMonitor.convert(monitor, JptCoreMessages.JAVA_METADATA_CONVERSION_IN_PROGRESS, convertibleJavaGenerators.size());
for (JavaGenerator generator : convertibleJavaGenerators) {
this.convertJavaGenerator(entityMappings, generator, subMonitor.newChild(1));
}
- subMonitor.setTaskName(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_COMPLETE);
+ subMonitor.setTaskName(JptCoreMessages.JAVA_METADATA_CONVERSION_COMPLETE);
}
protected void convertJavaGenerator(EntityMappings entityMappings, JavaGenerator generator, SubMonitor monitor) {
if (monitor.isCanceled()) {
- throw new OperationCanceledException(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_CANCELED);
+ throw new OperationCanceledException(JptCoreMessages.JAVA_METADATA_CONVERSION_CANCELED);
}
- monitor.setTaskName(NLS.bind(JptCoreMessages.JPA_METADATA_CONVERSION_CONVERT_GENERATOR, generator.getName()));
+ monitor.setTaskName(NLS.bind(JptCoreMessages.JAVA_METADATA_CONVERSION_CONVERT_GENERATOR, generator.getName()));
generator.convertTo(entityMappings);
generator.delete(); // delete any converted generators
}
@@ -1661,18 +1661,18 @@ public abstract class AbstractPersistenceUnit
public void convertJavaQueries(EntityMappings entityMappings, IProgressMonitor monitor) {
OrmQueryContainer queryContainer = entityMappings.getQueryContainer();
ArrayList<JavaQuery> convertibleJavaQueries = this.getConvertibleJavaQueries();
- SubMonitor subMonitor = SubMonitor.convert(monitor, JptCoreMessages.JPA_METADATA_CONVERSION_CONVERTING, convertibleJavaQueries.size());
+ SubMonitor subMonitor = SubMonitor.convert(monitor, JptCoreMessages.JAVA_METADATA_CONVERSION_IN_PROGRESS, convertibleJavaQueries.size());
for (JavaQuery query : convertibleJavaQueries) {
this.convertJavaQuery(queryContainer, query, subMonitor.newChild(1));
}
- subMonitor.setTaskName(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_COMPLETE);
+ subMonitor.setTaskName(JptCoreMessages.JAVA_METADATA_CONVERSION_COMPLETE);
}
protected void convertJavaQuery(OrmQueryContainer queryContainer, JavaQuery query, SubMonitor monitor) {
if (monitor.isCanceled()) {
- throw new OperationCanceledException(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_CANCELED);
+ throw new OperationCanceledException(JptCoreMessages.JAVA_METADATA_CONVERSION_CANCELED);
}
- monitor.setTaskName(NLS.bind(JptCoreMessages.JPA_METADATA_CONVERSION_CONVERT_QUERY, query.getName()));
+ monitor.setTaskName(NLS.bind(JptCoreMessages.JAVA_METADATA_CONVERSION_CONVERT_QUERY, query.getName()));
query.convertTo(queryContainer);
query.delete(); // delete any converted queries
}
@@ -2379,36 +2379,44 @@ public abstract class AbstractPersistenceUnit
* the typical "override" in JPA....
*/
protected void validateGenerators(List<IMessage> messages, IReporter reporter) {
- this.checkForDuplicateGenerators(messages);
+ this.checkForGeneratorsWithSameName(messages);
for (Generator generator : this.getGenerators()) {
this.validate(generator, messages, reporter);
}
}
- protected void checkForDuplicateGenerators(List<IMessage> messages) {
+ protected void checkForGeneratorsWithSameName(List<IMessage> messages) {
HashMap<String, ArrayList<Generator>> generatorsByName = this.mapByName(this.getGenerators());
for (Map.Entry<String, ArrayList<Generator>> entry : generatorsByName.entrySet()) {
String generatorName = entry.getKey();
if (StringTools.stringIsNotEmpty(generatorName)) { // ignore empty names
ArrayList<Generator> dups = entry.getValue();
if (dups.size() > 1) {
- String[] parms = new String[] {generatorName};
- for (Generator dup : dups) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
+ this.validateGeneratorsWithSameName(generatorName, dups, messages);
}
}
}
}
+ /**
+ * All the specified generators have the same specified name.
+ * Mark them appropriately.
+ */
+ protected void validateGeneratorsWithSameName(String generatorName, ArrayList<Generator> dups, List<IMessage> messages) {
+ String[] parms = new String[] {generatorName};
+ for (Generator dup : dups) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
+ parms,
+ dup,
+ this.extractNameTextRange(dup)
+ )
+ );
+ }
+ }
+
// TODO bjv isn't it obvious?
protected TextRange extractNameTextRange(Generator generator) {
return (generator instanceof OrmGenerator) ?
@@ -2430,7 +2438,7 @@ public abstract class AbstractPersistenceUnit
* @see #validateGenerators(List, IReporter)
*/
protected void validateQueries(List<IMessage> messages, IReporter reporter) {
- this.checkForDuplicateQueries(messages);
+ this.checkForQueriesWithSameName(messages);
JpaJpqlQueryHelper queryHelper = this.createJpqlQueryHelper();
@@ -2439,30 +2447,34 @@ public abstract class AbstractPersistenceUnit
}
}
- protected void checkForDuplicateQueries(List<IMessage> messages) {
+ protected void checkForQueriesWithSameName(List<IMessage> messages) {
HashMap<String, ArrayList<Query>> queriesByName = this.mapByName(this.getQueries());
for (Map.Entry<String, ArrayList<Query>> entry : queriesByName.entrySet()) {
String queryName = entry.getKey();
if (StringTools.stringIsNotEmpty(queryName)) { // ignore empty names
ArrayList<Query> dups = entry.getValue();
if (dups.size() > 1) {
- String[] parms = new String[] {queryName};
- for (Query dup : dups) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.QUERY_DUPLICATE_NAME,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
+ this.validateQueriesWithSameName(queryName, dups, messages);
}
}
}
}
+ protected void validateQueriesWithSameName(String queryName, ArrayList<Query> dups, List<IMessage> messages) {
+ String[] parms = new String[] {queryName};
+ for (Query dup : dups) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.QUERY_DUPLICATE_NAME,
+ parms,
+ dup,
+ this.extractNameTextRange(dup)
+ )
+ );
+ }
+ }
+
// TODO bjv isn't it obvious?
protected TextRange extractNameTextRange(Query query) {
return (query instanceof OrmQuery) ?
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedNativeQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedNativeQuery.java
index f059eb1a64..e3b64c23e6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedNativeQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedNativeQuery.java
@@ -11,8 +11,8 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.context.java;
import java.util.List;
import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
import org.eclipse.jpt.jpa.core.context.NamedNativeQuery;
+import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.java.JavaNamedNativeQuery;
import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
@@ -128,14 +128,14 @@ public class GenericJavaNamedNativeQuery
}
@Override
- public boolean isEquivalentTo(JpaNamedContextNode node) {
- return super.isEquivalentTo(node)
- && this.isEquivalentTo((NamedNativeQuery) node);
+ protected boolean isEquivalentTo(Query other) {
+ return super.isEquivalentTo(other)
+ && this.isEquivalentTo((NamedNativeQuery) other);
}
- protected boolean isEquivalentTo(NamedNativeQuery nativeQuery) {
- return Tools.valuesAreEqual(this.resultClass, nativeQuery.getResultClass()) &&
- Tools.valuesAreEqual(this.resultSetMapping, nativeQuery.getResultSetMapping());
+ protected boolean isEquivalentTo(NamedNativeQuery other) {
+ return Tools.valuesAreEqual(this.resultClass, other.getResultClass()) &&
+ Tools.valuesAreEqual(this.resultSetMapping, other.getResultSetMapping());
}
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java
index 2c977b7d35..a5a5c469c1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -11,7 +11,7 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.context.java;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.jpa.core.context.QueryHint;
import org.eclipse.jpt.jpa.core.context.java.JavaQuery;
import org.eclipse.jpt.jpa.core.context.java.JavaQueryHint;
@@ -93,8 +93,8 @@ public class GenericJavaQueryHint
}
public boolean isEquivalentTo(QueryHint hint) {
- return StringTools.stringsAreEqual(this.getName(), hint.getName()) &&
- StringTools.stringsAreEqual(this.getValue(), hint.getValue()) ;
+ return Tools.valuesAreEqual(this.name, hint.getName()) &&
+ Tools.valuesAreEqual(this.value, hint.getValue()) ;
}
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java
index 4ed1b078bd..f00d64589f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java
@@ -9,14 +9,16 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.jpa1.context.java;
+import java.util.ArrayList;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.utility.Filter;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
+import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.TableGenerator;
import org.eclipse.jpt.jpa.core.context.UniqueConstraint;
import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
@@ -565,32 +567,33 @@ public class GenericJavaTableGenerator
// ********** validation **********
@Override
- public boolean isEquivalentTo(JpaNamedContextNode node) {
- return super.isEquivalentTo(node)
- && this.isEquivalentTo((TableGenerator) node);
+ protected boolean isEquivalentTo(Generator generator) {
+ return super.isEquivalentTo(generator)
+ && this.isEquivalentTo((TableGenerator) generator);
}
protected boolean isEquivalentTo(TableGenerator generator) {
- return super.isEquivalentTo(generator) &&
- Tools.valuesAreEqual(this.specifiedTable, generator.getSpecifiedTable()) &&
+ return Tools.valuesAreEqual(this.specifiedTable, generator.getSpecifiedTable()) &&
Tools.valuesAreEqual(this.specifiedSchema, generator.getSpecifiedSchema()) &&
Tools.valuesAreEqual(this.specifiedCatalog, generator.getSpecifiedCatalog()) &&
Tools.valuesAreEqual(this.specifiedPkColumnName, generator.getSpecifiedPkColumnName()) &&
Tools.valuesAreEqual(this.specifiedPkColumnValue, generator.getSpecifiedPkColumnValue()) &&
Tools.valuesAreEqual(this.specifiedValueColumnName, generator.getSpecifiedValueColumnName()) &&
- uniqueConstrainsAreEquivalentTo(generator);
+ this.uniqueConstrainsAreEquivalentTo(generator);
}
protected boolean uniqueConstrainsAreEquivalentTo(TableGenerator generator) {
- if (this.getUniqueConstraintsSize() != generator.getUniqueConstraintsSize()) {
+ // get fixed lists of the unique constraints
+ ArrayList<JavaUniqueConstraint> uniqueConstraints1 = CollectionTools.list(this.getUniqueConstraints());
+ ArrayList<UniqueConstraint> uniqueConstraints2 = CollectionTools.list(generator.getUniqueConstraints());
+ if (uniqueConstraints1.size() != uniqueConstraints2.size()) {
return false;
}
-
- for (int i=0; i<this.getUniqueConstraintsSize(); i++) {
- if (! this.uniqueConstraintContainer.get(i).isEquivalentTo(generator.getUniqueConstraint(i))) {
+ for (int i = 0; i < uniqueConstraints1.size(); i++) {
+ if ( ! uniqueConstraints1.get(i).isEquivalentTo(uniqueConstraints2.get(i))) {
return false;
}
}
return true;
}
-} \ No newline at end of file
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedNativeQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedNativeQuery.java
index 6c0ebef097..f85b824552 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedNativeQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmNamedNativeQuery.java
@@ -11,8 +11,8 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm;
import java.util.List;
import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
import org.eclipse.jpt.jpa.core.context.NamedNativeQuery;
+import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.context.java.JavaNamedNativeQuery;
import org.eclipse.jpt.jpa.core.context.orm.OrmNamedNativeQuery;
@@ -126,14 +126,14 @@ public class GenericOrmNamedNativeQuery
}
@Override
- public boolean isEquivalentTo(JpaNamedContextNode node) {
- return super.isEquivalentTo(node)
- && this.isEquivalentTo((NamedNativeQuery) node);
+ protected boolean isEquivalentTo(Query other) {
+ return super.isEquivalentTo(other)
+ && this.isEquivalentTo((NamedNativeQuery) other);
}
- protected boolean isEquivalentTo(NamedNativeQuery nnQuery) {
- return Tools.valuesAreEqual(this.resultClass, nnQuery.getResultClass()) &&
- Tools.valuesAreEqual(this.resultSetMapping, nnQuery.getResultSetMapping());
+ protected boolean isEquivalentTo(NamedNativeQuery other) {
+ return Tools.valuesAreEqual(this.resultClass, other.getResultClass()) &&
+ Tools.valuesAreEqual(this.resultSetMapping, other.getResultSetMapping());
}
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java
index 3bf4a14837..ba5a96c483 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2012 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -10,7 +10,7 @@
package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm;
import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.jpa.core.context.QueryHint;
import org.eclipse.jpt.jpa.core.context.java.JavaQueryHint;
import org.eclipse.jpt.jpa.core.context.orm.OrmQuery;
@@ -99,8 +99,8 @@ public class GenericOrmQueryHint
}
public boolean isEquivalentTo(QueryHint hint) {
- return StringTools.stringsAreEqual(this.getName(), hint.getName()) &&
- StringTools.stringsAreEqual(this.getValue(), hint.getValue()) ;
+ return Tools.valuesAreEqual(this.name, hint.getName()) &&
+ Tools.valuesAreEqual(this.value, hint.getValue()) ;
}
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java
index 6ce0ac56e3..ed9eed7f13 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTableGenerator.java
@@ -9,11 +9,13 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm;
+import java.util.ArrayList;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
+import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.TableGenerator;
import org.eclipse.jpt.jpa.core.context.UniqueConstraint;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
@@ -431,35 +433,37 @@ public class GenericOrmTableGenerator
// ********** validation **********
@Override
- public boolean isEquivalentTo(JpaNamedContextNode node) {
- return super.isEquivalentTo(node)
- && this.isEquivalentTo((TableGenerator) node);
+ protected boolean isEquivalentTo(Generator generator) {
+ return super.isEquivalentTo(generator)
+ && this.isEquivalentTo((TableGenerator) generator);
}
protected boolean isEquivalentTo(TableGenerator generator) {
- return super.isEquivalentTo(generator) &&
- Tools.valuesAreEqual(this.specifiedTable, generator.getSpecifiedTable()) &&
+ return Tools.valuesAreEqual(this.specifiedTable, generator.getSpecifiedTable()) &&
Tools.valuesAreEqual(this.specifiedSchema, generator.getSpecifiedSchema()) &&
Tools.valuesAreEqual(this.specifiedCatalog, generator.getSpecifiedCatalog()) &&
Tools.valuesAreEqual(this.specifiedPkColumnName, generator.getSpecifiedPkColumnName()) &&
Tools.valuesAreEqual(this.specifiedValueColumnName, generator.getSpecifiedValueColumnName()) &&
Tools.valuesAreEqual(this.specifiedPkColumnValue, generator.getSpecifiedPkColumnValue()) &&
- uniqueConstrainsAreEquivalentTo(generator);
+ this.uniqueConstrainsAreEquivalentTo(generator);
}
protected boolean uniqueConstrainsAreEquivalentTo(TableGenerator generator) {
- if (this.getUniqueConstraintsSize() != generator.getUniqueConstraintsSize()) {
+ // get fixed lists of the unique constraints
+ ArrayList<OrmUniqueConstraint> uniqueConstraints1 = CollectionTools.list(this.getUniqueConstraints());
+ ArrayList<UniqueConstraint> uniqueConstraints2 = CollectionTools.list(generator.getUniqueConstraints());
+ if (uniqueConstraints1.size() != uniqueConstraints2.size()) {
return false;
}
-
- for (int i=0; i<this.getUniqueConstraintsSize(); i++) {
- if (! this.uniqueConstraintContainer.get(i).isEquivalentTo(generator.getUniqueConstraint(i))) {
+ for (int i = 0; i < uniqueConstraints1.size(); i++) {
+ if ( ! uniqueConstraints1.get(i).isEquivalentTo(uniqueConstraints2.get(i))) {
return false;
}
}
return true;
}
+
// ********** metadata conversion **********
public void convertFrom(JavaTableGenerator javaTableGenerator) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java
index efc9425294..177799482d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java
@@ -10,8 +10,8 @@
package org.eclipse.jpt.jpa.core.internal.jpa2.context.java;
import java.util.List;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
import org.eclipse.jpt.jpa.core.context.NamedQuery;
+import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaQuery;
@@ -113,13 +113,13 @@ public class GenericJavaNamedQuery2_0
}
@Override
- public boolean isEquivalentTo(JpaNamedContextNode node) {
- return super.isEquivalentTo(node)
- && this.isEquivalentTo((NamedQuery2_0) node);
+ protected boolean isEquivalentTo(Query other) {
+ return super.isEquivalentTo(other)
+ && this.isEquivalentTo((NamedQuery2_0) other);
}
- protected boolean isEquivalentTo(NamedQuery2_0 namedQuery) {
- return this.specifiedLockMode == namedQuery.getSpecifiedLockMode();
+ protected boolean isEquivalentTo(NamedQuery2_0 other) {
+ return this.specifiedLockMode == other.getSpecifiedLockMode();
}
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java
index 54f78368bc..aeb75763d2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java
@@ -10,8 +10,8 @@
package org.eclipse.jpt.jpa.core.internal.jpa2.context.orm;
import java.util.List;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
import org.eclipse.jpt.jpa.core.context.NamedQuery;
+import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.XmlContextNode;
import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmQuery;
@@ -116,9 +116,9 @@ public class GenericOrmNamedQuery2_0
}
@Override
- public boolean isEquivalentTo(JpaNamedContextNode node) {
- return super.isEquivalentTo(node)
- && this.isEquivalentTo((NamedQuery) node);
+ protected boolean isEquivalentTo(Query other) {
+ return super.isEquivalentTo(other)
+ && this.isEquivalentTo((NamedQuery) other);
}
protected boolean isEquivalentTo(NamedQuery namedQuery) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_jpa_eclipselink_core.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_jpa_eclipselink_core.properties
index 2788c3aef5..6636a82260 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_jpa_eclipselink_core.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/property_files/jpt_jpa_eclipselink_core.properties
@@ -8,4 +8,4 @@
# Oracle - initial API and implementation
################################################################################
-JPA_METADATA_CONVERSION_CONVERT_CONVERTER=Converting JPA Java converter ''{0}''
+JAVA_METADATA_CONVERSION_CONVERT_CONVERTER=Converting Java converter ''{0}''
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/JptJpaEclipseLinkCorePlugin.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/JptJpaEclipseLinkCorePlugin.java
index f495d91dc2..401ee1ae0f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/JptJpaEclipseLinkCorePlugin.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/JptJpaEclipseLinkCorePlugin.java
@@ -32,10 +32,12 @@ import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
-public class JptJpaEclipseLinkCorePlugin extends Plugin
+public class JptJpaEclipseLinkCorePlugin
+ extends Plugin
{
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.jpt.jpa.eclipselink.core"; //$NON-NLS-1$
+ public static final String PLUGIN_ID_ = PLUGIN_ID + '.';
/**
* Version string for EclipseLink platform version 1.0
@@ -85,7 +87,7 @@ public class JptJpaEclipseLinkCorePlugin extends Plugin
* @see org.eclipse.core.runtime.content.IContentTypeManager#getContentType(String)
*/
public static final IContentType ECLIPSELINK_ORM_XML_CONTENT_TYPE =
- Platform.getContentTypeManager().getContentType(PLUGIN_ID + ".content.orm"); //$NON-NLS-1$
+ Platform.getContentTypeManager().getContentType(PLUGIN_ID_ + "content.orm"); //$NON-NLS-1$
/**
* The resource type for eclipselink-orm.xml version 1.0 mapping files
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
index 0339f65c37..8351b41812 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
@@ -453,7 +453,7 @@ public class EclipseLinkPersistenceUnit
return result;
}
- public Iterable<EclipseLinkConverter> getMappingFileConverters() {
+ protected Iterable<EclipseLinkConverter> getMappingFileConverters() {
return new CompositeIterable<EclipseLinkConverter>(this.getMappingFileConverterLists());
}
@@ -945,61 +945,48 @@ public class EclipseLinkPersistenceUnit
* @see #validateGenerators(List, IReporter)
*/
protected void validateConverters(List<IMessage> messages, IReporter reporter) {
- this.checkForDuplicateConverters(messages);
+ this.checkForConvertersWithSameName(messages);
for (EclipseLinkConverter converter : this.getConverters()) {
this.validate(converter, messages, reporter);
}
}
- protected void checkForDuplicateConverters(List<IMessage> messages) {
+ protected void checkForConvertersWithSameName(List<IMessage> messages) {
HashMap<String, ArrayList<EclipseLinkConverter>> convertersByName = this.mapByName(this.getConverters());
for (Map.Entry<String, ArrayList<EclipseLinkConverter>> entry : convertersByName.entrySet()) {
String converterName = entry.getKey();
if (StringTools.stringIsNotEmpty(converterName)) { // ignore empty names
ArrayList<EclipseLinkConverter> dups = entry.getValue();
if (dups.size() > 1) {
- // if duplicate name exists, check the types of the converters with the duplicate name
- HashMap<Class<? extends JpaNamedContextNode>, ArrayList<EclipseLinkConverter>> convertersByType = this.mapByType(dups);
- // if more than one types of converters have the same name,
- // report duplicate error on every converter in the list;
- if (convertersByType.size() > 1) {
- String[] parms = new String[] {converterName};
- for (EclipseLinkConverter dup : dups) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- EclipseLinkJpaValidationMessages.CONVERTER_DUPLICATE_NAME,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- } else {
- // otherwise if all the converters are with the same type, check every converter
- // to see if its definition is not equivalent with any one of the converters in the list;
- // if any one of the converters is NOT equivalent, add errors for all of them; otherwise do nothing
- if (this.anyNodesAreInequivalent(dups)) {
- String[] parms = new String[] {converterName};
- for (EclipseLinkConverter dup : dups) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- EclipseLinkJpaValidationMessages.CONVERTER_DUPLICATE_NAME,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- }
- }
+ this.validateConvertersWithSameName(converterName, dups, messages);
}
}
}
}
/**
+ * <strong>NB:</strong> Unlike generators and queries, we do not mark
+ * "equivalent" converters with info messages - we just ignore them
+ * because they cannot be "portable" (since only EclipseLink has converters).
+ */
+ protected void validateConvertersWithSameName(String converterName, ArrayList<EclipseLinkConverter> dups, List<IMessage> messages) {
+ String[] parms = new String[] {converterName};
+ if (this.anyNodesAreInequivalent(dups)) {
+ for (EclipseLinkConverter dup : dups) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.CONVERTER_DUPLICATE_NAME,
+ parms,
+ dup,
+ this.extractNameTextRange(dup)
+ )
+ );
+ }
+ }
+ }
+
+ /**
* Return whether all the specified nodes are "equivalent"
* (i.e. they all have the same state).
*/
@@ -1037,145 +1024,53 @@ public class EclipseLinkPersistenceUnit
}
}
+ /**
+ * If all the generators are "equivalent" add info messages;
+ * otherwise mark them all as duplicates.
+ */
@Override
- protected void checkForDuplicateGenerators(List<IMessage> messages) {
- HashMap<String, ArrayList<Generator>> generatorsByName = this.mapByName(this.getGenerators());
- for (Map.Entry<String, ArrayList<Generator>> entry : generatorsByName.entrySet()) {
- String generatorName = entry.getKey();
- if (StringTools.stringIsNotEmpty(generatorName)) { // ignore empty names
- ArrayList<Generator> dups = entry.getValue();
- if (dups.size() > 1) {
- // if duplicate name exists, check the types of the generators with the duplicate name
- HashMap<Class<? extends JpaNamedContextNode>, ArrayList<Generator>> generatorsByType = this.mapByType(dups);
- // if more than one types of generators have the same name,
- // report duplicate error on every generator in the list;
- if (generatorsByType.size() > 1) {
- String[] parms = new String[] {generatorName};
- for (Generator dup : dups) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- EclipseLinkJpaValidationMessages.GENERATOR_DUPLICATE_NAME,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- } else {
- // if all the generators are "equivalent", add info messages
- if (this.allNodesAreEquivalent(dups)) {
- String[] parms = new String[] {generatorName};
- for (Generator dup : dups) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.LOW_SEVERITY,
- EclipseLinkJpaValidationMessages.GENERATOR_EQUIVALENT,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- } else {
- // otherwise if all the generators are with the same type, check every generator
- // to see if its definition is not equivalent with any one of the generators in the list;
- // if any one of the generators is NOT equivalent, add errors for all of them; otherwise do nothing
- String[] parms = new String[] {generatorName};
- for (Generator dup : dups) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- EclipseLinkJpaValidationMessages.GENERATOR_DUPLICATE_NAME,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- }
- }
- }
+ protected void validateGeneratorsWithSameName(String generatorName, ArrayList<Generator> dups, List<IMessage> messages) {
+ if (this.allNodesAreEquivalent(dups)) {
+ String[] parms = new String[] {generatorName};
+ for (Generator dup : dups) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.LOW_SEVERITY,
+ EclipseLinkJpaValidationMessages.GENERATOR_EQUIVALENT,
+ parms,
+ dup,
+ this.extractNameTextRange(dup)
+ )
+ );
}
+ } else {
+ super.validateGeneratorsWithSameName(generatorName, dups, messages);
}
}
+ /**
+ * @see #validateGeneratorsWithSameName(String, ArrayList, List)
+ */
@Override
- protected void checkForDuplicateQueries(List<IMessage> messages) {
- HashMap<String, ArrayList<Query>> queriesByName = this.mapByName(this.getQueries());
- for (Map.Entry<String, ArrayList<Query>> entry : queriesByName.entrySet()) {
- String queryName = entry.getKey();
- if (StringTools.stringIsNotEmpty(queryName)) { // ignore empty names
- ArrayList<Query> dups = entry.getValue();
- if (dups.size() > 1) {
- // if duplicate name exists, check the types of the queries with the duplicate name
- HashMap<Class<? extends JpaNamedContextNode>, ArrayList<Query>> querisByType = this.mapByType(dups);
- // if more than one types of queries have the same name,
- // report duplicate error on every query in the list;
- if (querisByType.size() > 1) {
- String[] parms = new String[] {queryName};
- for (Query dup : dups) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- EclipseLinkJpaValidationMessages.QUERY_DUPLICATE_NAME,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- } else {
- // if all the queries are "equivalent", add info messages
- if (this.allNodesAreEquivalent(dups)) {
- String[] parms = new String[] {queryName};
- for (Query dup : dups) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.LOW_SEVERITY,
- EclipseLinkJpaValidationMessages.QUERY_EQUIVALENT,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- } else {
- // otherwise if all the queries are with the same type, check every query
- // to see if its definition is not equivalent with any one of the queries in the list;
- // if any one of the queries is NOT equivalent, add errors for all of them; otherwise do nothing
- String[] parms = new String[] {queryName};
- for (Query dup : dups) {
- messages.add(
- DefaultEclipseLinkJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- EclipseLinkJpaValidationMessages.QUERY_DUPLICATE_NAME,
- parms,
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- }
- }
- }
+ protected void validateQueriesWithSameName(String queryName, ArrayList<Query> dups, List<IMessage> messages) {
+ if (this.allNodesAreEquivalent(dups)) {
+ String[] parms = new String[] {queryName};
+ for (Query dup : dups) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.LOW_SEVERITY,
+ EclipseLinkJpaValidationMessages.QUERY_EQUIVALENT,
+ parms,
+ dup,
+ this.extractNameTextRange(dup)
+ )
+ );
}
+ } else {
+ super.validateQueriesWithSameName(queryName, dups, messages);
}
}
- protected <N extends JpaNamedContextNode> HashMap<Class<? extends JpaNamedContextNode>, ArrayList<N>> mapByType(Iterable<N> nodes) {
- HashMap<Class<? extends JpaNamedContextNode>, ArrayList<N>> map = new HashMap<Class<? extends JpaNamedContextNode>, ArrayList<N>>();
- for (N node : nodes) {
- Class<? extends JpaNamedContextNode> type = node.getType();
- ArrayList<N> list = map.get(type);
- if (list == null) {
- list = new ArrayList<N>();
- map.put(type, list);
- }
- list.add(node);
- }
- return map;
- }
// ********** refactoring **********
@@ -1236,18 +1131,18 @@ public class EclipseLinkPersistenceUnit
OrmQueryContainer queryContainer = entityMappings.getQueryContainer();
HashMap<String, ArrayList<JavaQuery>> convertibleJavaQueries = this.getEclipseLinkConvertibleJavaQueries();
int work = this.calculateCumulativeSize(convertibleJavaQueries.values());
- SubMonitor sm = SubMonitor.convert(monitor, JptCoreMessages.JPA_METADATA_CONVERSION_CONVERTING, work);
+ SubMonitor sm = SubMonitor.convert(monitor, JptCoreMessages.JAVA_METADATA_CONVERSION_IN_PROGRESS, work);
for (Map.Entry<String, ArrayList<JavaQuery>> entry : convertibleJavaQueries.entrySet()) {
this.convertJavaQueriesWithSameName(queryContainer, entry, sm.newChild(entry.getValue().size()));
}
- sm.setTaskName(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_COMPLETE);
+ sm.setTaskName(JptCoreMessages.JAVA_METADATA_CONVERSION_COMPLETE);
}
protected void convertJavaQueriesWithSameName(OrmQueryContainer queryContainer, Map.Entry<String, ArrayList<JavaQuery>> entry, SubMonitor monitor) {
if (monitor.isCanceled()) {
- throw new OperationCanceledException(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_CANCELED);
+ throw new OperationCanceledException(JptCoreMessages.JAVA_METADATA_CONVERSION_CANCELED);
}
- monitor.setTaskName(NLS.bind(JptCoreMessages.JPA_METADATA_CONVERSION_CONVERT_QUERY, entry.getKey()));
+ monitor.setTaskName(NLS.bind(JptCoreMessages.JAVA_METADATA_CONVERSION_CONVERT_QUERY, entry.getKey()));
ArrayList<JavaQuery> javaQueriesWithSameName = entry.getValue();
JavaQuery first = javaQueriesWithSameName.get(0);
@@ -1293,18 +1188,18 @@ public class EclipseLinkPersistenceUnit
public void convertJavaGenerators(EntityMappings entityMappings, IProgressMonitor monitor) {
HashMap<String, ArrayList<JavaGenerator>> convertibleJavaGenerators = this.getEclipseLinkConvertibleJavaGenerators();
int work = this.calculateCumulativeSize(convertibleJavaGenerators.values());
- SubMonitor sm = SubMonitor.convert(monitor, JptCoreMessages.JPA_METADATA_CONVERSION_CONVERTING, work);
+ SubMonitor sm = SubMonitor.convert(monitor, JptCoreMessages.JAVA_METADATA_CONVERSION_IN_PROGRESS, work);
for (Map.Entry<String, ArrayList<JavaGenerator>> entry : convertibleJavaGenerators.entrySet()) {
this.convertJavaGeneratorsWithSameName(entityMappings, entry, sm.newChild(entry.getValue().size()));
}
- sm.setTaskName(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_COMPLETE);
+ sm.setTaskName(JptCoreMessages.JAVA_METADATA_CONVERSION_COMPLETE);
}
protected void convertJavaGeneratorsWithSameName(EntityMappings entityMappings, Map.Entry<String, ArrayList<JavaGenerator>> entry, SubMonitor monitor) {
if (monitor.isCanceled()) {
- throw new OperationCanceledException(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_CANCELED);
+ throw new OperationCanceledException(JptCoreMessages.JAVA_METADATA_CONVERSION_CANCELED);
}
- monitor.setTaskName(NLS.bind(JptCoreMessages.JPA_METADATA_CONVERSION_CONVERT_GENERATOR, entry.getKey()));
+ monitor.setTaskName(NLS.bind(JptCoreMessages.JAVA_METADATA_CONVERSION_CONVERT_GENERATOR, entry.getKey()));
ArrayList<JavaGenerator> javaGeneratorsWithSameName = entry.getValue();
JavaGenerator first = javaGeneratorsWithSameName.get(0);
@@ -1349,18 +1244,18 @@ public class EclipseLinkPersistenceUnit
OrmEclipseLinkConverterContainer ormConverterContainer = entityMappings.getConverterContainer();
HashMap<String, ArrayList<JavaEclipseLinkConverter<?>>> convertibleJavaConverters = this.getEclipseLinkConvertibleJavaConverters();
int work = this.calculateCumulativeSize(convertibleJavaConverters.values());
- SubMonitor sm = SubMonitor.convert(monitor, JptCoreMessages.JPA_METADATA_CONVERSION_CONVERTING, work);
+ SubMonitor sm = SubMonitor.convert(monitor, JptCoreMessages.JAVA_METADATA_CONVERSION_IN_PROGRESS, work);
for (Map.Entry<String, ArrayList<JavaEclipseLinkConverter<?>>> entry : convertibleJavaConverters.entrySet()) {
this.convertJavaConvertersWithSameName(ormConverterContainer, entry, sm.newChild(entry.getValue().size()));
}
- sm.setTaskName(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_COMPLETE);
+ sm.setTaskName(JptCoreMessages.JAVA_METADATA_CONVERSION_COMPLETE);
}
protected void convertJavaConvertersWithSameName(OrmEclipseLinkConverterContainer ormConverterContainer, Map.Entry<String, ArrayList<JavaEclipseLinkConverter<?>>> entry, SubMonitor monitor) {
if (monitor.isCanceled()) {
- throw new OperationCanceledException(JptCoreMessages.JPA_METADATA_CONVERSION_OPERATION_CANCELED);
+ throw new OperationCanceledException(JptCoreMessages.JAVA_METADATA_CONVERSION_CANCELED);
}
- monitor.setTaskName(NLS.bind(JptJpaEclipseLinkCoreMessages.JPA_METADATA_CONVERSION_CONVERT_CONVERTER, entry.getKey()));
+ monitor.setTaskName(NLS.bind(JptJpaEclipseLinkCoreMessages.JAVA_METADATA_CONVERSION_CONVERT_CONVERTER, entry.getKey()));
ArrayList<JavaEclipseLinkConverter<?>> javaConvertersWithSameName = entry.getValue();
JavaEclipseLinkConverter<?> first = javaConvertersWithSameName.get(0);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptJpaEclipseLinkCoreMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptJpaEclipseLinkCoreMessages.java
index fe25959081..c7d748efcd 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptJpaEclipseLinkCoreMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/JptJpaEclipseLinkCoreMessages.java
@@ -12,16 +12,14 @@ package org.eclipse.jpt.jpa.eclipselink.core.internal;
import org.eclipse.osgi.util.NLS;
public class JptJpaEclipseLinkCoreMessages {
-
- public static String JPA_METADATA_CONVERSION_CONVERT_CONVERTER;
-
-
private static final String BUNDLE_NAME = "jpt_jpa_eclipselink_core"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptJpaEclipseLinkCoreMessages.class;
static {
NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
}
+ public static String JAVA_METADATA_CONVERSION_CONVERT_CONVERTER;
+
private JptJpaEclipseLinkCoreMessages() {
throw new UnsupportedOperationException();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java
index 085884302f..8be199c18e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java
@@ -13,6 +13,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
@@ -318,12 +319,14 @@ public class JavaEclipseLinkObjectTypeConverter
}
protected boolean conversionValuesAreEquivalentTo(EclipseLinkObjectTypeConverter converter) {
- if (this.getConversionValuesSize() != converter.getConversionValuesSize()) {
+ // get fixed lists of the conversion values
+ ArrayList<JavaEclipseLinkConversionValue> conversionValues1 = CollectionTools.list(this.getConversionValues());
+ ArrayList<? extends EclipseLinkConversionValue> conversionValues2 = CollectionTools.list(converter.getConversionValues());
+ if (conversionValues1.size() != conversionValues2.size()) {
return false;
}
-
- for (int i=0; i<this.getConversionValuesSize(); i++) {
- if ( ! this.conversionValueContainer.get(i).isEquivalentTo(converter.getConversionValue(i))) {
+ for (int i = 0; i < conversionValues1.size(); i++) {
+ if ( ! conversionValues1.get(i).isEquivalentTo(conversionValues2.get(i))) {
return false;
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkObjectTypeConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkObjectTypeConverter.java
index 646ce317ac..65477b4da5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkObjectTypeConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkObjectTypeConverter.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.Tools;
import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
@@ -455,18 +456,21 @@ public class OrmEclipseLinkObjectTypeConverter
}
protected boolean conversionValuesAreEquivalentTo(EclipseLinkObjectTypeConverter converter) {
- if (this.getConversionValuesSize() != converter.getConversionValuesSize()) {
+ // get fixed lists of the conversion values
+ ArrayList<OrmEclipseLinkConversionValue> conversionValues1 = CollectionTools.list(this.getConversionValues());
+ ArrayList<? extends EclipseLinkConversionValue> conversionValues2 = CollectionTools.list(converter.getConversionValues());
+ if (conversionValues1.size() != conversionValues2.size()) {
return false;
}
-
- for (int i=0; i<this.getConversionValuesSize(); i++) {
- if ( ! this.conversionValueContainer.get(i).isEquivalentTo(converter.getConversionValue(i))) {
+ for (int i = 0; i < conversionValues1.size(); i++) {
+ if ( ! conversionValues1.get(i).isEquivalentTo(conversionValues2.get(i))) {
return false;
}
}
return true;
}
+
// ********** metadata conversion **********
public void convertFrom(JavaEclipseLinkObjectTypeConverter javaConverter) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml
index 3804841e8d..c42430f428 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/plugin.xml
@@ -201,7 +201,7 @@
<handler
commandId="org.eclipse.jpt.jpa.eclipselink.ui.convertJavaConverters"
- class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.JpaJavaConverterMetadataConversionHandler">
+ class="org.eclipse.jpt.jpa.eclipselink.ui.internal.commands.JavaConverterConversionHandler">
</handler>
<handler
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties
index 45cb4f7a18..afe60d3098 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/property_files/eclipselink_ui.properties
@@ -373,15 +373,15 @@ GenerationOutputModeWizardPage_desc = Select DDL generation action
GenerationOutputModeWizardPage_generationOutputMode = Generation Output Mode
# MetadataConversion
-JpaGlobalMetadataConversion_noConverterMetadataToConvert=No Java converter metadata existing to convert
-JpaJavaGConverterMetadataConversionWizardPage_description = Move all the annotated JPA converters to XML as mapping file level metadata
-JpaJavaConverterMetadataConversionWizardPage_title = Java Converter Metadata Conversion
-JpaGlobalMetadataConversion_equivalentConverterMetadataWarningMessage=Warning: Equivalent converters are found. Only one of these converters will be converted while the rest will be deleted. Do you want to continue?
-JpaGlobalMetadataConversion_equivalentConverterMetadataWarningTitle=Equivalent Converters Found
-JpaGlobalMetadataConversion_equivalentGeneratorMetadataWarningMessage=Warning: Equivalent generators are found. Only one of these generators will be converted while the rest will be deleted. Do you want to continue?
-JpaGlobalMetadataConversion_equivalentGeneratorMetadataWarningTitle=Equivalent Generators Found
-JpaGlobalMetadataConversion_equivalentQueryMetadataWarningMessage=Warning: Equivalent queries are found. Only one of these queries will be converted while the rest will be deleted. Do you want to continue?
-JpaGlobalMetadataConversion_equivalentQueryMetadataWarningTitle=Equivalent Queries Found
+JavaMetadataConversion_noConvertersToConvert=No Java converters to convert
+JavaConverterConversionWizardPage_title = Java Converter Metadata Conversion
+JavaConverterConversionWizardPage_description = Move all the annotated JPA converters to XML as mapping file level metadata
+JavaMetadataConversion_equivalentConvertersWarningTitle=Equivalent Converters Found
+JavaMetadataConversion_equivalentConvertersWarningMessage=Warning: Equivalent converters are found. Only one of these converters will be converted while the rest will be deleted. Do you want to continue?
+JavaMetadataConversion_equivalentGeneratorsWarningTitle=Equivalent Generators Found
+JavaMetadataConversion_equivalentGeneratorsWarningMessage=Warning: Equivalent generators are found. Only one of these generators will be converted while the rest will be deleted. Do you want to continue?
+JavaMetadataConversion_equivalentQueriesWarningTitle=Equivalent Queries Found
+JavaMetadataConversion_equivalentQueriesWarningMessage=Warning: Equivalent queries are found. Only one of these queries will be converted while the rest will be deleted. Do you want to continue?
# Static Weaving
EclipselinkPreferencePage_description = Configure EclipseLink specific preferences for the project:
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java
index c6a68cc94f..282c437065 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/EclipseLinkUiMessages.java
@@ -377,15 +377,15 @@ public class EclipseLinkUiMessages {
public static String GenerationOutputModeWizardPage_generationOutputMode;
// Metadata Conversion
- public static String JpaGlobalMetadataConversion_noConverterMetadataToConvert;
- public static String JpaJavaGConverterMetadataConversionWizardPage_description;
- public static String JpaJavaConverterMetadataConversionWizardPage_title;
- public static String JpaGlobalMetadataConversion_equivalentConverterMetadataWarningTitle;
- public static String JpaGlobalMetadataConversion_equivalentConverterMetadataWarningMessage;
- public static String JpaGlobalMetadataConversion_equivalentGeneratorMetadataWarningMessage;
- public static String JpaGlobalMetadataConversion_equivalentGeneratorMetadataWarningTitle;
- public static String JpaGlobalMetadataConversion_equivalentQueryMetadataWarningTitle;
- public static String JpaGlobalMetadataConversion_equivalentQueryMetadataWarningMessage;
+ public static String JavaMetadataConversion_noConvertersToConvert;
+ public static String JavaConverterConversionWizardPage_title;
+ public static String JavaConverterConversionWizardPage_description;
+ public static String JavaMetadataConversion_equivalentConvertersWarningTitle;
+ public static String JavaMetadataConversion_equivalentConvertersWarningMessage;
+ public static String JavaMetadataConversion_equivalentGeneratorsWarningTitle;
+ public static String JavaMetadataConversion_equivalentGeneratorsWarningMessage;
+ public static String JavaMetadataConversion_equivalentQueriesWarningTitle;
+ public static String JavaMetadataConversion_equivalentQueriesWarningMessage;
// Static Weaving
public static String EclipselinkPreferencePage_description;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/JpaJavaConverterMetadataConversionHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/JavaConverterConversionHandler.java
index 493489c337..a90c210266 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/JpaJavaConverterMetadataConversionHandler.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/commands/JavaConverterConversionHandler.java
@@ -11,16 +11,17 @@ package org.eclipse.jpt.jpa.eclipselink.ui.internal.commands;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.platform.EclipseLinkJpaPlatformUi;
-import org.eclipse.jpt.jpa.ui.internal.commands.AbstractJpaJavaMetadataConversionHandler;
+import org.eclipse.jpt.jpa.ui.internal.commands.AbstractJavaMetadataConversionHandler;
-public class JpaJavaConverterMetadataConversionHandler extends AbstractJpaJavaMetadataConversionHandler {
-
- public JpaJavaConverterMetadataConversionHandler() {
+public class JavaConverterConversionHandler
+ extends AbstractJavaMetadataConversionHandler
+{
+ public JavaConverterConversionHandler() {
super();
}
@Override
- protected void converterJavaGlobalMetadata(JpaProject jpaProject) {
+ protected void convertJavaMetadata(JpaProject jpaProject) {
this.getJpaPlatformUi(jpaProject).convertJavaConverterMetadataToGlobal(jpaProject);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/AbstractEclipseLinkJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/AbstractEclipseLinkJpaPlatformUi.java
new file mode 100644
index 0000000000..a6c334325e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/AbstractEclipseLinkJpaPlatformUi.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.ui.internal.platform;
+
+import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java.EclipseLinkJavaConverterConversionWizardPage;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java.EclipseLinkJavaGeneratorConversionWizardPage;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java.EclipseLinkJavaQueryConversionWizardPage;
+import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider;
+import org.eclipse.jpt.jpa.ui.internal.platform.base.AbstractJpaPlatformUi;
+
+public abstract class AbstractEclipseLinkJpaPlatformUi
+ extends AbstractJpaPlatformUi
+ implements EclipseLinkJpaPlatformUi
+{
+ protected AbstractEclipseLinkJpaPlatformUi(
+ ItemTreeStateProviderFactoryProvider navigatorFactoryProvider,
+ JpaPlatformUiProvider platformUiProvider
+ ) {
+ super(navigatorFactoryProvider, platformUiProvider);
+ }
+
+ // ********** metadata conversion **********
+
+ public void convertJavaQueryMetadataToGlobal(JpaProject jpaProject) {
+ this.openInDialog(new EclipseLinkJavaQueryConversionWizardPage(jpaProject));
+ }
+
+ public void convertJavaGeneratorMetadataToGlobal(JpaProject jpaProject) {
+ this.openInDialog(new EclipseLinkJavaGeneratorConversionWizardPage(jpaProject));
+ }
+
+ public void convertJavaConverterMetadataToGlobal(JpaProject jpaProject) {
+ this.openInDialog(new EclipseLinkJavaConverterConversionWizardPage(jpaProject));
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink1_0JpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink1_0JpaPlatformUi.java
index 018c5f1b42..3cecd98f50 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink1_0JpaPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink1_0JpaPlatformUi.java
@@ -14,11 +14,9 @@ import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.EclipseLinkDDLGeneratorUi;
import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider;
-import org.eclipse.jpt.jpa.ui.internal.platform.base.BaseJpaPlatformUi;
public class EclipseLink1_0JpaPlatformUi
- extends BaseJpaPlatformUi
- implements EclipseLinkJpaPlatformUi
+ extends AbstractEclipseLinkJpaPlatformUi
{
public EclipseLink1_0JpaPlatformUi(
ItemTreeStateProviderFactoryProvider navigatorFactoryProvider,
@@ -32,18 +30,4 @@ public class EclipseLink1_0JpaPlatformUi
public void generateDDL(JpaProject project, IStructuredSelection selection) {
EclipseLinkDDLGeneratorUi.generate(project);
}
-
- // ********** metadata conversion **********
-
- public void convertJavaQueryMetadataToGlobal(JpaProject jpaProject) {
- EclipseLinkJpaJavaQueryMetadataConvertor.convert(jpaProject);
- }
-
- public void convertJavaGeneratorMetadataToGlobal(JpaProject jpaProject) {
- EclipseLinkJpaJavaGeneratorMetadataConvertor.convert(jpaProject);
- }
-
- public void convertJavaConverterMetadataToGlobal(JpaProject jpaProject) {
- EclipseLinkJpaJavaConverterMetadataConvertor.convert(jpaProject);
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink2_0JpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink2_0JpaPlatformUi.java
index 6b75ad62ff..953afc83c9 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink2_0JpaPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLink2_0JpaPlatformUi.java
@@ -14,15 +14,13 @@ import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.wizards.EclipseLink2_0DDLGeneratorUi;
import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider;
-import org.eclipse.jpt.jpa.ui.internal.platform.base.BaseJpaPlatformUi;
public class EclipseLink2_0JpaPlatformUi
- extends BaseJpaPlatformUi
- implements EclipseLinkJpaPlatformUi
+ extends AbstractEclipseLinkJpaPlatformUi
{
public EclipseLink2_0JpaPlatformUi(
- ItemTreeStateProviderFactoryProvider navigatorFactoryProvider,
- JpaPlatformUiProvider platformUiProvider
+ ItemTreeStateProviderFactoryProvider navigatorFactoryProvider,
+ JpaPlatformUiProvider platformUiProvider
) {
super(navigatorFactoryProvider, platformUiProvider);
}
@@ -32,17 +30,4 @@ public class EclipseLink2_0JpaPlatformUi
public void generateDDL(JpaProject project, IStructuredSelection selection) {
EclipseLink2_0DDLGeneratorUi.generate(project);
}
- // ********** metadata conversion **********
-
- public void convertJavaQueryMetadataToGlobal(JpaProject jpaProject) {
- EclipseLinkJpaJavaQueryMetadataConvertor.convert(jpaProject);
- }
-
- public void convertJavaGeneratorMetadataToGlobal(JpaProject jpaProject) {
- EclipseLinkJpaJavaGeneratorMetadataConvertor.convert(jpaProject);
- }
-
- public void convertJavaConverterMetadataToGlobal(JpaProject jpaProject) {
- EclipseLinkJpaJavaConverterMetadataConvertor.convert(jpaProject);
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaConverterMetadataConvertor.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaConverterMetadataConvertor.java
deleted file mode 100644
index 674fdfd29c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaConverterMetadataConvertor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.platform;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java.EclipseLinkJpaJavaConverterMetadataConversionWizard;
-import org.eclipse.jpt.jpa.ui.internal.platform.base.AbstractJpaJavaGlobalMetadataConvertor;
-
-public class EclipseLinkJpaJavaConverterMetadataConvertor extends
- AbstractJpaJavaGlobalMetadataConvertor {
-
- public EclipseLinkJpaJavaConverterMetadataConvertor(JpaProject jpaProject) {
- super(jpaProject);
- }
-
- public static void convert(JpaProject jpaProject) {
- new EclipseLinkJpaJavaConverterMetadataConvertor(jpaProject).convert();
- }
-
- @Override
- protected Wizard getWizard(){
- return new EclipseLinkJpaJavaConverterMetadataConversionWizard(super.jpaProject);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaGeneratorMetadataConvertor.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaGeneratorMetadataConvertor.java
deleted file mode 100644
index 1dac7418ee..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaGeneratorMetadataConvertor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.platform;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java.EclipseLinkJpaJavaGeneratorMetadataConversionWizard;
-import org.eclipse.jpt.jpa.ui.internal.platform.base.AbstractJpaJavaGlobalMetadataConvertor;
-
-public class EclipseLinkJpaJavaGeneratorMetadataConvertor extends
- AbstractJpaJavaGlobalMetadataConvertor {
-
- public EclipseLinkJpaJavaGeneratorMetadataConvertor(JpaProject jpaProject) {
- super(jpaProject);
- }
-
- public static void convert(JpaProject jpaProject) {
- new EclipseLinkJpaJavaGeneratorMetadataConvertor(jpaProject).convert();
- }
-
- @Override
- protected Wizard getWizard(){
- return new EclipseLinkJpaJavaGeneratorMetadataConversionWizard(super.jpaProject);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaQueryMetadataConvertor.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaQueryMetadataConvertor.java
deleted file mode 100644
index 18f353a877..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/platform/EclipseLinkJpaJavaQueryMetadataConvertor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.platform;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java.EclipseLinkJpaJavaQueryMetadataConversionWizard;
-import org.eclipse.jpt.jpa.ui.internal.platform.base.AbstractJpaJavaGlobalMetadataConvertor;
-
-public class EclipseLinkJpaJavaQueryMetadataConvertor extends
- AbstractJpaJavaGlobalMetadataConvertor {
-
- public EclipseLinkJpaJavaQueryMetadataConvertor(JpaProject jpaProject) {
- super(jpaProject);
- }
-
- public static void convert(JpaProject jpaProject) {
- new EclipseLinkJpaJavaQueryMetadataConvertor(jpaProject).convert();
- }
-
- @Override
- protected Wizard getWizard(){
- return new EclipseLinkJpaJavaQueryMetadataConversionWizard(super.jpaProject);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java
index 4a2a6103f8..ed57313e71 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EclipseLinkMappingFileWizard.java
@@ -1,13 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * 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:
- * Oracle - initial API and implementation
- *******************************************************************************/
+ * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards;
import org.eclipse.core.runtime.IPath;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EmbeddedEclipseLinkMappingFileWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EmbeddedEclipseLinkMappingFileWizard.java
index e191cbd53a..4da312f65f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EmbeddedEclipseLinkMappingFileWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/EmbeddedEclipseLinkMappingFileWizard.java
@@ -17,35 +17,39 @@ import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
/**
- * This wizard will create a new EclipseLink mapping file without open it afterwards.
- * It is used within other wizards where opening mapping file is unnecessary,
- * therefore, making the whole process more smooth.
- * This wizard has one more attribute called <code> DEFAULT_XML_FILE_NAME </code>
- * used when the given XML file name is null to avoid NullPointerException.
+ * This wizard will create a new EclipseLink mapping file without opening it
+ * afterwards.
+ * It can be used within other wizards where opening the mapping file is
+ * unnecessary, making the process smoother.
*/
+public class EmbeddedEclipseLinkMappingFileWizard
+ extends EclipseLinkMappingFileWizard
+{
+ public static IPath createNewMappingFile(IStructuredSelection selection) {
+ return createNewMappingFile(selection, null);
+ }
+
+ public static IPath createNewMappingFile(IStructuredSelection selection, String xmlFileName) {
+ if (xmlFileName == null) {
+ xmlFileName = DEFAULT_XML_FILE_NAME;
+ }
+ EmbeddedEclipseLinkMappingFileWizard wizard = new EmbeddedEclipseLinkMappingFileWizard(DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider()));
+ return MappingFileWizard.createMappingFile(selection, xmlFileName, wizard);
+ }
+
+ public static final String DEFAULT_XML_FILE_NAME = "eclipselink-orm.xml"; //$NON-NLS-1$
-@SuppressWarnings("restriction")
-public class EmbeddedEclipseLinkMappingFileWizard extends
- EclipseLinkMappingFileWizard {
-
- public static final String DEFAULT_XML_FILE_NAME = "eclipselink-orm.xml";
public EmbeddedEclipseLinkMappingFileWizard() {
+ super();
}
public EmbeddedEclipseLinkMappingFileWizard(IDataModel dataModel) {
super(dataModel);
}
-
+
@Override
public boolean performFinish() {
return this.createMappingFile();
}
-
- public static IPath createNewMappingFile(IStructuredSelection selection, String xmlFileName) {
- if (xmlFileName == null) {xmlFileName = DEFAULT_XML_FILE_NAME;}
- EmbeddedEclipseLinkMappingFileWizard wizard = new EmbeddedEclipseLinkMappingFileWizard(
- DataModelFactory.createDataModel(new EclipseLinkOrmFileCreationDataModelProvider()));
- return MappingFileWizard.createMappingFile(selection, xmlFileName, wizard);
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/SelectEcliplseLinkMappingFileDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/SelectEclipseLinkMappingFileDialog.java
index 35922fbacd..693b64c841 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/SelectEcliplseLinkMappingFileDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/SelectEclipseLinkMappingFileDialog.java
@@ -14,25 +14,26 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog;
+import org.eclipse.jpt.jpa.ui.internal.wizards.SelectMappingFileDialog;
import org.eclipse.swt.widgets.Shell;
/**
* Only EclipseLink mapping file will show up on EclipseLink platform with this dialog
- *
*/
+public class SelectEclipseLinkMappingFileDialog
+ extends SelectMappingFileDialog
+{
+ public SelectEclipseLinkMappingFileDialog(Shell parent, IProject project) {
+ super(parent, project);
+ }
-public class SelectEcliplseLinkMappingFileDialog extends SelectJpaOrmMappingFileDialog {
-
- public SelectEcliplseLinkMappingFileDialog(Shell parent,
- IProject project, ILabelProvider labelProvider,
- ITreeContentProvider contentProvider) {
+ public SelectEclipseLinkMappingFileDialog(Shell parent, IProject project, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
super(parent, project, labelProvider, contentProvider);
}
@Override
protected void openNewMappingFileWizard() {
- IPath path = EmbeddedEclipseLinkMappingFileWizard.createNewMappingFile(new StructuredSelection(super.project), null);
- super.updateDialog(path);
+ IPath path = EmbeddedEclipseLinkMappingFileWizard.createNewMappingFile(new StructuredSelection(super.project));
+ this.updateDialog(path);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaConverterConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaConverterConversionWizardPage.java
new file mode 100644
index 0000000000..6f51cb1cab
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaConverterConversionWizardPage.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
+import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+
+public class EclipseLinkJavaConverterConversionWizardPage
+ extends EclipseLinkJavaMetadataConversionWizardPage
+{
+ public EclipseLinkJavaConverterConversionWizardPage(JpaProject jpaProject) {
+ super(jpaProject, EclipseLinkUiMessages.JavaConverterConversionWizardPage_title, EclipseLinkUiMessages.JavaConverterConversionWizardPage_description);
+ }
+
+ @Override
+ protected boolean hasConvertibleJavaMetadata_() {
+ return this.getPersistenceUnit().hasConvertibleJavaConverters();
+ }
+
+ @Override
+ protected String getMissingJavaMetadataWarningMessage() {
+ return EclipseLinkUiMessages.JavaMetadataConversion_noConvertersToConvert;
+ }
+
+ /**
+ * Mapping file must be an EclipseLink ORM file.
+ */
+ @Override
+ protected IContentType getMappingFileContentType() {
+ return JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE;
+ }
+
+ @Override
+ protected ConversionCommand.Strategy getConversionCommandStrategy() {
+ return CONVERSION_COMMAND_STRATEGY;
+ }
+
+ public static final ConversionCommandStrategy CONVERSION_COMMAND_STRATEGY = new ConversionCommandStrategy();
+
+ protected static class ConversionCommandStrategy
+ implements ConversionCommand.Strategy
+ {
+ public void execute(EntityMappings entityMappings, IProgressMonitor monitor) {
+ ((EclipseLinkPersistenceUnit) entityMappings.getPersistenceUnit()).convertJavaConverters((EclipseLinkEntityMappings) entityMappings, monitor);
+ }
+ }
+
+ @Override
+ protected boolean hasAnyEquivalentJavaMetadata_() {
+ return this.getPersistenceUnit().hasAnyEquivalentJavaConverters();
+ }
+
+ @Override
+ public String getEquivalentJavaMetadataWarningDialogTitle() {
+ return EclipseLinkUiMessages.JavaMetadataConversion_equivalentConvertersWarningTitle;
+ }
+
+ @Override
+ public String getEquivalentJavaMetadataWarningDialogMessage() {
+ return EclipseLinkUiMessages.JavaMetadataConversion_equivalentConvertersWarningMessage;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaGeneratorConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaGeneratorConversionWizardPage.java
new file mode 100644
index 0000000000..bb7814776d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaGeneratorConversionWizardPage.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
+
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.GenericJavaGeneratorConversionWizardPage;
+
+public class EclipseLinkJavaGeneratorConversionWizardPage
+ extends EclipseLinkJavaMetadataConversionWizardPage
+{
+ public EclipseLinkJavaGeneratorConversionWizardPage(JpaProject jpaProject) {
+ super(jpaProject, JptUiMessages.JavaGeneratorConversionWizardPage_title, JptUiMessages.JavaGeneratorConversionWizardPage_description);
+ }
+
+ @Override
+ protected boolean hasConvertibleJavaMetadata_() {
+ return this.persistenceUnit.hasConvertibleJavaGenerators();
+ }
+
+ @Override
+ protected String getMissingJavaMetadataWarningMessage() {
+ return JptUiMessages.JavaMetadataConversion_noGeneratorsToConvert;
+ }
+
+ @Override
+ protected ConversionCommand.Strategy getConversionCommandStrategy() {
+ return GenericJavaGeneratorConversionWizardPage.CONVERSION_COMMAND_STRATEGY;
+ }
+
+ @Override
+ protected boolean hasAnyEquivalentJavaMetadata_() {
+ return this.getPersistenceUnit().hasAnyEquivalentJavaGenerators();
+ }
+
+ @Override
+ public String getEquivalentJavaMetadataWarningDialogTitle() {
+ return EclipseLinkUiMessages.JavaMetadataConversion_equivalentGeneratorsWarningTitle;
+ }
+
+ @Override
+ public String getEquivalentJavaMetadataWarningDialogMessage() {
+ return EclipseLinkUiMessages.JavaMetadataConversion_equivalentGeneratorsWarningMessage;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaMetadataConversionWizardPage.java
new file mode 100644
index 0000000000..277d4c7396
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaMetadataConversionWizardPage.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
+import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.EmbeddedEclipseLinkMappingFileWizard;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.SelectEclipseLinkMappingFileDialog;
+import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter;
+import org.eclipse.jpt.jpa.ui.internal.wizards.SelectMappingFileDialog;
+import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.JavaMetadataConversionWizardPage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+public abstract class EclipseLinkJavaMetadataConversionWizardPage
+ extends JavaMetadataConversionWizardPage
+{
+ public EclipseLinkJavaMetadataConversionWizardPage(JpaProject jpaProject, String title, String description) {
+ super(jpaProject, title, description);
+ }
+
+ @Override
+ protected ViewerFilter buildSelectMappingFileDialogViewerFilter() {
+ return new XmlMappingFileViewerFilter(this.jpaProject, JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE);
+ }
+
+ @Override
+ protected IPath openNewMappingFileWizard() {
+ return EmbeddedEclipseLinkMappingFileWizard.createNewMappingFile(new StructuredSelection(this.jpaProject.getProject()));
+ }
+
+ @Override
+ protected SelectMappingFileDialog buildSelectMappingFileDialog() {
+ return new SelectEclipseLinkMappingFileDialog(this.getShell(), this.jpaProject.getProject());
+ }
+
+ protected EclipseLinkPersistenceUnit getPersistenceUnit() {
+ return (EclipseLinkPersistenceUnit) this.persistenceUnit;
+ }
+
+ @Override
+ protected IPath getDefaultMappingFileRuntimPath() {
+ return JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH;
+ }
+
+ @Override
+ protected IContentType getMappingFileContentType() {
+ return JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE;
+ }
+
+
+ // ********** finish **********
+
+ @Override
+ protected final boolean isOKToConvert() {
+ if (this.hasAnyEquivalentJavaMetadata()) {
+ return this.userWantsToContinueWithEquivalentJavaMetadata();
+ }
+ return super.isOKToConvert();
+ }
+
+ protected final boolean hasAnyEquivalentJavaMetadata() {
+ return (this.persistenceUnit != null) && this.hasAnyEquivalentJavaMetadata_();
+ }
+
+ /**
+ * Pre-condition: the {@link #persistenceUnit persistence unit}
+ * is not <code>null</code>.
+ */
+ protected abstract boolean hasAnyEquivalentJavaMetadata_();
+
+
+ // ********** equivalent Java metadata warning dialog **********
+
+ /**
+ * Return whether the user wants to continue the conversion even though
+ * the persistence unit contains "equivalent" Java metadata (e.g. one or
+ * more of the Java queries are "equivalent").
+ */
+ protected boolean userWantsToContinueWithEquivalentJavaMetadata() {
+ if ( ! OptionalMessageDialog.isDialogEnabled(EquivalentJavaMetadataWarningDialog.ID)) {
+ return true; // ?
+ }
+ MessageDialog dialog = this.buildEquivalentJavaMetadataWarningDialog();
+ return dialog.open() == IDialogConstants.YES_ID;
+ }
+
+ protected MessageDialog buildEquivalentJavaMetadataWarningDialog() {
+ return new EquivalentJavaMetadataWarningDialog(this.getShell(), this.getEquivalentJavaMetadataWarningDialogTitle(), this.getEquivalentJavaMetadataWarningDialogMessage());
+ }
+
+ protected abstract String getEquivalentJavaMetadataWarningDialogTitle();
+
+ protected abstract String getEquivalentJavaMetadataWarningDialogMessage();
+
+
+ /* CU private */ static class EquivalentJavaMetadataWarningDialog
+ extends OptionalMessageDialog
+ {
+ static final String ID = "dontShowEquivalentMetadataExisting.warning"; //$NON-NLS-1$
+
+ EquivalentJavaMetadataWarningDialog(Shell parent, String title, String message) {
+ super(ID, parent, title, message, MessageDialog.WARNING,
+ new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
+ 1);
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
+ this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaQueryConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaQueryConversionWizardPage.java
new file mode 100644
index 0000000000..6a2ce64df3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJavaQueryConversionWizardPage.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
+
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.GenericJavaQueryConversionWizardPage;
+
+public class EclipseLinkJavaQueryConversionWizardPage
+ extends EclipseLinkJavaMetadataConversionWizardPage
+{
+ public EclipseLinkJavaQueryConversionWizardPage(JpaProject jpaProject) {
+ super(jpaProject, JptUiMessages.JavaQueryConversionWizardPage_title, JptUiMessages.JavaQueryConversionWizardPage_description);
+ }
+
+ @Override
+ protected boolean hasConvertibleJavaMetadata_() {
+ return this.persistenceUnit.hasConvertibleJavaQueries();
+ }
+
+ @Override
+ protected String getMissingJavaMetadataWarningMessage() {
+ return JptUiMessages.JavaMetadataConversion_noQueriesToConvert;
+ }
+
+ @Override
+ protected ConversionCommand.Strategy getConversionCommandStrategy() {
+ return GenericJavaQueryConversionWizardPage.CONVERSION_COMMAND_STRATEGY;
+ }
+
+ @Override
+ protected boolean hasAnyEquivalentJavaMetadata_() {
+ return this.getPersistenceUnit().hasAnyEquivalentJavaQueries();
+ }
+
+ @Override
+ public String getEquivalentJavaMetadataWarningDialogTitle() {
+ return EclipseLinkUiMessages.JavaMetadataConversion_equivalentQueriesWarningTitle;
+ }
+
+ @Override
+ public String getEquivalentJavaMetadataWarningDialogMessage() {
+ return EclipseLinkUiMessages.JavaMetadataConversion_equivalentQueriesWarningMessage;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaConverterMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaConverterMetadataConversionWizard.java
deleted file mode 100644
index dda5adce2f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaConverterMetadataConversionWizard.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.jpt.jpa.core.JpaProject;
-
-public class EclipseLinkJpaJavaConverterMetadataConversionWizard extends
- EclipseLinkJpaJavaGlobalMetadataConversionWizard {
-
-
- public EclipseLinkJpaJavaConverterMetadataConversionWizard(
- JpaProject jpaProject) {
- super(jpaProject);
- }
-
- @Override
- public boolean performFinish() {
- try {
- ((EclipseLinkJpaJavaConverterMetadataConversionWizardPage)
- super.jpaMetadataConversionWizardPage).performFinish();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- return true;
- }
-
- @Override
- protected EclipseLinkJpaJavaConverterMetadataConversionWizardPage buildJpaMetadataConversionWizardPage() {
- return new EclipseLinkJpaJavaConverterMetadataConversionWizardPage(
- this.getPersistenceUnit(), this.mappingXmlModel, HELP_CONTEXT_ID);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaConverterMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaConverterMetadataConversionWizardPage.java
deleted file mode 100644
index cf4619b98d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaConverterMetadataConversionWizardPage.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-
-public class EclipseLinkJpaJavaConverterMetadataConversionWizardPage extends
- EclipseLinkJpaJavaGlobalMetadataConversionWizardPage {
-
- public EclipseLinkJpaJavaConverterMetadataConversionWizardPage(
- EclipseLinkPersistenceUnit persistenceUnit, SimplePropertyValueModel<String> model, String helpContextId) {
- super(persistenceUnit, model, helpContextId);
- }
-
- @Override
- protected String getWizardPageTitle() {
- return EclipseLinkUiMessages.JpaJavaConverterMetadataConversionWizardPage_title;
- }
-
- @Override
- protected String getWizardPageDescription() {
- return EclipseLinkUiMessages.JpaJavaGConverterMetadataConversionWizardPage_description;
- }
-
- @Override
- protected void executeConversion(EntityMappings entityMappings, IProgressMonitor monitor){
- this.persistenceUnit.convertJavaConverters((EclipseLinkEntityMappings) entityMappings, monitor);
- }
-
- @Override
- protected boolean hasConvertibleJavaGlobalMetadata() {
- return this.persistenceUnit.hasConvertibleJavaConverters();
- }
-
- @Override
- protected String getWarningMessageForNonExistentGlobals() {
- return EclipseLinkUiMessages.JpaGlobalMetadataConversion_noConverterMetadataToConvert;
- }
-
- @Override
- public String getWarningDialogTitle() {
- return EclipseLinkUiMessages.JpaGlobalMetadataConversion_equivalentConverterMetadataWarningTitle;
- }
-
- @Override
- public String getWarningDialogMessage() {
- return EclipseLinkUiMessages.JpaGlobalMetadataConversion_equivalentConverterMetadataWarningMessage;
- }
-
-
- @Override
- protected boolean isOKToConvert() {
- if ( ! OptionalMessageDialog.isDialogEnabled(EquivalentGlobalMetadataWarningDialog.ID)) {
- return true;
- }
- if (this.persistenceUnit.hasAnyEquivalentJavaConverters()) {
- return this.openEquivalentGlobalMetadataWarningDialog();
- }
- return this.hasConvertibleJavaGlobalMetadata();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGeneratorMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGeneratorMetadataConversionWizard.java
deleted file mode 100644
index 7686c3ade5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGeneratorMetadataConversionWizard.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.jpt.jpa.core.JpaProject;
-
-public class EclipseLinkJpaJavaGeneratorMetadataConversionWizard extends
- EclipseLinkJpaJavaGlobalMetadataConversionWizard {
-
- public EclipseLinkJpaJavaGeneratorMetadataConversionWizard(
- JpaProject jpaProject) {
- super(jpaProject);
- }
-
- @Override
- public boolean performFinish() {
- try {
- ((EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage)
- super.jpaMetadataConversionWizardPage).performFinish();
-
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- return true;
- }
-
- @Override
- protected EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage buildJpaMetadataConversionWizardPage() {
- return new EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage(
- this.getPersistenceUnit(), this.mappingXmlModel, HELP_CONTEXT_ID);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage.java
deleted file mode 100644
index 5f395e4021..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
-
-public class EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage extends
- EclipseLinkJpaJavaGlobalMetadataConversionWizardPage {
-
- public EclipseLinkJpaJavaGeneratorMetadataConversionWizardPage(
- EclipseLinkPersistenceUnit persistenceUnit, SimplePropertyValueModel<String> model, String helpContextId) {
- super(persistenceUnit, model, helpContextId);
- }
-
- @Override
- protected String getWizardPageTitle() {
- return JptUiMessages.JpaJavaGeneratorMetadataConversionWizardPage_title;
- }
-
- @Override
- protected String getWizardPageDescription() {
- return JptUiMessages.JpaJavaGeneratorMetadataConversionWizardPage_description;
- }
-
- @Override
- protected void executeConversion(EntityMappings entityMappings, IProgressMonitor monitor){
- persistenceUnit.convertJavaGenerators(entityMappings, monitor);
- }
-
- @Override
- protected boolean isOKToConvert() {
- if ( ! OptionalMessageDialog.isDialogEnabled(EquivalentGlobalMetadataWarningDialog.ID)) {
- return true;
- }
- if (this.persistenceUnit.hasAnyEquivalentJavaGenerators()) {
- return this.openEquivalentGlobalMetadataWarningDialog();
- }
- return this.hasConvertibleJavaGlobalMetadata();
- }
-
- @Override
- protected String getWarningMessageForNonExistentGlobals() {
- return JptUiMessages.JpaGlobalMetadataConversion_noGeneratorMetadataToConvert;
- }
-
- @Override
- protected boolean hasConvertibleJavaGlobalMetadata() {
- return persistenceUnit.hasConvertibleJavaGenerators();
- }
-
- @Override
- public String getWarningDialogTitle() {
- return EclipseLinkUiMessages.JpaGlobalMetadataConversion_equivalentGeneratorMetadataWarningTitle;
- }
-
- @Override
- public String getWarningDialogMessage() {
- return EclipseLinkUiMessages.JpaGlobalMetadataConversion_equivalentGeneratorMetadataWarningMessage;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGlobalMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGlobalMetadataConversionWizard.java
deleted file mode 100644
index 11855e95ad..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGlobalMetadataConversionWizard.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.MappingFile;
-import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.JpaJavaGlobalMetadataConversionWizard;
-
-public abstract class EclipseLinkJpaJavaGlobalMetadataConversionWizard extends
- JpaJavaGlobalMetadataConversionWizard {
-
-
- public EclipseLinkJpaJavaGlobalMetadataConversionWizard(
- JpaProject jpaProject) {
- super(jpaProject);
- }
-
- @Override
- protected String getDefaultMappingFileRuntimPath() {
- return JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH.toString();
- }
-
- @Override
- protected MappingFile getFirstAvaliableMappingFile() {
- for (MappingFileRef ref : getPersistenceUnit().getMappingFileRefs()) {
- MappingFile mappingFile = ref.getMappingFile();
- if (mappingFile != null) {
- IFile file = ref.getMappingFile().getXmlResource().getFile();
- if (jpaProject.getJpaFile(file).getContentType().isKindOf(JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE))
- return ref.getMappingFile();
- }
- }
- return null;
- }
-
- @Override
- protected EclipseLinkPersistenceUnit getPersistenceUnit() {
- return (EclipseLinkPersistenceUnit) super.getPersistenceUnit();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGlobalMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGlobalMetadataConversionWizardPage.java
deleted file mode 100644
index a0498f1090..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaGlobalMetadataConversionWizardPage.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.EmbeddedEclipseLinkMappingFileWizard;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.SelectEcliplseLinkMappingFileDialog;
-import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter;
-import org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog;
-import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.JpaJavaGlobalMetadataConversionWizardPage;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-
-public abstract class EclipseLinkJpaJavaGlobalMetadataConversionWizardPage extends
- JpaJavaGlobalMetadataConversionWizardPage<EclipseLinkPersistenceUnit> {
-
- public EclipseLinkJpaJavaGlobalMetadataConversionWizardPage(
- EclipseLinkPersistenceUnit persistenceUnit, SimplePropertyValueModel<String> model, String helpContextId) {
- super(persistenceUnit, model, helpContextId);
- }
-
- @Override
- protected ViewerFilter buildSelectMappingFileDialogViewerFilter() {
- return new XmlMappingFileViewerFilter(this.getJpaProject(), JptJpaEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE);
- }
-
- @Override
- protected SelectJpaOrmMappingFileDialog buildSelectMappingFileDialog(
- Shell shell, IProject project, ILabelProvider lp,
- ITreeContentProvider cp) {
- return new SelectEcliplseLinkMappingFileDialog(shell, project, lp, cp);
- }
-
- @Override
- protected IPath getMappingFilePath() {
- return EmbeddedEclipseLinkMappingFileWizard.createNewMappingFile(
- new StructuredSelection(this.getJpaProject().getProject()),
- getOrmXmlResourceName());
- }
-
- @Override
- protected String getDefaultMappingFileRuntimPath() {
- return JptJpaEclipseLinkCorePlugin.DEFAULT_ECLIPSELINK_ORM_XML_RUNTIME_PATH.toString();
- }
-
- @Override
- public void performFinish() throws InvocationTargetException {
- try {
- if( !this.isOKToConvert()) {
- return;
- }
-
- // true=fork; true=cancellable
- this.buildPerformFinishProgressMonitorDialog().run(true, true, this.buildPerformFinishRunableWithProgress());
- }
- catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- }
-
- // ********** abstract methods **********
-
- abstract public String getWarningDialogTitle();
-
- abstract public String getWarningDialogMessage();
-
- abstract protected boolean isOKToConvert();
-
- // ********** warning dialog **********
-
- static class EquivalentGlobalMetadataWarningDialog extends OptionalMessageDialog {
-
- static final String ID= "dontShowEquivalentMetadataExisting.warning"; //$NON-NLS-1$
-
- EquivalentGlobalMetadataWarningDialog(Shell parent, String title, String message) {
- super(ID, parent, title, message, MessageDialog.WARNING,
- new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL},
- 1);
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- this.createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, false);
- this.createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true);
- }
- }
-
-
- protected boolean openEquivalentGlobalMetadataWarningDialog() {
- EquivalentGlobalMetadataWarningDialog dialog =
- new EquivalentGlobalMetadataWarningDialog(this.getShell(), this.getWarningDialogTitle(), this.getWarningDialogMessage());
- return dialog.open() == IDialogConstants.YES_ID;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaQueryMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaQueryMetadataConversionWizard.java
deleted file mode 100644
index 33f242abc9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaQueryMetadataConversionWizard.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.jpt.jpa.core.JpaProject;
-
-public class EclipseLinkJpaJavaQueryMetadataConversionWizard extends
- EclipseLinkJpaJavaGlobalMetadataConversionWizard {
-
- public EclipseLinkJpaJavaQueryMetadataConversionWizard(JpaProject jpaProject) {
- super(jpaProject);
- }
-
- @Override
- public boolean performFinish() {
- try {
- ((EclipseLinkJpaJavaQueryMetadataConversionWizardPage)
- super.jpaMetadataConversionWizardPage).performFinish();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- return true;
- }
-
- @Override
- protected EclipseLinkJpaJavaQueryMetadataConversionWizardPage buildJpaMetadataConversionWizardPage() {
- return new EclipseLinkJpaJavaQueryMetadataConversionWizardPage(
- this.getPersistenceUnit(), this.mappingXmlModel, HELP_CONTEXT_ID);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaQueryMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaQueryMetadataConversionWizardPage.java
deleted file mode 100644
index 8fff49373d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/conversion/java/EclipseLinkJpaJavaQueryMetadataConversionWizardPage.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jpt.common.ui.internal.dialogs.OptionalMessageDialog;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.EclipseLinkUiMessages;
-import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
-
-public class EclipseLinkJpaJavaQueryMetadataConversionWizardPage extends
- EclipseLinkJpaJavaGlobalMetadataConversionWizardPage {
-
- public EclipseLinkJpaJavaQueryMetadataConversionWizardPage(
- EclipseLinkPersistenceUnit persistenceUnit, SimplePropertyValueModel<String> model, String helpContextId) {
- super(persistenceUnit, model, helpContextId);
- }
-
- @Override
- protected String getWizardPageTitle() {
- return JptUiMessages.JpaJavaQueryMetadataConversionWizardPage_title;
- }
-
- @Override
- protected String getWizardPageDescription() {
- return JptUiMessages.JpaJavaQueryMetadataConversionWizardPage_description;
- }
-
- @Override
- protected void executeConversion(EntityMappings entityMappings, IProgressMonitor monitor){
- persistenceUnit.convertJavaQueries(entityMappings, monitor);
- }
-
- @Override
- protected boolean hasConvertibleJavaGlobalMetadata() {
- return persistenceUnit.hasConvertibleJavaQueries();
- }
-
- @Override
- protected String getWarningMessageForNonExistentGlobals() {
- return JptUiMessages.JpaGlobalMetadataConversion_noQueryMetadataToConvert;
- }
-
- @Override
- public String getWarningDialogTitle() {
- return EclipseLinkUiMessages.JpaGlobalMetadataConversion_equivalentQueryMetadataWarningTitle;
- }
-
- @Override
- public String getWarningDialogMessage() {
- return EclipseLinkUiMessages.JpaGlobalMetadataConversion_equivalentQueryMetadataWarningMessage;
- }
-
- @Override
- protected boolean isOKToConvert() {
- if ( ! OptionalMessageDialog.isDialogEnabled(EquivalentGlobalMetadataWarningDialog.ID)) {
- return true;
- }
- if (this.persistenceUnit.hasAnyEquivalentJavaQueries()) {
- return this.openEquivalentGlobalMetadataWarningDialog();
- }
- return this.hasConvertibleJavaGlobalMetadata();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/gen/DynamicDefaultTableGenerationWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/gen/DynamicDefaultTableGenerationWizardPage.java
index 174641216d..46c38f9062 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/gen/DynamicDefaultTableGenerationWizardPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/wizards/gen/DynamicDefaultTableGenerationWizardPage.java
@@ -18,11 +18,11 @@ import org.eclipse.jface.window.Window;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.jpa.eclipselink.core.JptJpaEclipseLinkCorePlugin;
-import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.SelectEcliplseLinkMappingFileDialog;
+import org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.SelectEclipseLinkMappingFileDialog;
import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter;
-import org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog;
+import org.eclipse.jpt.jpa.ui.internal.wizards.SelectMappingFileDialog;
import org.eclipse.jpt.jpa.ui.internal.wizards.entity.EntityWizardMsg;
import org.eclipse.jpt.jpa.ui.internal.wizards.gen.DefaultTableGenerationWizardPage;
import org.eclipse.swt.SWT;
@@ -131,9 +131,9 @@ public class DynamicDefaultTableGenerationWizardPage extends
ViewerFilter filter = getDialogViewerFilter(this.jpaProject);
ITreeContentProvider contentProvider = new WorkbenchContentProvider();
ILabelProvider labelProvider = new WorkbenchLabelProvider();
- SelectJpaOrmMappingFileDialog dialog = new SelectEcliplseLinkMappingFileDialog(getShell(), this.jpaProject.getProject(), labelProvider, contentProvider);
- dialog.setTitle(JptUiMessages.SelectJpaOrmMappingFileDialog_title);
- dialog.setMessage(JptUiMessages.SelectJpaOrmMappingFileDialog_message);
+ SelectMappingFileDialog dialog = new SelectEclipseLinkMappingFileDialog(getShell(), this.jpaProject.getProject(), labelProvider, contentProvider);
+ dialog.setTitle(JptUiMessages.SelectMappingFileDialog_title);
+ dialog.setMessage(JptUiMessages.SelectMappingFileDialog_message);
dialog.addFilter(filter);
String ormFileName = this.xmlMappingFileText.getText();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
index 827bd79016..265977c237 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/plugin.xml
@@ -483,11 +483,11 @@
</handler>
<handler
- class="org.eclipse.jpt.jpa.ui.internal.commands.JpaJavaGeneratorMetadataConversionHandler"
+ class="org.eclipse.jpt.jpa.ui.internal.commands.JavaGeneratorConversionHandler"
commandId="org.eclipse.jpt.jpa.ui.convertJavaGenerators"/>
<handler
- class="org.eclipse.jpt.jpa.ui.internal.commands.JpaJavaQueryMetadataConversionHandler"
+ class="org.eclipse.jpt.jpa.ui.internal.commands.JavaQueryConversionHandler"
commandId="org.eclipse.jpt.jpa.ui.convertJavaQueries"/>
</extension>
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
index fd189cfb74..8959cb9991 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_ui.properties
@@ -8,6 +8,8 @@
# Oracle - initial API and implementation
################################################################################
+# JptUiMessages
+
AccessTypeComposite_access=Access:
AddToEarComposite_earMemberShip=EAR membership
@@ -174,26 +176,29 @@ PersistenceItemLabelProviderFactory_persistenceLabel=Persistence
OverwriteConfirmerDialog_title=Overwrite Existing File
OverwriteConfirmerDialog_text=Overwrite the existing file ''{0}''?
-SelectJpaOrmMappingFileDialog_title=Mapping File
-SelectJpaOrmMappingFileDialog_message=Choose a mapping file
-SelectJpaOrmMappingFileDialog_newButton=New...
-SelectJpaOrmMappingFileDialog_newBtnToolTip=Create a new mapping file
-
-JpaGlobalMetadataConversion_convertingJpaGlobalMetadataWarning=[Warning]: Malformed metadata will result in non-functional XML mapping file.{0} Duplicated or overridden annotations will not be moved to XML.
-JpaGlobalMetadataConversion_mappingFileDoesNotExist=The specified mapping file does not exist
-JpaGlobalMetadataConversion_mappingFileHasInvalidVersion=The specified mapping file has invalid version
-JpaGlobalMetadataConversion_mappingFileNotListedInPersistenceXml=The XML mapping file is not listed in the persistence.xml
-JpaGlobalMetadataConversion_noGeneratorMetadataToConvert=No generator metadata existing to convert
-JpaGlobalMetadataConversion_noQueryMetadataToConvert=No Java query metadata existing to convert
-JpaGlobalMetadataConversionWizard_title=JPA Global Metadata Conversion
-JpaGlobalMetadataConversionWizardPage_browseMappingFileBtn=Browse...
-JpaGlobalMetadataConversionWizardPage_browseMappingFileBtnToolTip=Select a mapping file
-JpaGlobalMetadataConversionWizardPage_label=Create a new mapping file or select one:
-JpaGlobalMetadataConversionWizardPage_newMappingFileLink=<a>Mapping XML:</a>
-JpaGlobalMetadataConversionWizardPage_newMappingFileLinkToolTip=Create a new mapping file
-JpaJavaGeneratorMetadataConversionWizardPage_description=Move all the annotated JPA generators to XML as mapping file level metadata
-JpaJavaGeneratorMetadataConversionWizardPage_title=Java Generator Metadata Conversion
-JpaJavaQueryMetadataConversionWizardPage_description=Move all the annotated JPA queries to XML as mapping file level metadata
-JpaJavaQueryMetadataConversionWizardPage_title=Java Query Metadata Conversion
+SelectMappingFileDialog_title=Mapping File
+SelectMappingFileDialog_message=Choose a mapping file
+SelectMappingFileDialog_newButton=New...
+SelectMappingFileDialog_newButtonToolTip=Create a new mapping file
+
+JavaMetadataConversion_warning=Warning: Malformed metadata will result in a non-functional mapping file.{0}Duplicated or overridden annotations will not be moved to the mapping file.
+JavaMetadataConversion_mappingFileDoesNotExist=The specified mapping file does not exist
+JavaMetadataConversion_mappingFileVersionIsInvalid=The mapping file''s version ''{0}'' does not match the JPA project''s version ''{1}''
+JavaMetadataConversion_mappingFileNotListedInPersistenceXml=The mapping file is not listed in the persistence.xml file
+JavaMetadataConversion_noGeneratorsToConvert=There are no Java generators to convert
+JavaMetadataConversion_noQueriesToConvert=There are no Java queries to convert
+JavaMetadataConversionWizard_title=JPA Global Metadata Conversion
+JavaMetadataConversionWizardPage_mappingFileBrowseButton=Browse...
+JavaMetadataConversionWizardPage_mappingFileBrowseButtonToolTip=Select a mapping file
+JavaMetadataConversionWizardPage_label=Create a new mapping file or select one:
+JavaMetadataConversionWizardPage_newMappingFileLink=<a>Mapping file:</a>
+JavaMetadataConversionWizardPage_newMappingFileLinkToolTip=Create a new mapping file
+JavaGeneratorConversionWizardPage_title=Java Generator Metadata Conversion
+JavaGeneratorConversionWizardPage_description=Move all the annotated JPA generators to XML as mapping file level metadata
+JavaQueryConversionWizardPage_title=Java Query Metadata Conversion
+JavaQueryConversionWizardPage_description=Move all the annotated JPA queries to XML as mapping file level metadata
+
+SelectJpaProjectWizardPage_title=JPA Project Selection
+SelectJpaProjectWizardPage_msg=Select a JPA project.
SynchronizingClasses_TaskName=Synchronizing classes...
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
index 2926fa483b..de595118db 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JptUiMessages.java
@@ -19,6 +19,12 @@ import org.eclipse.osgi.util.NLS;
*/
// TODO bjv rename...
public class JptUiMessages {
+ private static final String BUNDLE_NAME = "jpt_ui"; //$NON-NLS-1$
+ private static final Class<?> BUNDLE_CLASS = JptUiMessages.class;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
+ }
public static String AccessTypeComposite_access;
public static String AddToEarComposite_earMemberShip;
@@ -153,41 +159,38 @@ public class JptUiMessages {
public static String JpaProblemSeveritiesPage_Ignore;
public static String JpaProblemSeveritiesPage_Info;
public static String JpaProblemSeveritiesPage_Warning;
- public static String SelectJpaOrmMappingFileDialog_title;
- public static String SelectJpaOrmMappingFileDialog_message;
public static String JpaEntityGenPreferencePage_Description;
public static String JpaEntityGenPreferencePage_generalGroup_title;
public static String JpaEntityGenPreferencePage_defaultPackageLabel;
- public static String SelectJpaOrmMappingFileDialog_newButton;
- public static String SelectJpaOrmMappingFileDialog_newBtnToolTip;
- public static String SynchronizingClasses_TaskName;
- public static String JpaGlobalMetadataConversionWizard_title;
- public static String JpaGlobalMetadataConversion_convertingJpaGlobalMetadataWarning;
- public static String JpaGlobalMetadataConversion_mappingFileDoesNotExist;
- public static String JpaGlobalMetadataConversion_mappingFileHasInvalidVersion;
- public static String JpaGlobalMetadataConversion_mappingFileNotListedInPersistenceXml;
- public static String JpaGlobalMetadataConversion_noGeneratorMetadataToConvert;
- public static String JpaGlobalMetadataConversion_noQueryMetadataToConvert;
- public static String JpaGlobalMetadataConversionWizardPage_browseMappingFileBtn;
- public static String JpaGlobalMetadataConversionWizardPage_browseMappingFileBtnToolTip;
- public static String JpaGlobalMetadataConversionWizardPage_label;
- public static String JpaGlobalMetadataConversionWizardPage_newMappingFileLink;
- public static String JpaGlobalMetadataConversionWizardPage_newMappingFileLinkToolTip;
- public static String JpaJavaGeneratorMetadataConversionWizardPage_description;
- public static String JpaJavaGeneratorMetadataConversionWizardPage_title;
- public static String JpaJavaQueryMetadataConversionWizardPage_description;
- public static String JpaJavaQueryMetadataConversionWizardPage_title;
+ public static String SelectJpaProjectWizardPage_title;
+ public static String SelectJpaProjectWizardPage_msg;
+ public static String SelectMappingFileDialog_title;
+ public static String SelectMappingFileDialog_message;
+ public static String SelectMappingFileDialog_newButton;
+ public static String SelectMappingFileDialog_newButtonToolTip;
- private static final String BUNDLE_NAME = "jpt_ui"; //$NON-NLS-1$
- private static final Class<?> BUNDLE_CLASS = JptUiMessages.class;
+ public static String SynchronizingClasses_TaskName;
- static {
- NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
- }
+ public static String JavaMetadataConversionWizard_title;
+ public static String JavaMetadataConversion_warning;
+ public static String JavaMetadataConversion_mappingFileDoesNotExist;
+ public static String JavaMetadataConversion_mappingFileVersionIsInvalid;
+ public static String JavaMetadataConversion_mappingFileNotListedInPersistenceXml;
+ public static String JavaMetadataConversion_noGeneratorsToConvert;
+ public static String JavaMetadataConversion_noQueriesToConvert;
+ public static String JavaMetadataConversionWizardPage_mappingFileBrowseButton;
+ public static String JavaMetadataConversionWizardPage_mappingFileBrowseButtonToolTip;
+ public static String JavaMetadataConversionWizardPage_label;
+ public static String JavaMetadataConversionWizardPage_newMappingFileLink;
+ public static String JavaMetadataConversionWizardPage_newMappingFileLinkToolTip;
+ public static String JavaGeneratorConversionWizardPage_title;
+ public static String JavaGeneratorConversionWizardPage_description;
+ public static String JavaQueryConversionWizardPage_title;
+ public static String JavaQueryConversionWizardPage_description;
private JptUiMessages() {
throw new UnsupportedOperationException();
}
-} \ No newline at end of file
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AbstractJavaMetadataConversionHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AbstractJavaMetadataConversionHandler.java
new file mode 100644
index 0000000000..4fe1d873ae
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AbstractJavaMetadataConversionHandler.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.ui.JpaPlatformUi;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public abstract class AbstractJavaMetadataConversionHandler
+ extends AbstractHandler
+{
+ public AbstractJavaMetadataConversionHandler() {
+ super();
+ }
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ this.execute_(event);
+ return null;
+ }
+
+ protected void execute_(ExecutionEvent event) throws ExecutionException {
+ IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);
+ JpaProject jpaProject = this.convertSelectionToJpaProject(selection.getFirstElement());
+ if (jpaProject != null) {
+ this.convertJavaMetadata(jpaProject);
+ }
+ }
+
+ protected abstract void convertJavaMetadata(JpaProject jpaProject);
+
+ protected JpaProject convertSelectionToJpaProject(Object sel) {
+ try {
+ return (sel == null) ? null : this.convertSelectionToJpaProject_(sel);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ return null;
+ }
+ }
+
+ protected JpaProject convertSelectionToJpaProject_(Object sel) throws InterruptedException {
+ // this will handle JpaProject and IProject (when the JpaProject is already present)
+ JpaProject jpaProject = PlatformTools.getAdapter(sel, JpaProject.class);
+ if (jpaProject != null) {
+ return jpaProject;
+ }
+ IProject project = this.convertSelectionToProject(sel);
+ if (project == null) {
+ return null;
+ }
+ JpaProject.Reference ref = (JpaProject.Reference) project.getAdapter(JpaProject.Reference.class);
+ // this will wait for the JpaProject if it is under construction
+ return (ref == null) ? null : ref.getValue();
+ }
+
+ protected IProject convertSelectionToProject(Object sel) {
+ // this will handle JpaProject and IProject
+ IResource resource = PlatformTools.getAdapter(sel, IResource.class);
+ if (resource != null) {
+ return resource.getProject();
+ }
+
+ IJavaProject javaProject = this.convertSelectionToJavaProject(sel);
+ return (javaProject == null) ? null : javaProject.getProject();
+ }
+
+ protected IJavaProject convertSelectionToJavaProject(Object sel) {
+ IJavaElement javaElement = PlatformTools.getAdapter(sel, IJavaElement.class);
+ return (javaElement == null) ? null : javaElement.getJavaProject();
+ }
+
+ /**
+ * Convenience method.
+ */
+ protected JpaPlatformUi getJpaPlatformUi(JpaProject jpaProject) {
+ return (JpaPlatformUi) jpaProject.getJpaPlatform().getAdapter(JpaPlatformUi.class);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AbstractJpaJavaMetadataConversionHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AbstractJpaJavaMetadataConversionHandler.java
deleted file mode 100644
index fc9908083f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/AbstractJpaJavaMetadataConversionHandler.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.ui.JpaPlatformUi;
-import org.eclipse.jpt.jpa.ui.internal.platform.JpaPlatformUiRegistry;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-public abstract class AbstractJpaJavaMetadataConversionHandler extends AbstractHandler {
-
- public AbstractJpaJavaMetadataConversionHandler() {
- super();
- }
-
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IStructuredSelection selections = (IStructuredSelection)
- HandlerUtil.getCurrentSelectionChecked(event);
-
- Object selection = selections.iterator().next();
- JpaProject jpaProject = getJpaProjectFromSelection(selection);
- if (jpaProject != null) {
- converterJavaGlobalMetadata(jpaProject);
- }
- return null;
- }
-
-
- abstract protected void converterJavaGlobalMetadata(JpaProject jpaProject);
-
- protected JpaPlatformUi getJpaPlatformUi(JpaProject project) {
- String coreJpaPlatformId = project.getJpaPlatform().getId();
- return JpaPlatformUiRegistry.instance().getJpaPlatformUi(coreJpaPlatformId);
- }
-
- protected JpaProject getJpaProjectFromSelection(Object selection) {
- IProject project = getIProjectFromSelection(selection);
- if (project != null) {
- return (JpaProject) project.getAdapter(JpaProject.class);
- }
- return null;
- }
-
- protected IProject getIProjectFromSelection(Object selection) {
- if (selection instanceof IProject) {
- return (IProject) selection;
- }
- if (selection instanceof IJavaProject) {
- return ((IJavaProject) selection).getProject();
- }
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JpaJavaQueryMetadataConversionHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JavaGeneratorConversionHandler.java
index 8e4ed93bc5..dadb127fbe 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JpaJavaQueryMetadataConversionHandler.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JavaGeneratorConversionHandler.java
@@ -11,13 +11,15 @@ package org.eclipse.jpt.jpa.ui.internal.commands;
import org.eclipse.jpt.jpa.core.JpaProject;
-public class JpaJavaQueryMetadataConversionHandler extends AbstractJpaJavaMetadataConversionHandler {
- public JpaJavaQueryMetadataConversionHandler() {
+public class JavaGeneratorConversionHandler
+ extends AbstractJavaMetadataConversionHandler
+{
+ public JavaGeneratorConversionHandler() {
super();
}
@Override
- protected void converterJavaGlobalMetadata(JpaProject jpaProject) {
- super.getJpaPlatformUi(jpaProject).convertJavaQueryMetadataToGlobal(jpaProject);
+ protected void convertJavaMetadata(JpaProject jpaProject) {
+ this.getJpaPlatformUi(jpaProject).convertJavaGeneratorMetadataToGlobal(jpaProject);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JpaJavaGeneratorMetadataConversionHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JavaQueryConversionHandler.java
index b9d9149eb8..8aa38f790b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JpaJavaGeneratorMetadataConversionHandler.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/commands/JavaQueryConversionHandler.java
@@ -11,15 +11,15 @@ package org.eclipse.jpt.jpa.ui.internal.commands;
import org.eclipse.jpt.jpa.core.JpaProject;
-public class JpaJavaGeneratorMetadataConversionHandler extends AbstractJpaJavaMetadataConversionHandler {
-
- public JpaJavaGeneratorMetadataConversionHandler() {
+public class JavaQueryConversionHandler
+ extends AbstractJavaMetadataConversionHandler
+{
+ public JavaQueryConversionHandler() {
super();
}
@Override
- protected void converterJavaGlobalMetadata(JpaProject jpaProject) {
- super.getJpaPlatformUi(jpaProject).convertJavaGeneratorMetadataToGlobal(jpaProject);
-
+ protected void convertJavaMetadata(JpaProject jpaProject) {
+ this.getJpaPlatformUi(jpaProject).convertJavaQueryMetadataToGlobal(jpaProject);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractJpaJavaGlobalMetadataConvertor.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractJpaJavaGlobalMetadataConvertor.java
deleted file mode 100644
index 65d75a6639..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractJpaJavaGlobalMetadataConvertor.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.platform.base;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public abstract class AbstractJpaJavaGlobalMetadataConvertor {
-
- protected JpaProject jpaProject;
-
- public AbstractJpaJavaGlobalMetadataConvertor(JpaProject jpaProject) {
- super();
- this.jpaProject = jpaProject;
- }
-
- public static void convert(JpaProject jpaProject) {
- new GenericJpaJavaQueryMetadataConvertor(jpaProject).convert();
- }
-
- protected void convert() {
- WizardDialog dialog = new WizardDialog(this.getCurrentShell(), getWizard()) {
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setSize(520, 460);
- center(newShell);
- }
- };
- dialog.create();
- dialog.open();
- }
-
- abstract protected Wizard getWizard();
-
- protected Shell getCurrentShell() {
- return Display.getCurrent().getActiveShell();
- }
-
- protected void center(Shell shell) {
- Rectangle bounds = shell.getDisplay().getBounds();
- Point point = shell.getSize();
- int nLeft = (bounds.width - point.x) / 2;
- int nTop = (bounds.height - point.y) / 3;
- shell.setBounds(nLeft, nTop, point.x, point.y);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/BaseJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractJpaPlatformUi.java
index 567f09e21a..7942c16b0c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/BaseJpaPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/AbstractJpaPlatformUi.java
@@ -13,8 +13,11 @@ import java.util.Iterator;
import java.util.ListIterator;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
@@ -35,11 +38,12 @@ import org.eclipse.jpt.jpa.ui.details.JpaComposite;
import org.eclipse.jpt.jpa.ui.details.JpaDetailsPageManager;
import org.eclipse.jpt.jpa.ui.details.JpaDetailsProvider;
import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition;
+import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.JavaMetadataConversionWizard;
+import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.JavaMetadataConversionWizardPage;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-public abstract class BaseJpaPlatformUi
+public abstract class AbstractJpaPlatformUi
implements JpaPlatformUi
{
private final ItemTreeStateProviderFactoryProvider navigatorFactoryProvider;
@@ -47,11 +51,14 @@ public abstract class BaseJpaPlatformUi
private final JpaPlatformUiProvider platformUiProvider;
- protected BaseJpaPlatformUi(
+ protected AbstractJpaPlatformUi(
ItemTreeStateProviderFactoryProvider navigatorFactoryProvider,
JpaPlatformUiProvider platformUiProvider
) {
super();
+ if ((navigatorFactoryProvider == null) || (platformUiProvider == null)) {
+ throw new NullPointerException();
+ }
this.navigatorFactoryProvider = navigatorFactoryProvider;
this.platformUiProvider = platformUiProvider;
}
@@ -182,7 +189,45 @@ public abstract class BaseJpaPlatformUi
// ********** convenience methods **********
protected void displayMessage(String title, String message) {
- Shell currentShell = Display.getCurrent().getActiveShell();
- MessageDialog.openInformation(currentShell, title, message);
+ MessageDialog.openInformation(SWTUtil.getShell(), title, message);
+ }
+
+ protected void openInDialog(JavaMetadataConversionWizardPage wizardPage) {
+ openInDialog(new JavaMetadataConversionWizard(wizardPage));
+ }
+
+ protected void openInDialog(IWizard wizard) {
+ new SizedWizardDialog(wizard).open();
+ }
+
+
+ // ********** wizard dialog **********
+
+ public class SizedWizardDialog
+ extends WizardDialog
+ {
+ private final int width;
+ private final int height;
+
+ public SizedWizardDialog(IWizard wizard) {
+ this(wizard, 520, 460);
+ }
+
+ public SizedWizardDialog(IWizard wizard, int width, int height) {
+ this(SWTUtil.getShell(), wizard, width, height);
+ }
+
+ public SizedWizardDialog(Shell shell, IWizard wizard, int width, int height) {
+ super(shell, wizard);
+ this.width = width;
+ this.height = height;
+ }
+
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setSize(this.width, this.height);
+ SWTUtil.center(shell, this.getParentShell());
+ }
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/GenericJpaJavaGeneratorMetadataConvertor.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/GenericJpaJavaGeneratorMetadataConvertor.java
deleted file mode 100644
index ea25b11617..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/GenericJpaJavaGeneratorMetadataConvertor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.platform.base;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.GenericJpaJavaGeneratorMetadataConversionWizard;
-
-public class GenericJpaJavaGeneratorMetadataConvertor extends
- AbstractJpaJavaGlobalMetadataConvertor {
-
- public GenericJpaJavaGeneratorMetadataConvertor(JpaProject jpaProject) {
- super(jpaProject);
- }
-
-
- public static void convert(JpaProject jpaProject) {
- new GenericJpaJavaGeneratorMetadataConvertor(jpaProject).convert();
- }
-
- @Override
- protected Wizard getWizard() {
- return new GenericJpaJavaGeneratorMetadataConversionWizard(super.jpaProject);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/GenericJpaJavaQueryMetadataConvertor.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/GenericJpaJavaQueryMetadataConvertor.java
deleted file mode 100644
index 8e8080133e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/base/GenericJpaJavaQueryMetadataConvertor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.platform.base;
-
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.GenericJpaJavaQueryMetadataConversionWizard;
-
-public class GenericJpaJavaQueryMetadataConvertor extends
- AbstractJpaJavaGlobalMetadataConvertor {
-
- public GenericJpaJavaQueryMetadataConvertor(JpaProject jpaProject) {
- super(jpaProject);
- }
-
- public static void convert(JpaProject jpaProject) {
- new GenericJpaJavaQueryMetadataConvertor(jpaProject).convert();
- }
-
- @Override
- protected Wizard getWizard(){
- return new GenericJpaJavaQueryMetadataConversionWizard(super.jpaProject);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUi.java
index 7b37e22675..32e3e4743e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericJpaPlatformUi.java
@@ -14,12 +14,12 @@ import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.ui.JpaPlatformUiProvider;
import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
-import org.eclipse.jpt.jpa.ui.internal.platform.base.BaseJpaPlatformUi;
-import org.eclipse.jpt.jpa.ui.internal.platform.base.GenericJpaJavaGeneratorMetadataConvertor;
-import org.eclipse.jpt.jpa.ui.internal.platform.base.GenericJpaJavaQueryMetadataConvertor;
+import org.eclipse.jpt.jpa.ui.internal.platform.base.AbstractJpaPlatformUi;
+import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.GenericJavaGeneratorConversionWizardPage;
+import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.GenericJavaQueryConversionWizardPage;
public class GenericJpaPlatformUi
- extends BaseJpaPlatformUi
+ extends AbstractJpaPlatformUi
{
public GenericJpaPlatformUi(
ItemTreeStateProviderFactoryProvider navigatorFactoryProvider,
@@ -37,10 +37,10 @@ public class GenericJpaPlatformUi
// ********** metadata conversion **********
public void convertJavaQueryMetadataToGlobal(JpaProject jpaProject) {
- GenericJpaJavaQueryMetadataConvertor.convert(jpaProject);
+ this.openInDialog(new GenericJavaQueryConversionWizardPage(jpaProject));
}
public void convertJavaGeneratorMetadataToGlobal(JpaProject jpaProject) {
- GenericJpaJavaGeneratorMetadataConvertor.convert(jpaProject);
+ this.openInDialog(new GenericJavaGeneratorConversionWizardPage(jpaProject));
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizardPage.java
index 8d919df218..49d8ed44ae 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizardPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/JpaMakePersistentWizardPage.java
@@ -283,7 +283,7 @@ public class JpaMakePersistentWizardPage extends WizardPage {
ViewerFilter filter = buildMappingFileDialogViewerFilter();
ITreeContentProvider contentProvider = new WorkbenchContentProvider();
ILabelProvider labelProvider = new WorkbenchLabelProvider();
- SelectJpaOrmMappingFileDialog dialog = new SelectJpaOrmMappingFileDialog(getShell(), this.jpaProject.getProject(), labelProvider, contentProvider);
+ SelectMappingFileDialog dialog = new SelectMappingFileDialog(getShell(), this.jpaProject.getProject(), labelProvider, contentProvider);
dialog.setTitle(EntityWizardMsg.MAPPING_XML_TITLE);
dialog.setMessage(EntityWizardMsg.CHOOSE_MAPPING_XML_MESSAGE);
dialog.addFilter(filter);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJPAProjectWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJPAProjectWizardPage.java
deleted file mode 100644
index 1b4df67238..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJPAProjectWizardPage.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java.JpaJavaGlobalMetadataConversionWizard;
-import org.eclipse.jpt.jpa.ui.internal.wizards.gen.PromptJPAProjectWizardPage;
-import org.eclipse.swt.widgets.TableItem;
-
-public class SelectJPAProjectWizardPage extends PromptJPAProjectWizardPage {
-
- public SelectJPAProjectWizardPage( final String helpContextId ) {
- super(SELECT_PROJECT_PAGE_NAME);
- }
-
- @Override
- protected void handleJpaProjectSelection() {
- if (projTable.getSelectionIndex() != -1) {
- TableItem item = projTable.getItem(projTable.getSelectionIndex());
- String projName = item.getText(0);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
- JpaProject jpaProject = (JpaProject)project.getAdapter(JpaProject.class);
- ((JpaJavaGlobalMetadataConversionWizard)getWizard()).setJpaProject(jpaProject);
- validate();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectMappingFileDialog.java
index eab16c4331..5e27540411 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/SelectMappingFileDialog.java
@@ -9,7 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.wizards;
-import java.io.File;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -37,15 +36,23 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
-public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog
+public class SelectMappingFileDialog
+ extends ElementTreeSelectionDialog
{
protected final IProject project;
protected Label messageLabel;
protected Tree treeWidget;
- public SelectJpaOrmMappingFileDialog(Shell parent, IProject project, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
+
+ public SelectMappingFileDialog(Shell parent, IProject project) {
+ this(parent, project, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+ }
+
+ public SelectMappingFileDialog(Shell parent, IProject project, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
super(parent, labelProvider, contentProvider);
setAllowMultiple(false);
this.project = project;
@@ -55,10 +62,10 @@ public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
Button newButton = new Button(composite, SWT.PUSH);
- newButton.setText(JptUiMessages.SelectJpaOrmMappingFileDialog_newButton);
+ newButton.setText(JptUiMessages.SelectMappingFileDialog_newButton);
GridData browseButtonData = new GridData(GridData.HORIZONTAL_ALIGN_END);
newButton.setLayoutData(browseButtonData);
- newButton.setToolTipText(JptUiMessages.SelectJpaOrmMappingFileDialog_newBtnToolTip);
+ newButton.setToolTipText(JptUiMessages.SelectMappingFileDialog_newButtonToolTip);
newButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
openNewMappingFileWizard();
@@ -84,10 +91,6 @@ public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog
return treeViewer;
}
- /**
- * @param project
- * @return the runtime path of the chosen element
- */
public String getChosenName() {
IPath resourcePath = null;
Object element = getFirstResult();
@@ -96,8 +99,7 @@ public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog
} else {
resourcePath = ((IFile) element).getFullPath();
}
- String runtimePath = this.getProjectResourceLocator().getRuntimePath(resourcePath).toOSString();
- return runtimePath.replace(File.separatorChar, '/');
+ return this.getProjectResourceLocator().getRuntimePath(resourcePath).toString();
}
@Override
@@ -109,15 +111,15 @@ public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog
TreeSelection selection = (TreeSelection)getTreeViewer().getSelection();
IResource selectedResource = (IResource) selection.getFirstElement();
if (selectedResource instanceof IFile) {
- updateStatus(new Status(IStatus.OK, JptJpaUiPlugin.PLUGIN_ID, ""));
+ updateStatus(new Status(IStatus.OK, JptJpaUiPlugin.PLUGIN_ID, "")); //$NON-NLS-1$
}
else {
- updateStatus(new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, ""));
+ updateStatus(new Status(IStatus.ERROR, JptJpaUiPlugin.PLUGIN_ID, "")); //$NON-NLS-1$
}
}
protected void openNewMappingFileWizard() {
- IPath path = EmbeddedMappingFileWizard.createNewMappingFile(new StructuredSelection(this.project), null);
+ IPath path = EmbeddedMappingFileWizard.createNewMappingFile(new StructuredSelection(this.project));
updateDialog(path);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaGeneratorConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaGeneratorConversionWizardPage.java
new file mode 100644
index 0000000000..3b549a5022
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaGeneratorConversionWizardPage.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+
+public class GenericJavaGeneratorConversionWizardPage
+ extends GenericJavaMetadataConversionWizardPage
+{
+ public GenericJavaGeneratorConversionWizardPage(JpaProject jpaProject) {
+ super(jpaProject, JptUiMessages.JavaGeneratorConversionWizardPage_title, JptUiMessages.JavaGeneratorConversionWizardPage_description);
+ }
+
+ @Override
+ protected boolean hasConvertibleJavaMetadata_() {
+ return this.persistenceUnit.hasConvertibleJavaGenerators();
+ }
+
+ @Override
+ protected String getMissingJavaMetadataWarningMessage() {
+ return JptUiMessages.JavaMetadataConversion_noGeneratorsToConvert;
+ }
+
+ @Override
+ protected ConversionCommand.Strategy getConversionCommandStrategy() {
+ return CONVERSION_COMMAND_STRATEGY;
+ }
+
+ public static final ConversionCommandStrategy CONVERSION_COMMAND_STRATEGY = new ConversionCommandStrategy();
+
+ protected static class ConversionCommandStrategy
+ implements ConversionCommand.Strategy
+ {
+ public void execute(EntityMappings entityMappings, IProgressMonitor monitor) {
+ entityMappings.getPersistenceUnit().convertJavaGenerators(entityMappings, monitor);
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaMetadataConversionWizardPage.java
new file mode 100644
index 0000000000..cb5c6c253f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaMetadataConversionWizardPage.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
+import org.eclipse.jpt.jpa.ui.internal.wizards.SelectMappingFileDialog;
+import org.eclipse.jpt.jpa.ui.internal.wizards.orm.EmbeddedMappingFileWizard;
+
+public abstract class GenericJavaMetadataConversionWizardPage
+ extends JavaMetadataConversionWizardPage
+{
+ public GenericJavaMetadataConversionWizardPage(JpaProject jpaProject, String title, String description) {
+ super(jpaProject, title, description);
+ }
+
+ @Override
+ protected IPath getDefaultMappingFileRuntimPath() {
+ return JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH;
+ }
+
+ @Override
+ protected IContentType getMappingFileContentType() {
+ return JptJpaCorePlugin.ORM_XML_CONTENT_TYPE;
+ }
+
+ @Override
+ protected IPath openNewMappingFileWizard() {
+ return EmbeddedMappingFileWizard.createNewMappingFile(new StructuredSelection(this.jpaProject.getProject()));
+ }
+
+ @Override
+ protected SelectMappingFileDialog buildSelectMappingFileDialog(){
+ return new SelectMappingFileDialog(this.getShell(), this.jpaProject.getProject());
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaQueryConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaQueryConversionWizardPage.java
new file mode 100644
index 0000000000..5e9412a13f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJavaQueryConversionWizardPage.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+
+public class GenericJavaQueryConversionWizardPage
+ extends GenericJavaMetadataConversionWizardPage
+{
+ public GenericJavaQueryConversionWizardPage(JpaProject jpaProject) {
+ super(jpaProject, JptUiMessages.JavaQueryConversionWizardPage_title, JptUiMessages.JavaQueryConversionWizardPage_description);
+ }
+
+ @Override
+ protected boolean hasConvertibleJavaMetadata_() {
+ return this.persistenceUnit.hasConvertibleJavaQueries();
+ }
+
+ @Override
+ protected String getMissingJavaMetadataWarningMessage() {
+ return JptUiMessages.JavaMetadataConversion_noQueriesToConvert;
+ }
+
+ @Override
+ protected ConversionCommand.Strategy getConversionCommandStrategy() {
+ return CONVERSION_COMMAND_STRATEGY;
+ }
+
+ public static final ConversionCommandStrategy CONVERSION_COMMAND_STRATEGY = new ConversionCommandStrategy();
+
+ protected static class ConversionCommandStrategy
+ implements ConversionCommand.Strategy
+ {
+ public void execute(EntityMappings entityMappings, IProgressMonitor monitor) {
+ entityMappings.getPersistenceUnit().convertJavaQueries(entityMappings, monitor);
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGeneratorMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGeneratorMetadataConversionWizard.java
deleted file mode 100644
index 604d27fb56..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGeneratorMetadataConversionWizard.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.jpt.jpa.core.JpaProject;
-
-public class GenericJpaJavaGeneratorMetadataConversionWizard extends
- GenericJpaJavaGlobalMetadataConversionWizard {
-
- public GenericJpaJavaGeneratorMetadataConversionWizard(JpaProject jpaProject) {
- super(jpaProject);
- }
-
- @Override
- protected GenericJpaJavaGeneratorMetadataConversionWizardPage buildJpaMetadataConversionWizardPage() {
- return new GenericJpaJavaGeneratorMetadataConversionWizardPage(
- this.getPersistenceUnit(), this.mappingXmlModel, HELP_CONTEXT_ID);
- }
-
- @Override
- public boolean performFinish() {
- try {
- ((GenericJpaJavaGeneratorMetadataConversionWizardPage)
- super.jpaMetadataConversionWizardPage).performFinish();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- return true;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGeneratorMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGeneratorMetadataConversionWizardPage.java
deleted file mode 100644
index ffc18f69b3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGeneratorMetadataConversionWizardPage.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
-
-public class GenericJpaJavaGeneratorMetadataConversionWizardPage extends
- GenericJpaJavaGlobalMetadataConversionWizardPage {
-
- public GenericJpaJavaGeneratorMetadataConversionWizardPage(
- PersistenceUnit persistenceUnit, SimplePropertyValueModel<String> model, String helpContextId) {
- super(persistenceUnit, model, helpContextId);
- }
-
- @Override
- protected String getWizardPageTitle() {
- return JptUiMessages.JpaJavaGeneratorMetadataConversionWizardPage_title;
- }
-
- @Override
- protected String getWizardPageDescription() {
- return JptUiMessages.JpaJavaGeneratorMetadataConversionWizardPage_description;
- }
-
- @Override
- protected void executeConversion(EntityMappings entityMappings, IProgressMonitor monitor){
- persistenceUnit.convertJavaGenerators(entityMappings, monitor);
- }
-
- @Override
- protected boolean hasConvertibleJavaGlobalMetadata() {
- return persistenceUnit.hasConvertibleJavaGenerators();
- }
-
- @Override
- protected String getWarningMessageForNonExistentGlobals() {
- return JptUiMessages.JpaGlobalMetadataConversion_noGeneratorMetadataToConvert;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGlobalMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGlobalMetadataConversionWizard.java
deleted file mode 100644
index a7bdfa77a0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGlobalMetadataConversionWizard.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.context.MappingFile;
-import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
-
-public abstract class GenericJpaJavaGlobalMetadataConversionWizard extends
- JpaJavaGlobalMetadataConversionWizard {
-
- public GenericJpaJavaGlobalMetadataConversionWizard(JpaProject jpaProject) {
- super(jpaProject);
- }
-
- @Override
- protected String getDefaultMappingFileRuntimPath() {
- return JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString();
- }
-
- @Override
- protected MappingFile getFirstAvaliableMappingFile() {
- for (MappingFileRef ref : getPersistenceUnit().getMappingFileRefs()) {
- MappingFile mappingFile = ref.getMappingFile();
- if (mappingFile != null) {
- IFile file = ref.getMappingFile().getXmlResource().getFile();
- if (jpaProject.getJpaFile(file).getContentType().isKindOf(JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE))
- return ref.getMappingFile();
- }
- }
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGlobalMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGlobalMetadataConversionWizardPage.java
deleted file mode 100644
index 0ab7ec3497..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaGlobalMetadataConversionWizardPage.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter;
-import org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog;
-import org.eclipse.jpt.jpa.ui.internal.wizards.orm.EmbeddedMappingFileWizard;
-import org.eclipse.swt.widgets.Shell;
-
-public abstract class GenericJpaJavaGlobalMetadataConversionWizardPage extends
- JpaJavaGlobalMetadataConversionWizardPage<PersistenceUnit> {
-
- public GenericJpaJavaGlobalMetadataConversionWizardPage(
- PersistenceUnit persistenceUnit, SimplePropertyValueModel<String> model, String helpContextId) {
- super(persistenceUnit, model, helpContextId);
- }
-
- @Override
- protected ViewerFilter buildSelectMappingFileDialogViewerFilter() {
- return new XmlMappingFileViewerFilter(this.getJpaProject(), JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE);
- }
-
- @Override
- protected SelectJpaOrmMappingFileDialog buildSelectMappingFileDialog
- (Shell shell, IProject project, ILabelProvider lp, ITreeContentProvider cp){
- return new SelectJpaOrmMappingFileDialog(shell, project, lp, cp);
- }
-
- @Override
- protected IPath getMappingFilePath(){
- return EmbeddedMappingFileWizard.createNewMappingFile(
- new StructuredSelection(this.getJpaProject().getProject()),
- getOrmXmlResourceName());
- }
-
- @Override
- protected String getDefaultMappingFileRuntimPath() {
- return JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaQueryMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaQueryMetadataConversionWizard.java
deleted file mode 100644
index 45590b5b0f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaQueryMetadataConversionWizard.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.jpt.jpa.core.JpaProject;
-
-public class GenericJpaJavaQueryMetadataConversionWizard extends GenericJpaJavaGlobalMetadataConversionWizard {
-
- public GenericJpaJavaQueryMetadataConversionWizard(JpaProject jpaProject) {
- super(jpaProject);
- }
-
- @Override
- protected GenericJpaJavaQueryMetadataConversionWizardPage buildJpaMetadataConversionWizardPage() {
- return new GenericJpaJavaQueryMetadataConversionWizardPage(
- this.getPersistenceUnit(), this.mappingXmlModel, HELP_CONTEXT_ID);
- }
-
- @Override
- public boolean performFinish() {
- try {
- ((GenericJpaJavaQueryMetadataConversionWizardPage)
- super.jpaMetadataConversionWizardPage).performFinish();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- return true;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaQueryMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaQueryMetadataConversionWizardPage.java
deleted file mode 100644
index dafcd851bd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/GenericJpaJavaQueryMetadataConversionWizardPage.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
-
-public class GenericJpaJavaQueryMetadataConversionWizardPage extends
- GenericJpaJavaGlobalMetadataConversionWizardPage {
-
- public GenericJpaJavaQueryMetadataConversionWizardPage(
- PersistenceUnit persistenceUnit, SimplePropertyValueModel<String> model, String helpContextId) {
- super(persistenceUnit, model, helpContextId);
- }
-
-
- @Override
- protected String getWizardPageTitle() {
- return JptUiMessages.JpaJavaQueryMetadataConversionWizardPage_title;
- }
-
- @Override
- protected String getWizardPageDescription() {
- return JptUiMessages.JpaJavaQueryMetadataConversionWizardPage_description;
- }
-
- @Override
- protected void executeConversion(EntityMappings entityMappings, IProgressMonitor monitor) {
- persistenceUnit.convertJavaQueries(entityMappings, monitor);
- }
-
- @Override
- protected boolean hasConvertibleJavaGlobalMetadata() {
- return persistenceUnit.hasConvertibleJavaQueries();
- }
-
- @Override
- protected String getWarningMessageForNonExistentGlobals() {
- return JptUiMessages.JpaGlobalMetadataConversion_noQueryMetadataToConvert;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JavaMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JavaMetadataConversionWizard.java
new file mode 100644
index 0000000000..fa2d215d37
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JavaMetadataConversionWizard.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
+import org.eclipse.jpt.jpa.ui.internal.JptUiIcons;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+
+public class JavaMetadataConversionWizard
+ extends Wizard
+{
+ private final JavaMetadataConversionWizardPage page;
+
+
+ public JavaMetadataConversionWizard(JavaMetadataConversionWizardPage page) {
+ super();
+ if (page == null) {
+ throw new NullPointerException();
+ }
+ this.page = page;
+ this.setWindowTitle(JptUiMessages.JavaMetadataConversionWizard_title);
+ this.setDefaultPageImageDescriptor(JptJpaUiPlugin.getImageDescriptor(JptUiIcons.JPA_FILE_WIZ_BANNER));
+ }
+
+ @Override
+ public void addPages() {
+ this.addPage(this.page);
+ }
+
+ @Override
+ public boolean performFinish() {
+ return this.page.performFinish();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JavaMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JavaMetadataConversionWizardPage.java
new file mode 100644
index 0000000000..159ee0d120
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JavaMetadataConversionWizardPage.java
@@ -0,0 +1,625 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Oracle. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jpt.common.core.internal.utility.WorkspaceRunnableAdapter;
+import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
+import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
+import org.eclipse.jpt.common.ui.internal.utility.SynchronousUiCommandExecutor;
+import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
+import org.eclipse.jpt.common.utility.command.Command;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.Tools;
+import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
+import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
+import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JpaProjectManager;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
+import org.eclipse.jpt.jpa.core.context.MappingFile;
+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
+import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
+import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
+import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
+import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
+import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter;
+import org.eclipse.jpt.jpa.ui.internal.wizards.SelectMappingFileDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+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.Link;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+public abstract class JavaMetadataConversionWizardPage
+ extends WizardPage
+{
+ /**
+ * The JPA project can<em>not</em> be <code>null</code>.
+ */
+ protected final JpaProject jpaProject;
+
+ /**
+ * The persistence unit can be <code>null</code>.
+ */
+ protected final PersistenceUnit persistenceUnit;
+ protected final boolean noConvertibleJavaMetadata;
+
+ private final SimplePropertyValueModel<String> mappingFileNameModel = new SimplePropertyValueModel<String>();
+
+ private static final String PAGE_NAME = "JavaMetadataConversion"; //$NON-NLS-1$
+ public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID_ + PAGE_NAME;
+
+
+ protected JavaMetadataConversionWizardPage(JpaProject jpaProject, String title, String description) {
+ super(PAGE_NAME);
+ if (jpaProject == null) {
+ throw new NullPointerException();
+ }
+ this.jpaProject = jpaProject;
+ this.persistenceUnit = this.buildPersistenceUnit();
+ this.mappingFileNameModel.setValue(this.buildDefaultMappingFileName());
+ this.setTitle(title);
+ this.setDescription(description);
+ this.noConvertibleJavaMetadata = this.hasNoConvertibleJavaMetadata();
+ }
+
+ /**
+ * Return the JPA project's <em>first</em> persistence unit.
+ */
+ protected PersistenceUnit buildPersistenceUnit() {
+ PersistenceXml persistenceXml = this.jpaProject.getRootContextNode().getPersistenceXml();
+ if (persistenceXml == null) {
+ return null;
+ }
+ Persistence persistence = persistenceXml.getPersistence();
+ if (persistence == null) {
+ return null;
+ }
+ Iterator<PersistenceUnit> stream = persistence.getPersistenceUnits().iterator();
+ return stream.hasNext() ? stream.next() : null;
+ }
+
+ protected String buildDefaultMappingFileName() {
+ IPath path = this.buildDefaultMappingFilePath();
+ return (path == null) ? null : path.toString();
+ }
+
+ protected IPath buildDefaultMappingFilePath() {
+ IPath path = this.getFirstMappingFilePath();
+ return (path == null) ? this.getDefaultMappingFileRuntimPath() : this.convertToRuntimPath(path);
+ }
+
+ protected abstract IPath getDefaultMappingFileRuntimPath();
+
+ /**
+ * Return the JPA project's <em>first</em> mapping file with the
+ * {@link #getMappingFileContentType() default content type}.
+ */
+ protected IPath getFirstMappingFilePath() {
+ if (this.persistenceUnit == null) {
+ return null;
+ }
+ for (MappingFileRef ref : this.persistenceUnit.getMappingFileRefs()) {
+ MappingFile mappingFile = ref.getMappingFile();
+ if (mappingFile != null) {
+ IFile file = mappingFile.getXmlResource().getFile();
+ if (this.jpaProject.getJpaFile(file).getContentType().isKindOf(this.getMappingFileContentType())) {
+ return file.getFullPath();
+ }
+ }
+ }
+ return null;
+ }
+
+ protected IContentType getMappingFileContentType() {
+ return JptJpaCorePlugin.MAPPING_FILE_CONTENT_TYPE;
+ }
+
+ protected IPath convertToRuntimPath(IPath path) {
+ ProjectResourceLocator locator = (ProjectResourceLocator) this.jpaProject.getProject().getAdapter(ProjectResourceLocator.class);
+ return locator.getRuntimePath(path);
+ }
+
+
+ // ********** missing metadata warning message **********
+
+ protected final boolean hasNoConvertibleJavaMetadata() {
+ return ! this.hasConvertibleJavaMetadata();
+ }
+
+ protected final boolean hasConvertibleJavaMetadata() {
+ return (this.persistenceUnit != null) && this.hasConvertibleJavaMetadata_();
+ }
+
+ /**
+ * Pre-condition: the {@link #persistenceUnit persistence unit}
+ * is not <code>null</code>.
+ */
+ protected abstract boolean hasConvertibleJavaMetadata_();
+
+ protected abstract String getMissingJavaMetadataWarningMessage();
+
+
+ // ********** UI control **********
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout());
+
+ Label pageLabel = new Label(composite, SWT.NONE);
+ pageLabel.setText(JptUiMessages.JavaMetadataConversionWizardPage_label);
+ pageLabel.setBounds(3, 230, 150, 12);
+
+ Control mappingFileControl = this.createMappingFileControl(composite);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ data.heightHint = 58;
+ data.grabExcessHorizontalSpace = true;
+ mappingFileControl.setLayoutData(data);
+
+ Text noteTextField = new Text(composite, SWT.READ_ONLY | SWT.MULTI);
+ noteTextField.setText(NLS.bind(JptUiMessages.JavaMetadataConversion_warning, StringTools.CR));
+ noteTextField.setFont(new Font(composite.getDisplay(), "Arial", 10, SWT.EMBEDDED)); //$NON-NLS-1$
+ noteTextField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
+
+ this.setControl(composite);
+
+ // no need to remove this listener, since we build the model ourselves
+ this.mappingFileNameModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildMappingFileNameListener());
+ this.setPageComplete(this.getOrmXmlResource() != null);
+ }
+
+ protected Control createMappingFileControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout(3, false));
+
+ Link link = new Link(composite, SWT.LEFT);
+ link.setText(JptUiMessages.JavaMetadataConversionWizardPage_newMappingFileLink);
+ link.setToolTipText(JptUiMessages.JavaMetadataConversionWizardPage_newMappingFileLinkToolTip);
+ link.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ link.addSelectionListener(this.buildMappingFileLinkListener());
+
+ Text nameTextField = new Text(composite, SWT.SEARCH | SWT.SINGLE);
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.grabExcessVerticalSpace = true;
+ gridData.widthHint = 486;
+ gridData.heightHint = 14;
+ gridData.horizontalSpan = 1;
+ gridData.grabExcessHorizontalSpace = true;
+ nameTextField.setLayoutData(gridData);
+ SWTTools.bind(this.mappingFileNameModel, nameTextField);
+
+ Button browseButton = new Button(composite, SWT.CENTER);
+ browseButton.setToolTipText(JptUiMessages.JavaMetadataConversionWizardPage_mappingFileBrowseButtonToolTip);
+ browseButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
+ browseButton.setText(JptUiMessages.JavaMetadataConversionWizardPage_mappingFileBrowseButton);
+ browseButton.addSelectionListener(this.buildMappingFileBrowseButtonListener());
+
+ return composite;
+ }
+
+
+ // ********** mapping file name listener **********
+
+ protected PropertyChangeListener buildMappingFileNameListener() {
+ return new MappingFileNameListener();
+ }
+
+ protected class MappingFileNameListener
+ extends PropertyChangeAdapter
+ {
+ @Override
+ public void propertyChanged(PropertyChangeEvent event) {
+ JavaMetadataConversionWizardPage.this.validate();
+ }
+ }
+
+ protected void validate() {
+ String errorMessage = this.buildErrorMessage();
+ this.setErrorMessage(errorMessage);
+ this.setPageComplete(errorMessage == null);
+ }
+
+ protected String buildErrorMessage() {
+ JpaXmlResource ormXmlResource = this.getOrmXmlResource();
+ if (ormXmlResource == null) {
+ return JptUiMessages.JavaMetadataConversion_mappingFileDoesNotExist;
+ }
+ String mappingFileVersion = ormXmlResource.getVersion();
+ String jpaProjectVersion = this.getJpaProjectVersion();
+ if (Tools.valuesAreDifferent(mappingFileVersion, jpaProjectVersion)) {
+ return NLS.bind(JptUiMessages.JavaMetadataConversion_mappingFileVersionIsInvalid, mappingFileVersion, jpaProjectVersion);
+ }
+ if (this.getEntityMappings(ormXmlResource) == null) {
+ return JptUiMessages.JavaMetadataConversion_mappingFileNotListedInPersistenceXml;
+ }
+ if (this.noConvertibleJavaMetadata) {
+ this.setMessage(this.getMissingJavaMetadataWarningMessage(), IMessageProvider.WARNING);
+ }
+ return null;
+ }
+
+ protected EntityMappings getEntityMappings() {
+ return this.getEntityMappings(this.getOrmXmlResource());
+ }
+
+ protected EntityMappings getEntityMappings(JpaXmlResource ormXmlResource) {
+ return (ormXmlResource == null) ? null : this.getEntityMappings_(ormXmlResource);
+ }
+
+ /**
+ * Pre-condition: the specified <code>orm.xml</code> resource is
+ * not <code>null</code>.
+ */
+ protected EntityMappings getEntityMappings_(JpaXmlResource ormXmlResource) {
+ Iterator<JpaStructureNode> nodes = this.jpaProject.getJpaFile(ormXmlResource.getFile()).getRootStructureNodes().iterator();
+ return nodes.hasNext() ? (EntityMappings) nodes.next() : null;
+ }
+
+ protected JpaXmlResource getOrmXmlResource() {
+ IPath mappingFilePath = this.getMappingFilePath();
+ return (mappingFilePath == null) ? null : this.jpaProject.getMappingFileXmlResource(mappingFilePath);
+ }
+
+ protected IPath getMappingFilePath() {
+ String mappingFileName = this.getMappingFileName();
+ return StringTools.stringIsEmpty(mappingFileName) ? null : new Path(mappingFileName);
+ }
+
+ protected String getMappingFileName() {
+ String mappingFileName = this.mappingFileNameModel.getValue();
+ return StringTools.stringIsEmpty(mappingFileName) ? null : mappingFileName;
+ }
+
+ protected String getJpaProjectVersion(){
+ return this.jpaProject.getJpaPlatform().getJpaVersion().getVersion();
+ }
+
+
+ // ********** mapping file link listener **********
+
+ protected SelectionListener buildMappingFileLinkListener() {
+ return new MappingFileLinkListener();
+ }
+
+ protected class MappingFileLinkListener
+ extends SelectionAdapter
+ {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ JavaMetadataConversionWizardPage.this.mappingFileLinkPressed();
+ }
+ }
+
+ protected void mappingFileLinkPressed() {
+ IPath path = this.openNewMappingFileWizard();
+ if (path != null) {
+ this.mappingFileNameModel.setValue(path.toString());
+ // revalidate because the mapping file may have been created
+ this.validate();
+ }
+ }
+
+ protected abstract IPath openNewMappingFileWizard();
+
+
+ // ********** mapping file browse button listener **********
+
+ protected SelectionListener buildMappingFileBrowseButtonListener() {
+ return new MappingFileBrowseButtonListener();
+ }
+
+ protected class MappingFileBrowseButtonListener
+ extends SelectionAdapter
+ {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ JavaMetadataConversionWizardPage.this.mappingFileBrowseButtonPressed();
+ }
+ }
+
+ protected void mappingFileBrowseButtonPressed() {
+ IProject project = this.jpaProject.getProject();
+ SelectMappingFileDialog dialog = this.buildSelectMappingFileDialog();
+ dialog.setTitle(JptUiMessages.SelectMappingFileDialog_title);
+ dialog.setMessage(JptUiMessages.SelectMappingFileDialog_message);
+ dialog.addFilter(this.buildSelectMappingFileDialogViewerFilter());
+ dialog.setInput(project);
+
+ JpaXmlResource resource = this.getOrmXmlResource();
+ IFile file = (resource == null) ? null : resource.getFile();
+ if (file != null) {
+ dialog.setInitialSelection(file);
+ }
+ if (dialog.open() == Window.OK) {
+ this.mappingFileNameModel.setValue(dialog.getChosenName());
+ // revalidate because the mapping file may have been created
+ this.validate();
+ }
+ }
+
+ protected abstract SelectMappingFileDialog buildSelectMappingFileDialog();
+
+ protected ViewerFilter buildSelectMappingFileDialogViewerFilter() {
+ return new XmlMappingFileViewerFilter(this.jpaProject, this.getMappingFileContentType());
+ }
+
+
+ // ********** finish => conversion **********
+
+ protected boolean performFinish() {
+ return this.isOKToConvert() && this.performFinish_();
+ }
+
+ protected boolean isOKToConvert() {
+ return this.hasConvertibleJavaMetadata();
+ }
+
+ protected boolean performFinish_() {
+ // true=fork; true=cancellable
+ try {
+ this.buildProgressMonitorDialog().run(true, true, this.buildConversionRunnable());
+ } catch (InvocationTargetException ex) {
+ JptJpaUiPlugin.log(ex);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt(); // runnable cancelled
+ }
+ return true;
+ }
+
+ protected ProgressMonitorDialog buildProgressMonitorDialog() {
+ return new ProgressMonitorDialog(this.getShell());
+ }
+
+ protected IRunnableWithProgress buildConversionRunnable() {
+ return new ConversionRunnable(this.getConversionCommandStrategy(), this.getEntityMappings());
+ }
+
+ protected abstract ConversionCommand.Strategy getConversionCommandStrategy();
+
+ /**
+ * UI runnable
+ */
+ protected static class ConversionRunnable
+ implements IRunnableWithProgress
+ {
+ protected final ConversionCommand.Strategy conversionCommandStrategy;
+ protected final EntityMappings entityMappings;
+
+ protected ConversionRunnable(ConversionCommand.Strategy conversionCommandStrategy, EntityMappings entityMappings) {
+ super();
+ if ((conversionCommandStrategy == null) || (entityMappings == null)) {
+ throw new NullPointerException();
+ }
+ this.conversionCommandStrategy = conversionCommandStrategy;
+ this.entityMappings = entityMappings;
+ }
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ IWorkspace ws = ResourcesPlugin.getWorkspace();
+ ISchedulingRule rule = ws.getRuleFactory().modifyRule(ws.getRoot());
+ try {
+ ws.run(this.buildWorkspaceRunnable(), rule, IWorkspace.AVOID_UPDATE, monitor);
+ } catch (CoreException ex) {
+ if (ex.getStatus().getSeverity() == IStatus.CANCEL) {
+ throw new InterruptedException(); // ???
+ }
+ throw new InvocationTargetException(ex);
+ }
+ }
+
+ protected void run_(IProgressMonitor monitor) {
+ Command conversionCommand = new ConversionCommand(this.conversionCommandStrategy, this.entityMappings, monitor);
+ try {
+ this.getJpaProjectManager().execute(conversionCommand, SynchronousUiCommandExecutor.instance());
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ throw new OperationCanceledException();
+ }
+ }
+
+ protected IWorkspaceRunnable buildWorkspaceRunnable() {
+ return new WorkspaceRunnable();
+ }
+
+ protected JpaProjectManager getJpaProjectManager() {
+ return (JpaProjectManager) this.getWorkspace().getAdapter(JpaProjectManager.class);
+ }
+
+ protected IWorkspace getWorkspace() {
+ return this.entityMappings.getParent().getXmlResource().getFile().getWorkspace();
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this);
+ }
+
+ /**
+ * Workspace runnable
+ */
+ protected class WorkspaceRunnable
+ extends WorkspaceRunnableAdapter
+ {
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ConversionRunnable.this.run_(monitor);
+ }
+ }
+ }
+
+
+ /**
+ * Conversion command.
+ * This is dispatched to the JPA project manager.
+ */
+ protected static class ConversionCommand
+ implements Command
+ {
+ protected final Strategy strategy;
+ protected final EntityMappings entityMappings;
+ protected final IProgressMonitor monitor;
+
+ protected ConversionCommand(Strategy strategy, EntityMappings entityMappings, IProgressMonitor monitor) {
+ super();
+ if ((strategy == null) || (entityMappings == null) || (monitor == null)) {
+ throw new NullPointerException();
+ }
+ this.strategy = strategy;
+ this.entityMappings = entityMappings;
+ this.monitor = monitor;
+ }
+
+ public void execute() {
+ this.strategy.execute(this.entityMappings, this.monitor);
+ this.getOrmXmlResource().save();
+ this.saveAllFiles();
+ this.openEditorOnMappingFile();
+ }
+
+ protected JpaXmlResource getOrmXmlResource() {
+ return this.entityMappings.getParent().getXmlResource();
+ }
+
+ protected void saveAllFiles() {
+ SWTUtil.asyncExec(this.buildSaveAllFilesRunnable());
+ }
+
+ protected Runnable buildSaveAllFilesRunnable() {
+ return new SaveFilesRunnable(this.getProject());
+ }
+
+ protected IProject getProject() {
+ return this.entityMappings.getJpaProject().getProject();
+ }
+
+ protected void openEditorOnMappingFile() {
+ SWTUtil.asyncExec(this.buildOpenEditorOnMappingFileRunnable());
+ }
+
+ protected Runnable buildOpenEditorOnMappingFileRunnable() {
+ return new OpenEditorRunnable(this.getOrmXmlResource().getFile());
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this, this.entityMappings.getPersistenceUnit());
+ }
+
+ public interface Strategy {
+ void execute(EntityMappings entityMappings, IProgressMonitor monitor);
+ }
+ }
+
+
+ // ********** save files **********
+
+ protected static class SaveFilesRunnable
+ implements Runnable
+ {
+ protected final IResource[] resourceRoots;
+
+ protected SaveFilesRunnable(IProject project) {
+ super();
+ if (project == null) {
+ throw new NullPointerException();
+ }
+ this.resourceRoots = new IResource[] { project };
+ }
+
+ public void run() {
+ IDE.saveAllEditors(this.resourceRoots, false); // false=no confirm
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this, this.resourceRoots[0]);
+ }
+ }
+
+
+ // ********** open editor **********
+
+ protected static class OpenEditorRunnable
+ implements Runnable
+ {
+ protected final IFile file;
+
+ protected OpenEditorRunnable(IFile file) {
+ super();
+ if (file == null) {
+ throw new NullPointerException();
+ }
+ this.file = file;
+ }
+
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, this.file);
+ } catch (PartInitException ex) {
+ JptJpaUiPlugin.log(ex);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return StringTools.buildToStringFor(this, this.file);
+ }
+ }
+
+
+ // ********** misc **********
+
+ @Override
+ public final void performHelp() {
+ PlatformUI.getWorkbench().getHelpSystem().displayHelp(HELP_CONTEXT_ID);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JpaJavaGlobalMetadataConversionWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JpaJavaGlobalMetadataConversionWizard.java
deleted file mode 100644
index c15a78af1c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JpaJavaGlobalMetadataConversionWizard.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
-import java.io.File;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.resource.LocalResourceManager;
-import org.eclipse.jface.resource.ResourceManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jpt.common.core.internal.resource.ResourceLocatorManager;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.MappingFile;
-import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin;
-import org.eclipse.jpt.jpa.ui.internal.JptUiIcons;
-import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
-import org.eclipse.jpt.jpa.ui.internal.wizards.SelectJPAProjectWizardPage;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public abstract class JpaJavaGlobalMetadataConversionWizard extends Wizard {
- public static final String HELP_CONTEXT_ID = JptJpaUiPlugin.PLUGIN_ID + ".GLobalMetadataConversion"; //$NON-NLS-1$
-
- protected JpaProject jpaProject;
- protected final ResourceManager resourceManager;
- protected SimplePropertyValueModel<String> mappingXmlModel;
- protected IStructuredSelection selection;
-
- private SelectJPAProjectWizardPage selectJPAProjectWizardPage;
- protected JpaJavaGlobalMetadataConversionWizardPage<?> jpaMetadataConversionWizardPage;
-
- public JpaJavaGlobalMetadataConversionWizard(JpaProject jpaProject) {
- this.jpaProject = jpaProject;
- this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
- this.mappingXmlModel = new SimplePropertyValueModel<String>();
- this.setWindowTitle(JptUiMessages.JpaGlobalMetadataConversionWizard_title);
- this.setDefaultPageImageDescriptor(JptJpaUiPlugin.getImageDescriptor(JptUiIcons.JPA_FILE_WIZ_BANNER));
- return;
- }
-
- @Override
- public void addPages() {
- if( this.jpaProject == null ){
- this.selectJPAProjectWizardPage= new SelectJPAProjectWizardPage(HELP_CONTEXT_ID);
- this.addPage(this.selectJPAProjectWizardPage);
- return;
- }
- setMappingXml();
- addMainPages();
- }
-
- protected void addMainPages(){
- this.jpaMetadataConversionWizardPage = buildJpaMetadataConversionWizardPage();
- this.addPage(jpaMetadataConversionWizardPage);
- }
-
- @Override
- public boolean performFinish() {
- return true;
- }
-
- protected PersistenceUnit getPersistenceUnit() {
- PersistenceXml persistenceXml = this.jpaProject.getRootContextNode().getPersistenceXml();
- if (persistenceXml != null) {
- Persistence persistence = persistenceXml.getPersistence();
- if (persistence != null && persistence.getPersistenceUnitsSize() > 0) {
- for (PersistenceUnit pu : persistence.getPersistenceUnits())
- return pu; // return the first persistence unit
- }
- }
- return null;
- }
-
- public void setJpaProject(JpaProject jpaProject) {
- if (this.jpaProject == null) {
- this.jpaProject = jpaProject;
- IWizardPage currentPage = getContainer().getCurrentPage();
- if (this.selectJPAProjectWizardPage != null && currentPage.equals(this.selectJPAProjectWizardPage)) {
- setMappingXml();
- buildJpaMetadataConversionWizardPage();
- }
- }
- }
-
- @Override
- public void dispose() {
- this.resourceManager.dispose();
- super.dispose();
- }
-
- protected void setMappingXml() {
- if (getFirstAvaliableMappingFile() == null) {
- this.mappingXmlModel.setValue(null);
- } else
- if (getDefaultOrmXmlResource() != null) {
- this.mappingXmlModel.setValue(getDefaultMappingFileRuntimPath());
- } else {
- this.mappingXmlModel.setValue(getMappingFileRuntimPath(getFirstAvaliableMappingFile()));
- }
- }
-
- protected String getMappingFileRuntimPath(MappingFile mappingFile) {
- if (mappingFile != null) {
- IPath resourcePath = mappingFile.getXmlResource().getFile().getFullPath();
- IProject project = jpaProject.getProject();
- @SuppressWarnings("restriction")
- String runtimePath = ResourceLocatorManager.instance().getResourceLocator(project).
- getRuntimePath(project, resourcePath).toOSString();
- return runtimePath.replace(File.separatorChar, '/');
- }
- return null;
- }
-
- protected JpaXmlResource getDefaultOrmXmlResource() {
- return jpaProject.getMappingFileXmlResource(new Path(getDefaultMappingFileRuntimPath()));
- }
-
- protected static Shell getCurrentShell() {
- return Display.getCurrent().getActiveShell();
- }
-
- // ************ abstract methods ***************
-
- abstract protected JpaJavaGlobalMetadataConversionWizardPage<?> buildJpaMetadataConversionWizardPage();
-
- abstract protected String getDefaultMappingFileRuntimPath();
-
- abstract protected MappingFile getFirstAvaliableMappingFile();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JpaJavaGlobalMetadataConversionWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JpaJavaGlobalMetadataConversionWizardPage.java
deleted file mode 100644
index 7bdd2e66be..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/conversion/java/JpaJavaGlobalMetadataConversionWizardPage.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are 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:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.ui.internal.wizards.conversion.java;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.jpt.common.ui.internal.utility.SynchronousUiCommandExecutor;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.JpaProjectManager;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.jpa.ui.internal.JptUiMessages;
-import org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-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.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
-
-public abstract class JpaJavaGlobalMetadataConversionWizardPage<P extends PersistenceUnit>
-extends WizardPage {
-
- private static String METADATA_CONVERSION_PAGE_NAME = "MetadataConversion"; //$NON-NLS-1$
- protected final P persistenceUnit;
- private final ModifiablePropertyValueModel<String> mappingFileModel;
-
- private final String helpContextId;
-
- public JpaJavaGlobalMetadataConversionWizardPage(
- final P persistenceUnit, SimplePropertyValueModel<String> model, final String helpContextId) {
- super(METADATA_CONVERSION_PAGE_NAME);
- this.persistenceUnit = persistenceUnit;
- this.mappingFileModel = model;
- this.helpContextId = helpContextId;
- setTitle(this.getWizardPageTitle());
- setDescription(this.getWizardPageDescription());
- }
-
- public void createControl(Composite parent) {
-
- Composite composite = new Composite(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
-
- Label WizardPageLbl = new Label(composite, SWT.NONE);
- WizardPageLbl.setText(JptUiMessages.JpaGlobalMetadataConversionWizardPage_label);
- WizardPageLbl.setBounds(3, 230, 150, 12);
-
- Composite mappingFileComposite = this.createMappingFileControl(composite);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.heightHint = 58;
- data.grabExcessHorizontalSpace = true;
- mappingFileComposite.setLayoutData(data);
- setControl(composite);
-
- String message = org.eclipse.osgi.util.NLS.bind(
- JptUiMessages.JpaGlobalMetadataConversion_convertingJpaGlobalMetadataWarning, StringTools.CR);
- Text noteText = new Text(composite, SWT.READ_ONLY | SWT.MULTI);
- Font font = new Font(composite.getDisplay(), "Arial", 10, SWT.EMBEDDED);
- noteText.setText(message);
- noteText.setFont(font);
- noteText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
-
- setPageComplete(this.mappingFileModel.getValue() != null);
- }
-
- private Composite createMappingFileControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- int nColumns = 3;
- GridLayout layout = new GridLayout();
- layout.numColumns = nColumns;
- composite.setLayout(layout);
-
- final Link mappingFileLink = new Link(composite, SWT.LEFT);
- mappingFileLink.setText(JptUiMessages.JpaGlobalMetadataConversionWizardPage_newMappingFileLink);
- mappingFileLink.setToolTipText(JptUiMessages.JpaGlobalMetadataConversionWizardPage_newMappingFileLinkToolTip);
- mappingFileLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- mappingFileLink.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- openNewMappingFileWizard();
- }
- });
-
- Text mappingFileNameTextField = createMappingFileNameText(composite, 1);
- SWTTools.bind(this.mappingFileModel, mappingFileNameTextField);
- this.mappingFileModel.addPropertyChangeListener(PropertyValueModel.VALUE, new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- validate();
- }
- });
-
- Button mappingFileBrowseBtn = new Button(composite, SWT.CENTER);
- mappingFileBrowseBtn.setToolTipText(JptUiMessages.JpaGlobalMetadataConversionWizardPage_browseMappingFileBtnToolTip);
- mappingFileBrowseBtn.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
- mappingFileBrowseBtn.setText(JptUiMessages.JpaGlobalMetadataConversionWizardPage_browseMappingFileBtn);
- mappingFileBrowseBtn.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mappingFileBrowseBtnPressed();
- }
- });
-
- return composite;
- }
-
- private Text createMappingFileNameText(Composite parent, int span) {
- Text text = new Text(parent, SWT.SEARCH | SWT.SINGLE);
- text.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- }
- });
-
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.grabExcessVerticalSpace = true;
- gridData.widthHint = 486;
- gridData.heightHint = 14;
- gridData.horizontalSpan = span;
- gridData.grabExcessHorizontalSpace = true;
-
- text.setLayoutData(gridData);
-
- return text;
- }
-
- protected void mappingFileBrowseBtnPressed() {
- IProject project = this.getJpaProject().getProject();
- ViewerFilter filter = this.buildSelectMappingFileDialogViewerFilter();
- ITreeContentProvider contentProvider = new WorkbenchContentProvider();
- ILabelProvider labelProvider = new WorkbenchLabelProvider();
- SelectJpaOrmMappingFileDialog dialog = buildSelectMappingFileDialog(getShell(), project, labelProvider, contentProvider);
- dialog.setTitle(JptUiMessages.SelectJpaOrmMappingFileDialog_title);
- dialog.setMessage(JptUiMessages.SelectJpaOrmMappingFileDialog_message);
- dialog.addFilter(filter);
- dialog.setInput(project);
-
- JpaXmlResource resource = this.getJpaProject().getMappingFileXmlResource(new Path(getMappingFileRuntimePath()));
- IFile file = (resource == null) ? null : resource.getFile();
- if (file != null) {
- dialog.setInitialSelection(file);
- }
- if (dialog.open() == org.eclipse.jface.window.Window.OK) {
- this.mappingFileModel.setValue(dialog.getChosenName());
- }
- }
-
- protected JpaProject getJpaProject() {
- return this.persistenceUnit.getJpaProject();
- }
-
- protected void openNewMappingFileWizard() {
- IPath path = getMappingFilePath();
- if (path != null) {
- this.mappingFileModel.setValue(path.toString());
- }
- }
-
- protected String getMappingFileRuntimePath() {
- if (this.mappingFileModel.getValue() != null) {
- return this.mappingFileModel.getValue();
- }
- return getDefaultMappingFileRuntimPath();
- }
-
- protected String getDefaultOrmXmlResourceName() {
- return new File(getDefaultMappingFileRuntimPath()).getName();
- }
-
- protected JpaXmlResource getDefaultOrmXmlResource() {
- return getJpaProject().getMappingFileXmlResource(new Path(getDefaultMappingFileRuntimPath()));
- }
-
- protected String getOrmXmlResourceName() {
- return new File(getMappingFileRuntimePath()).getName();
- }
-
- protected JpaXmlResource getOrmXmlResource() {
- return getJpaProject().getMappingFileXmlResource(new Path(getMappingFileRuntimePath()));
- }
-
- @Override
- public final void performHelp() {
- PlatformUI.getWorkbench().getHelpSystem().displayHelp(this.helpContextId);
- }
-
- public void performFinish() throws InvocationTargetException {
- try {
- // true=fork; true=cancellable
- this.buildPerformFinishProgressMonitorDialog().run(true, true, this.buildPerformFinishRunableWithProgress());
- }
- catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- }
-
- protected ProgressMonitorDialog buildPerformFinishProgressMonitorDialog() {
- return new ProgressMonitorDialog(getControl().getShell());
- }
-
- protected IRunnableWithProgress buildPerformFinishRunableWithProgress() {
- return new IRunnableWithProgress() {
- public void run( final IProgressMonitor monitor) throws InvocationTargetException {
- IWorkspace ws = ResourcesPlugin.getWorkspace();
- ISchedulingRule rule = ws.getRuleFactory().modifyRule(ws.getRoot());
- try {
- ws.run(
- buildPerformFinishWorkspaceRunnable(),
- rule,
- IWorkspace.AVOID_UPDATE,
- monitor);
- }
- catch (CoreException ex) {
- throw new InvocationTargetException(ex);
- }
- }
- };
- }
-
- private IWorkspaceRunnable buildPerformFinishWorkspaceRunnable() {
- return new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- Command syncCommand = new SyncCommand(persistenceUnit, monitor);
- try {
- JpaJavaGlobalMetadataConversionWizardPage.this.getJpaProjectManager().
- execute(syncCommand, SynchronousUiCommandExecutor.instance());
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- }
- };
- }
-
- private JpaProjectManager getJpaProjectManager() {
- return (JpaProjectManager) this.getWorkspace().getAdapter(JpaProjectManager.class);
- }
-
- private IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- protected IDataModelProvider getDefaultProvider() {
- return new OrmFileCreationDataModelProvider();
- }
-
- protected String getMappingFileVersion(){
- return getOrmXmlResource().getVersion();
- }
-
- protected String getJpaProjectVersion(){
- return getJpaProject().getJpaPlatform().getJpaVersion().getVersion();
- }
-
- protected void validate() {
- String errorMessage = null;
- JpaXmlResource ormXmlResource = getOrmXmlResource();
- if (ormXmlResource == null) {
- errorMessage = JptUiMessages.JpaGlobalMetadataConversion_mappingFileDoesNotExist;
- } else
- if (!StringTools.stringsAreEqual(getMappingFileVersion(),getJpaProjectVersion())) {
- errorMessage = JptUiMessages.JpaGlobalMetadataConversion_mappingFileHasInvalidVersion;
- }
- else
- if (getJpaProject().getJpaFile(ormXmlResource.getFile()).getRootStructureNodesSize() == 0) {
- errorMessage = JptUiMessages.JpaGlobalMetadataConversion_mappingFileNotListedInPersistenceXml;
- }
- if ( ! this.hasConvertibleJavaGlobalMetadata()) {
- String message = getWarningMessageForNonExistentGlobals();
- setMessage(message, 2);
- }
- setErrorMessage(errorMessage);
- setPageComplete(errorMessage == null);
- }
-
- // ********* abstract methods *************
-
- abstract protected String getWizardPageTitle();
-
- abstract protected String getWizardPageDescription();
-
- abstract protected ViewerFilter buildSelectMappingFileDialogViewerFilter();
-
- abstract protected SelectJpaOrmMappingFileDialog buildSelectMappingFileDialog
- (Shell shell, IProject project, ILabelProvider lp, ITreeContentProvider cp);
-
- abstract protected IPath getMappingFilePath();
-
- abstract protected String getDefaultMappingFileRuntimPath();
-
- abstract protected void executeConversion(EntityMappings entityMappings, IProgressMonitor monitor);
-
- abstract protected boolean hasConvertibleJavaGlobalMetadata();
-
- abstract protected String getWarningMessageForNonExistentGlobals();
-
- // ********** sync command **********
-
- /**
- * This is dispatched to the JPA project manager.
- */
- class SyncCommand implements Command {
- private final PersistenceUnit persistenceUnit;
- private final IProgressMonitor monitor;
-
- SyncCommand(PersistenceUnit persistenceUnit, IProgressMonitor monitor) {
- super();
- this.persistenceUnit = persistenceUnit;
- this.monitor = monitor;
- }
-
- public void execute() {
- JpaXmlResource ormXmlResource = getOrmXmlResource();
- final EntityMappings entityMappings = getEntityMappings();
- execute(entityMappings).run();
- ormXmlResource.save();
- saveFiles(JpaJavaGlobalMetadataConversionWizardPage.this.getJpaProject());
- openEditor();
- }
-
- private Runnable execute(final EntityMappings entityMappings) {
- return (new Runnable() {
- public void run() {
- executeConversion(entityMappings, monitor);
- }});
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.persistenceUnit);
- }
- }
-
- protected EntityMappings getEntityMappings() {
- JpaXmlResource xmlResource = getOrmXmlResource();
- return (EntityMappings) getJpaProject().getJpaFile(xmlResource.getFile()).getRootStructureNodes().iterator().next();
- }
-
- protected void saveFiles(final JpaProject jpaProject) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- IDE.saveAllEditors(new IResource[]{jpaProject.getProject()}, false);
- }
- });
- }
-
- protected void openEditor() {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- getConversionCompletedAction().run();
- }
- });
- }
-
- protected Action getConversionCompletedAction() {
- return new Action() {
- @Override
- public void run() {
- JpaXmlResource resource = getJpaProject().getMappingFileXmlResource(new Path(getMappingFileRuntimePath()));
- IFile file = resource.getFile();
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- try {
- IDE.openEditor(page, file, true);
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- }
- };
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityClassWizardPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityClassWizardPage.java
index e0a187b5dd..249a70c579 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityClassWizardPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/entity/EntityClassWizardPage.java
@@ -35,7 +35,7 @@ import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter;
-import org.eclipse.jpt.jpa.ui.internal.wizards.SelectJpaOrmMappingFileDialog;
+import org.eclipse.jpt.jpa.ui.internal.wizards.SelectMappingFileDialog;
import org.eclipse.jpt.jpa.ui.internal.wizards.entity.data.model.IEntityDataModelProperties;
import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
@@ -342,7 +342,7 @@ public class EntityClassWizardPage
ViewerFilter filter = getDialogViewerFilter(jpaProject);
ITreeContentProvider contentProvider = new WorkbenchContentProvider();
ILabelProvider labelProvider = new WorkbenchLabelProvider();
- SelectJpaOrmMappingFileDialog dialog = new SelectJpaOrmMappingFileDialog(getShell(), project, labelProvider, contentProvider);
+ SelectMappingFileDialog dialog = new SelectMappingFileDialog(getShell(), project, labelProvider, contentProvider);
dialog.setTitle(EntityWizardMsg.MAPPING_XML_TITLE);
dialog.setMessage(EntityWizardMsg.CHOOSE_MAPPING_XML_MESSAGE);
dialog.addFilter(filter);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/EmbeddedMappingFileWizard.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/EmbeddedMappingFileWizard.java
index 1c1072c284..2cddf4578c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/EmbeddedMappingFileWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/wizards/orm/EmbeddedMappingFileWizard.java
@@ -16,19 +16,30 @@ import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
/**
- * This wizard will create a new mapping file without open it afterwards.
- * It is used within other wizards where opening mapping file is unnecessary,
- * therefore, making the whole process more smooth.
- * This wizard has one more attribute called <code> DEFAULT_XML_FILE_NAME </code>
- * used when the given XML file name is null to avoid NullPointerException.
+ * This wizard will create a new mapping file without opening it afterwards.
+ * It can be used within other wizards where opening the mapping file is
+ * unnecessary, making the process smoother.
*/
+public class EmbeddedMappingFileWizard
+ extends MappingFileWizard
+{
+ public static IPath createNewMappingFile(IStructuredSelection selection) {
+ return createNewMappingFile(selection, null);
+ }
+
+ public static IPath createNewMappingFile(IStructuredSelection selection, String xmlFileName) {
+ if (xmlFileName == null) {
+ xmlFileName = DEFAULT_XML_FILE_NAME;
+ }
+ EmbeddedMappingFileWizard wizard = new EmbeddedMappingFileWizard(DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider()));
+ return MappingFileWizard.createMappingFile(selection, xmlFileName, wizard);
+ }
+
+ private static final String DEFAULT_XML_FILE_NAME = "orm.xml"; //$NON-NLS-1$
-public class EmbeddedMappingFileWizard extends MappingFileWizard {
-
-
- public static final String DEFAULT_XML_FILE_NAME = "orm.xml";
public EmbeddedMappingFileWizard() {
+ super();
}
public EmbeddedMappingFileWizard(IDataModel dataModel) {
@@ -39,10 +50,4 @@ public class EmbeddedMappingFileWizard extends MappingFileWizard {
public final boolean performFinish() {
return this.createMappingFile();
}
-
- public static IPath createNewMappingFile(IStructuredSelection selection, String xmlFileName) {
- if (xmlFileName == null) {xmlFileName = DEFAULT_XML_FILE_NAME;}
- EmbeddedMappingFileWizard wizard = new EmbeddedMappingFileWizard(DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider()));
- return MappingFileWizard.createMappingFile(selection, xmlFileName, wizard);
- }
}

Back to the top