From ee40a09158f12dc6e71fb19e37ce4adaec761555 Mon Sep 17 00:00:00 2001
From: tle
Date: Wed, 9 May 2007 04:13:02 +0000
Subject: Added DDL Generation behavior to JpaPlatformUi.
---
jpa/plugins/org.eclipse.jpt.ui/plugin.properties | 1 +
jpa/plugins/org.eclipse.jpt.ui/plugin.xml | 20 ++++++
.../eclipse/jpt/ui/internal/BaseJpaPlatformUi.java | 73 ++++++++++++++++++----
.../eclipse/jpt/ui/internal/IJpaPlatformUi.java | 23 ++++---
.../jpt/ui/internal/actions/GenerateDLLAction.java | 43 +++++++++++++
.../jpt/ui/internal/generic/GenericPlatformUi.java | 38 ++++++++---
6 files changed, 168 insertions(+), 30 deletions(-)
create mode 100644 jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/actions/GenerateDLLAction.java
(limited to 'jpa')
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
@@ -87,6 +87,26 @@
+
+
+
+
+
+
+
+
+
+
+
detailsProviders;
private Collection structureProviders;
+ protected BaseJpaPlatformUi() {
+ super();
+ }
+
+ // ********** behavior **********
+ protected void initialize(IJpaProject project, IStructuredSelection selection) {
+ this.project = project;
+ this.selection = selection;
+ }
+
public Collection 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 getPersistenceUnits() {
+ return this.getPlatform().persistenceUnits();
+ }
+
+ protected int getPersistenceUnitSize() {
+ return this.getPlatform().persistenceUnitSize();
+ }
+
protected Collection buildJpaDetailsProvider() {
Collection detailsProviders = new ArrayList();
detailsProviders.add(new JavaDetailsProvider());
@@ -40,7 +80,7 @@ public abstract class BaseJpaPlatformUi implements IJpaPlatformUi
public Collection 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 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);
+ }
+
+}
--
cgit v1.2.1