sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.button/src/com/nokia/carbide/cpp/internal/pi/button/ui/ExportBupMapWizard.java
changeset 2 b9ab3b238396
equal deleted inserted replaced
1:1050670c6980 2:b9ab3b238396
       
     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 the License "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 
       
    18 package com.nokia.carbide.cpp.internal.pi.button.ui;
       
    19 
       
    20 import java.util.ArrayList;
       
    21 
       
    22 import org.eclipse.jface.viewers.IStructuredSelection;
       
    23 import org.eclipse.jface.wizard.Wizard;
       
    24 import org.eclipse.ui.IExportWizard;
       
    25 import org.eclipse.ui.IWorkbench;
       
    26 
       
    27 import com.nokia.carbide.cpp.internal.pi.util.config.gen.PIConfig.ButtonEventProfileType;
       
    28 import com.nokia.carbide.cpp.pi.button.BupEventMapManager;
       
    29 import com.nokia.carbide.cpp.pi.button.IBupEventMap;
       
    30 import com.nokia.carbide.cpp.pi.button.IBupEventMapProfile;
       
    31 import com.nokia.carbide.cpp.pi.util.GeneralMessages;
       
    32 
       
    33 
       
    34 public class ExportBupMapWizard extends Wizard implements IExportWizard {
       
    35 
       
    36 	private ExportBupMapGetXmlTask exportPage;
       
    37 	
       
    38 	public ExportBupMapWizard() {
       
    39 		setWindowTitle(Messages.getString("ExportBupMapWizard.0"));   //$NON-NLS-1$
       
    40 	}
       
    41 	
       
    42 	/* (non-Javadoc)
       
    43 	 * @see org.eclipse.jface.wizard.Wizard#addPages()
       
    44 	 */
       
    45 	public void addPages() {
       
    46 		addPage(exportPage = new ExportBupMapGetXmlTask());
       
    47 	}
       
    48 
       
    49 	/* (non-Javadoc)
       
    50 	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
       
    51 	 */
       
    52 	@Override
       
    53 	public boolean performFinish() {
       
    54 		ArrayList<IBupEventMapProfile> workspacePrefProfiles = BupEventMapManager.getInstance().getProfilesFromWorkspacePref();
       
    55 		if (workspacePrefProfiles.size() <= 0) {
       
    56 			GeneralMessages.showErrorMessage(Messages.getString("ExportBupMapWizard.1"));   //$NON-NLS-1$
       
    57 			return false;
       
    58 		}
       
    59 
       
    60 		java.io.File file = new java.io.File(exportPage.getExportXml());
       
    61 		ArrayList<ButtonEventProfileType> profileList = new ArrayList<ButtonEventProfileType>();
       
    62 		for (IBupEventMapProfile profile : workspacePrefProfiles) {
       
    63 			IBupEventMap map = BupEventMapManager.getInstance().captureMap(profile);
       
    64 			profileList.add(map.toEmfModel());
       
    65 			BupEventMapManager.getInstance().releaseMap(map);
       
    66 		}
       
    67 		BupEventMapManager.getInstance().saveMap(file.toURI(), profileList);	
       
    68 
       
    69 		return true;
       
    70 	}
       
    71 
       
    72 	/* (non-Javadoc)
       
    73 	 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
       
    74 	 */
       
    75 	public void init(IWorkbench arg0, IStructuredSelection arg1) {
       
    76 	}
       
    77 }