From baad8deba40478fcc2719734134eab54396697c8 Mon Sep 17 00:00:00 2001 From: Violaine Batthish Date: Fri, 3 May 2013 12:10:10 -0400 Subject: Bug 407117 - Restore defaults button on Service Configuration property page --- .../ui/ServiceConfigurationPropertyPage.java | 43 ++++++++++++++++++++-- .../ServiceProviderConfigurationWidget.java | 6 +++ .../rdt/ui/wizards/IndexFileLocationWidget.java | 17 ++++++++- 3 files changed, 61 insertions(+), 5 deletions(-) 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 7b4bd2f94..08137448d 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 @@ -127,6 +127,7 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements private IServiceConfiguration currentConfig; private Vector deletedServiceConfigurations; + private Vector addedServiceConfigurations; private final EventHandler eventHandler = new EventHandler(); private Composite propertiesPane; private Button removeButton; @@ -150,6 +151,7 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements */ public boolean performOk() { deleteServiceConfigurations(); + addServiceConfigurations(); serviceModelWidget.applyChangesToConfiguration(); try { ServiceModelManager.getInstance().saveModelConfiguration(); @@ -159,6 +161,17 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements return super.performOk(); } + /** + * Add selected service configurations to the set of service + * configurations known to the service model manager + */ + private void addServiceConfigurations() { + if (addedServiceConfigurations != null) + for (IServiceConfiguration configuration : addedServiceConfigurations) + ServiceModelManager.getInstance().addConfiguration( + getProject(), configuration); + } + /** * Add a new service configuration to the list of service configurations * used by this project @@ -187,8 +200,11 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements item = new TableItem(serviceConfigurationList, 0); item.setData(config); item.setText(config.getName()); - ServiceModelManager.getInstance().addConfiguration( - getProject(), config); + // ServiceModelManager.getInstance().addConfiguration( + // getProject(), config); + if (addedServiceConfigurations == null) + addedServiceConfigurations = new Vector(); + addedServiceConfigurations.add(config); } } } @@ -263,7 +279,8 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements // Selected service model is added to vector to be deleted during Ok // or Apply button processing deletedServiceConfigurations.add(selectedConfig); - serviceConfigurationList.remove(serviceConfigurationList.getSelectionIndex()); + serviceConfigurationList.remove(serviceConfigurationList + .getSelectionIndex()); serviceModelWidget.setServiceConfiguration(null); } } @@ -367,4 +384,24 @@ public class ServiceConfigurationPropertyPage extends PropertyPage implements getProjectConfigurations(); return propertiesPane; } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#performDefaults() + */ + @Override + protected void performDefaults() { + // clean up pending deletes + if (deletedServiceConfigurations != null) + deletedServiceConfigurations.removeAllElements(); + // remove any pending additions + if (addedServiceConfigurations != null) + addedServiceConfigurations.removeAllElements(); + currentConfig = null; + serviceConfigurationList.removeAll(); // cleanup table + getProjectConfigurations(); // reload table + serviceModelWidget.setServiceConfiguration(null); + super.performDefaults(); + setErrorMessage(null); + } + } diff --git a/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/widgets/ServiceProviderConfigurationWidget.java b/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/widgets/ServiceProviderConfigurationWidget.java index 0c8c23acf..2ae7e8aa8 100644 --- a/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/widgets/ServiceProviderConfigurationWidget.java +++ b/core/org.eclipse.ptp.services.ui/src/org/eclipse/ptp/services/ui/widgets/ServiceProviderConfigurationWidget.java @@ -439,6 +439,12 @@ public class ServiceProviderConfigurationWidget extends Composite { providerLabel.setEnabled(!disabled); enabledCheckbox.setSelection(!disabled); enabledCheckbox.setEnabled(true); + } else { + providerCombo.removeAll(); + enabledCheckbox.setEnabled(false); + providerLabel.setEnabled(false); + stackLayout.topControl = null; + configurationComposite.layout(); } } diff --git a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/IndexFileLocationWidget.java b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/IndexFileLocationWidget.java index 41a3e8a62..9d6138c02 100644 --- a/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/IndexFileLocationWidget.java +++ b/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/IndexFileLocationWidget.java @@ -16,6 +16,7 @@ import java.util.Map; import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.ptp.internal.rdt.ui.RSEUtils; import org.eclipse.ptp.rdt.ui.messages.Messages; import org.eclipse.rse.core.model.IHost; @@ -36,6 +37,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class IndexFileLocationWidget extends Composite { @@ -181,8 +183,19 @@ public class IndexFileLocationWidget extends Composite { remoteFileSubSystem.getRemoteFileObject(path, new NullProgressMonitor()); if (!currentRemoteFolder.canWrite()){ - MessageDialog.openWarning(getShell(), - Messages.getString("InvalidIndexLocationTitle"), Messages.getString("InvalidIndexLocationLabel")); //$NON-NLS-1$ //$NON-NLS-2$ + // display the message in the property dialog if possible + Composite parent = text.getParent(); + while (parent!=null && !(parent instanceof Shell)) + parent=parent.getParent(); + if (parent instanceof Shell) { + if (parent.getData() instanceof PreferenceDialog) { + PreferenceDialog dialog = (PreferenceDialog)parent.getData(); + dialog.setErrorMessage(Messages.getString("InvalidIndexLocationLabel")); //$NON-NLS-1$ + } + } else + // just display a dialog + MessageDialog.openWarning(getShell(), + Messages.getString("InvalidIndexLocationTitle"), Messages.getString("InvalidIndexLocationLabel")); //$NON-NLS-1$ //$NON-NLS-2$ } } catch (SystemMessageException e1) { -- cgit v1.2.3