sftemplateswizard/com.nokia.s60tools.symbianfoundationtemplates/src/com/nokia/s60tools/symbianfoundationtemplates/ui/wizards/s60/S60TemplateWizardPage.java
changeset 0 61163b28edca
equal deleted inserted replaced
-1:000000000000 0:61163b28edca
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 package com.nokia.s60tools.symbianfoundationtemplates.ui.wizards.s60;
       
    18 
       
    19 import java.util.AbstractList;
       
    20 
       
    21 import org.eclipse.core.runtime.IStatus;
       
    22 import org.eclipse.core.runtime.Status;
       
    23 import org.eclipse.jface.preference.IPreferenceStore;
       
    24 import org.eclipse.swt.widgets.Event;
       
    25 import org.eclipse.swt.widgets.Listener;
       
    26 
       
    27 import com.nokia.s60tools.symbianfoundationtemplates.SymbianFoundationTemplates;
       
    28 import com.nokia.s60tools.symbianfoundationtemplates.ui.wizards.BaseTemplateWizardPage;
       
    29 
       
    30 /**
       
    31  * S60 template wizard base page.
       
    32  *
       
    33  */
       
    34 public abstract class S60TemplateWizardPage extends BaseTemplateWizardPage implements Listener {
       
    35 	protected static final IPreferenceStore preferenceStore = SymbianFoundationTemplates.getDefault().getPreferenceStore();
       
    36 	
       
    37 	protected final S60TemplatePageType pageType;
       
    38 
       
    39 	/**
       
    40 	 * Default constructor.
       
    41 	 * 
       
    42 	 * @param pageType the page type
       
    43 	 */
       
    44 	public S60TemplateWizardPage(S60TemplatePageType pageType) {
       
    45 		super(pageType.getTitle());
       
    46 		
       
    47 		this.pageType = pageType;
       
    48 	}
       
    49 	
       
    50 	public void handleEvent(Event event) {
       
    51 		updateStatus();
       
    52 			
       
    53 		getWizard().getContainer().updateButtons();
       
    54 	}
       
    55 
       
    56 	public IStatus getStatus() {
       
    57 		for(IStatus status : getStatuses())
       
    58 			if(status.matches(IStatus.ERROR))
       
    59 				return status;
       
    60 		
       
    61 		return new Status(IStatus.OK, SymbianFoundationTemplates.PLUGIN_ID, 0, "", null);
       
    62 	}
       
    63 	
       
    64 	public String getPageMessage() {
       
    65 		return pageType.getMessage();
       
    66 	}
       
    67 	
       
    68 	/**
       
    69 	 * Update the status of the page.
       
    70 	 *
       
    71 	 */
       
    72 	protected void updateStatus() {
       
    73 		IStatus mostSevere = new Status(IStatus.OK, SymbianFoundationTemplates.PLUGIN_ID, 0, "", null);
       
    74 		
       
    75 		for(IStatus status : getStatuses())
       
    76 			if(status.getSeverity() > mostSevere.getSeverity())
       
    77 				mostSevere = status;
       
    78 		
       
    79 		applyStatus(mostSevere);
       
    80 		
       
    81 		updateFields();
       
    82 	}
       
    83 
       
    84 	/**
       
    85 	 * Get the statuses of this page.
       
    86 	 * 
       
    87 	 * @return the statuses
       
    88 	 */
       
    89 	protected abstract AbstractList<IStatus> getStatuses();
       
    90 	
       
    91 	/**
       
    92 	 * Update the fields of this page.
       
    93 	 *
       
    94 	 */
       
    95 	protected abstract void updateFields();
       
    96 }