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: ConversionPreviewPage.java
13   * Created: 2009-09-17
14   * Author: entrop
15   * $Id$
16   */
17  
18  package pl.edu.agh.cast.importer.wizard.page;
19  
20  import java.util.List;
21  
22  import org.eclipse.jface.wizard.IWizardPage;
23  import org.eclipse.swt.SWT;
24  import org.eclipse.swt.widgets.Composite;
25  
26  import pl.edu.agh.cast.importer.base.data.TabularData;
27  import pl.edu.agh.cast.importer.wizard.util.Messages;
28  
29  /**
30   * Page of import wizard which serves preview of converted data.
31   *
32   * @author AGH CAST Team
33   */
34  public class ConversionPreviewPage extends AbstractImportWizardPage {
35  	private ConversionPreviewPageComposite composite;
36  
37  	/**
38  	 * The default constructor.
39  	 */
40  	public ConversionPreviewPage() {
41  		super(Messages.ConversionPreviewPage_Name, Messages.ConversionPreviewPage_Description);
42  	}
43  
44  	@Override
45  	protected boolean isComplete() {
46  		return true;
47  	}
48  
49  	/**
50  	 * {@inheritDoc}
51  	 *
52  	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
53  	 */
54  	@Override
55  	public void createControl(Composite parent) {
56  		composite = new ConversionPreviewPageComposite(parent, SWT.NONE);
57  		setControl(composite);
58  		refreshView();
59  	}
60  
61  	/**
62  	 *
63  	 * {@inheritDoc}
64  	 *
65  	 * @see pl.edu.agh.cast.importer.wizard.page.AbstractImportWizardPage#initPage()
66  	 */
67  	@Override
68  	public void initPage() {
69  		refreshView();
70  	}
71  
72  	@Override
73  	public IWizardPage getNextPage() {
74  		return null;
75  	}
76  
77  	/**
78  	 * {@inheritDoc}
79  	 *
80  	 * @see pl.edu.agh.cast.importer.wizard.page.AbstractImportWizardPage#canFlipToNextPage()
81  	 */
82  	@Override
83  	public boolean canFlipToNextPage() {
84  		return false;
85  	}
86  
87  	/**
88  	 * {@inheritDoc}
89  	 *
90  	 * @see org.eclipse.jface.wizard.WizardPage#isCurrentPage()
91  	 */
92  	@Override
93  	public boolean isCurrentPage() {
94  		return super.isCurrentPage();
95  	}
96  
97  	private void refreshView() {
98  		if (composite != null) {
99  			final List<TabularData> previewData = getImportProcess().getConversionPreview();
100 			composite.refreshPreview(previewData.get(0));
101 		}
102 	}
103 
104 }