summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCong Wang2013-05-08 16:09:12 (EDT)
committerChris Recoskie2013-05-08 16:09:12 (EDT)
commit33a779960bfe8a7161e30a02c1844eeb677b83f7 (patch)
tree88477484fbe65b5afe458bd0cdd033be7efc0e20
parent3c61a6f06398f1549f221cbce0f9b82a4fad84e5 (diff)
downloadorg.eclipse.ptp-33a779960bfe8a7161e30a02c1844eeb677b83f7.zip
org.eclipse.ptp-33a779960bfe8a7161e30a02c1844eeb677b83f7.tar.gz
org.eclipse.ptp-33a779960bfe8a7161e30a02c1844eeb677b83f7.tar.bz2
Bug 405351 - service configuration property page does not show which
config is active or allow you to set the active config
-rw-r--r--core/org.eclipse.ptp.services.ui/.settings/.api_filters7
-rw-r--r--core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/ServiceConfigurationPropertyPage.java51
-rw-r--r--core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/Messages.java3
-rw-r--r--core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/messages.properties1
4 files changed, 61 insertions, 1 deletions
diff --git a/core/org.eclipse.ptp.services.ui/.settings/.api_filters b/core/org.eclipse.ptp.services.ui/.settings/.api_filters
index 483ba2b..1d25b4a 100644
--- a/core/org.eclipse.ptp.services.ui/.settings/.api_filters
+++ b/core/org.eclipse.ptp.services.ui/.settings/.api_filters
@@ -7,6 +7,13 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/ptp/services/ui/messages/Messages.java" type="org.eclipse.ptp.services.ui.messages.Messages">
+ <filter id="1143996420">
+ <message_arguments>
+ <message_argument value="ServiceConfigurationPropertyPage_3"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/ptp/services/ui/preferences/ServiceConfigurationPreferencePage.java" type="org.eclipse.ptp.services.ui.preferences.ServiceConfigurationPreferencePage">
<filter id="1108344834">
<message_arguments>
diff --git a/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/ServiceConfigurationPropertyPage.java b/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/ServiceConfigurationPropertyPage.java
index 0813744..f0fe4a0 100644
--- a/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/ServiceConfigurationPropertyPage.java
+++ b/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/ServiceConfigurationPropertyPage.java
@@ -96,6 +96,8 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements
addServiceConfiguration();
} else if (source == removeButton) {
removeServiceConfiguration();
+ } else if (source == setActiveConfigButton) {
+ setActiveServiceConfiguration();
} else if (source == serviceModelWidget) {
serviceModelPane.reflow(true);
}
@@ -131,10 +133,12 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements
private final EventHandler eventHandler = new EventHandler();
private Composite propertiesPane;
private Button removeButton;
+ private Button setActiveConfigButton;
private ServiceConfigurationComparator serviceConfigurationComparator;
private Table serviceConfigurationList;
private ServiceScrolledComposite serviceModelPane;
private ServiceProviderConfigurationWidget serviceModelWidget;
+ private IServiceConfiguration activeConfig;
/**
* Create the service configuration properties page
@@ -153,6 +157,9 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements
deleteServiceConfigurations();
addServiceConfigurations();
serviceModelWidget.applyChangesToConfiguration();
+ if(activeConfig != null) {
+ ServiceModelManager.getInstance().setActiveConfiguration(getProject(), activeConfig);
+ }
try {
ServiceModelManager.getInstance().saveModelConfiguration();
} catch (IOException e) {
@@ -222,6 +229,37 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements
deletedServiceConfigurations.clear();
}
}
+
+ /**
+ * User is able to set active service configuration from a set of configurations.
+ */
+ private void setActiveServiceConfiguration() {
+ TableItem selection[];
+ selection = serviceConfigurationList.getSelection();
+ if (selection.length > 0) {
+ activeConfig = (IServiceConfiguration) selection[0].getData();
+ addOrRemoveActiveConfigLabel();
+ }
+ }
+
+ private void addOrRemoveActiveConfigLabel() {
+ if (serviceConfigurationList == null) {
+ return;
+ }
+ String activeLabel = "(Active)";
+ for (TableItem item: serviceConfigurationList.getItems()) {
+ String text = item.getText();
+ if(!item.getData().equals(activeConfig) && text.endsWith(activeLabel)) {
+ int index = text.indexOf(activeLabel);
+ item.setText(text.substring(0, index));
+ }
+ if(item.getData().equals(activeConfig) && !text.endsWith(activeLabel)) {
+ item.setText(text + " " + activeLabel);
+ setActiveConfigButton.setEnabled(false);
+ }
+ }
+
+ }
/**
* Get the project Object
@@ -249,6 +287,7 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements
IServiceConfiguration serviceConfigurations[];
try {
+ activeConfig = ServiceModelManager.getInstance().getActiveConfiguration(getProject());
serviceConfigurations = ServiceModelManager.getInstance()
.getConfigurations(getProject()).toArray(new IServiceConfiguration[0]);
Arrays.sort(serviceConfigurations, serviceConfigurationComparator);
@@ -310,6 +349,11 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements
serviceModelWidget.setServiceConfiguration(selectedConfig, natures);
serviceModelWidget.setEnabled(true);
serviceModelPane.reflow(true);
+ if (selectedConfig.equals(activeConfig)) {
+ setActiveConfigButton.setEnabled(false);
+ } else {
+ setActiveConfigButton.setEnabled(true);
+ }
}
} else {
currentConfig = null;
@@ -362,6 +406,12 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements
data = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
data.widthHint = BUTTON_WIDTH;
removeButton.setLayoutData(data);
+ setActiveConfigButton = new Button(buttonPane, SWT.PUSH);
+ setActiveConfigButton.setText(Messages.ServiceConfigurationPropertyPage_3);
+ setActiveConfigButton.addSelectionListener(eventHandler);
+ data = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+ data.widthHint = BUTTON_WIDTH;
+ setActiveConfigButton.setLayoutData(data);
// Create the pane which will contain the current service model
serviceModelPane = new ServiceScrolledComposite(propertiesPane, SWT.V_SCROLL|SWT.H_SCROLL);
@@ -382,6 +432,7 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements
// Fill in the list of service configurations currently used by this
// project
getProjectConfigurations();
+ addOrRemoveActiveConfigLabel();
return propertiesPane;
}
diff --git a/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/Messages.java b/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/Messages.java
index e3a2559..bc5f88c 100644
--- a/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/Messages.java
+++ b/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/Messages.java
@@ -75,7 +75,8 @@ public class Messages extends NLS {
public static String ServiceConfigurationPropertyPage_0;
public static String ServiceConfigurationPropertyPage_1;
public static String ServiceConfigurationPropertyPage_2;
-
+ public static String ServiceConfigurationPropertyPage_3;
+
public static String ServiceConfigurationSelectionDialog_0;
public static String ServiceConfigurationSelectionDialog_1;
diff --git a/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/messages.properties b/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/messages.properties
index 1c24eac..4f2019b 100644
--- a/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/messages.properties
+++ b/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/messages/messages.properties
@@ -48,6 +48,7 @@ ServiceConfigurationPreferencePage_9=Import...
ServiceConfigurationPropertyPage_0=Add
ServiceConfigurationPropertyPage_1=Remove
ServiceConfigurationPropertyPage_2=Project Service Configurations
+ServiceConfigurationPropertyPage_3=Set Active
ServiceConfigurationSelectionDialog_0=Available Service Configurations
ServiceConfigurationSelectionDialog_1=Select Service Configuration
ServiceConfigurationSelectionWidget_1=Add...