Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b3831b5aa0043646320ee1e576720f8ff75547db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Copyright (c) 2015 Eike Stepper (Loehne, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.oomph.setup.ui.synchronizer;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.userstorage.IStorageService;

/**
 * @author Eike Stepper
 */
public class OptInDialog extends AbstractServiceDialog
{
  private Boolean answer = true;

  public OptInDialog(Shell parentShell, IStorageService service)
  {
    super(parentShell, service);
  }

  public Boolean getAnswer()
  {
    return answer;
  }

  @Override
  protected void createUI(Composite parent, String serviceLabel, String shortLabel)
  {
    setMessage("Do you want to save your preferences on the " + serviceLabel + " server so you can share them on other workstations?");

    Button yesButton = new Button(parent, SWT.RADIO);
    yesButton.setText("Yes  - You will be required to login to your " + shortLabel + " account.");
    yesButton.addSelectionListener(new SelectionAdapter()
    {
      @Override
      public void widgetSelected(SelectionEvent e)
      {
        answer = true;
      }
    });

    Button noButton = new Button(parent, SWT.RADIO);
    noButton.setText("No  - Preferences will be saved locally.");
    noButton.addSelectionListener(new SelectionAdapter()
    {
      @Override
      public void widgetSelected(SelectionEvent e)
      {
        answer = false;
      }
    });
  }

  @Override
  protected void createButtonsForButtonBar(Composite parent)
  {
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, "Ask Me Later", false);
  }

  @Override
  protected void cancelPressed()
  {
    answer = null;
    super.cancelPressed();
  }
}

Back to the top