Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authortle2007-05-09 04:13:02 +0000
committertle2007-05-09 04:13:02 +0000
commitee40a09158f12dc6e71fb19e37ce4adaec761555 (patch)
treee9d31104c56bf815c6059f2208732811764a3cbc /jpa
parentc4b6d710d6ac8cc29d7ee67b7e2c0cf52a250dcc (diff)
downloadwebtools.dali-ee40a09158f12dc6e71fb19e37ce4adaec761555.tar.gz
webtools.dali-ee40a09158f12dc6e71fb19e37ce4adaec761555.tar.xz
webtools.dali-ee40a09158f12dc6e71fb19e37ce4adaec761555.zip
Added DDL Generation behavior to JpaPlatformUi.
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/plugin.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/plugin.xml20
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateDLLAction.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java38
6 files changed, 168 insertions, 30 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.ui/plugin.properties
index bdac807ea3..d4fb815628 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/plugin.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/plugin.properties
@@ -35,6 +35,7 @@ newJpaProjectWizardDesc = Create a JPA project
jpaMenuName = JPA Tools
generateEntities = Generate Entities...
+generateDLL = Generate DLL...
synchronizeClasses = Synchronize Classes
addPersistentClass = Add persistent class ...
removePersistentClass = Remove persistent class
diff --git a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
index b03e2b5376..09cc585fee 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
@@ -88,6 +88,26 @@
</objectContribution>
<objectContribution
+ id="org.eclipse.jpt.ui.project.JPATools"
+ objectClass="org.eclipse.core.resources.IProject"
+ adaptable="true">
+ <menu
+ id="org.eclipse.jpt.ui.project.JPATools"
+ label="%jpaMenuName"/>
+
+ <enablement>
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jpt.jpa"/>
+ </enablement>
+
+ <action
+ class="org.eclipse.jpt.ui.internal.actions.GenerateDLLAction"
+ id="org.eclipse.jpt.ui.generateDLL"
+ label="%generateDLL"
+ menubarPath="org.eclipse.jpt.ui.project.JPATools/content"/>
+
+ </objectContribution>
+
+ <objectContribution
id="org.eclipse.jpt.ui.persistenceXmlActions"
objectClass="org.eclipse.core.resources.IFile"
nameFilter="persistence.xml">
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java
index 895cbdc957..ce30bc4acc 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/BaseJpaPlatformUi.java
@@ -1,36 +1,76 @@
/*******************************************************************************
- * Copyright (c) 2007 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) 2007 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.ui.internal;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.core.internal.IJpaPlatform;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.content.persistence.PersistenceUnit;
+import org.eclipse.jpt.db.internal.ConnectionProfile;
import org.eclipse.jpt.ui.internal.details.IJpaDetailsProvider;
import org.eclipse.jpt.ui.internal.java.details.JavaDetailsProvider;
import org.eclipse.jpt.ui.internal.java.structure.JavaStructureProvider;
import org.eclipse.jpt.ui.internal.structure.IJpaStructureProvider;
import org.eclipse.jpt.ui.internal.xml.details.XmlDetailsProvider;
import org.eclipse.jpt.ui.internal.xml.structure.XmlStructureProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
public abstract class BaseJpaPlatformUi implements IJpaPlatformUi
{
+ protected IJpaProject project;
+ protected IStructuredSelection selection;
private Collection<IJpaDetailsProvider> detailsProviders;
private Collection<IJpaStructureProvider> structureProviders;
+ protected BaseJpaPlatformUi() {
+ super();
+ }
+
+ // ********** behavior **********
+ protected void initialize(IJpaProject project, IStructuredSelection selection) {
+ this.project = project;
+ this.selection = selection;
+ }
+
public Collection<IJpaDetailsProvider> detailsProviders() {
if (this.detailsProviders == null) {
- this.detailsProviders = buildJpaDetailsProvider();
+ this.detailsProviders = this.buildJpaDetailsProvider();
}
return this.detailsProviders;
}
+
+ protected IJpaPlatform getPlatform() {
+ return this.project.getPlatform();
+ }
+
+ protected ConnectionProfile getConnectionProfile() {
+ return this.project.connectionProfile();
+ }
+ protected PersistenceUnit getPersistenceUnitNamed(String puName) {
+ return this.getPlatform().persistenceUnitNamed(puName);
+ }
+
+ protected Iterator<PersistenceUnit> getPersistenceUnits() {
+ return this.getPlatform().persistenceUnits();
+ }
+
+ protected int getPersistenceUnitSize() {
+ return this.getPlatform().persistenceUnitSize();
+ }
+
protected Collection<IJpaDetailsProvider> buildJpaDetailsProvider() {
Collection<IJpaDetailsProvider> detailsProviders = new ArrayList<IJpaDetailsProvider>();
detailsProviders.add(new JavaDetailsProvider());
@@ -40,7 +80,7 @@ public abstract class BaseJpaPlatformUi implements IJpaPlatformUi
public Collection<IJpaStructureProvider> structureProviders() {
if (this.structureProviders == null) {
- this.structureProviders = buildJpaStructureProvider();
+ this.structureProviders = this.buildJpaStructureProvider();
}
return this.structureProviders;
}
@@ -52,5 +92,16 @@ public abstract class BaseJpaPlatformUi implements IJpaPlatformUi
return structureProviders;
}
+ protected Shell getCurrentShell() {
+ return Display.getCurrent().getActiveShell();
+ }
+
+
+ // ********** Generate Entities **********
+ public void generateEntities( IJpaProject project, IStructuredSelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java
index 7d20185d15..b5597643f7 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/IJpaPlatformUi.java
@@ -1,16 +1,18 @@
/*******************************************************************************
- * Copyright (c) 2007 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) 2007 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.ui.internal;
import java.util.Collection;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.core.internal.IJpaProject;
import org.eclipse.jpt.ui.internal.details.IJpaDetailsProvider;
import org.eclipse.jpt.ui.internal.structure.IJpaStructureProvider;
@@ -20,4 +22,7 @@ public interface IJpaPlatformUi
Collection<IJpaDetailsProvider> detailsProviders();
+ void generateDLL(IJpaProject project, IStructuredSelection selection);
+
+ void generateEntities(IJpaProject project, IStructuredSelection selection);
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateDLLAction.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateDLLAction.java
new file mode 100644
index 0000000000..1994021956
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateDLLAction.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.ui.internal.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.ui.internal.IJpaPlatformUi;
+import org.eclipse.jpt.ui.internal.PlatformRegistry;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * GenerateDLLAction
+ */
+public class GenerateDLLAction extends ProjectAction {
+ private IWorkbenchPart targetPart;
+
+ public GenerateDLLAction() {
+ super();
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ super.setActivePart(action, targetPart);
+ this.targetPart = targetPart;
+ }
+
+ protected void execute(IJpaProject project) {
+ String vendorId = project.getPlatform().getId();
+
+ this.jpaPlatformUI(vendorId).generateDLL(project, this.getCurrentSelection());
+ }
+
+ private IJpaPlatformUi jpaPlatformUI(String vendorId) {
+ return PlatformRegistry.INSTANCE.getJpaPlatform(vendorId);
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java
index a084a769f1..1b7a5e9618 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/generic/GenericPlatformUi.java
@@ -1,16 +1,34 @@
/*******************************************************************************
- * Copyright (c) 2007 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) 2007 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.ui.internal.generic;
+import java.text.MessageFormat;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jpt.core.internal.IJpaProject;
import org.eclipse.jpt.ui.internal.BaseJpaPlatformUi;
public class GenericPlatformUi extends BaseJpaPlatformUi
-{}
+{
+ public GenericPlatformUi() {
+ super();
+ }
+
+ public void generateDLL(IJpaProject project, IStructuredSelection selection) {
+ this.displayWarning("Warning", "DLL Generation not supported");
+ }
+
+ protected void displayWarning(String title, String message) {
+ String formattedMessage = MessageFormat.format( message, (Object [])(new String [] { message}));
+ MessageDialog.openWarning(this.getCurrentShell(), title, formattedMessage);
+ }
+
+}

Back to the top