Bug 499932 - [USS] Eclipse USS SDK should not support session authentication

Remove legacy UI

Change-Id: I2fd2fff56f66e44a8c678274585a1487c7554e32
diff --git a/org.eclipse.userstorage.ui/plugin.xml b/org.eclipse.userstorage.ui/plugin.xml
index 3096e7f..b164bb1 100644
--- a/org.eclipse.userstorage.ui/plugin.xml
+++ b/org.eclipse.userstorage.ui/plugin.xml
@@ -13,11 +13,6 @@
 -->
 
 <plugin>
-
-   <extension point="org.eclipse.userstorage.credentialsProviders">
-      <credentialsProvider class="org.eclipse.userstorage.ui.internal.DialogCredentialsProvider"/>
-   </extension>
-
    <extension point="org.eclipse.ui.preferencePages">
       <page
             category="org.eclipse.ui.preferencePages.Workbench"
@@ -31,10 +26,6 @@
          <keywordReference
                id="org.eclipse.userstorage.keyword.eclipseuss"/>
       </page>
-      <page category="org.eclipse.userstorage.ui.PreferencePage"
-            class="org.eclipse.userstorage.ui.internal.ServicesPreferencePage"
-            id="org.eclipse.userstorage.ui.ServicesPreferencePage"
-            name="Services (legacy)"/>
    </extension>
    
    <extension
diff --git a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/ServiceSelectorComposite.java b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/ServiceSelectorComposite.java
index 72e69ae..503cf6b 100644
--- a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/ServiceSelectorComposite.java
+++ b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/ServiceSelectorComposite.java
@@ -12,8 +12,8 @@
 package org.eclipse.userstorage.ui;
 
 import org.eclipse.userstorage.IStorageService;
+import org.eclipse.userstorage.ui.internal.OverviewPreferencePage;
 import org.eclipse.userstorage.ui.internal.ServicesContentProvider;
-import org.eclipse.userstorage.ui.internal.ServicesPreferencePage;
 
 import org.eclipse.jface.preference.PreferenceDialog;
 import org.eclipse.jface.viewers.ComboViewer;
@@ -33,6 +33,7 @@
 
 /**
  * @author Eike Stepper
+ * @since 1.0
  */
 public class ServiceSelectorComposite extends Composite
 {
@@ -90,7 +91,7 @@
       {
         IStorageService service = getViewerSelection();
 
-        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), ServicesPreferencePage.ID, null, service);
+        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), OverviewPreferencePage.ID, null, service);
         dialog.open();
       }
     });
diff --git a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/AddServiceDialog.java b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/AddServiceDialog.java
deleted file mode 100644
index 812776d..0000000
--- a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/AddServiceDialog.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Eike Stepper - initial API and implementation
- */
-package org.eclipse.userstorage.ui.internal;
-
-import org.eclipse.userstorage.IStorageService;
-import org.eclipse.userstorage.internal.util.StringUtil;
-import org.eclipse.userstorage.ui.AbstractDialog;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * @author Eike Stepper
- */
-public class AddServiceDialog extends AbstractDialog implements ModifyListener
-{
-  private Text serviceLabelText;
-
-  private Text serviceURIText;
-
-  private Text createAccountURIText;
-
-  private Text editAccountURIText;
-
-  private Text recoverPasswordURIText;
-
-  private Text termsOfUseLinkText;
-
-  private Button okButton;
-
-  private String serviceLabel;
-
-  private URI serviceURI;
-
-  private URI createAccountURI;
-
-  private URI editAccountURI;
-
-  private URI recoverPasswordURI;
-
-  private String termsOfUseLink;
-
-  public AddServiceDialog(Shell parentShell)
-  {
-    super(parentShell);
-  }
-
-  public String getServiceLabel()
-  {
-    return serviceLabel;
-  }
-
-  public URI getServiceURI()
-  {
-    return serviceURI;
-  }
-
-  public URI getCreateAccountURI()
-  {
-    return createAccountURI;
-  }
-
-  public URI getEditAccountURI()
-  {
-    return editAccountURI;
-  }
-
-  public URI getRecoverPasswordURI()
-  {
-    return recoverPasswordURI;
-  }
-
-  public String getTermsOfUseLink()
-  {
-    return termsOfUseLink;
-  }
-
-  @Override
-  protected IDialogSettings getPluginSettings()
-  {
-    return Activator.getDefault().getDialogSettings();
-  }
-
-  @Override
-  protected Point getMinimumSize()
-  {
-    return new Point(600, 350);
-  }
-
-  @Override
-  protected void configureShell(Shell newShell)
-  {
-    super.configureShell(newShell);
-    newShell.setText("User Storage Service");
-  }
-
-  @Override
-  protected Control createDialogArea(Composite parent)
-  {
-    setTitle("Add Service");
-    setMessage("Enter a service label and a unique service URI.");
-    initializeDialogUnits(parent);
-
-    Composite area = (Composite)super.createDialogArea(parent);
-
-    GridLayout containerGridLayout = new GridLayout();
-    containerGridLayout.numColumns = 2;
-
-    Composite container = new Composite(area, SWT.NONE);
-    container.setLayoutData(new GridData(GridData.FILL_BOTH));
-    container.setLayout(containerGridLayout);
-
-    Label serviceLabelLabel = new Label(container, SWT.NONE);
-    serviceLabelLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-    serviceLabelLabel.setText("Service label:");
-
-    serviceLabelText = new Text(container, SWT.BORDER);
-    serviceLabelText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    serviceLabelText.addModifyListener(this);
-
-    Label serviceURILabel = new Label(container, SWT.NONE);
-    serviceURILabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-    serviceURILabel.setText("Service URI:");
-
-    serviceURIText = new Text(container, SWT.BORDER);
-    serviceURIText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    serviceURIText.addModifyListener(this);
-
-    Label createAccountURILabel = new Label(container, SWT.NONE);
-    createAccountURILabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-    createAccountURILabel.setText("Create account URI:");
-
-    createAccountURIText = new Text(container, SWT.BORDER);
-    createAccountURIText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    createAccountURIText.addModifyListener(this);
-
-    Label editAccountURILabel = new Label(container, SWT.NONE);
-    editAccountURILabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-    editAccountURILabel.setText("Edit account URI:");
-
-    editAccountURIText = new Text(container, SWT.BORDER);
-    editAccountURIText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    editAccountURIText.addModifyListener(this);
-
-    Label recoverPasswordURILabel = new Label(container, SWT.NONE);
-    recoverPasswordURILabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-    recoverPasswordURILabel.setText("Recover password URI:");
-
-    recoverPasswordURIText = new Text(container, SWT.BORDER);
-    recoverPasswordURIText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    recoverPasswordURIText.addModifyListener(this);
-
-    Label termsOfUseLinkLabel = new Label(container, SWT.NONE);
-    termsOfUseLinkLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-    termsOfUseLinkLabel.setText("Terms of Use Link:");
-
-    termsOfUseLinkText = new Text(container, SWT.BORDER);
-    termsOfUseLinkText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-    termsOfUseLinkText.addModifyListener(this);
-
-    return area;
-  }
-
-  @Override
-  protected void createButtonsForButtonBar(Composite parent)
-  {
-    okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
-    okButton.setEnabled(false);
-
-    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
-  }
-
-  @Override
-  public void modifyText(ModifyEvent e)
-  {
-    okButton.setEnabled(true);
-    setErrorMessage(null);
-
-    serviceLabel = serviceLabelText.getText();
-
-    try
-    {
-      String text = serviceURIText.getText();
-      if (StringUtil.isEmpty(text))
-      {
-        serviceURI = null;
-      }
-      else
-      {
-        serviceURI = new URI(text);
-
-        if (IStorageService.Registry.INSTANCE.getService(serviceURI) != null)
-        {
-          setErrorMessage("The service URI is not unique.");
-          okButton.setEnabled(false);
-          return;
-        }
-      }
-    }
-    catch (URISyntaxException ex)
-    {
-      setErrorMessage("The service URI is invalid.");
-      okButton.setEnabled(false);
-      return;
-    }
-
-    try
-    {
-      String text = createAccountURIText.getText();
-      createAccountURI = StringUtil.isEmpty(text) ? null : new URI(text);
-    }
-    catch (URISyntaxException ex)
-    {
-      setErrorMessage("The create account URI is invalid.");
-      okButton.setEnabled(false);
-      return;
-    }
-
-    try
-    {
-      String text = editAccountURIText.getText();
-      editAccountURI = StringUtil.isEmpty(text) ? null : new URI(text);
-    }
-    catch (URISyntaxException ex)
-    {
-      setErrorMessage("The edit account URI is invalid.");
-      okButton.setEnabled(false);
-      return;
-    }
-
-    try
-    {
-      String text = recoverPasswordURIText.getText();
-      recoverPasswordURI = StringUtil.isEmpty(text) ? null : new URI(text);
-    }
-    catch (URISyntaxException ex)
-    {
-      setErrorMessage("The recover password URI is invalid.");
-      okButton.setEnabled(false);
-      return;
-    }
-
-    String text = termsOfUseLinkText.getText();
-    termsOfUseLink = StringUtil.isEmpty(text) ? null : text;
-
-    if (StringUtil.isEmpty(serviceLabel))
-    {
-      okButton.setEnabled(false);
-      return;
-    }
-
-    if (serviceURI == null)
-    {
-      okButton.setEnabled(false);
-      return;
-    }
-  }
-}
diff --git a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/CredentialsComposite.java b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/CredentialsComposite.java
deleted file mode 100644
index e4bbeff..0000000
--- a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/CredentialsComposite.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Eike Stepper - initial API and implementation
- */
-package org.eclipse.userstorage.ui.internal;
-
-import org.eclipse.userstorage.IStorageService;
-import org.eclipse.userstorage.internal.StorageService;
-import org.eclipse.userstorage.internal.util.StringUtil;
-import org.eclipse.userstorage.spi.Credentials;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Text;
-
-import java.net.URI;
-import java.util.concurrent.Callable;
-
-/**
- * @author Eike Stepper
- */
-public class CredentialsComposite extends Composite
-{
-  public static final Point INITIAL_SIZE = new Point(600, 500);
-
-  private final Callable<URI> createAccountURIProvider = new Callable<URI>()
-  {
-    @Override
-    public URI call() throws Exception
-    {
-      return service.getCreateAccountURI();
-    }
-  };
-
-  private final Callable<URI> editAccountURIProvider = new Callable<URI>()
-  {
-    @Override
-    public URI call() throws Exception
-    {
-      return service.getEditAccountURI();
-    }
-  };
-
-  private final Callable<URI> recoverPasswordURIProvider = new Callable<URI>()
-  {
-    @Override
-    public URI call() throws Exception
-    {
-      return service.getRecoverPasswordURI();
-    }
-  };
-
-  private final ModifyListener modifyListener = new ModifyListener()
-  {
-    @Override
-    public void modifyText(ModifyEvent e)
-    {
-      credentials = new Credentials(usernameText.getText(), passwordText.getText());
-      updateEnablement();
-    }
-  };
-
-  private final boolean showServiceCredentials;
-
-  private IStorageService service;
-
-  private Credentials credentials;
-
-  private Label usernameLabel;
-
-  private Text usernameText;
-
-  private Label passwordLabel;
-
-  private Text passwordText;
-
-  private Label horizontalSpacer;
-
-  private boolean termsOfUseAgreed;
-
-  private Button termsOfUseButton;
-
-  private MultiLink termsOfUseMultiLink;
-
-  private Label verticalSpacer;
-
-  private Link createAccountLink;
-
-  private Link editAccountLink;
-
-  private Link recoverPasswordLink;
-
-  private boolean valid;
-
-  public CredentialsComposite(Composite parent, int style, int marginWidth, int marginHeight, boolean showServiceCredentials)
-  {
-    super(parent, style);
-    this.showServiceCredentials = showServiceCredentials;
-
-    GridLayout layout = UIUtil.createGridLayout(getGridColumns());
-    layout.marginWidth = marginWidth;
-    layout.marginHeight = marginHeight;
-    setLayout(layout);
-
-    createUI(this, layout.numColumns);
-    setCredentials(null);
-  }
-
-  public IStorageService getService()
-  {
-    return service;
-  }
-
-  public void setService(IStorageService service)
-  {
-    this.service = service;
-    if (service != null)
-    {
-      String termsOfUse = service.getTermsOfUseLink();
-      if (StringUtil.isEmpty(termsOfUse))
-      {
-        hideTermsOfUse();
-      }
-      else
-      {
-        int columns = getGridColumns();
-
-        horizontalSpacer.setVisible(true);
-        horizontalSpacer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
-
-        termsOfUseButton.setVisible(true);
-        termsOfUseButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
-
-        termsOfUseMultiLink.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, columns - 2, 1));
-        termsOfUseMultiLink.setVisible(true);
-        termsOfUseMultiLink.setText(termsOfUse);
-
-        verticalSpacer.setVisible(true);
-        verticalSpacer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, columns, 1));
-      }
-
-      if (showServiceCredentials)
-      {
-        setCredentials(((StorageService)service).getCredentials());
-        setTermsOfUseAgreed(((StorageService)service).isTermsOfUseAgreed());
-      }
-    }
-    else
-    {
-      hideTermsOfUse();
-
-      if (showServiceCredentials)
-      {
-        setCredentials(null);
-        setTermsOfUseAgreed(false);
-      }
-    }
-
-    updateEnablement();
-    layout();
-  }
-
-  public boolean isTermsOfUseAgreed()
-  {
-    return termsOfUseAgreed;
-  }
-
-  public void setTermsOfUseAgreed(boolean termsOfUseAgreed)
-  {
-    this.termsOfUseAgreed = termsOfUseAgreed;
-    termsOfUseButton.setSelection(termsOfUseAgreed);
-    updateEnablement();
-  }
-
-  public Credentials getCredentials()
-  {
-    return credentials;
-  }
-
-  public void setCredentials(Credentials credentials)
-  {
-    this.credentials = credentials;
-    if (credentials != null)
-    {
-      usernameText.setText(StringUtil.safe(credentials.getUsername()));
-      passwordText.setText(StringUtil.safe(credentials.getPassword()));
-    }
-    else
-    {
-      usernameText.setText(StringUtil.EMPTY);
-      passwordText.setText(StringUtil.EMPTY);
-    }
-  }
-
-  public int getGridColumns()
-  {
-    return 3;
-  }
-
-  public boolean isValid()
-  {
-    return valid;
-  }
-
-  @Override
-  public void setEnabled(boolean enabled)
-  {
-    super.setEnabled(true);
-    usernameLabel.setEnabled(enabled);
-    usernameText.setEnabled(enabled);
-    passwordLabel.setEnabled(enabled);
-    passwordText.setEnabled(enabled);
-    createAccountLink.setEnabled(enabled);
-    editAccountLink.setEnabled(enabled);
-    recoverPasswordLink.setEnabled(enabled);
-  }
-
-  protected void createUI(Composite parent, int columns)
-  {
-    usernameLabel = new Label(parent, SWT.NONE);
-    usernameLabel.setText("User name:");
-    usernameText = new Text(parent, SWT.BORDER);
-    usernameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, columns - 1, 1));
-    usernameText.addModifyListener(modifyListener);
-
-    passwordLabel = new Label(parent, SWT.NONE);
-    passwordLabel.setText("Password:");
-    passwordText = new Text(parent, SWT.BORDER | SWT.PASSWORD);
-    passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, columns - 1, 1));
-    passwordText.addModifyListener(modifyListener);
-
-    horizontalSpacer = new Label(parent, SWT.NONE);
-    termsOfUseButton = new Button(parent, SWT.CHECK);
-    termsOfUseButton.addSelectionListener(new SelectionAdapter()
-    {
-      @Override
-      public void widgetSelected(SelectionEvent e)
-      {
-        termsOfUseAgreed = termsOfUseButton.getSelection();
-        updateEnablement();
-      }
-    });
-
-    termsOfUseMultiLink = new MultiLink.ForSystemBrowser(parent, SWT.WRAP);
-    verticalSpacer = new Label(parent, SWT.NONE);
-
-    createAccountLink = createLink(parent, columns, "Create an account", createAccountURIProvider);
-    editAccountLink = createLink(parent, columns, "Edit your account", editAccountURIProvider);
-    recoverPasswordLink = createLink(parent, columns, "Recover your password", recoverPasswordURIProvider);
-
-    hideTermsOfUse();
-  }
-
-  protected void validate()
-  {
-  }
-
-  private void updateEnablement()
-  {
-    boolean enabled = isEnabled() && service != null;
-
-    enableLink(createAccountLink, createAccountURIProvider, enabled);
-    enableLink(editAccountLink, editAccountURIProvider, enabled);
-    enableLink(recoverPasswordLink, recoverPasswordURIProvider, enabled);
-
-    if (enabled)
-    {
-      String termsOfUseLink = service.getTermsOfUseLink();
-      if (!StringUtil.isEmpty(termsOfUseLink))
-      {
-        if (!termsOfUseAgreed)
-        {
-          valid = false;
-          validate();
-          return;
-        }
-      }
-    }
-
-    valid = enabled;
-    validate();
-  }
-
-  private Link createLink(Composite parent, int columns, final String label, final Callable<URI> uriProvider)
-  {
-    new Label(parent, SWT.NONE); // Skip first column.
-
-    final Link link = new Link(parent, SWT.NONE);
-    link.setText("<a>" + label + "</a>");
-    link.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, columns - 1, 1));
-    link.addSelectionListener(new SelectionAdapter()
-    {
-      @Override
-      public void widgetSelected(SelectionEvent e)
-      {
-        if (link.isEnabled())
-        {
-          try
-          {
-            String uri = uriProvider.call().toString();
-            SystemBrowser.openSafe(getShell(), uri, "Go to " + uri + " to " + label.toLowerCase() + ".");
-          }
-          catch (Exception ex)
-          {
-            Activator.log(ex);
-          }
-        }
-      }
-    });
-
-    return link;
-  }
-
-  private void enableLink(Link link, Callable<URI> uriProvider, boolean enabled)
-  {
-    try
-    {
-      link.setEnabled(enabled && uriProvider.call() != null);
-    }
-    catch (Exception ex)
-    {
-      //$FALL-THROUGH$
-    }
-  }
-
-  private void hideTermsOfUse()
-  {
-    horizontalSpacer.setVisible(false);
-    horizontalSpacer.setLayoutData(emptyGridData(1, 1));
-
-    termsOfUseButton.setVisible(false);
-    termsOfUseButton.setLayoutData(emptyGridData(1, 1));
-
-    termsOfUseMultiLink.setVisible(false);
-    termsOfUseMultiLink.setLayoutData(emptyGridData(getGridColumns() - 2, 1));
-    termsOfUseMultiLink.setText(StringUtil.EMPTY);
-
-    verticalSpacer.setVisible(false);
-    verticalSpacer.setLayoutData(emptyGridData(getGridColumns(), 1));
-  }
-
-  private static GridData emptyGridData(int horizontalSpan, int verticalSpan)
-  {
-    GridData gridData = new GridData(0, 0);
-    gridData.horizontalSpan = horizontalSpan;
-    gridData.verticalSpan = verticalSpan;
-    return gridData;
-  }
-}
diff --git a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/CredentialsDialog.java b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/CredentialsDialog.java
deleted file mode 100644
index 4093447..0000000
--- a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/CredentialsDialog.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Eike Stepper - initial API and implementation
- */
-package org.eclipse.userstorage.ui.internal;
-
-import org.eclipse.userstorage.IStorageService;
-import org.eclipse.userstorage.internal.StorageService;
-import org.eclipse.userstorage.internal.util.StringUtil;
-import org.eclipse.userstorage.spi.Credentials;
-import org.eclipse.userstorage.ui.AbstractDialog;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @author Eike Stepper
- */
-public class CredentialsDialog extends AbstractDialog
-{
-  private final IStorageService service;
-
-  private final boolean reauthentication;
-
-  private Credentials credentials;
-
-  private CredentialsComposite credentialsComposite;
-
-  private Button okButton;
-
-  public CredentialsDialog(Shell parentShell, IStorageService service, boolean reauthentication)
-  {
-    super(parentShell);
-    this.service = service;
-    this.reauthentication = reauthentication;
-  }
-
-  public final IStorageService getService()
-  {
-    return service;
-  }
-
-  public final Credentials getCredentials()
-  {
-    return credentials;
-  }
-
-  @Override
-  protected IDialogSettings getPluginSettings()
-  {
-    return Activator.getDefault().getDialogSettings();
-  }
-
-  @Override
-  protected void configureShell(Shell newShell)
-  {
-    super.configureShell(newShell);
-
-    String shellText = "User Storage Service";
-
-    String authority = service.getServiceURI().getAuthority();
-    if (authority != null && authority.endsWith(".eclipse.org"))
-    {
-      shellText = "Eclipse " + shellText;
-    }
-
-    newShell.setText(shellText);
-  }
-
-  @Override
-  protected Control createDialogArea(Composite parent)
-  {
-    setTitle("Login");
-    if (reauthentication)
-    {
-      setErrorMessage("You could not be logged in to your " + service.getServiceLabel() + " account. Please try again.");
-    }
-    else
-    {
-      setMessage("Enter the login information for your " + service.getServiceLabel() + " account.");
-    }
-
-    initializeDialogUnits(parent);
-    Composite area = (Composite)super.createDialogArea(parent);
-
-    credentialsComposite = new CredentialsComposite(area, SWT.NONE, 10, 10, true)
-    {
-      @Override
-      protected void validate()
-      {
-        validatePage();
-      }
-    };
-
-    credentialsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-    credentialsComposite.setService(service);
-    Dialog.applyDialogFont(credentialsComposite);
-
-    return area;
-  }
-
-  @Override
-  protected void createButtonsForButtonBar(Composite parent)
-  {
-    super.createButtonsForButtonBar(parent);
-    okButton = getButton(IDialogConstants.OK_ID);
-    validatePage();
-  }
-
-  @Override
-  protected void okPressed()
-  {
-    ((StorageService)service).setTermsOfUseAgreed(credentialsComposite.isTermsOfUseAgreed());
-    credentials = credentialsComposite.getCredentials();
-    super.okPressed();
-  }
-
-  protected boolean isPageValid()
-  {
-    String termsOfUseLink = service.getTermsOfUseLink();
-    if (!StringUtil.isEmpty(termsOfUseLink))
-    {
-      boolean termsOfUseAgreed = credentialsComposite.isTermsOfUseAgreed();
-      if (!termsOfUseAgreed)
-      {
-        return false;
-      }
-    }
-
-    Credentials credentials = credentialsComposite.getCredentials();
-    if (credentials == null)
-    {
-      return false;
-    }
-
-    if (StringUtil.isEmpty(credentials.getUsername()))
-    {
-      return false;
-    }
-
-    if (StringUtil.isEmpty(credentials.getPassword()))
-    {
-      return false;
-    }
-
-    return true;
-  }
-
-  private void validatePage()
-  {
-    if (okButton != null)
-    {
-      boolean valid = credentialsComposite.isValid();
-      okButton.setEnabled(valid);
-    }
-  }
-}
diff --git a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/DialogCredentialsProvider.java b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/DialogCredentialsProvider.java
deleted file mode 100644
index 6acdd81..0000000
--- a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/DialogCredentialsProvider.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Eike Stepper - initial API and implementation
- */
-package org.eclipse.userstorage.ui.internal;
-
-import org.eclipse.userstorage.IStorageService;
-import org.eclipse.userstorage.internal.Activator;
-import org.eclipse.userstorage.internal.CredentialedSession;
-import org.eclipse.userstorage.internal.Session;
-import org.eclipse.userstorage.internal.util.StringUtil;
-import org.eclipse.userstorage.spi.AbstractCredentialsProvider;
-import org.eclipse.userstorage.spi.Credentials;
-
-import org.eclipse.equinox.security.storage.ISecurePreferences;
-import org.eclipse.equinox.security.storage.StorageException;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @author Eike Stepper
- */
-public final class DialogCredentialsProvider extends AbstractCredentialsProvider
-{
-  public static final DialogCredentialsProvider INSTANCE = new DialogCredentialsProvider();
-
-  private static final String USERNAME_KEY = "username";
-
-  private static final String PASSWORD_KEY = "password";
-
-  @Override
-  public Credentials provideCredentials(final IStorageService service, final boolean reauthentication)
-  {
-    final Credentials[] credentials = { null };
-
-    try
-    {
-      final Shell shell = UIUtil.getShell();
-      shell.getDisplay().syncExec(new Runnable()
-      {
-        @Override
-        public void run()
-        {
-          CredentialsDialog dialog = new CredentialsDialog(shell, service, reauthentication);
-          if (dialog.open() == CredentialsDialog.OK)
-          {
-            credentials[0] = dialog.getCredentials();
-          }
-        }
-      });
-    }
-    catch (Throwable ex)
-    {
-      Activator.log(ex);
-    }
-
-    return credentials[0];
-  }
-
-  @Override
-  public Credentials getCredentials(IStorageService service)
-  {
-    try
-    {
-      ISecurePreferences securePreferences = Activator.getSecurePreferences();
-      if (securePreferences == null)
-      {
-        return null;
-      }
-      String serviceNode = StringUtil.encodeURI(service.getServiceURI());
-      securePreferences = securePreferences.node(serviceNode);
-      if (securePreferences != null)
-      {
-        String username = securePreferences.get(USERNAME_KEY, null);
-        String password = securePreferences.get(PASSWORD_KEY, null);
-
-        if (StringUtil.isEmpty(username))
-        {
-          username = null;
-        }
-
-        if (StringUtil.isEmpty(password))
-        {
-          password = null;
-        }
-
-        if (username != null || password != null)
-        {
-          return new Credentials(username, password);
-        }
-      }
-    }
-    catch (StorageException ex)
-    {
-      logSecureStorageProblem(ex);
-    }
-    return null;
-  }
-
-  @Override
-  public boolean updateCredentials(IStorageService service, Credentials credentials)
-  {
-    try
-    {
-      ISecurePreferences securePreferences = Activator.getSecurePreferences();
-      if (securePreferences == null)
-      {
-        return false;
-      }
-      String serviceNode = StringUtil.encodeURI(service.getServiceURI());
-      securePreferences = securePreferences.node(serviceNode);
-      if (securePreferences == null)
-      {
-        return false;
-      }
-      String username = credentials == null ? null : credentials.getUsername();
-      if (StringUtil.isEmpty(username))
-      {
-        securePreferences.remove(USERNAME_KEY);
-      }
-      else
-      {
-        securePreferences.put(USERNAME_KEY, username, false);
-      }
-
-      String password = credentials == null ? null : credentials.getPassword();
-      if (StringUtil.isEmpty(password))
-      {
-        securePreferences.remove(PASSWORD_KEY);
-      }
-      else
-      {
-        securePreferences.put(PASSWORD_KEY, password, true);
-      }
-
-      securePreferences.flush();
-      return true;
-    }
-    catch (Exception ex)
-    {
-      logSecureStorageProblem(ex);
-      return false;
-    }
-  }
-
-  private static void logSecureStorageProblem(Exception ex)
-  {
-    /*
-     * if (QUIET_SECURE_STORAGE_EXCEPTION && ex instanceof StorageException) { return; }
-     */
-
-    Activator.log(ex);
-  }
-
-  @Override
-  public Session openSession(IStorageService service)
-  {
-    return new CredentialedSession(service, this);
-  }
-}
diff --git a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/MultiLink.java b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/MultiLink.java
deleted file mode 100644
index d76baa5..0000000
--- a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/MultiLink.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Eike Stepper - initial API and implementation
- */
-package org.eclipse.userstorage.ui.internal;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Link;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author Eike Stepper
- */
-public abstract class MultiLink extends Composite
-{
-  private static final Pattern PATTERN = Pattern.compile("<a href=[\"']([^\"']+)[\"']>([^<]+)</a>");
-
-  private final Map<String, String> hrefs = new HashMap<String, String>();
-
-  private Link link;
-
-  private String text;
-
-  public MultiLink(Composite parent, int style)
-  {
-    super(parent, SWT.NONE);
-    setLayout(new FillLayout());
-
-    link = new Link(this, style);
-    link.addSelectionListener(new SelectionAdapter()
-    {
-      @Override
-      public void widgetSelected(SelectionEvent e)
-      {
-        String label = e.text;
-
-        String href = hrefs.get(label);
-        if (href != null)
-        {
-          linkSelected(label, href);
-        }
-      }
-    });
-  }
-
-  public String getText()
-  {
-    return text;
-  }
-
-  public void setText(String text)
-  {
-    this.text = text;
-
-    hrefs.clear();
-    StringBuffer buffer = new StringBuffer();
-
-    Matcher matcher = PATTERN.matcher(text);
-    while (matcher.find())
-    {
-      String href = matcher.group(1);
-      String label = matcher.group(2);
-      hrefs.put(label, href);
-      matcher.appendReplacement(buffer, "<a>" + label + "</a>");
-    }
-
-    matcher.appendTail(buffer);
-    link.setText(buffer.toString());
-  }
-
-  @Override
-  public void setEnabled(boolean enabled)
-  {
-    super.setEnabled(enabled);
-    link.setEnabled(enabled);
-  }
-
-  @Override
-  public void setVisible(boolean visible)
-  {
-    super.setVisible(visible);
-    link.setVisible(visible);
-  }
-
-  @Override
-  public boolean setFocus()
-  {
-    return link.setFocus();
-  }
-
-  protected abstract void linkSelected(String label, String href);
-
-  /**
-   * @author Eike Stepper
-   */
-  public static class ForSystemBrowser extends MultiLink
-  {
-    public ForSystemBrowser(Composite parent, int style)
-    {
-      super(parent, style);
-    }
-
-    @Override
-    protected void linkSelected(String label, String href)
-    {
-      SystemBrowser.openSafe(getShell(), href, "Go to " + href + " to read the " + label + ".");
-    }
-  }
-}
diff --git a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/OverviewPreferencePage.java b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/OverviewPreferencePage.java
index 82af949..e758a26 100644
--- a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/OverviewPreferencePage.java
+++ b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/OverviewPreferencePage.java
@@ -12,6 +12,8 @@
 
 public class OverviewPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
 {
+  public static final String ID = "org.eclipse.userstorage.ui.PreferencePage";
+
   @Override
   public void init(IWorkbench workbench)
   {
diff --git a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/ServicesPreferencePage.java b/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/ServicesPreferencePage.java
deleted file mode 100644
index ed37195..0000000
--- a/org.eclipse.userstorage.ui/src/org/eclipse/userstorage/ui/internal/ServicesPreferencePage.java
+++ /dev/null
@@ -1,496 +0,0 @@
-/*
- * Copyright (c) 2015 Eike Stepper (Berlin, Germany) and others.
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- *    Eike Stepper - initial API and implementation
- */
-package org.eclipse.userstorage.ui.internal;
-
-import org.eclipse.userstorage.IBlob;
-import org.eclipse.userstorage.IStorage;
-import org.eclipse.userstorage.IStorageService;
-import org.eclipse.userstorage.IStorageService.Registry;
-import org.eclipse.userstorage.StorageFactory;
-import org.eclipse.userstorage.internal.StorageService;
-import org.eclipse.userstorage.internal.util.StringUtil;
-import org.eclipse.userstorage.spi.Credentials;
-import org.eclipse.userstorage.ui.ServiceSelectorComposite;
-
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.layout.TableColumnLayout;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * @author Eike Stepper
- */
-public class ServicesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
-{
-  public static final String ID = "org.eclipse.userstorage.ui.ServicesPreferencePage";
-
-  private static final Registry REGISTRY = IStorageService.Registry.INSTANCE;
-
-  private Map<IStorageService, Credentials> credentialsMap = new HashMap<IStorageService, Credentials>();
-
-  private Map<IStorageService, Boolean> termsOfUseAgreedMap = new HashMap<IStorageService, Boolean>();
-
-  private TableViewer servicesViewer;
-
-  private CredentialsComposite credentialsComposite;
-
-  private Button addButton;
-
-  private Button removeButton;
-
-  private Button testButton;
-
-  private IStorageService selectedService;
-
-  private boolean skipValidate;
-
-  public ServicesPreferencePage()
-  {
-    super("User Storage Service");
-  }
-
-  @Override
-  public void init(IWorkbench workbench)
-  {
-    // Do nothing.
-  }
-
-  @Override
-  public void applyData(Object data)
-  {
-    if (data instanceof IStorageService)
-    {
-      IStorageService service = (IStorageService)data;
-      setSelectedService(service);
-    }
-  }
-
-  @Override
-  public void createControl(Composite parent)
-  {
-    super.createControl(parent);
-    updateEnablement();
-  }
-
-  @Override
-  protected Control createContents(final Composite parent)
-  {
-    final ServicesContentProvider contentProvider = ServiceSelectorComposite.isShowServices() ? new ServicesContentProvider() : null;
-
-    final Composite mainArea = createArea(parent, 2);
-    mainArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-    Composite leftArea = createArea(mainArea, 1);
-    leftArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-    if (contentProvider != null)
-    {
-      Label servicesLabel = new Label(leftArea, SWT.NONE);
-      servicesLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-      servicesLabel.setText("Services:");
-
-      TableColumnLayout tableLayout = new TableColumnLayout();
-      Composite tableComposite = new Composite(leftArea, SWT.NONE);
-      tableComposite.setLayout(tableLayout);
-      tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
-      servicesViewer = new TableViewer(tableComposite, SWT.BORDER);
-      servicesViewer.setContentProvider(contentProvider);
-      servicesViewer.setLabelProvider(new ServicesLabelProvider());
-      servicesViewer.setInput(REGISTRY);
-      servicesViewer.addSelectionChangedListener(new ISelectionChangedListener()
-      {
-        @Override
-        public void selectionChanged(SelectionChangedEvent event)
-        {
-          IStructuredSelection selection = (IStructuredSelection)event.getSelection();
-          setSelectedService((IStorageService)selection.getFirstElement());
-        }
-      });
-
-      TableColumn tableColumn = new TableColumn(servicesViewer.getTable(), SWT.LEFT);
-      tableLayout.setColumnData(tableColumn, new ColumnWeightData(100));
-
-      new Label(leftArea, SWT.NONE);
-    }
-
-    credentialsComposite = new CredentialsComposite(leftArea, SWT.NONE, 0, 0, false)
-    {
-      @Override
-      protected void validate()
-      {
-        if (selectedService != null && !skipValidate)
-        {
-          Credentials credentials = getCredentials();
-          boolean termsOfUseAgreed = isTermsOfUseAgreed();
-          update(credentials, termsOfUseAgreed);
-        }
-      }
-    };
-
-    credentialsComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-
-    if (contentProvider != null)
-    {
-      Composite rightArea = createArea(mainArea, 1);
-      rightArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
-
-      new Label(rightArea, SWT.NONE);
-
-      addButton = new Button(rightArea, SWT.NONE);
-      addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-      addButton.setText("Add...");
-      addButton.addSelectionListener(new SelectionAdapter()
-      {
-        @Override
-        public void widgetSelected(SelectionEvent e)
-        {
-          AddServiceDialog dialog = new AddServiceDialog(getShell());
-          if (dialog.open() == AddServiceDialog.OK)
-          {
-            String serviceLabel = dialog.getServiceLabel();
-            URI serviceURI = dialog.getServiceURI();
-            URI createAccountURI = dialog.getCreateAccountURI();
-            URI editAccountURI = dialog.getEditAccountURI();
-            URI recoverPasswordURI = dialog.getRecoverPasswordURI();
-            String termsOfUseLink = dialog.getTermsOfUseLink();
-
-            REGISTRY.addService(serviceLabel, serviceURI, createAccountURI, editAccountURI, recoverPasswordURI, termsOfUseLink);
-          }
-        }
-      });
-
-      removeButton = new Button(rightArea, SWT.NONE);
-      removeButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-      removeButton.setText("Remove");
-      removeButton.addSelectionListener(new SelectionAdapter()
-      {
-        @Override
-        public void widgetSelected(SelectionEvent e)
-        {
-          if (selectedService instanceof IStorageService.Dynamic)
-          {
-            IStorageService.Dynamic dynamicService = (IStorageService.Dynamic)selectedService;
-            Object[] elements = contentProvider.getElements(null);
-            final int currentIndex = getCurrentIndex(elements, dynamicService);
-
-            if (MessageDialog.openQuestion(getShell(), "Remove Service",
-                "Do you really want to remove the '" + dynamicService.getServiceLabel() + "' service?"))
-            {
-              dynamicService.remove();
-
-              final Control control = servicesViewer.getControl();
-              control.getDisplay().asyncExec(new Runnable()
-              {
-                @Override
-                public void run()
-                {
-                  if (!control.isDisposed())
-                  {
-                    Object[] elements = contentProvider.getElements(null);
-                    if (elements.length != 0)
-                    {
-                      int newIndex = currentIndex;
-                      if (newIndex >= elements.length)
-                      {
-                        newIndex = elements.length - 1;
-                      }
-
-                      setSelectedService((IStorageService)elements[newIndex]);
-                    }
-                  }
-                }
-              });
-            }
-          }
-        }
-
-        private int getCurrentIndex(Object[] elements, IStorageService service)
-        {
-          for (int i = 0; i < elements.length; i++)
-          {
-            Object element = elements[i];
-            if (element == service)
-            {
-              return i;
-            }
-          }
-
-          return 0;
-        }
-      });
-
-      Button refreshButton = new Button(rightArea, SWT.NONE);
-      refreshButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
-      refreshButton.setText("Refresh");
-      refreshButton.addSelectionListener(new SelectionAdapter()
-      {
-        @Override
-        public void widgetSelected(SelectionEvent e)
-        {
-          REGISTRY.refresh();
-        }
-      });
-    }
-
-    Object[] elements = contentProvider == null ? REGISTRY.getServices() : contentProvider.getElements(null);
-    if (elements.length != 0)
-    {
-      setSelectedService((IStorageService)elements[0]);
-    }
-
-    if (Boolean.getBoolean("org.eclipse.userstorage.ui.showTestButton"))
-    {
-      testButton = new Button(leftArea, SWT.PUSH);
-      testButton.setText("Test");
-      testButton.addSelectionListener(new SelectionAdapter()
-      {
-        @Override
-        public void widgetSelected(SelectionEvent e)
-        {
-          try
-          {
-            IStorage storage = StorageFactory.DEFAULT.create("pDKTqBfDuNxlAKydhEwxBZPxa4q");
-            IBlob blob = storage.getBlob("ui_test");
-            blob.setContentsUTF("Test 123");
-            performDefaults();
-            MessageDialog.openInformation(getShell(), "Test", "Test succeeded.");
-          }
-          catch (Exception ex)
-          {
-            performDefaults();
-            ErrorDialog.openError(getShell(), "Test", "Test failed.", Activator.getStatus(ex));
-          }
-        }
-      });
-    }
-
-    applyDialogFont(mainArea);
-    return mainArea;
-  }
-
-  @Override
-  protected void performDefaults()
-  {
-    credentialsMap.clear();
-    termsOfUseAgreedMap.clear();
-
-    try
-    {
-      skipValidate = true;
-
-      IStorageService service = selectedService;
-      selectedService = null;
-      setSelectedService(service);
-    }
-    finally
-    {
-      skipValidate = false;
-    }
-
-    updateEnablement();
-  }
-
-  @Override
-  protected Point doComputeSize()
-  {
-    return CredentialsComposite.INITIAL_SIZE;
-  }
-
-  @Override
-  public boolean performOk()
-  {
-    for (Map.Entry<IStorageService, Credentials> entry : credentialsMap.entrySet())
-    {
-      IStorageService service = entry.getKey();
-      Credentials credentials = entry.getValue();
-      ((StorageService)service).setCredentials(credentials);
-    }
-
-    for (Entry<IStorageService, Boolean> entry : termsOfUseAgreedMap.entrySet())
-    {
-      IStorageService service = entry.getKey();
-      Boolean termsOfUseAgreed = entry.getValue();
-      ((StorageService)service).setTermsOfUseAgreed(Boolean.TRUE.equals(termsOfUseAgreed));
-    }
-
-    updateEnablement();
-    return true;
-  }
-
-  private Composite createArea(Composite parent, int columns)
-  {
-    GridLayout layout = new GridLayout(columns, false);
-    layout.marginWidth = 0;
-    layout.marginHeight = 0;
-
-    final Composite main = new Composite(parent, SWT.NONE);
-    main.setLayout(layout);
-    return main;
-  }
-
-  private void setSelectedService(IStorageService service)
-  {
-    if (service != selectedService)
-    {
-      selectedService = service;
-
-      if (selectedService != null)
-      {
-        Credentials credentials = credentialsMap.get(selectedService);
-        if (credentials == null)
-        {
-          credentials = ((StorageService)selectedService).getCredentials();
-          if (credentials != null)
-          {
-            credentialsMap.put(selectedService, credentials);
-          }
-        }
-
-        Boolean termsOfUseAgreed = termsOfUseAgreedMap.get(selectedService);
-        if (termsOfUseAgreed == null)
-        {
-          termsOfUseAgreed = ((StorageService)selectedService).isTermsOfUseAgreed();
-          termsOfUseAgreedMap.put(selectedService, termsOfUseAgreed);
-        }
-
-        try
-        {
-          skipValidate = true;
-
-          credentialsComposite.setService(selectedService);
-          credentialsComposite.setCredentials(credentials);
-          credentialsComposite.setTermsOfUseAgreed(termsOfUseAgreed);
-        }
-        finally
-        {
-          skipValidate = false;
-        }
-
-        update(credentials, termsOfUseAgreed);
-
-        if (removeButton != null)
-        {
-          removeButton.setEnabled(selectedService instanceof IStorageService.Dynamic);
-        }
-
-        if (servicesViewer != null)
-        {
-          servicesViewer.setSelection(new StructuredSelection(selectedService));
-        }
-      }
-      else
-      {
-        credentialsComposite.setService(null);
-        credentialsComposite.setCredentials(null);
-
-        if (removeButton != null)
-        {
-          removeButton.setEnabled(false);
-        }
-      }
-    }
-  }
-
-  private void update(Credentials credentials, boolean termsOfUseAgreed)
-  {
-    credentialsMap.put(selectedService, credentials);
-    termsOfUseAgreedMap.put(selectedService, termsOfUseAgreed);
-    updateEnablement();
-  }
-
-  private void updateEnablement()
-  {
-    boolean dirty = false;
-
-    for (IStorageService service : REGISTRY.getServices())
-    {
-      Credentials localCredentials = credentialsMap.get(service);
-      String localUsername = "";
-      String localPassword = "";
-      if (localCredentials != null)
-      {
-        localUsername = StringUtil.safe(localCredentials.getUsername());
-        localPassword = StringUtil.safe(localCredentials.getPassword());
-      }
-      else
-      {
-        continue;
-      }
-
-      Credentials credentials = ((StorageService)service).getCredentials();
-      String username = "";
-      String password = "";
-      if (credentials != null)
-      {
-        username = StringUtil.safe(credentials.getUsername());
-        password = StringUtil.safe(credentials.getPassword());
-      }
-
-      if (!localUsername.equals(username) || !localPassword.equals(password))
-      {
-        dirty = true;
-        break;
-      }
-    }
-
-    if (!dirty)
-    {
-      for (IStorageService service : REGISTRY.getServices())
-      {
-        boolean localTermsOfUseAgreed = Boolean.TRUE.equals(termsOfUseAgreedMap.get(service));
-        boolean termsOfUseAgreed = ((StorageService)service).isTermsOfUseAgreed();
-        if (localTermsOfUseAgreed != termsOfUseAgreed)
-        {
-          dirty = true;
-          break;
-        }
-      }
-    }
-
-    Button defaultsButton = getDefaultsButton();
-    if (defaultsButton != null)
-    {
-      defaultsButton.setEnabled(dirty);
-    }
-
-    Button applyButton = getApplyButton();
-    if (applyButton != null)
-    {
-      applyButton.setEnabled(dirty);
-    }
-  }
-}