Author: dgeraskov
Date: 2008-06-23 10:11:23 -0400 (Mon, 23 Jun 2008)
New Revision: 8909
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/EntitiesInitWizardPage.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java
Log:
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2008-06-23
13:57:24 UTC (rev 8908)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2008-06-23
14:11:23 UTC (rev 8909)
@@ -16,7 +16,11 @@
org.hibernate.eclipse.console;bundle-version="3.2.0",
org.hibernate.eclipse;bundle-version="3.2.0",
org.eclipse.core.resources;bundle-version="3.4.0",
- org.eclipse.debug.core;bundle-version="3.4.0"
+ org.eclipse.debug.core;bundle-version="3.4.0",
+ org.eclipse.jdt.core;bundle-version="3.4.0",
+ org.eclipse.jpt.db;bundle-version="1.1.1",
+ org.eclipse.jdt.ui;bundle-version="3.4.0",
+ org.eclipse.jpt.db.ui;bundle-version="1.0.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Hibernate Team
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java 2008-06-23
13:57:24 UTC (rev 8908)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java 2008-06-23
14:11:23 UTC (rev 8909)
@@ -11,20 +11,31 @@
package org.jboss.tools.hibernate.jpt.ui.internal.platform;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.db.Table;
+import org.eclipse.jpt.gen.internal.EntityGenerator;
+import org.eclipse.jpt.gen.internal.PackageGenerator;
import org.eclipse.jpt.ui.internal.platform.generic.GenericPlatformUi;
import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.jboss.tools.hibernate.jpt.ui.wizard.GenerateEntitiesWizard;
/**
* @author Dmitry Geraskov
@@ -39,26 +50,35 @@
@Override
public void generateEntities(JpaProject project, IStructuredSelection selection) {
- ILaunchConfigurationWorkingCopy wc = createDefaultLaunchConfig(project.getName());
- if (wc != null) {
- // Main
- // SHOULD PRESENT THE CONFIGURATION!!!
- wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
project.getName());
+ GenerateEntitiesWizard wizard = new GenerateEntitiesWizard(project, selection);
+
+ WizardDialog dialog = new WizardDialog(null, wizard);
+ dialog.create();
+ int returnCode = dialog.open();
+ if (returnCode == Window.OK) {
+ ILaunchConfigurationWorkingCopy wc = createDefaultLaunchConfig(project.getName());
+ if (wc != null) {
+ // SHOULD PRESENT THE CONFIGURATION!!!
+ //unknown - ccname, outputdir, packagename
+ wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
project.getName());
- wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, project.getName() +
"\\src"); //$NON-NLS-1$
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, project.getName() +
"\\src"); //$NON-NLS-1$
- wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME,
"package_name");
- wc.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, true);
- wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
- wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME,
"package_name");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
- wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5, true);
- wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS, true);
- wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + '.' + exporter_id +
".extension_id",
- HibernateLaunchConstants.ATTR_PREFIX + "hbm2java"); //$NON-NLS-1$
//$NON-NLS-2$
- runLaunchConfiguration(wc);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + '.' + exporter_id +
".extension_id",
+ HibernateLaunchConstants.ATTR_PREFIX + "hbm2java"); //$NON-NLS-1$
//$NON-NLS-2$
+ runLaunchConfiguration(wc);
+ }
}
+
+
}
@Override
@@ -66,13 +86,13 @@
ILaunchConfigurationWorkingCopy wc = createDefaultLaunchConfig(project.getName());
if (wc != null) {
// Main
- // SHOULD PRESENT THE CONFIGURATION!!!
+ //unknown - ccname, outputdir, filename
wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
project.getName());
wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, project.getName() +
"\\src"); //$NON-NLS-1$
Map<String, String> prop = new HashMap<String, String>();
prop.put("outputFileName", "schema.ddl");
- prop.put("outputdir", project.getName() + "\\src");
+ //prop.put("outputdir", project.getName() + "\\src");
prop.put("format", "true");
prop.put("scriptToConsole", "false");
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/EntitiesInitWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/EntitiesInitWizardPage.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/EntitiesInitWizardPage.java 2008-06-23
14:11:23 UTC (rev 8909)
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.wizard;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
+import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.db.JptDbPlugin;
+import org.eclipse.jpt.ui.internal.JptUiMessages;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class EntitiesInitWizardPage extends WizardPage {
+
+ private ComboDialogField connectionProfileName;
+
+ private StringButtonDialogField schemaName;
+
+ private ComboDialogField consoleConfigurationName;
+
+ private Group dbGroup;
+
+ private JpaProject jpaProject;
+
+ public EntitiesInitWizardPage(JpaProject jpaProject){
+ super("", "", null);
+ this.jpaProject = jpaProject;
+ }
+
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ int numColumns = 3;
+
+ container.setLayout(layout);
+ layout.numColumns = numColumns;
+ layout.verticalSpacing = 10;
+
+ createDBGroup(container, numColumns);
+
+ ComboDialogField consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
+ consoleConfigurationName.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_console_configuration);
+ ConsoleConfiguration[] cfg =
KnownConfigurations.getInstance().getConfigurationsSortedByName();
+ String[] names = new String[cfg.length];
+ for (int i = 0; i < cfg.length; i++) {
+ ConsoleConfiguration configuration = cfg[i];
+ names[i] = configuration.getName();
+ }
+ consoleConfigurationName.setItems(names);
+
+ IDialogFieldListener fieldlistener = new IDialogFieldListener() {
+ public void dialogFieldChanged(DialogField field) {
+ dialogChanged();
+ }
+ };
+
+ consoleConfigurationName.setDialogFieldListener(fieldlistener);
+ consoleConfigurationName.doFillIntoGrid(container, numColumns);
+
+ setControl(container);
+ setPageComplete( false);
+ }
+
+ /**
+ * @param container
+ * @param colCount
+ */
+ private void createDBGroup(Composite container, int numColumns) {
+ dbGroup = new Group(container, SWT.FILL);
+ dbGroup.setLayout(new FillLayout());
+ GridLayout layout = new GridLayout();
+ dbGroup.setLayout(layout);
+ layout.numColumns = numColumns;
+ layout.verticalSpacing = 10;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = numColumns;
+ dbGroup.setLayoutData(gd);
+ dbGroup.setText(JptUiMessages.DatabaseReconnectWizardPage_database);
+
+ connectionProfileName = new ComboDialogField(SWT.READ_ONLY);
+ connectionProfileName.setLabelText(JptUiMessages.DatabaseReconnectWizardPage_connection);
+
+ List<String> list = dtpConnectionProfileNames();
+ connectionProfileName.setItems((String[]) list.toArray(new String[list.size()]));
+
+ String connectionName = getProjectConnectionProfileName();
+ if (!StringTools.stringIsEmpty(connectionName)) {
+ connectionProfileName.selectItem(connectionName);
+ }
+ connectionProfileName.doFillIntoGrid(dbGroup, numColumns);
+
+ schemaName = new StringButtonDialogField(new IStringButtonAdapter(){
+ public void changeControlPressed(DialogField field) {
+ // TODO Auto-generated method stub
+
+ }});
+ schemaName.setLabelText(JptUiMessages.DatabaseReconnectWizardPage_schema);
+ schemaName.setButtonLabel("Refresh");
+ Control[] controls = schemaName.doFillIntoGrid(dbGroup, numColumns);
+ // Hack to tell the text field to stretch!
+ ( (GridData)controls[1].getLayoutData() ).grabExcessHorizontalSpace = true;
+ }
+
+ /**
+ *
+ */
+ protected void dialogChanged() {
+ // TODO Auto-generated method stub
+
+ }
+
+ private List<String> dtpConnectionProfileNames() {
+ List<String> list = new ArrayList<String>();
+ for (Iterator<String> i =
CollectionTools.sort(JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNames());
i.hasNext();) {
+ list.add(i.next());
+ }
+ return list;
+ }
+
+ private String getProjectConnectionProfileName() {
+ return jpaProject.getDataSource().getConnectionProfileName();
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/EntitiesInitWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java 2008-06-23
14:11:23 UTC (rev 8909)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.ui.wizard;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.db.ConnectionProfile;
+import org.eclipse.jpt.db.Schema;
+import org.eclipse.jpt.db.Table;
+import org.eclipse.jpt.gen.internal.EntityGenerator;
+import org.eclipse.jpt.gen.internal.PackageGenerator;
+import org.eclipse.jpt.ui.internal.JptUiMessages;
+import org.eclipse.jpt.ui.internal.wizards.DatabaseReconnectWizardPage;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenerateEntitiesWizard extends Wizard {
+
+ private JpaProject jpaProject;
+
+ private IStructuredSelection selection;
+
+
+
+ private Collection<Table> selectedTables;
+
+ public GenerateEntitiesWizard( JpaProject jpaProject, IStructuredSelection selection) {
+ super();
+ this.jpaProject = jpaProject;
+ this.selection = selection;
+ this.setWindowTitle( JptUiMessages.GenerateEntitiesWizard_generateEntities);
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ addPage(new EntitiesInitWizardPage(jpaProject));
+ }
+
+ @Override
+ public boolean performFinish() {
+
+ return true;
+ }
+
+ private IPackageFragment buildPackageFragment() {
+ IPackageFragmentRoot packageFragmentRoot =
null;//this.generateEntitiesPage.getPackageFragmentRoot();
+ IPackageFragment packageFragment =
null;//this.generateEntitiesPage.getPackageFragment();
+
+ if ( packageFragment == null) {
+ packageFragment= packageFragmentRoot.getPackageFragment( ""); //$NON-NLS-1$
+ }
+
+ if ( packageFragment.exists()) {
+ return packageFragment;
+ }
+
+ try {
+ return packageFragmentRoot.createPackageFragment( packageFragment.getElementName(),
true, null);
+ }
+ catch ( JavaModelException ex) {
+ throw new RuntimeException( ex);
+ }
+ }
+
+
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native