Author: dgeraskov
Date: 2008-09-29 08:07:28 -0400 (Mon, 29 Sep 2008)
New Revision: 10529
Modified:
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/GenerateEntitiesWizard.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
Log:
https://jira.jboss.org/jira/browse/JBIDE-2698
Modified:
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 2008-09-29
11:15:51 UTC (rev 10528)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizard.java 2008-09-29
12:07:28 UTC (rev 10529)
@@ -14,12 +14,8 @@
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
-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;
@@ -39,11 +35,9 @@
private IStructuredSelection selection;
- private GenerateInitWizardPage initPage;
+ private GenerateDdlWizardPage initPage;
- private GenerateDdlWizardPage page2;
-
public GenerateDdlWizard(JpaProject jpaProject, IStructuredSelection selection) {
super();
this.jpaProject = jpaProject;
@@ -54,12 +48,10 @@
@Override
public void addPages() {
super.addPages();
- initPage = new GenerateInitWizardPage(jpaProject);
- page2 = new GenerateDdlWizardPage("");
+ initPage = new GenerateDdlWizardPage(jpaProject);
addPage(initPage);
- addPage(page2);
}
-
+
@Override
public boolean performFinish() {
String projectName = jpaProject.getName();
@@ -67,10 +59,10 @@
if (wc != null) {
String concoleConfigurationName = initPage.getConfigurationName();
wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
concoleConfigurationName);
- wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, page2.getOutputDir());
//$NON-NLS-1$
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, initPage.getOutputDir());
//$NON-NLS-1$
Map<String, String> prop = new HashMap<String, String>();
- prop.put("outputFileName", page2.getFilename());
+ prop.put("outputFileName", initPage.getFilename());
//prop.put("outputdir", project.getName() + "\\src");
prop.put("format", "true");
prop.put("scriptToConsole", "false");
Modified:
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 2008-09-29
11:15:51 UTC (rev 10528)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateDdlWizardPage.java 2008-09-29
12:07:28 UTC (rev 10529)
@@ -11,22 +11,18 @@
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.jpt.core.JpaProject;
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;
@@ -38,7 +34,7 @@
* @author Dmitry Geraskov
*
*/
-public class GenerateDdlWizardPage extends WizardPage {
+public class GenerateDdlWizardPage extends GenerateInitWizardPage {
private StringButtonDialogField outputdir;
@@ -46,27 +42,18 @@
private LocationValidator validator = new LocationValidator((Workspace)
ResourcesPlugin.getWorkspace());
- /**
- * @param pageName
- */
- protected GenerateDdlWizardPage(String pageName) {
- super(pageName);
- // TODO Auto-generated constructor stub
+
+ protected GenerateDdlWizardPage(JpaProject jpaProject) {
+ super(jpaProject);
}
/* (non-Javadoc)
- * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ * @see
org.jboss.tools.hibernate.jpt.ui.wizard.GenerateInitWizardPage#createChildControls(org.eclipse.swt.widgets.Composite)
*/
- public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
+ @Override
+ protected void createChildControls(Composite container) {
int numColumns = 3;
-
- container.setLayout(layout);
- layout.numColumns = numColumns;
- layout.verticalSpacing = 10;
-
-
+
IDialogFieldListener fieldlistener = new IDialogFieldListener() {
public void dialogFieldChanged(DialogField field) {
dialogChanged();
@@ -94,11 +81,10 @@
filename.setText("schema.ddl");
filename.setDialogFieldListener(fieldlistener);
filename.doFillIntoGrid(container, numColumns);
-
- setControl(container);
- setPageComplete( false );
- }
+ setPageComplete( false );
+ }
+
protected void dialogChanged() {
String msg = PathHelper.checkDirectory(getOutputDir(),
HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, false);
@@ -120,8 +106,7 @@
return;
}
- setErrorMessage( null );
- setPageComplete( true );
+ super.dialogChanged();
}
public String getFilename(){
@@ -132,4 +117,5 @@
return outputdir.getText();
}
+
}
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-09-29
11:15:51 UTC (rev 10528)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizard.java 2008-09-29
12:07:28 UTC (rev 10529)
@@ -28,13 +28,13 @@
*/
public class GenerateEntitiesWizard extends Wizard {
+
private JpaProject jpaProject;
private IStructuredSelection selection;
- private GenerateInitWizardPage initPage;
+ private GenerateEntitiesWizardPage initPage;
- private GenerateEntitiesWizardPage page2;
public GenerateEntitiesWizard( JpaProject jpaProject, IStructuredSelection selection) {
super();
@@ -46,10 +46,8 @@
@Override
public void addPages() {
super.addPages();
- initPage = new GenerateInitWizardPage(jpaProject);
- page2 = new GenerateEntitiesWizardPage("");
+ initPage = new GenerateEntitiesWizardPage(jpaProject);
addPage(initPage);
- addPage(page2);
}
@Override
@@ -61,10 +59,10 @@
String concoleConfigurationName = initPage.getConfigurationName();
wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME,
concoleConfigurationName);
- wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, page2.getOutputDir());
//$NON-NLS-1$
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, initPage.getOutputDir());
//$NON-NLS-1$
wc.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, true);
- wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, page2.getPackageName());
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME,
initPage.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);
@@ -88,4 +86,5 @@
}
return true;
}
+
}
Modified:
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 2008-09-29
11:15:51 UTC (rev 10528)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateEntitiesWizardPage.java 2008-09-29
12:07:28 UTC (rev 10529)
@@ -18,11 +18,8 @@
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.jpt.core.JpaProject;
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;
@@ -34,8 +31,8 @@
* @author Dmitry Geraskov
*
*/
-public class GenerateEntitiesWizardPage extends WizardPage {
-
+public class GenerateEntitiesWizardPage extends GenerateInitWizardPage {
+
private StringButtonDialogField outputdir;
private StringDialogField packageName;
@@ -43,34 +40,17 @@
/**
* @param pageName
*/
- public GenerateEntitiesWizardPage(String pageName) {
- super(pageName);
- // TODO Auto-generated constructor stub
+ public GenerateEntitiesWizardPage(JpaProject jpaProject) {
+ super(jpaProject);
}
-
- /**
- * @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)
+ * @see
org.jboss.tools.hibernate.jpt.ui.wizard.GenerateInitWizardPage#createChildControls(org.eclipse.swt.widgets.Composite)
*/
- public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
+ @Override
+ protected void createChildControls(Composite container) {
int numColumns = 3;
- container.setLayout(layout);
- layout.numColumns = numColumns;
- layout.verticalSpacing = 10;
-
-
IDialogFieldListener fieldlistener = new IDialogFieldListener() {
public void dialogFieldChanged(DialogField field) {
dialogChanged();
@@ -98,11 +78,10 @@
packageName.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_package);
packageName.doFillIntoGrid(container, numColumns);
- setControl(container);
- //default package is acceptable
- setPageComplete( true );
+ setPageComplete( false );
}
+
protected void dialogChanged() {
String msg = PathHelper.checkDirectory(getOutputDir(),
HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, false);
@@ -120,8 +99,7 @@
}
}
- setErrorMessage( null );
- setPageComplete( true );
+ super.dialogChanged();
}
public String getPackageName(){
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java 2008-09-29
11:15:51 UTC (rev 10528)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/wizard/GenerateInitWizardPage.java 2008-09-29
12:07:28 UTC (rev 10529)
@@ -58,7 +58,7 @@
* @author Dmitry Geraskov
*
*/
-public class GenerateInitWizardPage extends WizardPage {
+public abstract class GenerateInitWizardPage extends WizardPage {
private ComboDialogField connectionProfileName;
@@ -96,6 +96,8 @@
layout.numColumns = numColumns;
layout.verticalSpacing = 10;
+ createChildControls(container);
+
selectMethod = new Button(container, SWT.CHECK);
selectMethod.setText("Use Console Configuration");
selectMethod.setSelection(true);
@@ -122,19 +124,21 @@
names[i] = configuration.getName();
}
consoleConfigurationName.setItems(names);
-
-
-
consoleConfigurationName.setDialogFieldListener(fieldlistener);
consoleConfigurationName.doFillIntoGrid(container, numColumns);
- createDBGroup(container, numColumns);
+ createDBGroup(container, numColumns);
setControl(container);
- setPageComplete( false );
}
/**
+ * @param parent
+ */
+ protected abstract void createChildControls(Composite parent);
+
+
+ /**
* @param container
* @param colCount
*/
@@ -200,9 +204,7 @@
private String[] dtpConnectionProfileNames() {
List<String> list = new ArrayList<String>();
- /*for (Iterator<String> i =
CollectionTools.sort(JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNames());
i.hasNext();) {
- list.add(i.next());
- }*/
+
IConnectionProfile[] cps = ProfileManager.getInstance().getProfiles();
for (int i = 0; i < cps.length; i++) {
list.add(cps[i].getName());