Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authortle2008-04-22 01:14:48 +0000
committertle2008-04-22 01:14:48 +0000
commita36f7f4d1801839b5604421a90ac1961ed0a639e (patch)
tree879ab9f8197a5226c1dc08986b80c4c356e6730e /jpa
parent7cd1331cc466616378d2672b0d609a1215ab6ab6 (diff)
downloadwebtools.dali-a36f7f4d1801839b5604421a90ac1961ed0a639e.tar.gz
webtools.dali-a36f7f4d1801839b5604421a90ac1961ed0a639e.tar.xz
webtools.dali-a36f7f4d1801839b5604421a90ac1961ed0a639e.zip
Refactored to be used with EclipseLink DDL generation.
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseReconnectWizardPage.java252
1 files changed, 135 insertions, 117 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseReconnectWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseReconnectWizardPage.java
index ce7e18bf26..53e1de83e8 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseReconnectWizardPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/DatabaseReconnectWizardPage.java
@@ -40,53 +40,57 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.PlatformUI;
-public class DatabaseReconnectWizardPage extends WizardPage {
+public class DatabaseReconnectWizardPage extends WizardPage
+{
private JpaProject jpaProject;
private ConnectionProfile profile;
+
private ConnectionListener connectionListener;
- public DatabaseReconnectWizardPage( JpaProject jpaProject) {
- super( "Database Settings"); //$NON-NLS-1$
+ private DatabaseGroup databaseGroup;
+
+ public DatabaseReconnectWizardPage(JpaProject jpaProject) {
+ super("Database Settings"); //$NON-NLS-1$
this.jpaProject = jpaProject;
- setTitle( JptUiMessages.DatabaseReconnectWizardPage_databaseConnection);
- setMessage( JptUiMessages.DatabaseReconnectWizardPage_reconnectToDatabase);
+ setTitle(JptUiMessages.DatabaseReconnectWizardPage_databaseConnection);
+ setMessage(JptUiMessages.DatabaseReconnectWizardPage_reconnectToDatabase);
}
- public void createControl( Composite parent) {
- this.setPageComplete( false);
- Composite top = this.createTopLevelComposite( parent);
- this.setControl( top);
+ public void createControl(Composite parent) {
+ this.setPageComplete(false);
+ Composite top = this.createTopLevelComposite(parent);
+ this.setControl(top);
}
- protected Composite createTopLevelComposite( Composite parent) {
- Composite composite = new Composite( parent, SWT.NULL);
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
- composite.setLayout( layout);
- new DatabaseGroup( composite);
- Dialog.applyDialogFont( parent);
+ composite.setLayout(layout);
+ this.databaseGroup = new DatabaseGroup(composite);
+ Dialog.applyDialogFont(parent);
// TODO Add Help - testing
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, JpaHelpContextIds.PROPERTIES_JAVA_PERSISTENCE_CONNECTION);
return composite;
}
- private Label createLabel( Composite container, int span, String text) {
- Label label = new Label( container, SWT.NONE);
- label.setText( text);
+ private Label createLabel(Composite container, int span, String text) {
+ Label label = new Label(container, SWT.NONE);
+ label.setText(text);
GridData gd = new GridData();
gd.horizontalIndent = 30;
gd.horizontalSpan = span;
- label.setLayoutData( gd);
+ label.setLayoutData(gd);
return label;
}
- private Combo createCombo( Composite container, boolean fillHorizontal) {
- Combo combo = new Combo( container, SWT.BORDER | SWT.SINGLE);
- if ( fillHorizontal) {
- combo.setLayoutData( new GridData( GridData.FILL_HORIZONTAL));
+ private Combo createCombo(Composite container, boolean fillHorizontal) {
+ Combo combo = new Combo(container, SWT.BORDER | SWT.SINGLE);
+ if (fillHorizontal) {
+ combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
else {
- combo.setLayoutData( new GridData());
+ combo.setLayoutData(new GridData());
}
return combo;
}
@@ -94,12 +98,12 @@ public class DatabaseReconnectWizardPage extends WizardPage {
/**
* Initialize a grid layout with the default Dialog settings.
*/
- protected GridLayout initGridLayout( GridLayout layout, boolean margins) {
- layout.horizontalSpacing = this.convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING);
- layout.verticalSpacing = this.convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING);
- if ( margins) {
- layout.marginWidth = this.convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN);
- layout.marginHeight = this.convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN);
+ protected GridLayout initGridLayout(GridLayout layout, boolean margins) {
+ layout.horizontalSpacing = this.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+ layout.verticalSpacing = this.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+ if (margins) {
+ layout.marginWidth = this.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+ layout.marginHeight = this.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
}
else {
layout.marginWidth = 0;
@@ -110,15 +114,17 @@ public class DatabaseReconnectWizardPage extends WizardPage {
public Collection<Table> getTables() {
Schema schema = this.getDefaultSchema();
- if ( schema != null && schema.getName() != null) {
- return CollectionTools.collection( schema.tables());
+ if (schema != null && schema.getName() != null) {
+ return CollectionTools.collection(schema.tables());
}
- return Collections.<Table>emptyList();
+ return Collections.<Table> emptyList();
}
- private void updateGenerateEntitiesPage( Schema schema) {
- GenerateEntitiesWizard generateEntitiesWizard = (( GenerateEntitiesWizard) this.getWizard());
- generateEntitiesWizard.updatePossibleTables( CollectionTools.collection( schema.tables()));
+ private void updateGenerateEntitiesPage(Schema schema) {
+ if (this.getWizard() instanceof GenerateEntitiesWizard) {
+ GenerateEntitiesWizard generateEntitiesWizard = ((GenerateEntitiesWizard) this.getWizard());
+ generateEntitiesWizard.updatePossibleTables(CollectionTools.collection(schema.tables()));
+ }
}
@Override
@@ -128,105 +134,115 @@ public class DatabaseReconnectWizardPage extends WizardPage {
}
private void removeConnectionListener() {
- if ( this.connectionListener != null) {
- if ( this.profile != null) {
- this.profile.removeConnectionListener( this.connectionListener);
+ if (this.connectionListener != null) {
+ if (this.profile != null) {
+ this.profile.removeConnectionListener(this.connectionListener);
}
this.connectionListener = null;
}
}
-
ConnectionProfile getProjectConnectionProfile() {
String profileName = this.jpaProject.getDataSource().getConnectionProfileName();
- return this.connectionProfileNamed( profileName);
+ return this.connectionProfileNamed(profileName);
}
- ConnectionProfile connectionProfileNamed( String profileName) {
- return JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNamed( profileName);
+ ConnectionProfile connectionProfileNamed(String profileName) {
+ return JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNamed(profileName);
}
-
+
Schema getDefaultSchema() {
return getProjectConnectionProfile().getDefaultSchema();
}
- // ********** member classes **********
+ public String getSelectedConnectionProfileName() {
+ return this.databaseGroup.getConnectionProfileName();
+ }
- private final class DatabaseGroup {
+ public void clearConnectionProfileName() {
+ this.databaseGroup.clearConnectionProfileName();
+ }
+ // ********** member classes **********
+ private final class DatabaseGroup
+ {
private final Group group;
+
private final Combo connectionCombo;
+
private final Combo schemaCombo;
-
+
private Link addConnectionLink;
+
private Link reconnectLink;
- public DatabaseGroup( Composite composite) {
- this.group = new Group( composite, SWT.NONE);
+ public DatabaseGroup(Composite composite) {
+ this.group = new Group(composite, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
- this.group.setLayout( layout);
- this.group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL));
- this.group.setText( JptUiMessages.DatabaseReconnectWizardPage_database);
- //TODO Add Help
-// PlatformUI.getWorkbench().getHelpSystem().setHelp( this.group, IDaliHelpContextIds.XXX);
- createLabel( this.group, 1, JptUiMessages.DatabaseReconnectWizardPage_connection);
- this.connectionCombo = createCombo( this.group, true);
- this.connectionCombo.addSelectionListener( new SelectionAdapter() {
+ this.group.setLayout(layout);
+ this.group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.group.setText(JptUiMessages.DatabaseReconnectWizardPage_database);
+ // TODO Add Help
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp( this.group,
+ // IDaliHelpContextIds.XXX);
+ createLabel(this.group, 1, JptUiMessages.DatabaseReconnectWizardPage_connection);
+ this.connectionCombo = createCombo(this.group, true);
+ this.connectionCombo.addSelectionListener(new SelectionAdapter() {
@Override
- public void widgetDefaultSelected( SelectionEvent e) {
- widgetSelected( e);
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
}
@Override
- public void widgetSelected( SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
handleConnectionChange();
}
});
- createLabel( this.group, 1, JptUiMessages.DatabaseReconnectWizardPage_schema);
- this.schemaCombo = createCombo( this.group, true);
- this.schemaCombo.addSelectionListener( new SelectionAdapter() {
+ createLabel(this.group, 1, JptUiMessages.DatabaseReconnectWizardPage_schema);
+ this.schemaCombo = createCombo(this.group, true);
+ this.schemaCombo.addSelectionListener(new SelectionAdapter() {
@Override
- public void widgetDefaultSelected( SelectionEvent e) {
- widgetSelected( e);
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
}
@Override
- public void widgetSelected( SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
handleSchemaChange();
}
});
- createLabel( this.group, 2, JptUiMessages.DatabaseReconnectWizardPage_schemaInfo);
- this.addConnectionLink = new Link( this.group, SWT.NONE);
- GridData data = new GridData( GridData.END, GridData.CENTER, false, false);
+ createLabel(this.group, 2, JptUiMessages.DatabaseReconnectWizardPage_schemaInfo);
+ this.addConnectionLink = new Link(this.group, SWT.NONE);
+ GridData data = new GridData(GridData.END, GridData.CENTER, false, false);
data.horizontalSpan = 2;
- this.addConnectionLink.setLayoutData( data);
- this.addConnectionLink.setText( JptUiMessages.DatabaseReconnectWizardPage_addConnectionLink);
- this.addConnectionLink.addSelectionListener( new SelectionAdapter() {
+ this.addConnectionLink.setLayoutData(data);
+ this.addConnectionLink.setText(JptUiMessages.DatabaseReconnectWizardPage_addConnectionLink);
+ this.addConnectionLink.addSelectionListener(new SelectionAdapter() {
@Override
- public void widgetSelected( SelectionEvent e) {
+ public void widgetSelected(SelectionEvent e) {
openNewConnectionWizard();
}
});
- this.reconnectLink = new Link( this.group, SWT.NONE);
- data = new GridData( GridData.END, GridData.CENTER, false, false);
+ this.reconnectLink = new Link(this.group, SWT.NONE);
+ data = new GridData(GridData.END, GridData.CENTER, false, false);
data.horizontalSpan = 2;
- this.reconnectLink.setLayoutData( data);
- this.reconnectLink.setText( JptUiMessages.DatabaseReconnectWizardPage_reconnectLink);
- this.reconnectLink.setEnabled( false);
- this.reconnectLink.addSelectionListener( new SelectionAdapter() {
+ this.reconnectLink.setLayoutData(data);
+ this.reconnectLink.setText(JptUiMessages.DatabaseReconnectWizardPage_reconnectLink);
+ this.reconnectLink.setEnabled(false);
+ this.reconnectLink.addSelectionListener(new SelectionAdapter() {
@Override
- public void widgetSelected( SelectionEvent e) {
- openConnectionProfileNamed( connectionCombo.getText());
+ public void widgetSelected(SelectionEvent e) {
+ openConnectionProfileNamed(getConnectionProfileName());
}
});
this.populateConnectionCombo();
this.populateSchemaCombo();
}
- private ConnectionProfile connectionProfileNamed( String profileName) {
+ private ConnectionProfile connectionProfileNamed(String profileName) {
return DatabaseReconnectWizardPage.this.connectionProfileNamed(profileName);
}
-
+
private Iterator<String> dtpConnectionProfileNames() {
return JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNames();
}
@@ -234,65 +250,65 @@ public class DatabaseReconnectWizardPage extends WizardPage {
private String getProjectConnectionProfileName() {
return jpaProject.getDataSource().getConnectionProfileName();
}
-
+
Schema getDefaultSchema() {
return getProjectConnectionProfile().getDefaultSchema();
}
- private void openConnectionProfileNamed( String connectionProfileName) {
+ private void openConnectionProfileNamed(String connectionProfileName) {
DatabaseReconnectWizardPage.this.removeConnectionListener();
-
- DatabaseReconnectWizardPage.this.profile = this.connectionProfileNamed( connectionProfileName);
+ DatabaseReconnectWizardPage.this.profile = this.connectionProfileNamed(connectionProfileName);
DatabaseReconnectWizardPage.this.profile.connect();
- if( DatabaseReconnectWizardPage.this.profile.isActive()) {
+ if (DatabaseReconnectWizardPage.this.profile.isActive()) {
this.populateSchemaCombo();
DatabaseReconnectWizardPage.this.connectionListener = this.buildConnectionListener();
- DatabaseReconnectWizardPage.this.profile.addConnectionListener( DatabaseReconnectWizardPage.this.connectionListener);
+ DatabaseReconnectWizardPage.this.profile.addConnectionListener(DatabaseReconnectWizardPage.this.connectionListener);
}
return;
}
-
+
private void populateConnectionCombo() {
// clear out connection entries from previous login.
this.connectionCombo.removeAll();
- for ( Iterator<String> i = CollectionTools.sort( this.dtpConnectionProfileNames()); i.hasNext();) {
+ for (Iterator<String> i = CollectionTools.sort(this.dtpConnectionProfileNames()); i.hasNext();) {
this.connectionCombo.add(i.next());
}
-
String connectionName = getProjectConnectionProfileName();
- if ( !StringTools.stringIsEmpty( connectionName)) {
- this.connectionCombo.select( connectionCombo.indexOf( connectionName));
- this.reconnectLink.setEnabled( true);
+ if (!StringTools.stringIsEmpty(connectionName)) {
+ this.connectionCombo.select(connectionCombo.indexOf(connectionName));
+ this.reconnectLink.setEnabled(true);
}
}
private void handleConnectionChange() {
- this.reconnectLink.setEnabled( true);
+ this.reconnectLink.setEnabled(true);
this.populateSchemaCombo();
}
private void handleSchemaChange() {
- ConnectionProfile connectionProfile = this.connectionProfileNamed( getConnectionProfileName());
- Schema schema = connectionProfile.getDatabase().schemaNamed( this.getSchemaName());
- DatabaseReconnectWizardPage.this.updateGenerateEntitiesPage( schema);
- DatabaseReconnectWizardPage.this.setPageComplete( true);
+ ConnectionProfile connectionProfile = this.connectionProfileNamed(getConnectionProfileName());
+ Schema schema = connectionProfile.getDatabase().schemaNamed(this.getSchemaName());
+ DatabaseReconnectWizardPage.this.updateGenerateEntitiesPage(schema);
+ DatabaseReconnectWizardPage.this.setPageComplete(true);
}
private void populateSchemaCombo() {
// clear out schema entries from previous connection selection
this.schemaCombo.removeAll();
- ConnectionProfile connectionProfile = this.connectionProfileNamed( getConnectionProfileName());
- for ( Iterator<String> stream = CollectionTools.sort( connectionProfile.getDatabase().schemaNames()); stream.hasNext();) {
+ ConnectionProfile connectionProfile = this.connectionProfileNamed(getConnectionProfileName());
+ for (Iterator<String> stream = CollectionTools.sort(connectionProfile.getDatabase().schemaNames()); stream.hasNext();) {
this.schemaCombo.add(stream.next());
}
// set login user name as default schema
Schema schema = this.getDefaultSchema();
- if ( schema != null && schema.getName() != null) {
- schema = connectionProfile.getDatabase().schemaNamed( schema.getName()); // verify schema exist
- if ( schema != null) {
- this.schemaCombo.select( this.schemaCombo.indexOf( schema.getName()));
- updateGenerateEntitiesPage( schema);
- setPageComplete( true);
+ if (schema != null && schema.getName() != null) {
+ schema = connectionProfile.getDatabase().schemaNamed(schema.getName()); // verify
+ // schema
+ // exist
+ if (schema != null) {
+ this.schemaCombo.select(this.schemaCombo.indexOf(schema.getName()));
+ DatabaseReconnectWizardPage.this.updateGenerateEntitiesPage(schema);
+ DatabaseReconnectWizardPage.this.setPageComplete(true);
}
}
}
@@ -305,15 +321,17 @@ public class DatabaseReconnectWizardPage extends WizardPage {
return this.schemaCombo.getText();
}
+ void clearConnectionProfileName() {
+ this.connectionCombo.setText("");
+ }
+
private void openNewConnectionWizard() {
String addedProfileName = DTPUiTools.createNewProfile();
-
- ConnectionProfile addedProfile = this.connectionProfileNamed( addedProfileName);
-
- if( !addedProfile.isNull()) {
+ ConnectionProfile addedProfile = this.connectionProfileNamed(addedProfileName);
+ if (!addedProfile.isNull()) {
addedProfile.connect();
this.populateConnectionCombo();
- this.connectionCombo.select( connectionCombo.indexOf( addedProfile.getName()));
+ this.connectionCombo.select(connectionCombo.indexOf(addedProfile.getName()));
this.handleConnectionChange();
}
}
@@ -321,18 +339,18 @@ public class DatabaseReconnectWizardPage extends WizardPage {
private ConnectionListener buildConnectionListener() {
return new ConnectionAdapter() {
@Override
- public void opened( ConnectionProfile profile) {
- if( DatabaseReconnectWizardPage.this.profile.equals( profile)) {
+ public void opened(ConnectionProfile profile) {
+ if (DatabaseReconnectWizardPage.this.profile.equals(profile)) {
DatabaseGroup.this.populateSchemaCombo();
}
}
+
@Override
- public void aboutToClose( ConnectionProfile profile) {
- if( DatabaseReconnectWizardPage.this.profile.equals( profile)) {
+ public void aboutToClose(ConnectionProfile profile) {
+ if (DatabaseReconnectWizardPage.this.profile.equals(profile)) {
DatabaseReconnectWizardPage.this.removeConnectionListener();
}
}
-
};
}
}

Back to the top