KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > wizards > ConfigurationWizardAutoconnectPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
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
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.wizards;
12
13
14 import org.eclipse.core.resources.IProject;
15 import org.eclipse.jface.dialogs.Dialog;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.layout.GridData;
19 import org.eclipse.swt.widgets.*;
20 import org.eclipse.team.core.TeamException;
21 import org.eclipse.team.internal.ccvs.core.ICVSFolder;
22 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
23 import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
24 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
25 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
26 import org.eclipse.team.internal.ccvs.ui.*;
27 import org.eclipse.ui.PlatformUI;
28
29 /**
30  * This configuration page explains to the user that CVS/ directories already exists and
31  * it will attach the selected project to the repository that is specified in the CVS/ files.
32  *
33  * This is useful for people who have checked out a project using command-line tools.
34  */

35 public class ConfigurationWizardAutoconnectPage extends CVSWizardPage {
36     private boolean validate = true;
37     private FolderSyncInfo info;
38     ICVSRepositoryLocation location;
39     
40     public ConfigurationWizardAutoconnectPage(String JavaDoc pageName, String JavaDoc title, ImageDescriptor titleImage) {
41         super(pageName, title, titleImage);
42     }
43
44     /*
45      * @see IDialogPage#createControl(Composite)
46      */

47     public void createControl(Composite parent) {
48         Composite composite = createComposite(parent, 2, false);
49         setControl(composite);
50         
51         // set F1 help
52
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.SHARING_AUTOCONNECT_PAGE);
53         
54         Label description = new Label(composite, SWT.WRAP);
55         GridData data = new GridData();
56         data.horizontalSpan = 2;
57         data.widthHint = 350;
58         description.setLayoutData(data);
59         description.setText(CVSUIMessages.ConfigurationWizardAutoconnectPage_description);
60         
61         if (location == null) return;
62
63         // Spacer
64
createLabel(composite, ""); //$NON-NLS-1$
65
createLabel(composite, ""); //$NON-NLS-1$
66

67         createLabel(composite, CVSUIMessages.ConfigurationWizardAutoconnectPage_user);
68         createLabel(composite, location.getUsername());
69         createLabel(composite, CVSUIMessages.ConfigurationWizardAutoconnectPage_host);
70         createLabel(composite, location.getHost());
71         createLabel(composite, CVSUIMessages.ConfigurationWizardAutoconnectPage_port);
72         int port = location.getPort();
73         if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) {
74             createLabel(composite, CVSUIMessages.ConfigurationWizardAutoconnectPage_default);
75         } else {
76             createLabel(composite, "" + port); //$NON-NLS-1$
77
}
78         createLabel(composite, CVSUIMessages.ConfigurationWizardAutoconnectPage_connectionType);
79         createLabel(composite, location.getMethod().getName());
80         createLabel(composite, CVSUIMessages.ConfigurationWizardAutoconnectPage_repositoryPath);
81         createLabel(composite, location.getRootDirectory());
82         createLabel(composite, CVSUIMessages.ConfigurationWizardAutoconnectPage_module);
83         createLabel(composite, info.getRepository());
84         
85         // Spacer
86
createLabel(composite, ""); //$NON-NLS-1$
87
createLabel(composite, ""); //$NON-NLS-1$
88

89         final Button check = new Button(composite, SWT.CHECK);
90         data = new GridData();
91         data.horizontalSpan = 2;
92         check.setText(CVSUIMessages.ConfigurationWizardAutoconnectPage_validate);
93         check.addListener(SWT.Selection, new Listener() {
94             public void handleEvent(Event event) {
95                 validate = check.getSelection();
96             }
97         });
98         check.setSelection(true);
99         Dialog.applyDialogFont(parent);
100     }
101     
102     public FolderSyncInfo getFolderSyncInfo() {
103         return info;
104     }
105     public boolean getValidate() {
106         return validate;
107     }
108     public boolean setProject(IProject project) {
109         try {
110             ICVSFolder folder = (ICVSFolder)CVSWorkspaceRoot.getCVSResourceFor(project);
111             info = folder.getFolderSyncInfo();
112             if (info == null) {
113                 // This should never happen
114
CVSUIPlugin.openError(null, CVSUIMessages.ConfigurationWizardAutoconnectPage_noSyncInfo, CVSUIMessages.ConfigurationWizardAutoconnectPage_noCVSDirectory, null); //
115
return false;
116             }
117             location = CVSRepositoryLocation.fromString(info.getRoot());
118             return true;
119         } catch (TeamException e) {
120             CVSUIPlugin.openError(null, null, null, e);
121             return false;
122         }
123     }
124     
125     /**
126      * Gets the location.
127      * @return Returns a ICVSRepositoryLocation
128      */

129     public ICVSRepositoryLocation getLocation() {
130         return location;
131     }
132
133 }
134
Popular Tags