KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > cheatsheet > SimpleCSFileWizardPage


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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
12 package org.eclipse.pde.internal.ui.wizards.cheatsheet;
13
14 import java.util.StringTokenizer JavaDoc;
15
16 import org.eclipse.core.runtime.IPath;
17 import org.eclipse.jface.viewers.IStructuredSelection;
18 import org.eclipse.osgi.util.NLS;
19 import org.eclipse.pde.internal.core.util.PDETextHelper;
20 import org.eclipse.pde.internal.ui.PDEUIMessages;
21 import org.eclipse.swt.widgets.Composite;
22
23 /**
24  * SimpleCheatSheetFileWizardPage
25  *
26  */

27 public class SimpleCSFileWizardPage extends CSFileWizardPage {
28
29     public final static String JavaDoc F_PAGE_NAME = "simple-cheatsheet"; //$NON-NLS-1$
30

31     private String JavaDoc fAbsoluteFileName;
32     
33     private String JavaDoc fProjectName;
34     
35     /**
36      * @param pageName
37      * @param selection
38      */

39     public SimpleCSFileWizardPage(IStructuredSelection selection) {
40         super(F_PAGE_NAME, selection);
41         
42         // Initialize called by parent
43
fAbsoluteFileName = null;
44     }
45     
46     /* (non-Javadoc)
47      * @see org.eclipse.pde.internal.ui.wizards.cheatsheet.CheatSheetFileWizardPage#initialize()
48      */

49     protected void initialize() {
50         setTitle(PDEUIMessages.CheatSheetFileWizardPage_1);
51         setDescription(PDEUIMessages.SimpleCSFileWizardPage_simpleCSWizardDescription);
52         // Force the file extension to be 'xml'
53
setFileExtension(F_FILE_EXTENSION);
54     }
55     
56     /* (non-Javadoc)
57      * @see org.eclipse.pde.internal.ui.wizards.cheatsheet.CheatSheetFileWizardPage#getCheatSheetType()
58      */

59     public int getCheatSheetType() {
60         return F_SIMPLE_CHEAT_SHEET;
61     }
62     
63     /* (non-Javadoc)
64      * @see org.eclipse.pde.internal.ui.wizards.cheatsheet.CheatSheetFileWizardPage#createAdvancedControls(org.eclipse.swt.widgets.Composite)
65      */

66     protected void createAdvancedControls(Composite parent) {
67         // NO-OP
68
}
69     
70     /* (non-Javadoc)
71      * @see org.eclipse.pde.internal.ui.wizards.cheatsheet.CheatSheetFileWizardPage#validatePage()
72      */

73     protected boolean validatePage() {
74         // Set the absolute file name
75
fAbsoluteFileName = getContainerFullPath().toPortableString() +
76                             IPath.SEPARATOR +
77                             getFileName();
78         // Verify that the project name chosen by the user to store the simple
79
// cheat sheet is the same project name the composite cheat sheet is
80
// stored in
81
if (PDETextHelper.isDefined(fProjectName)) {
82             // Form: /<project-name>/<dir>/<dir>/<file>
83
String JavaDoc path = getContainerFullPath().toPortableString();
84             StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(path,
85                     new Character JavaDoc(IPath.SEPARATOR).toString());
86             String JavaDoc compareProject = tokenizer.nextToken();
87             if (compareProject.equals(fProjectName) == false) {
88                 setErrorMessage(NLS.bind(PDEUIMessages.SimpleCSFileWizardPage_errorInvalidProjectSelected, fProjectName));
89                 return false;
90             }
91         }
92         
93         return super.validatePage();
94     }
95     
96     /**
97      * @return
98      */

99     public String JavaDoc getAbsoluteFileName() {
100         // This is needed because the resource and group widget is disposed
101
// before the file name can be retrieved
102
return fAbsoluteFileName;
103     }
104     
105     /**
106      * @param projectName
107      */

108     public void setProjectName(String JavaDoc projectName) {
109         fProjectName = projectName;
110     }
111     
112 }
113
Popular Tags