Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornhauge2010-08-31 17:44:26 -0400
committernhauge2010-08-31 17:44:26 -0400
commit9f0829f69e7f044c0d1d0d7379b3194a7d743d35 (patch)
tree9813720a45b7107a984248772d00960e38710857
parent66ec64b266847d206b75ed005f48f01353247193 (diff)
downloadwebtools.dali-9f0829f69e7f044c0d1d0d7379b3194a7d743d35.tar.gz
webtools.dali-9f0829f69e7f044c0d1d0d7379b3194a7d743d35.tar.xz
webtools.dali-9f0829f69e7f044c0d1d0d7379b3194a7d743d35.zip
323627 - feature to change connect link text based on connection status of the selected connection profile.
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaFacetInstallPage.java24
4 files changed, 57 insertions, 5 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
index 09515b6c44..2e72c2a601 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
@@ -85,6 +85,7 @@ JpaFacetWizardPage_platformLabel=&Platform
JpaFacetWizardPage_connectionLabel=&Connection
JpaFacetWizardPage_connectionLink=<a>Add connection ...</a>
JpaFacetWizardPage_connectLink=<a>Connect</a>
+JpaFacetWizardPage_connectedText=<a>Connected</a>
JpaFacetWizardPage_addDriverLibraryLabel=&Add driver library to build path
JpaFacetWizardPage_driverLibraryLabel=&Driver:
JpaFacetWizardPage_overrideDefaultCatalogLabel=&Override default catalog from connection
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
index 37511279e8..5d9c61ea75 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
@@ -71,6 +71,7 @@ public class JptUiMessages {
public static String JpaFacetWizardPage_connectionLabel;
public static String JpaFacetWizardPage_connectionLink;
public static String JpaFacetWizardPage_connectLink;
+ public static String JpaFacetWizardPage_connectedText;
public static String JpaFacetWizardPage_createOrmXmlButton;
public static String JpaFacetWizardPage_defaultCatalogLabel;
public static String JpaFacetWizardPage_defaultSchemaLabel;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
index b8f2e006c0..32e6636bba 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/properties/JpaProjectPropertiesPage.java
@@ -60,6 +60,8 @@ import org.eclipse.jpt.db.ui.internal.DTPUiTools;
import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
import org.eclipse.jpt.ui.internal.JptUiMessages;
import org.eclipse.jpt.ui.internal.jpa2.Jpa2_0ProjectFlagModel;
+import org.eclipse.jpt.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
+import org.eclipse.jpt.ui.internal.util.SWTUtil;
import org.eclipse.jpt.ui.internal.utility.swt.SWTTools;
import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.jpt.utility.internal.BitTools;
@@ -139,6 +141,7 @@ public class JpaProjectPropertiesPage
private final BufferedWritablePropertyValueModel<String> connectionModel;
private final PropertyValueModel<ConnectionProfile> connectionProfileModel;
private final PropertyValueModel<Boolean> disconnectedModel;
+ private final PropertyChangeListener disconnectedModelListener;
private Link connectLink;
private final BufferedWritablePropertyValueModel<Boolean> userOverrideDefaultCatalogFlagModel;
@@ -183,6 +186,7 @@ public class JpaProjectPropertiesPage
this.connectionModel = this.buildConnectionModel();
this.connectionProfileModel = this.buildConnectionProfileModel();
this.disconnectedModel = this.buildDisconnectedModel();
+ this.disconnectedModelListener = buildDisconnectedModelListener();
this.userOverrideDefaultCatalogFlagModel = this.buildUserOverrideDefaultCatalogFlagModel();
this.userOverrideDefaultCatalogModel = this.buildUserOverrideDefaultCatalogModel();
@@ -556,9 +560,10 @@ public class JpaProjectPropertiesPage
Link addConnectionLink = this.buildLink(group, JptUiMessages.JpaFacetWizardPage_connectionLink);
addConnectionLink.addSelectionListener(this.buildAddConnectionLinkListener()); // the link will be GCed
- this.connectLink = this.buildLink(group, JptUiMessages.JpaFacetWizardPage_connectLink);
+ this.connectLink = this.buildLink(group, buildConnectLinkText());
SWTTools.controlEnabledState(this.disconnectedModel, this.connectLink);
this.connectLink.addSelectionListener(this.buildConnectLinkListener()); // the link will be GCed
+ this.disconnectedModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.disconnectedModelListener);
// override default catalog
Button overrideDefaultCatalogCheckBox = this.buildCheckBox(group, 3, JptUiMessages.JpaFacetWizardPage_overrideDefaultCatalogLabel);
@@ -588,6 +593,34 @@ public class JpaProjectPropertiesPage
}
};
+ private PropertyChangeListener buildDisconnectedModelListener() {
+ return new SWTPropertyChangeListenerWrapper(buildDisconnectedModelListener_());
+ }
+
+ private PropertyChangeListener buildDisconnectedModelListener_() {
+ return new PropertyChangeListener() {
+
+ public void propertyChanged(PropertyChangeEvent event) {
+ JpaProjectPropertiesPage.this.updateConnectLinkText(buildConnectLinkText());
+ }
+ };
+ }
+
+ private String buildConnectLinkText(){
+ ConnectionProfile connectionProfile = getConnectionProfile();
+ if (connectionProfile != null && connectionProfile.isConnected()) {
+ return JptUiMessages.JpaFacetWizardPage_connectedText;
+ }
+ else {
+ return JptUiMessages.JpaFacetWizardPage_connectLink;
+ }
+ }
+
+ private void updateConnectLinkText(String text) {
+ connectLink.setText(text);
+ SWTUtil.reflow(connectLink.getParent());
+ }
+
private SelectionListener buildAddConnectionLinkListener() {
return new SelectionAdapter() {
@Override
@@ -839,6 +872,7 @@ public class JpaProjectPropertiesPage
public void dispose() {
this.disengageValidationListener();
this.platformIdModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.platformIdListener);
+ this.disconnectedModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.disconnectedModelListener);
super.dispose();
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaFacetInstallPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaFacetInstallPage.java
index 65d4d77d7c..3e06201471 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaFacetInstallPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaFacetInstallPage.java
@@ -15,6 +15,7 @@ import org.eclipse.jpt.db.JptDbPlugin;
import org.eclipse.jpt.db.ui.internal.DTPUiTools;
import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
import org.eclipse.jpt.ui.internal.JptUiMessages;
+import org.eclipse.jpt.ui.internal.util.SWTUtil;
import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -105,7 +106,7 @@ public class JpaFacetInstallPage
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- updateConnectLink();
+ updateConnectionStatus();
}
});
@@ -195,13 +196,13 @@ public class JpaFacetInstallPage
if (cp != null) {
cp.connect();
model.setBooleanProperty(CONNECTION_ACTIVE, cp.isActive());
- updateConnectLink();
+ updateConnectionStatus();
}
}
- private void updateConnectLink() {
+ private void updateConnectionStatus() {
ConnectionProfile cp = this.getConnectionProfile();
- connectLink.setEnabled((cp != null) && cp.isDisconnected());
+ updateConnectLink(cp);
addDriverLibraryButton.setEnabled(cp != null);
}
@@ -209,6 +210,21 @@ public class JpaFacetInstallPage
// we just use the connection profile to log in, so go to the the db plug-in
return JptDbPlugin.getConnectionProfileFactory().buildConnectionProfile(model.getStringProperty(CONNECTION));
}
+
+ private void updateConnectLink(ConnectionProfile cp) {
+ connectLink.setEnabled((cp != null) && cp.isDisconnected());
+ if (cp != null && cp.isConnected()) {
+ updateConnectLinkText(JptUiMessages.JpaFacetWizardPage_connectedText);
+ }
+ else {
+ updateConnectLinkText(JptUiMessages.JpaFacetWizardPage_connectLink);
+ }
+ }
+
+ private void updateConnectLinkText(String text) {
+ connectLink.setText(text);
+ SWTUtil.reflow(connectLink.getParent());
+ }
}

Back to the top