1 /*******************************************************************************
2 * Copyright (c) 2010 SAP AG.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Mathias Kinzler (SAP AG) - initial implementation
10 *******************************************************************************/
11 package org
.eclipse
.egit
.ui
.internal
.repository
;
13 import org
.eclipse
.egit
.ui
.UIText
;
14 import org
.eclipse
.jface
.layout
.GridDataFactory
;
15 import org
.eclipse
.jface
.wizard
.WizardPage
;
16 import org
.eclipse
.swt
.SWT
;
17 import org
.eclipse
.swt
.events
.ModifyEvent
;
18 import org
.eclipse
.swt
.events
.ModifyListener
;
19 import org
.eclipse
.swt
.events
.SelectionAdapter
;
20 import org
.eclipse
.swt
.events
.SelectionEvent
;
21 import org
.eclipse
.swt
.layout
.GridLayout
;
22 import org
.eclipse
.swt
.widgets
.Button
;
23 import org
.eclipse
.swt
.widgets
.Composite
;
24 import org
.eclipse
.swt
.widgets
.Label
;
25 import org
.eclipse
.swt
.widgets
.Text
;
30 public class SelectRemoteNamePage
extends WizardPage
{
34 Button configureFetch
;
41 SelectRemoteNamePage() {
42 super(SelectRemoteNamePage
.class.getName());
43 setTitle(UIText
.SelectRemoteNamePage_RemoteNameTitle
);
44 setMessage(UIText
.SelectRemoteNamePage_RemoteNameMessage
);
47 public void createControl(Composite parent
) {
49 setMessage(UIText
.SelectRemoteNamePage_SelectRemoteNameMessage
);
51 Composite main
= new Composite(parent
, SWT
.NONE
);
53 main
.setLayout(new GridLayout(2, false));
54 GridDataFactory
.fillDefaults().grab(true, true).applyTo(main
);
55 Label nameLabel
= new Label(main
, SWT
.NONE
);
56 nameLabel
.setText(UIText
.SelectRemoteNamePage_RemoteNameLabel
);
58 remoteName
= new Text(main
, SWT
.BORDER
);
59 GridDataFactory
.fillDefaults().grab(true, false).applyTo(remoteName
);
60 remoteName
.addModifyListener(new ModifyListener() {
62 public void modifyText(ModifyEvent e
) {
67 configureFetch
= new Button(main
, SWT
.CHECK
);
69 .setText(UIText
.SelectRemoteNamePage_ConfigureFetch_button
);
70 configureFetch
.addSelectionListener(new SelectionAdapter() {
73 public void widgetSelected(SelectionEvent e
) {
79 GridDataFactory
.fillDefaults().span(2, 1).applyTo(configureFetch
);
81 configurePush
= new Button(main
, SWT
.CHECK
);
82 configurePush
.setText(UIText
.SelectRemoteNamePage_ConfigurePush_button
);
83 configurePush
.addSelectionListener(new SelectionAdapter() {
86 public void widgetSelected(SelectionEvent e
) {
91 GridDataFactory
.fillDefaults().span(2, 1).applyTo(configurePush
);
94 setPageComplete(false);
98 private void checkPage() {
100 setErrorMessage(null);
101 if (remoteName
.getText().equals("")) { //$NON-NLS-1$
102 setErrorMessage(UIText
.SelectRemoteNamePage_NameMustNotBeEmptyMessage
);
106 NewRemoteWizard wizard
= (NewRemoteWizard
) getWizard();
107 if (wizard
.getConfiguration().getSubsections(
108 RepositoriesView
.REMOTE
).contains(remoteName
.getText())) {
109 setErrorMessage(UIText
.SelectRemoteNamePage_NameInUseMessage
);
113 if (!configureFetch
.getSelection() && !configurePush
.getSelection()) {
114 setErrorMessage(UIText
.SelectRemoteNamePage_MustConfigureSomething_message
);
119 setPageComplete(getErrorMessage() == null);