View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: AbstractImportWizardPage.java
13   * Created: 2009-09-08
14   * Author: entrop
15   * $Id$
16   */
17  
18  package pl.edu.agh.cast.importer.wizard.page;
19  
20  import org.eclipse.jface.wizard.IWizardPage;
21  import org.eclipse.jface.wizard.WizardPage;
22  
23  import pl.edu.agh.cast.importer.base.process.ImportProcess;
24  import pl.edu.agh.cast.importer.wizard.ImporterWizard;
25  
26  /**
27   * Base class for all import wizard pages.
28   *
29   * @author AGH CAST Team
30   */
31  public abstract class AbstractImportWizardPage extends WizardPage {
32  
33  	protected AbstractImportWizardPage(String pageName, String description) {
34  		super(pageName);
35  		setTitle(pageName);
36  		setDescription(description);
37  	}
38  
39  	public ImporterWizard getImportWizard() {
40  		return (ImporterWizard)getWizard();
41  	}
42  
43  	public ImportProcess getImportProcess() {
44  		return getImportWizard().getImportProcess();
45  	}
46  
47  	@Override
48  	public IWizardPage getNextPage() {
49  		return getImportWizard().getWizardStrategy().getNextPage(this);
50  	}
51  
52  	/**
53  	 * Method is called whenever any widget had been selected or modified, and checks if the page had arrived to its
54  	 * completed state.
55  	 */
56  	public void widgetModified() {
57  		setPageComplete(isComplete());
58  	}
59  
60  	/**
61  	 * initPage() is invoked before showing page. Should be used to initialise page data (e.g. previews, combo fields).
62  	 */
63  	public void initPage() {
64  		// by default do nothing
65  	}
66  
67  	/**
68  	 * refrestImportData() is invoked before page leaving. Here actual information about import process from this page
69  	 * should be set in import process.
70  	 */
71  	public void refreshImportData() {
72  		// by default do nothing
73  	}
74  
75  	/**
76  	 * {@inheritDoc}
77  	 *
78  	 * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
79  	 */
80  	@Override
81  	public boolean canFlipToNextPage() {
82  		return isComplete();
83  	}
84  
85  	/**
86  	 * {@inheritDoc}
87  	 *
88  	 * @see org.eclipse.jface.dialogs.DialogPage#dispose()
89  	 */
90  	@Override
91  	public void dispose() {
92  		if (getControl() != null) {
93  			getControl().dispose();
94  		}
95  		super.dispose();
96  	}
97  
98  	protected abstract boolean isComplete();
99  }