01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.toc;
11:
12: import org.eclipse.jface.viewers.IStructuredSelection;
13: import org.eclipse.pde.internal.ui.IHelpContextIds;
14: import org.eclipse.pde.internal.ui.PDEUIMessages;
15: import org.eclipse.pde.internal.ui.wizards.PDEWizardNewFileCreationPage;
16: import org.eclipse.swt.widgets.Composite;
17: import org.eclipse.ui.PlatformUI;
18:
19: public class TocWizardPage extends PDEWizardNewFileCreationPage {
20:
21: private static String EXTENSION = "xml"; //$NON-NLS-1$
22:
23: public TocWizardPage(String pageName, IStructuredSelection selection) {
24: super (pageName, selection);
25: setTitle(PDEUIMessages.TocWizardPage_title);
26: setDescription(PDEUIMessages.TocWizardPage_desc);
27: // Force the file extension to be 'xml'
28: setFileExtension(EXTENSION);
29: }
30:
31: public void createControl(Composite parent) {
32: super .createControl(parent);
33:
34: PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
35: IHelpContextIds.TOC_PAGE);
36: }
37:
38: protected void createAdvancedControls(Composite parent) {
39: }
40:
41: protected boolean validatePage() {
42: String tocName = getTocName();
43: if (tocName == null) {
44: return false;
45: }
46:
47: tocName = tocName.trim();
48: // Verify the TOC name is non-empty
49: if (tocName.length() == 0) {
50: // Set the appropriate error message
51: setErrorMessage(PDEUIMessages.TocWizardPage_emptyTocName);
52: return false;
53: }
54: // Perform default validation
55: return super .validatePage();
56: }
57:
58: public String getTocName() {
59: return PDEUIMessages.TocWizardPage_book;
60: }
61: }
|