sftemplateswizard/com.nokia.s60tools.symbianfoundationtemplates/src/com/nokia/s60tools/symbianfoundationtemplates/ui/wizards/BaseTemplateWizardPage.java
author dpodwall
Tue, 12 Jan 2010 13:17:53 -0600
changeset 0 61163b28edca
permissions -rw-r--r--
initial EPL conversion
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     1
/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     3
* All rights reserved.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     4
* This component and the accompanying materials are made available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     6
* which accompanies this distribution, and is available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     8
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     9
* Initial Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    11
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    12
* Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    13
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    14
* Description:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    15
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    16
*/
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    17
package com.nokia.s60tools.symbianfoundationtemplates.ui.wizards;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    18
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    19
import java.util.AbstractList;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    20
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    21
import org.eclipse.core.runtime.IStatus;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    22
import org.eclipse.jface.wizard.WizardPage;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    23
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    24
import com.nokia.s60tools.symbianfoundationtemplates.engine.OriginalTemplate;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    25
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    26
/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    27
 * Base template wizard page.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    28
 *
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    29
 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    30
public abstract class BaseTemplateWizardPage extends WizardPage {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    31
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    32
	 * The default constructor.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    33
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    34
	 * @param title the page title
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    35
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    36
	protected BaseTemplateWizardPage(String title) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    37
		super(title);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    38
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    39
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    40
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    41
	 * Apply the given status to the wizard.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    42
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    43
	 * @param status the status of the page
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    44
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    45
	public void applyStatus(IStatus status) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    46
		String message = status.getMessage();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    47
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    48
		switch(status.getSeverity()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    49
			case IStatus.OK:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    50
				setErrorMessage(null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    51
				if(message.length() == 0)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    52
					setMessage(getPageMessage());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    53
				break;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    54
			case IStatus.WARNING:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    55
				setErrorMessage(null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    56
				setMessage(message, WizardPage.WARNING);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    57
				break;				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    58
			case IStatus.INFO:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    59
				setErrorMessage(null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    60
				setMessage(message, WizardPage.INFORMATION);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    61
				break;			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    62
			default:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    63
				setErrorMessage(message);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    64
				setMessage(null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    65
				break;		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    66
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    67
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    68
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    69
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    70
	 * Get templates from the page.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    71
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    72
	 * @return the templates
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    73
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    74
	public abstract AbstractList<OriginalTemplate> getTemplates();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    75
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    76
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    77
	 * Get this pages message for the wizard.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    78
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    79
	 * @return the message
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    80
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    81
	public abstract String getPageMessage();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    82
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    83
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    84
	 * Get the status of this page.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    85
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    86
	 * @return the status
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    87
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    88
	public abstract IStatus getStatus();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    89
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    90
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    91
	 * Save the preferences to the preference store.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    92
	 *
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    93
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    94
	protected abstract void savePreferencesToStore();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    95
}