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: TemplatePropertiesPage.java
13   * Created: 2009-09-29
14   * Author: entrop
15   * $Id$
16   */
17  
18  package pl.edu.agh.cast.importer.wizard.page;
19  
20  import java.io.File;
21  
22  import org.eclipse.swt.SWT;
23  import org.eclipse.swt.widgets.Composite;
24  
25  import pl.edu.agh.cast.importer.wizard.util.Messages;
26  
27  /**
28   * Template properties page. Used for getting from user template name and description.
29   *
30   * @author AGH CAST Team
31   */
32  public class TemplatePropertiesPage extends AbstractImportWizardPage {
33  	private TemplatePropertiesPageComposite composite;
34  
35  	private String defaultTemplateName;
36  
37  	/**
38  	 * The default constructor.
39  	 */
40  	public TemplatePropertiesPage() {
41  		super(Messages.TemplatePropertiesPage_PageName, Messages.TemplatePropertiesPage_PageDesc);
42  	}
43  
44  	/**
45  	 * {@inheritDoc}
46  	 *
47  	 * @see pl.edu.agh.cast.importer.wizard.page.AbstractImportWizardPage#canFlipToNextPage()
48  	 */
49  	@Override
50  	public boolean canFlipToNextPage() {
51  		return false;
52  	}
53  
54  	/**
55  	 * {@inheritDoc}
56  	 *
57  	 * @see pl.edu.agh.cast.importer.wizard.page.AbstractImportWizardPage#initPage()
58  	 */
59  	@Override
60  	public void initPage() {
61  		String pathCopy = getImportProcess().getFilePath() + ""; //$NON-NLS-1$
62  		int separatorPosition = pathCopy.lastIndexOf(File.separator);
63  		if (separatorPosition != -1) {
64  			pathCopy = pathCopy.substring(separatorPosition + 1);
65  		}
66  
67  		defaultTemplateName = pathCopy;
68  	}
69  
70  	@Override
71  	protected boolean isComplete() {
72  		return composite.getTemplateName() != null && !composite.getTemplateName().isEmpty();
73  	}
74  
75  	/**
76  	 * Method is a delegate of a protected method <code>WizardPage.isCurrentPage</code>. Returns whether this page is
77  	 * the current one in the wizard's container.
78  	 *
79  	 * @return <code>true</code> if the page is active, and <code>false</code> otherwise
80  	 */
81  	public boolean isCurrentWizardPage() {
82  		return isCurrentPage();
83  	}
84  
85  	/**
86  	 * {@inheritDoc}
87  	 *
88  	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
89  	 */
90  	@Override
91  	public void createControl(Composite parent) {
92  		composite = new TemplatePropertiesPageComposite(parent, SWT.NONE, this);
93  		setControl(composite);
94  
95  		composite.setTemplateName(defaultTemplateName);
96  	}
97  
98  	public String getTemplateName() {
99  		return composite.getTemplateName();
100 	}
101 
102 	public String getTemplateDescription() {
103 		return composite.getTemplateDescription();
104 	}
105 
106 }