Author: dgeraskov
Date: 2008-06-24 09:06:04 -0400 (Tue, 24 Jun 2008)
New Revision: 8919
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java
Removed:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/EntitiesInitWizardPage.java
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/wizard/GenerateEntitiesWizard.java
Log:
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-24
11:52:35 UTC (rev 8918)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java 2008-06-24
13:06:04 UTC (rev 8919)
@@ -35,6 +35,7 @@
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.GenerateDdlWizard;
import org.jboss.tools.hibernate.jpt.ui.wizard.GenerateEntitiesWizard;
/**
@@ -45,8 +46,8 @@
public static final String LaunchConfigurationType_ID =
"org.hibernate.eclipse.launch.CodeGenerationLaunchConfigurationType";
- private static String exporter_id = "hbmexporter";
- private static String full_exporter_id = HibernateLaunchConstants.ATTR_EXPORTERS +
'.' + "hbmexporter";
+ public static String exporter_id = "hbmexporter";
+ public static String full_exporter_id = HibernateLaunchConstants.ATTR_EXPORTERS +
'.' + "hbmexporter";
@Override
public void generateEntities(JpaProject project, IStructuredSelection selection) {
@@ -54,8 +55,8 @@
WizardDialog dialog = new WizardDialog(null, wizard);
dialog.create();
- int returnCode = dialog.open();
- if (returnCode == Window.OK) {
+ /*int returnCode = */dialog.open();
+ /*if (returnCode == Window.OK) {
ILaunchConfigurationWorkingCopy wc = createDefaultLaunchConfig(project.getName());
if (wc != null) {
// SHOULD PRESENT THE CONFIGURATION!!!
@@ -75,34 +76,39 @@
wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + '.' + exporter_id +
".extension_id",
HibernateLaunchConstants.ATTR_PREFIX + "hbm2java"); //$NON-NLS-1$
//$NON-NLS-2$
runLaunchConfiguration(wc);
- }
- }
-
-
+ }
+ } */
}
@Override
public void generateDDL(JpaProject project, IStructuredSelection selection) {
- ILaunchConfigurationWorkingCopy wc = createDefaultLaunchConfig(project.getName());
- if (wc != null) {
- // Main
- //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$
+ GenerateDdlWizard wizard = new GenerateDdlWizard(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) {
+ // Main
+ //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("format", "true");
- prop.put("scriptToConsole", "false");
+ Map<String, String> prop = new HashMap<String, String>();
+ prop.put("outputFileName", "schema.ddl");
+ //prop.put("outputdir", project.getName() + "\\src");
+ prop.put("format", "true");
+ prop.put("scriptToConsole", "false");
- wc.setAttribute(full_exporter_id + ".properties", prop);
- wc.setAttribute(full_exporter_id + ".extension_id",
HibernateLaunchConstants.ATTR_PREFIX + "hbm2ddl"); //$NON-NLS-1$ //$NON-NLS-2$
- runLaunchConfiguration(wc);
- }
+ wc.setAttribute(full_exporter_id + ".properties", prop);
+ wc.setAttribute(full_exporter_id + ".extension_id",
HibernateLaunchConstants.ATTR_PREFIX + "hbm2ddl"); //$NON-NLS-1$ //$NON-NLS-2$
+ runLaunchConfiguration(wc);
+ }
+ }*/
}
- private ILaunchConfigurationWorkingCopy createDefaultLaunchConfig(String projectName) {
+ public static ILaunchConfigurationWorkingCopy createDefaultLaunchConfig(String
projectName) {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType launchConfigurationType = launchManager
.getLaunchConfigurationType(LaunchConfigurationType_ID); //$NON-NLS-1$
@@ -123,7 +129,7 @@
return wc;
}
- private void runLaunchConfiguration(ILaunchConfiguration configuration) {
+ public static void runLaunchConfiguration(ILaunchConfiguration configuration) {
try {
DebugPlugin.getDefault().getLaunchManager().addLaunch(configuration.launch(ILaunchManager.RUN_MODE,
null));
} catch (CoreException e) {
Deleted:
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 2008-06-24
11:52:35 UTC (rev 8918)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/EntitiesInitWizardPage.java 2008-06-24
13:06:04 UTC (rev 8919)
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * 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();
- }
-
-}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java 2008-06-24
13:06:04 UTC (rev 8919)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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.HashMap;
+import java.util.Map;
+
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+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.ui.internal.JptUiMessages;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.jboss.tools.hibernate.jpt.ui.internal.platform.HibernatePlatformUI;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenerateDdlWizard extends Wizard {
+
+ private JpaProject jpaProject;
+
+ private IStructuredSelection selection;
+
+ private GenerateInitWizardPage initPage;
+
+ private GenerateDdlWizardPage page2;
+
+
+ public GenerateDdlWizard(JpaProject jpaProject, IStructuredSelection selection) {
+ super();
+ this.jpaProject = jpaProject;
+ this.selection = selection;
+ this.setWindowTitle( JptUiMessages.GenerateEntitiesWizard_generateEntities);
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ initPage = new GenerateInitWizardPage(jpaProject);
+ page2 = new GenerateDdlWizardPage("");
+ addPage(initPage);
+ addPage(page2);
+ }
+
+ @Override
+ public boolean performFinish() {
+ String projectName = jpaProject.getName();
+ ILaunchConfigurationWorkingCopy wc =
HibernatePlatformUI.createDefaultLaunchConfig(projectName);
+ if (wc != null) {
+ // Main
+ //unknown - ccname, outputdir, filename
+ wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
initPage.getConfigurationName());
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, page2.getOutputDir());
//$NON-NLS-1$
+
+ Map<String, String> prop = new HashMap<String, String>();
+ prop.put("outputFileName", page2.getFilename());
+ //prop.put("outputdir", project.getName() + "\\src");
+ prop.put("format", "true");
+ prop.put("scriptToConsole", "false");
+
+ wc.setAttribute(HibernatePlatformUI.full_exporter_id + ".properties",
prop);
+ wc.setAttribute(HibernatePlatformUI.full_exporter_id + ".extension_id",
HibernateLaunchConstants.ATTR_PREFIX + "hbm2ddl"); //$NON-NLS-1$ //$NON-NLS-2$
+ HibernatePlatformUI.runLaunchConfiguration(wc);
+ }
+ return true;
+ }
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.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/GenerateDdlWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java 2008-06-24
13:06:04 UTC (rev 8919)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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 org.eclipse.core.internal.resources.LocationValidator;
+import org.eclipse.core.internal.resources.OS;
+import org.eclipse.core.internal.resources.Workspace;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.JavaConventions;
+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.jdt.internal.ui.wizards.dialogfields.StringDialogField;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+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.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.utils.DialogSelectionHelper;
+import org.hibernate.eclipse.launch.PathHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenerateDdlWizardPage extends WizardPage {
+
+ private StringButtonDialogField outputdir;
+
+ private StringDialogField filename;
+
+ private LocationValidator validator = new LocationValidator((Workspace)
ResourcesPlugin.getWorkspace());
+
+ /**
+ * @param pageName
+ */
+ protected GenerateDdlWizardPage(String pageName) {
+ super(pageName);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (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;
+
+
+ IDialogFieldListener fieldlistener = new IDialogFieldListener() {
+ public void dialogFieldChanged(DialogField field) {
+ dialogChanged();
+ }
+ };
+
+ outputdir = new StringButtonDialogField(new IStringButtonAdapter() {
+ public void changeControlPressed(DialogField field) {
+ IPath[] paths = DialogSelectionHelper.chooseFolderEntries(getShell(),
PathHelper.pathOrNull(outputdir.getText()),
HibernateConsoleMessages.CodeGenerationSettingsTab_select_output_dir,
HibernateConsoleMessages.CodeGenerationSettingsTab_choose_dir_for_generated_files,
false);
+ if(paths!=null && paths.length==1) {
+ outputdir.setText( ( (paths[0]).toOSString() ) );
+ }
+ }
+ });
+ outputdir.setDialogFieldListener(fieldlistener);
+ outputdir.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_output_dir);
+ outputdir.setButtonLabel(HibernateConsoleMessages.CodeGenerationSettingsTab_browse);
+
+ Control[] controls = outputdir.doFillIntoGrid(container, numColumns);
+ // Hack to tell the text field to stretch!
+ ( (GridData)controls[1].getLayoutData() ).grabExcessHorizontalSpace = true;
+
+ filename = new StringDialogField();
+ filename.setLabelText("File name");
+ filename.setText("schema.ddl");
+ filename.setDialogFieldListener(fieldlistener);
+ filename.doFillIntoGrid(container, numColumns);
+
+ setControl(container);
+ setPageComplete( false );
+ }
+
+ protected void dialogChanged() {
+ String msg = PathHelper.checkDirectory(getOutputDir(),
HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, false);
+
+ if (msg!=null) {
+ setErrorMessage( msg );
+ setPageComplete( false );
+ return;
+ }
+
+ if (StringHelper.isEmpty(getFilename())) {
+ setErrorMessage( "Please, input file name" );
+ setPageComplete( false );
+ return;
+ }
+
+ IStatus status = ResourcesPlugin.getWorkspace().validateName(getFilename(),
IResource.FILE);
+ if (status.getSeverity() != status.OK){
+ setErrorMessage( status.getMessage() );
+ return;
+ }
+
+ setErrorMessage( null );
+ setPageComplete( true );
+ }
+
+ public String getFilename(){
+ return filename.getText();
+ }
+
+ public String getOutputDir(){
+ return outputdir.getText();
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java 2008-06-24
11:52:35 UTC (rev 8918)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java 2008-06-24
13:06:04 UTC (rev 8919)
@@ -13,6 +13,7 @@
import java.util.Collection;
import java.util.Collections;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
@@ -27,6 +28,8 @@
import org.eclipse.jpt.ui.internal.JptUiMessages;
import org.eclipse.jpt.ui.internal.wizards.DatabaseReconnectWizardPage;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
+import org.jboss.tools.hibernate.jpt.ui.internal.platform.HibernatePlatformUI;
/**
* @author Dmitry Geraskov
@@ -36,12 +39,12 @@
private JpaProject jpaProject;
- private IStructuredSelection selection;
-
+ private IStructuredSelection selection;
+ private GenerateInitWizardPage initPage;
- private Collection<Table> selectedTables;
-
+ private GenerateEntitiesWizardPage page2;
+
public GenerateEntitiesWizard( JpaProject jpaProject, IStructuredSelection selection) {
super();
this.jpaProject = jpaProject;
@@ -52,35 +55,35 @@
@Override
public void addPages() {
super.addPages();
- addPage(new EntitiesInitWizardPage(jpaProject));
+ initPage = new GenerateInitWizardPage(jpaProject);
+ page2 = new GenerateEntitiesWizardPage("");
+ addPage(initPage);
+ addPage(page2);
}
@Override
public boolean performFinish() {
+ String projectName = jpaProject.getName();
+ ILaunchConfigurationWorkingCopy wc =
HibernatePlatformUI.createDefaultLaunchConfig(projectName);
+ if (wc != null) {
+ // SHOULD PRESENT THE CONFIGURATION!!!
+ //unknown - ccname, outputdir, packagename
+ wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
initPage.getConfigurationName());
- 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;
- }
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, page2.getOutputDir());
//$NON-NLS-1$
- try {
- return packageFragmentRoot.createPackageFragment( packageFragment.getElementName(),
true, null);
- }
- catch ( JavaModelException ex) {
- throw new RuntimeException( ex);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, page2.getPackageName());
+ 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_EXPORTERS + '.' +
HibernatePlatformUI.exporter_id + ".extension_id",
+ HibernateLaunchConstants.ATTR_PREFIX + "hbm2java"); //$NON-NLS-1$
//$NON-NLS-2$
+ HibernatePlatformUI.runLaunchConfiguration(wc);
}
+ return true;
}
-
-
-
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java 2008-06-24
13:06:04 UTC (rev 8919)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * 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 org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.JavaConventions;
+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.jdt.internal.ui.wizards.dialogfields.StringDialogField;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+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.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.utils.DialogSelectionHelper;
+import org.hibernate.eclipse.launch.PathHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenerateEntitiesWizardPage extends WizardPage {
+
+ private StringButtonDialogField outputdir;
+
+ private StringDialogField packageName;
+
+ /**
+ * @param pageName
+ */
+ public GenerateEntitiesWizardPage(String pageName) {
+ super(pageName);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param pageName
+ * @param title
+ * @param titleImage
+ */
+ public GenerateEntitiesWizardPage(String pageName, String title, ImageDescriptor
titleImage) {
+ super(pageName, title, titleImage);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (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;
+
+
+ IDialogFieldListener fieldlistener = new IDialogFieldListener() {
+ public void dialogFieldChanged(DialogField field) {
+ dialogChanged();
+ }
+ };
+
+ outputdir = new StringButtonDialogField(new IStringButtonAdapter() {
+ public void changeControlPressed(DialogField field) {
+ IPath[] paths = DialogSelectionHelper.chooseFolderEntries(getShell(),
PathHelper.pathOrNull(outputdir.getText()),
HibernateConsoleMessages.CodeGenerationSettingsTab_select_output_dir,
HibernateConsoleMessages.CodeGenerationSettingsTab_choose_dir_for_generated_files,
false);
+ if(paths!=null && paths.length==1) {
+ outputdir.setText( ( (paths[0]).toOSString() ) );
+ }
+ }
+ });
+ outputdir.setDialogFieldListener(fieldlistener);
+ outputdir.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_output_dir);
+ outputdir.setButtonLabel(HibernateConsoleMessages.CodeGenerationSettingsTab_browse);
+
+ Control[] controls = outputdir.doFillIntoGrid(container, numColumns);
+ // Hack to tell the text field to stretch!
+ ( (GridData)controls[1].getLayoutData() ).grabExcessHorizontalSpace = true;
+
+ packageName = new StringDialogField();
+ packageName.setDialogFieldListener(fieldlistener);
+
packageName.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_package);
+ packageName.doFillIntoGrid(container, numColumns);
+
+ setControl(container);
+ //default package is acceptable
+ setPageComplete( true );
+ }
+
+ protected void dialogChanged() {
+ String msg = PathHelper.checkDirectory(getOutputDir(),
HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, false);
+
+ if (msg!=null) {
+ setErrorMessage( msg );
+ setPageComplete( false );
+ return;
+ }
+
+ if (StringHelper.isNotEmpty(getPackageName())){
+ IStatus status= JavaConventions.validatePackageName(getPackageName() );
+ if (status.getSeverity() == IStatus.ERROR || status.getSeverity() ==
IStatus.WARNING) {
+ setErrorMessage( status.getMessage() );
+ return;
+ }
+ }
+
+ setErrorMessage( null );
+ setPageComplete( true );
+ }
+
+ public String getPackageName(){
+ return packageName.getText();
+ }
+
+ public String getOutputDir(){
+ return outputdir.getText();
+ }
+
+}
Property changes on:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Copied:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java
(from rev 8909,
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/GenerateInitWizardPage.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java 2008-06-24
13:06:04 UTC (rev 8919)
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * 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.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+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.Group;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class GenerateInitWizardPage extends WizardPage {
+
+ private ComboDialogField connectionProfileName;
+
+ private StringButtonDialogField schemaName;
+
+ private ComboDialogField consoleConfigurationName;
+
+ private Button selectMethod;
+
+ private Group dbGroup;
+
+ private JpaProject jpaProject;
+
+ private IDialogFieldListener fieldlistener = new IDialogFieldListener() {
+ public void dialogFieldChanged(DialogField field) {
+ dialogChanged();
+ }
+ };
+
+ public GenerateInitWizardPage(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;
+
+ selectMethod = new Button(container, SWT.CHECK);
+ selectMethod.setText("Use Console Configuration");
+ selectMethod.setSelection(true);
+ selectMethod.addSelectionListener(new SelectionListener(){
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ dialogChanged();
+ }});
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = numColumns;
+ selectMethod.setLayoutData(gd);
+
+ 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);
+
+
+
+ consoleConfigurationName.setDialogFieldListener(fieldlistener);
+ consoleConfigurationName.doFillIntoGrid(container, numColumns);
+
+ createDBGroup(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);
+
+ //****************************connection profile*****************
+ 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);
+ connectionProfileName.setDialogFieldListener(fieldlistener);
+ connectionProfileName.setEnabled(!selectMethod.getSelection());
+ //****************************schema*****************
+ 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;
+ schemaName.setEnabled(!selectMethod.getSelection());
+ }
+
+
+ protected void dialogChanged() {
+ consoleConfigurationName.setEnabled(selectMethod.getSelection());
+ connectionProfileName.setEnabled(!selectMethod.getSelection());
+ schemaName.setEnabled(!selectMethod.getSelection());
+
+ if (selectMethod.getSelection() &&
(StringHelper.isEmpty(getConfigurationName()))){
+ setPageComplete(false);
+ setErrorMessage("Please, select console configuration");
+ return;
+ }
+ if (!selectMethod.getSelection() &&
(StringHelper.isEmpty(getConnectionProfileName()))){
+ setPageComplete(false);
+ setErrorMessage("Please, select connection profile");
+ return;
+ }
+ setPageComplete(true);
+ setErrorMessage(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
+ */
+ /*@Override
+ public boolean isPageComplete() {
+ return (selectMethod.getSelection() &&
(StringHelper.isNotEmpty(getConfigurationName())))
+ ||(!selectMethod.getSelection() &&
(StringHelper.isNotEmpty(getConnectionProfileName())));
+ }*/
+
+ 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();
+ }
+
+ public String getConfigurationName() {
+ return consoleConfigurationName.getText();
+ }
+
+ public String getConnectionProfileName() {
+ return connectionProfileName.getText();
+ }
+}