imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/UIConfiguration.java
author dpodwall
Tue, 12 Jan 2010 13:17:53 -0600
changeset 0 61163b28edca
child 2 a91cb670dd8e
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
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    18
package com.nokia.s60tools.imaker;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    19
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    20
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    21
import java.util.ArrayList;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    22
import java.util.Collections;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    23
import java.util.HashSet;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    24
import java.util.Iterator;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    25
import java.util.List;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    26
import java.util.Set;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    27
import java.util.StringTokenizer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    28
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    29
import com.nokia.s60tools.imaker.internal.iqrf.Configuration;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    30
import com.nokia.s60tools.imaker.internal.iqrf.ConfigurationElement;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    31
import com.nokia.s60tools.imaker.internal.iqrf.Setting;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    32
import com.nokia.s60tools.imaker.internal.iqrf.Target;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    33
import com.nokia.s60tools.imaker.internal.viewers.ISettingViewer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    34
import com.nokia.s60tools.imaker.internal.wrapper.IMakerWrapperPreferences;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    35
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    36
/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    37
 * Class represents a simple container for data presented in Configuration,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    38
 * Target and Setting objects (EMF). It only contains the most needed data
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    39
 * to be used in upper layers (UI).
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    40
 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    41
 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    42
public class UIConfiguration {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    43
//	public static final HashMap<String,String> UI_TARGETS = new HashMap<String,String>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    44
//	static {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    45
//		UI_TARGETS.put("all",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    46
//		UI_TARGETS.put("core",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    47
//		UI_TARGETS.put("flash",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    48
//		UI_TARGETS.put("image",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    49
//		UI_TARGETS.put("mmc",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    50
//		UI_TARGETS.put("rofs2",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    51
//		UI_TARGETS.put("rofs3",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    52
//		UI_TARGETS.put("rofs4",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    53
//		UI_TARGETS.put("uda",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    54
//		UI_TARGETS.put("udaerase",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    55
//		UI_TARGETS.put("variant",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    56
//		UI_TARGETS.put("default",null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    57
//	};
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    58
	/** Private instance variables */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    59
	private String           productName  = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    60
	private String           platformName = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    61
	private String           makeFileName = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    62
	private String           filePath     = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    63
	private String           defaultHWID  = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    64
	private List<String>     hwids        = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    65
	private List<UITarget>   targets      = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    66
	private List<UIVariable> variables    = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    67
	private boolean          defaultConfig = false;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    68
	private String           defaultTarget = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    69
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    70
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    71
	private Set<ISettingViewer> changeListeners = new HashSet<ISettingViewer>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    72
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    73
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    74
	 * Default constructor. Gets a Configuration object as a parameter
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    75
	 * and goes through it to find the needed data.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    76
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    77
	 * @param conf Configuration object to analyze
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    78
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    79
	public UIConfiguration(Configuration conf) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    80
		if (conf != null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    81
			makeFileName = conf.getName();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    82
			filePath     = conf.getFilePath();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    83
			targets      = new ArrayList<UITarget>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    84
			variables    = new ArrayList<UIVariable>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    85
			Target target;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    86
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    87
			Iterator<Target> targetIter = conf.getTargetrefs().iterator();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    88
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    89
			// Go through targets.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    90
			while((targetIter != null) && targetIter.hasNext()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    91
				target = targetIter.next();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    92
				targets.add(new UITarget(target.getName(), target.getDescription()));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    93
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    94
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    95
			Iterator<Setting> settingIter = conf.getSettings().iterator();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    96
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    97
			// Go through settings.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    98
			while((settingIter != null) && settingIter.hasNext()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    99
				Setting set                  = settingIter.next();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   100
				ConfigurationElement element = set.getRef();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   101
				String name = set.getName();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   102
				if (name==null) continue;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   103
				String value                 = name.toLowerCase();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   104
				String elementName           = element.getName().toLowerCase();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   105
				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   106
				// Is setting a product name
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   107
				if ((value != null) && (set != null) && (elementName != null)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   108
					// Put setting into variable list
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   109
					UIVariable var = new UIVariable(name, set.getValue(),
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   110
							"variable", element.getDescription(), element.getValues());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   111
					variables.add(var);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   112
					
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   113
					if (elementName.equals(IMakerWrapperPreferences.PRODUCT_NAME)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   114
						productName = set.getValue();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   115
					} else if (elementName.equals(IMakerWrapperPreferences.COREPLATFORM_NAME) ||
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   116
							elementName.equals(IMakerWrapperPreferences.UIPLATFORM_NAME)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   117
						// Is setting a platform name
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   118
						platformName = set.getValue();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   119
					} else if (elementName.equals(IMakerWrapperPreferences.HWID)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   120
						hwids = new ArrayList<String>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   121
						StringTokenizer tokenizer = new StringTokenizer(set.getValue(),
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   122
								IMakerWrapperPreferences.HWID_DELIMITER);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   123
						// Tokenize the list of HWIDs and loop through it.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   124
						// Search for a default HWID which is marked by
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   125
						// a special character at the end of it.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   126
						while (tokenizer.hasMoreTokens()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   127
							String token = tokenizer.nextToken();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   128
							if ((token != null) && (token.charAt(
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   129
								token.length()-1) == 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   130
									IMakerWrapperPreferences.HWID_DEFAULT_MARKER)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   131
								token = token.substring(0, token.length()-1);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   132
								defaultHWID = token;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   133
							}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   134
							token = token.trim();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   135
							hwids.add(token);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   136
							if ((defaultHWID == null) || defaultHWID.equals("")) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   137
								defaultHWID = token;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   138
							}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   139
						}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   140
						Collections.sort(hwids);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   141
					}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   142
				} else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   143
					// Something else found entirely?
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   144
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   145
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   146
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   147
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   148
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   149
	public boolean isDefaultConfig() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   150
		return defaultConfig;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   151
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   152
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   153
	public void setDefaultConfig(boolean def) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   154
		this.defaultConfig = def;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   155
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   156
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   157
	public String getDefaultTarget() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   158
		for (UITarget target : getAllTargets()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   159
			if(target.getName().equals("default")) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   160
				return target.getName();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   161
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   162
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   163
		return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   164
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   165
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   166
	public void setDefaultTarget(String target) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   167
		this.defaultTarget = target;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   168
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   169
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   170
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   171
	 * Get method for productName
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   172
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   173
	 * @return name of the product
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   174
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   175
	public String getProductName() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   176
		return productName;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   177
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   178
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   179
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   180
	 * Get method for makeFileName
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   181
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   182
	 * @return name of the makefile
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   183
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   184
	public String getMakeFileName() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   185
		return makeFileName;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   186
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   187
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   188
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   189
	 * Get method for filePath
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   190
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   191
	 * @return file path
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   192
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   193
	public String getFilePath() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   194
		return filePath;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   195
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   196
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   197
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   198
	 * Get method for default HWID
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   199
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   200
	 * @return default HWID
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   201
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   202
	public String getDefaultHWID() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   203
		return defaultHWID;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   204
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   205
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   206
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   207
	 * Get method for target names
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   208
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   209
	 * @return list of targets
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   210
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   211
	public List<UITarget> getAllTargets() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   212
		return targets;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   213
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   214
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   215
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   216
	 * Get method for variables
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   217
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   218
	 * @return list of variables.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   219
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   220
	public List<UIVariable> getVariables() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   221
		return variables;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   222
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   223
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   224
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   225
	 * Get method for HWIDs
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   226
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   227
	 * @return a list of HWIDs
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   228
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   229
	public List<String> getHWIDs() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   230
		return hwids;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   231
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   232
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   233
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   234
	 * Get platform name
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   235
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   236
	 * @return name of the platform
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   237
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   238
	public String getPlatformName() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   239
		return platformName;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   240
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   241
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   242
	public void removeChangeListener(ISettingViewer viewer) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   243
		changeListeners.remove(viewer);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   244
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   245
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   246
	public void addChangeListener(ISettingViewer viewer) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   247
		changeListeners.add(viewer);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   248
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   249
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   250
	public void variableChanged(UIVariable variable) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   251
		Iterator<ISettingViewer> iterator = changeListeners.iterator();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   252
		while (iterator.hasNext())
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   253
			iterator.next().updateVariable(variable);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   254
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   255
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   256
	public String toString() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   257
		StringBuffer out = new StringBuffer();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   258
		for(UIVariable v: variables) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   259
			if(v.isModified()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   260
				out.append(v.toString()+"\n");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   261
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   262
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   263
		return out.toString();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   264
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   265
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   266
	public void setTargets(List<UITarget> targets) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   267
		this.targets=targets;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   268
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   269
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   270
	public void setVariables(List<UIVariable> variables) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   271
		this.variables=variables;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   272
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   273
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   274
	public String getConfigurationName() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   275
		String path = getFilePath();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   276
		String start = "image_conf_";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   277
		int index = path.indexOf(start);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   278
		return path.substring(index+start.length(), path.length()-3);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   279
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   280
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   281
	public List<UITarget> getFilteredTargets() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   282
//		List<UITarget> temp = new ArrayList<UITarget>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   283
		return getAllTargets();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   284
//
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   285
//		String name = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   286
//		for (UITarget target : all) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   287
//			name = target.getName();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   288
//			if(UI_TARGETS.containsKey(name)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   289
//				UI_TARGETS.put(name, target.getDescription());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   290
//				temp.add(target);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   291
//			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   292
//		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   293
//		return temp;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   294
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   295
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   296
	public boolean isPlatsimConfiguration() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   297
		List<UIVariable> vars = this.getVariables();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   298
		for (UIVariable var : vars) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   299
			if(var.getName().equals(IMakerWrapperPreferences.USE_PLATSIM)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   300
				String value = var.getValue();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   301
				return (value.equals("1"))?true:false;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   302
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   303
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   304
		return false;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   305
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   306
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   307
	public UITarget getTarget(String name) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   308
		String ret = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   309
		for (UITarget t: getAllTargets()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   310
			if(name.equals(t.getName())) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   311
				return t;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   312
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   313
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   314
		return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   315
	}	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   316
}