Skip to main content
summaryrefslogtreecommitdiffstats
blob: 942f556fc0917a9799a5e2395a7ae7ea162ef206 (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
/*******************************************************************************
 * Copyright (c) 2008, 2009 Obeo.
 * 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:
 *     Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.emf.compare.examples.export.library.wizard;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;

/**
 * Overrides the default behavior of a wizard page to specify validation rules.
 * 
 * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a>
 */
public class LibraryExportWizardPage extends WizardNewFileCreationPage {
	/**
	 * Instantiates a wizard page given its name and the current selection.
	 * 
	 * @param pageName
	 *            Name of the page that is to be created.
	 * @param selection
	 *            Current resource selection.
	 */
	public LibraryExportWizardPage(String pageName, IStructuredSelection selection) {
		super(pageName, selection);
	}

	/**
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#validatePage()
	 */
	@Override
	protected boolean validatePage() {
		boolean result = super.validatePage();
		if (result) {
			final String fileName = getFileName();
			if (fileName.endsWith(".html")) { //$NON-NLS-1$
				setErrorMessage(null);
				return true;
			}
			setErrorMessage("File name must end in '.html'");
			return false;
		}
		// This will return false
		return result;
	}
}

Back to the top