imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/PreferencesTab.java
author dpodwall
Tue, 12 Jan 2010 13:17:53 -0600
changeset 0 61163b28edca
child 1 7ff23301fe22
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.internal.viewers;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    19
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    20
import java.io.IOException;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    21
import java.lang.reflect.InvocationTargetException;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    22
import java.util.ArrayList;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    23
import java.util.Arrays;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    24
import java.util.List;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    25
import java.util.Properties;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    26
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    27
import org.eclipse.core.resources.IFile;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    28
import org.eclipse.core.runtime.CoreException;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    29
import org.eclipse.core.runtime.IProgressMonitor;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    30
import org.eclipse.core.runtime.IStatus;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    31
import org.eclipse.core.runtime.Path;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    32
import org.eclipse.core.runtime.Platform;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    33
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    34
import org.eclipse.jface.operation.IRunnableWithProgress;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    35
import org.eclipse.jface.viewers.IStructuredSelection;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    36
import org.eclipse.jface.viewers.StructuredSelection;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    37
import org.eclipse.jface.wizard.WizardDialog;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    38
import org.eclipse.swt.SWT;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    39
import org.eclipse.swt.custom.CTabFolder;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    40
import org.eclipse.swt.custom.CTabItem;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    41
import org.eclipse.swt.events.SelectionAdapter;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    42
import org.eclipse.swt.events.SelectionEvent;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    43
import org.eclipse.swt.events.SelectionListener;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    44
import org.eclipse.swt.layout.GridData;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    45
import org.eclipse.swt.layout.GridLayout;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    46
import org.eclipse.swt.layout.RowData;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    47
import org.eclipse.swt.layout.RowLayout;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    48
import org.eclipse.swt.widgets.Button;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    49
import org.eclipse.swt.widgets.Composite;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    50
import org.eclipse.swt.widgets.Control;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    51
import org.eclipse.swt.widgets.Label;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    52
import org.eclipse.swt.widgets.Shell;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    53
import org.eclipse.swt.widgets.Text;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    54
import org.eclipse.swt.widgets.Widget;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    55
import org.eclipse.ui.IWorkbench;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    56
import org.eclipse.ui.IWorkbenchWindow;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    57
import org.eclipse.ui.PlatformUI;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    58
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    59
import com.nokia.s60tools.imaker.IEnvironment;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    60
import com.nokia.s60tools.imaker.IEnvironmentManager;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    61
import com.nokia.s60tools.imaker.IIMakerWrapper;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    62
import com.nokia.s60tools.imaker.IMakerPlugin;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    63
import com.nokia.s60tools.imaker.IMakerKeyConstants;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    64
import com.nokia.s60tools.imaker.IMakerUtils;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    65
import com.nokia.s60tools.imaker.ImageFlasherHelpContextIDs;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    66
import com.nokia.s60tools.imaker.Messages;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    67
import com.nokia.s60tools.imaker.StatusHandler;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    68
import com.nokia.s60tools.imaker.UIConfiguration;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    69
import com.nokia.s60tools.imaker.UITarget;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    70
import com.nokia.s60tools.imaker.UIVariable;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    71
import com.nokia.s60tools.imaker.exceptions.IMakerCoreExecutionException;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    72
import com.nokia.s60tools.imaker.exceptions.IMakerCoreNotFoundException;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    73
import com.nokia.s60tools.imaker.internal.dialogs.ProductSelectionDialog;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    74
import com.nokia.s60tools.imaker.internal.managers.ProjectManager;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    75
import com.nokia.s60tools.imaker.internal.model.ImakerProperties;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    76
import com.nokia.s60tools.imaker.internal.wizards.NewImakerFileWizard;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    77
import com.nokia.s60tools.imaker.internal.wrapper.IMakerWrapperPreferences;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    78
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    79
public class PreferencesTab extends CTabItem {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    80
	public static PreferencesTab currentPreferencesTab = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    81
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    82
//	private enum EDIT_STATE {EMPTY,EDITED,SAVED};
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    83
//	private enum NAME_STATE {UNNAMED,NAMED};
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    84
//	private EDIT_STATE editState = EDIT_STATE.EMPTY;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    85
//	private NAME_STATE nameState = NAME_STATE.UNNAMED;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    86
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    87
	private Label labelVersion;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    88
	private Text textUserDefinedParameters;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    89
	private Button buttonSymbolFiles;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    90
	private Button buttonVerbose;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    91
	private Button buttonImageTypeRnd;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    92
	private Button buttonImageTypePrd;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    93
	private Button buttonImageTypeSubcon;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    94
	private Text textProduct;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    95
	private org.eclipse.swt.widgets.List listTarget;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    96
	private Button buttonSave;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    97
	private Button buttonSaveAs;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    98
	private IEnvironmentManager environmentManager = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    99
	private IEnvironment activeEnvironment = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   100
	private PreferenceSelectionListener pListener;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   101
	private String iMakerCoreVersion;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   102
	private String pluginVersion;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   103
	private String pluginDate;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   104
	private IMakerTabsViewer tabsViewer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   105
	private org.eclipse.swt.widgets.List listSource;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   106
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   107
	private IPropertyViewer tabDebug;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   108
	private SettingsTab settingsTab;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   109
	private PlatsimTab platsimTab;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   110
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   111
	private ProjectManager projectManager;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   112
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   113
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   114
	 * The only constructor
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   115
	 * @param parent
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   116
	 * @param style
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   117
	 * @param tabsViewer
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   118
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   119
	public PreferencesTab(CTabFolder parent, int style, IMakerTabsViewer tabsViewer) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   120
		super(parent, style);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   121
		this.tabsViewer = tabsViewer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   122
		environmentManager  = tabsViewer.getEnvironmentManager();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   123
		this.activeEnvironment = environmentManager.getActiveEnvironment();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   124
		this.projectManager = tabsViewer.getProjectManager();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   125
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   126
		pListener = new PreferenceSelectionListener();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   127
		iMakerCoreVersion = Messages.getString("PreferencesTab.32"); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   128
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   129
		pluginVersion = 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   130
			(String)Platform.getBundle(IMakerPlugin.PLUGIN_ID) //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   131
			.getHeaders()
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   132
			.get("Bundle-Version"); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   133
		pluginDate = 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   134
			(String)Platform.getBundle(IMakerPlugin.PLUGIN_ID) //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   135
			.getHeaders()
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   136
			.get("Bundle-Date"); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   137
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   138
		setControl(createControl(parent));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   139
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   140
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   141
//	public void displayCurrentProperties() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   142
//		selectedProperties = workstation.getCurrentProperties();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   143
//		if(selectedProperties!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   144
//			displayProperties(selectedProperties);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   145
//			if(!selectedProperties.getFilename().equals(ImakerProperties.CREATE_NEW)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   146
//				nameState = NAME_STATE.NAMED;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   147
//				changeEditState(EDIT_STATE.SAVED);				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   148
//			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   149
//		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   150
//		setTextField();
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
	private Control createControl(CTabFolder parent) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   154
		// Create Top composite in top of the parent composite
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   155
		Composite container = new Composite(parent, SWT.FLAT);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   156
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   157
		GridData topCompositeGridData = new GridData(SWT.FILL, SWT.FILL, true,false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   158
		container.setLayoutData(topCompositeGridData);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   159
		GridLayout topCompositeGridLayout = createLayout();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   160
		container.setLayout(topCompositeGridLayout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   161
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   162
		setHelpForControl(container,ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   163
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   164
		try {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   165
			addConfigurationControls(container);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   166
			addImageTypeSelectionControls(container);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   167
			addFlagSelectionControls(container);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   168
			addAdditionalParametersControl(container);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   169
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   170
			addPreferencesControls(container);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   171
			addVersionInfoControls(container);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   172
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   173
//			// Set up context help ids
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   174
			setHelpForControl(textProduct, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_PRODUCT);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   175
			setHelpForControl(listSource, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_TARGETS);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   176
			setHelpForControl(listTarget, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_SELECTED_TARGETS);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   177
			setHelpForControl(buttonImageTypeRnd, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_IMAGE_TYPE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   178
			setHelpForControl(buttonImageTypePrd, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_IMAGE_TYPE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   179
			setHelpForControl(buttonImageTypeSubcon, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_IMAGE_TYPE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   180
			setHelpForControl(buttonSymbolFiles, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_FLAGS);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   181
			setHelpForControl(buttonVerbose, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_FLAGS);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   182
			setHelpForControl(textUserDefinedParameters, ImageFlasherHelpContextIDs.IMAKERPLUGIN_HELP_ADDITIONAL_PARAMS);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   183
		} catch( Exception e ) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   184
			//Creating preferences dialog caused an exception
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   185
			e.printStackTrace();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   186
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   187
		return container;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   188
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   189
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   190
	private GridLayout createLayout() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   191
		GridLayout topCompositeGridLayout = new GridLayout(2, false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   192
		topCompositeGridLayout.horizontalSpacing = 5; // CodForChk_Dis_Magic
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   193
		topCompositeGridLayout.verticalSpacing = 5; // CodForChk_Dis_Magic
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   194
		topCompositeGridLayout.marginWidth = 3;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   195
		topCompositeGridLayout.marginHeight = 3;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   196
		return topCompositeGridLayout;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   197
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   198
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   199
	private void addVersionInfoControls(Composite container) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   200
		labelVersion =  new Label(container, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   201
		labelVersion.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 2, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   202
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   203
		String versionText = getVersionText();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   204
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   205
		labelVersion.setText(versionText + "\n" + iMakerCoreVersion); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   206
		labelVersion.setToolTipText(Messages.getString("PreferencesTab.20"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   207
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   208
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   209
	private String getVersionText() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   210
		String versionText = "iMaker Extension: " + pluginVersion + ", " + pluginDate;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   211
		return versionText;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   212
	}
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
	 * @param container
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   216
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   217
	private void addPreferencesControls(Composite container) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   218
		Composite controlGroup = new Composite(container, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   219
		GridLayout layoutAdditionalParameters = new GridLayout(4, true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   220
		controlGroup.setLayout(layoutAdditionalParameters);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   221
		controlGroup.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   222
				2, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   223
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   224
		buttonSave = new Button(controlGroup, SWT.PUSH);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   225
		buttonSave.setEnabled(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   226
		buttonSave.setText(Messages.getString("PreferencesTab.16")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   227
		buttonSave.setToolTipText(Messages.getString("PreferencesTab.17")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   228
		buttonSave.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   229
		buttonSave.addSelectionListener(pListener);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   230
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   231
		buttonSaveAs = new Button(controlGroup, SWT.PUSH);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   232
		buttonSaveAs.setText(Messages.getString("PreferencesTab.18")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   233
		buttonSaveAs.setToolTipText(Messages.getString("PreferencesTab.19")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   234
		buttonSaveAs.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false, 1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   235
		buttonSaveAs.addSelectionListener(pListener);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   236
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   237
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   238
	private void addAdditionalParametersControl(Composite container) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   239
		Label label = new Label(container, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   240
		label.setText(Messages.getString("PreferencesTab.14")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   241
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   242
		label.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   243
						1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   244
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   245
		Composite comp = new Composite(container,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   246
		RowLayout layout = new RowLayout();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   247
		layout.type = SWT.HORIZONTAL;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   248
		layout.marginLeft = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   249
		comp.setLayout(layout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   250
		comp
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   251
				.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   252
						1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   253
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   254
		// User defined parameters text
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   255
		textUserDefinedParameters = new Text(comp, SWT.BORDER);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   256
		textUserDefinedParameters.setText("");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   257
		textUserDefinedParameters.setToolTipText(Messages.getString("PreferencesTab.15"));		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   258
		RowData rData = new RowData();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   259
		rData.width = 335;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   260
		textUserDefinedParameters.setLayoutData(rData);
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
	private void addFlagSelectionControls(Composite container) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   264
		Label label = new Label(container, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   265
		label.setText(Messages.getString("PreferencesTab.9")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   266
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   267
		label.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   268
						1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   269
		Composite comp = new Composite(container,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   270
		RowLayout layout = new RowLayout();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   271
		layout.type = SWT.VERTICAL;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   272
		layout.spacing = 2;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   273
		layout.marginLeft = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   274
		comp.setLayout(layout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   275
		comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   276
						1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   277
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   278
		buttonSymbolFiles = new Button(comp, SWT.CHECK);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   279
		buttonSymbolFiles.setText(Messages.getString("PreferencesTab.10"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   280
		buttonSymbolFiles.setToolTipText(Messages.getString("PreferencesTab.11"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   281
		buttonVerbose = new Button(comp, SWT.CHECK);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   282
		buttonVerbose.setText(Messages.getString("PreferencesTab.12"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   283
		buttonVerbose.setToolTipText(Messages.getString("PreferencesTab.13"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   284
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   285
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   286
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   287
	 * Adds image selection user interface components
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   288
	 * @param container
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   289
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   290
	private void addImageTypeSelectionControls(Composite container) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   291
		Label label = new Label(container, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   292
		label.setText(Messages.getString("PreferencesTab.2")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   293
		label.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   294
						1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   295
		Composite comp = new Composite(container,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   296
		RowLayout layout = new RowLayout();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   297
		layout.type = SWT.VERTICAL;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   298
		layout.spacing = 2;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   299
		layout.marginLeft = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   300
		comp.setLayout(layout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   301
		comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   302
						1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   303
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   304
		// Rnd/Prd/Subcon
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   305
		buttonImageTypeRnd = new Button(comp,SWT.RADIO);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   306
		buttonImageTypeRnd.setText(Messages.getString("PreferencesTab.3"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   307
		buttonImageTypeRnd.setToolTipText(Messages.getString("PreferencesTab.4"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   308
		buttonImageTypeRnd.setSelection(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   309
		buttonImageTypePrd = new Button(comp,SWT.RADIO);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   310
		buttonImageTypePrd.setText(Messages.getString("PreferencesTab.5"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   311
		buttonImageTypePrd.setToolTipText(Messages.getString("PreferencesTab.6"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   312
		buttonImageTypeSubcon = new Button(comp,SWT.RADIO);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   313
		buttonImageTypeSubcon.setText(Messages.getString("PreferencesTab.7"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   314
		buttonImageTypeSubcon.setToolTipText(Messages.getString("PreferencesTab.8"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   315
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   316
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   317
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   318
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   319
	 * Add configuration user interface components
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   320
	 * @param container
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   321
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   322
	private void addConfigurationControls(Composite container) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   323
		Label label = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   324
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   325
		label = new Label(container, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   326
		label.setText(Messages.getString("PreferencesTab.0")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   327
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   328
		// Product combo
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   329
		createProductWidgets(container);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   330
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   331
		// Target selection label
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   332
		label = new Label(container, SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   333
		label.setText(Messages.getString("PreferencesTab.1"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   334
		label.setLayoutData(new GridData(SWT.NONE, SWT.NONE, false, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   335
						1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   336
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   337
		addTargetLists(container);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   338
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   339
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   340
	 * @param container
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   341
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   342
	private void createProductWidgets(Composite container) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   343
		Composite product = new Composite(container,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   344
		product.setLayoutData(new GridData(SWT.BEGINNING, SWT.NONE, false, false, 1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   345
		product.setLayout(new GridLayout(2, false));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   346
		textProduct = new Text(product, SWT.BORDER);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   347
		textProduct.setText("");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   348
		textProduct.setEditable(false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   349
		GridData layoutData = new GridData(SWT.BEGINNING, SWT.CENTER, true, true, 1, 1);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   350
		layoutData.widthHint = 280;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   351
		textProduct.setLayoutData(layoutData);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   352
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   353
		Button select = new Button(product,SWT.PUSH);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   354
		select.setText("&Change...");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   355
		select.addSelectionListener(new SelectionListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   356
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   357
//			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   358
			public void widgetSelected(SelectionEvent se) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   359
				ProductSelectionDialog selectDialog = new ProductSelectionDialog(getControl().getShell(),
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   360
						activeEnvironment);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   361
				boolean ret = selectDialog.displayDialog();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   362
				if(ret) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   363
					UIConfiguration config = selectDialog.getSelectedConfiguration();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   364
					refreshProduct(config);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   365
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   366
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   367
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   368
//			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   369
			public void widgetDefaultSelected(SelectionEvent se) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   370
				widgetSelected(se);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   371
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   372
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   373
		select.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   374
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   375
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   376
	private void addTargetLists(Composite parent) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   377
		Composite top = new Composite(parent,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   378
		GridLayout layout = new GridLayout(3, false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   379
		layout.horizontalSpacing = 6;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   380
		layout.verticalSpacing = 1;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   381
		layout.marginWidth = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   382
		layout.marginHeight = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   383
		top.setLayout(layout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   384
		top.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   385
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   386
		listSource = createListComponent(top, "&All");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   387
		listSource.addSelectionListener(new SelectionListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   388
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   389
//			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   390
			public void widgetSelected(SelectionEvent se) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   391
				String item = listSource.getItem(listSource.getSelectionIndex());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   392
				UIConfiguration p = activeEnvironment.getCurrentProduct();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   393
				listSource.setToolTipText(p.getTarget(item).getDescription());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   394
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   395
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   396
//			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   397
			public void widgetDefaultSelected(SelectionEvent arg0) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   398
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   399
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   400
		createListButtons(top);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   401
		listTarget = createListComponent(top, "&Selected");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   402
		listTarget.addSelectionListener(new SelectionListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   403
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   404
//			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   405
			public void widgetSelected(SelectionEvent se) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   406
				String item = listTarget.getItem(listTarget.getSelectionIndex());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   407
				UIConfiguration p = activeEnvironment.getCurrentProduct();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   408
				listTarget.setToolTipText(p.getTarget(item).getDescription());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   409
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   410
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   411
//			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   412
			public void widgetDefaultSelected(SelectionEvent arg0) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   413
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   414
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   415
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   416
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   417
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   418
	private org.eclipse.swt.widgets.List createListComponent(Composite top,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   419
			String txt) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   420
		Composite comp = new Composite(top,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   421
		GridLayout layout = new GridLayout(1, true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   422
		layout.verticalSpacing = 1;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   423
		layout.marginWidth = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   424
		layout.marginHeight = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   425
		comp.setLayout(layout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   426
		comp
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   427
				.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   428
						1, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   429
		GridData gData;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   430
		Label label = new Label(comp,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   431
		label.setText(txt);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   432
		org.eclipse.swt.widgets.List list;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   433
		list = new org.eclipse.swt.widgets.List(comp, SWT.MULTI | SWT.V_SCROLL
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   434
				| SWT.BORDER);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   435
		gData = new GridData();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   436
		gData.widthHint = 132;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   437
		gData.heightHint = 132;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   438
		list.setLayoutData(gData);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   439
		return list;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   440
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   441
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   442
	private void createListButtons(Composite top) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   443
		Composite bComp = new Composite(top,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   444
		GridLayout layout = new GridLayout(1, true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   445
		layout.marginWidth = 1;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   446
		layout.verticalSpacing = 1;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   447
		bComp.setLayout(layout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   448
		bComp.setLayoutData(new GridData(SWT.NONE, SWT.CENTER, false, false, 1,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   449
				1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   450
		Button button = new Button(bComp,SWT.PUSH);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   451
		button.setText(">");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   452
		button.addSelectionListener(new SelectionAdapter() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   453
			public void widgetSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   454
				String[] selections = listSource.getSelection();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   455
				addToListTarget(selections);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   456
				listSource.setToolTipText("");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   457
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   458
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   459
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   460
		GridData gData = new GridData();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   461
		gData.verticalAlignment = SWT.END;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   462
		button.setLayoutData(gData);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   463
		button = new Button(bComp,SWT.PUSH);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   464
		button.setText("<");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   465
		button.addSelectionListener(new SelectionAdapter() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   466
			public void widgetSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   467
				String[] selections = listTarget.getSelection();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   468
				addToListSource(selections);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   469
				listTarget.setToolTipText("");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   470
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   471
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   472
		gData = new GridData();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   473
		gData.verticalAlignment = SWT.CENTER;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   474
		button.setLayoutData(gData);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   475
	}	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   476
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   477
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   478
	private void moveItemsInList(org.eclipse.swt.widgets.List source,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   479
			org.eclipse.swt.widgets.List target, String[] items) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   480
		List<String> sourceItems = Arrays.asList(source.getItems());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   481
		for (int i = 0; i < items.length; i++) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   482
			String item = items[i];
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   483
			if(sourceItems.contains(item)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   484
				source.remove(item);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   485
				target.add(item);				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   486
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   487
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   488
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   489
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   490
	protected void addToListSource(String[] selections) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   491
		moveItemsInList(listTarget, listSource, selections);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   492
		String[] items = listSource.getItems();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   493
		Arrays.sort(items);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   494
		listSource.removeAll();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   495
		listSource.setItems(items);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   496
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   497
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   498
	protected void addToListTarget(String[] selections) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   499
		UIConfiguration pr = activeEnvironment.getCurrentProduct();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   500
		moveItemsInList(listSource, listTarget, selections);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   501
		for (int i = 0; i < selections.length; i++) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   502
			String target = selections[i];
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   503
			UITarget tr = pr.getTarget(target);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   504
			if(tr.getSteps()==null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   505
				String targetSteps = activeEnvironment.getTargetSteps(target);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   506
				tr.setSteps(targetSteps);				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   507
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   508
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   509
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   510
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   511
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   512
	private void setHelpForControl(Control container, String id) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   513
		PlatformUI.getWorkbench().getHelpSystem().setHelp(container, id);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   514
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   515
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   516
	private void resetAdditionalFields() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   517
		buttonImageTypeRnd.setSelection(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   518
		buttonImageTypePrd.setSelection(false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   519
		buttonImageTypeSubcon.setSelection(false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   520
		buttonSymbolFiles.setSelection(false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   521
		buttonVerbose.setSelection(false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   522
		textUserDefinedParameters.setText("");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   523
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   524
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   525
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   526
	private void loadConfigurations() throws InvocationTargetException {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   527
		try {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   528
			iMakerCoreVersion = activeEnvironment.getIMakerCoreVersion();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   529
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   530
			//check imaker version here 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   531
			if(!verifyIMakerVersion()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   532
				String msg = Messages.getString("Error.3"); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   533
				String minVersion = Messages.getString("PreferencesTab.22"); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   534
				StatusHandler.handle(IStatus.ERROR,msg.replace("xxx", minVersion),null); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   535
				return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   536
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   537
			fixVersionText();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   538
			activeEnvironment.load();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   539
			if(activeEnvironment.isLoaded()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   540
				UIConfiguration def = getDefaultConfig();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   541
				if(def==null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   542
					def = activeEnvironment.getConfigurations().get(0);				
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   543
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   544
				refreshProduct(def);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   545
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   546
		} catch (IMakerCoreNotFoundException e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   547
			StatusHandler.handle(IStatus.ERROR,"iMaker Core was not found.",e); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   548
			return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   549
		} catch (IMakerCoreExecutionException e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   550
			StatusHandler.handle(IStatus.ERROR,"An error has occurred while executing iMaker Core. The selected environment cannot be used with iMaker extension.",e); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   551
			return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   552
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   553
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   554
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   555
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   556
	 * @param environment
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   557
	 * @return
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   558
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   559
	private UIConfiguration getDefaultConfig() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   560
		List<UIConfiguration> configs;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   561
		try {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   562
			configs = activeEnvironment.getConfigurations();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   563
			UIConfiguration ret = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   564
			for (UIConfiguration config : configs) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   565
				if(config.isDefaultConfig()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   566
					ret = config;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   567
					break;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   568
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   569
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   570
			return ret;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   571
		} catch (InvocationTargetException e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   572
			return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   573
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   574
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   575
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   576
	private void refreshProduct(UIConfiguration product) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   577
		if(product==null) return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   578
		textProduct.setText(product.getConfigurationName());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   579
		textProduct.setData(product);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   580
		clearWidgets();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   581
		activeEnvironment.setCurrentProduct(product);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   582
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   583
		List<UITarget> targets = product.getFilteredTargets();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   584
		if(targets!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   585
			for(UITarget target: targets) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   586
				listSource.add(target.getName());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   587
			}						
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   588
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   589
		settingsTab.setInput(product);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   590
		textProduct.setToolTipText(product.getFilePath());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   591
		platsimTab.activate(product.isPlatsimConfiguration());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   592
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   593
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   594
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   595
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   596
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   597
	private void clearWidgets() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   598
		listSource.removeAll();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   599
		listTarget.removeAll();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   600
		resetAdditionalFields();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   601
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   602
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   603
	private void fixVersionText() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   604
		StringBuilder version = new StringBuilder(labelVersion.getText());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   605
		int index = version.indexOf(Messages.getString("PreferencesTab.32")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   606
		if(index != -1) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   607
			version.replace(index, version.length(), Messages.getString("PreferencesTab.32") + " " + iMakerCoreVersion);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   608
			labelVersion.setText(version.toString());			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   609
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   610
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   611
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   612
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   613
	private boolean verifyIMakerVersion() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   614
		String minVersion = Messages.getString("PreferencesTab.22"); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   615
		String curVersion = IMakerUtils.parseIMakerVersion(iMakerCoreVersion);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   616
		if(curVersion.compareTo(minVersion)>0) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   617
			return true;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   618
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   619
		return false;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   620
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   621
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   622
	private void savePreferencesToFile(String filePath) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   623
		ImakerProperties uiValues = new ImakerProperties();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   624
		uiValues.putAll(getUIValues());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   625
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   626
		UIConfiguration current = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   627
		current = activeEnvironment.getCurrentProduct();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   628
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   629
		if (filePath == null||filePath.equals(ProjectManager.NEW_ITEM)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   630
			IStructuredSelection selection = new StructuredSelection(tabsViewer
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   631
					.getProjectManager().getProject());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   632
			IWorkbench workbench = PlatformUI.getWorkbench();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   633
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   634
			NewImakerFileWizard wizard = new NewImakerFileWizard(uiValues, current,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   635
					this);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   636
			wizard.init(workbench, selection);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   637
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   638
			WizardDialog dialog = new WizardDialog(workbench
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   639
					.getActiveWorkbenchWindow().getShell(), wizard);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   640
			dialog.open();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   641
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   642
			if (wizard.isSaved()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   643
				IFile file = wizard.getFile();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   644
				String loc = file.getLocation().toString();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   645
				tabsViewer.populateConfigurations(loc);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   646
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   647
		} else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   648
			IFile file = (IFile)projectManager.getImakerFile(new Path(filePath));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   649
			uiValues.saveToFile(file);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   650
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   651
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   652
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   653
	private Properties getUIValues() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   654
		ImakerProperties prop = new ImakerProperties();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   655
		try {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   656
			UIConfiguration config = (UIConfiguration) textProduct.getData();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   657
			if(config!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   658
				addField(prop,IMakerKeyConstants.MAKEFILE,config.getFilePath());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   659
				addField(prop,IMakerKeyConstants.PRODUCT,config.getMakeFileName());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   660
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   661
			StringBuilder sb = new StringBuilder();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   662
			for (int i = 0; i < listTarget.getItemCount(); i++) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   663
				sb.append(listTarget.getItem(i));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   664
				if(i<listTarget.getItemCount()-1) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   665
					sb.append(" ");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   666
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   667
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   668
			if(sb.length()>0) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   669
				addField(prop,IMakerKeyConstants.TARGET_LIST,sb.toString());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   670
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   671
			if(buttonImageTypePrd.getSelection()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   672
				addField(prop,IMakerKeyConstants.TYPE,Messages.getString("PreferencesTab.23")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   673
			} else if(buttonImageTypeSubcon.getSelection()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   674
				addField(prop,IMakerKeyConstants.TYPE,Messages.getString("PreferencesTab.24")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   675
			} else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   676
				addField(prop,IMakerKeyConstants.TYPE,Messages.getString("PreferencesTab.25")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   677
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   678
			if(buttonVerbose.getSelection()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   679
				addField(prop,IMakerKeyConstants.VERBOSE,Messages.getString("PreferencesTab.26")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   680
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   681
			if(buttonSymbolFiles.getSelection()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   682
				addField(prop,IMakerKeyConstants.SYMBOLFILES,Messages.getString("PreferencesTab.27")); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   683
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   684
			addField(prop, IMakerKeyConstants.ADDITIONAL_PARAMETERS, 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   685
					textUserDefinedParameters.getText());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   686
			settingsTab.addChangedSettings(prop);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   687
			platsimTab.addToProperties(prop);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   688
			tabDebug.addToProperties(prop);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   689
		} catch(Exception e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   690
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   691
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   692
		return prop;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   693
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   694
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   695
	private void addField(Properties properties, String name, String value) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   696
		if((name==null)||(name.equals(""))||(value==null)||(value.equals(""))) { //$NON-NLS-1$ //$NON-NLS-2$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   697
			return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   698
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   699
		properties.setProperty(name, value);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   700
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   701
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   702
	private void fillUIForm(ImakerProperties prop) throws InvocationTargetException {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   703
		String filePath = (String) prop.remove(IMakerKeyConstants.MAKEFILE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   704
		if(filePath==null) return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   705
		filePath = filePath.replaceAll("\\\\", "/");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   706
		List<UIConfiguration> configs = activeEnvironment.getConfigurations();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   707
		for (UIConfiguration config : configs) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   708
			if(config.getFilePath().equals(filePath)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   709
				refreshProduct(config);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   710
				break;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   711
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   712
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   713
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   714
		String targets = (String) prop.remove(IMakerKeyConstants.TARGET_LIST);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   715
		if((targets!=null)&&!(targets.equals(""))) { //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   716
			String[] tars = targets.split(" "); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   717
			addToListTarget(tars);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   718
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   719
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   720
		String str = (String)prop.remove(IMakerKeyConstants.TYPE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   721
		if(str!=null){
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   722
			buttonImageTypeRnd.setSelection(false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   723
			if(str.equals(Messages.getString("PreferencesTab.24"))) { //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   724
				buttonImageTypeSubcon.setSelection(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   725
			} else if(str.equals(Messages.getString("PreferencesTab.23"))) { //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   726
				buttonImageTypePrd.setSelection(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   727
			} else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   728
				buttonImageTypeRnd.setSelection(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   729
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   730
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   731
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   732
		str = (String)prop.remove(IMakerKeyConstants.VERBOSE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   733
		if((str!=null)&&!(str.equals(""))) { //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   734
			buttonVerbose.setSelection(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   735
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   736
		str = (String)prop.remove(IMakerKeyConstants.SYMBOLFILES);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   737
		if((str!=null)&&!(str.equals(""))) { //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   738
			buttonSymbolFiles.setSelection(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   739
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   740
		String adds = (String)prop.remove(IMakerKeyConstants.ADDITIONAL_PARAMETERS);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   741
		if(adds!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   742
			textUserDefinedParameters.setText(adds);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   743
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   744
		updateSettings(prop);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   745
		tabDebug.restoreFromProperties(prop);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   746
		platsimTab.restoreFromProperties(prop);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   747
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   748
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   749
	public void setSettings(SettingsTab tabSettings) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   750
		this.settingsTab = tabSettings;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   751
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   752
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   753
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   754
	 *
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   755
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   756
	private class PreferenceSelectionListener implements SelectionListener {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   757
		public void widgetDefaultSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   758
			widgetSelected(e);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   759
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   760
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   761
		public void widgetSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   762
			Widget source = e.widget;			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   763
			if(source==buttonSave) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   764
				savePreferencesToFile(tabsViewer.getSelectedItem());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   765
			} else if(source==buttonSaveAs) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   766
				savePreferencesToFile(null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   767
			} else {}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   768
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   769
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   770
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   771
	public void revertSettingsTab() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   772
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   773
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   774
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   775
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   776
	 * Called when something changed in the settingsTab.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   777
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   778
	public void refreshSettingsTab() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   779
		if(!settingsTab.isDirty()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   780
			return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   781
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   782
		String drive = activeEnvironment.getDrive();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   783
		IRunnableWithProgress op = new IMakerSettingsUpdater(null,drive);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   784
		executeRunnable(op);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   785
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   786
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   787
	private void executeRunnable(IRunnableWithProgress op) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   788
		IWorkbench wb = PlatformUI.getWorkbench();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   789
		IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   790
		Shell shell = win != null ? win.getShell() : null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   791
		try {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   792
			ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   793
			progressMonitorDialog.run(true, false, op);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   794
			settingsTab.getTableViewer().refresh();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   795
		} catch (InvocationTargetException e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   796
			StatusHandler.handle(IStatus.ERROR,Messages.getString("Error.1"),e.getTargetException()); //$NON-NLS-1$
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   797
			e.printStackTrace();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   798
		} catch (InterruptedException e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   799
			e.printStackTrace();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   800
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   801
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   802
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   803
	private class IMakerSettingsUpdater implements IRunnableWithProgress {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   804
		private List<String> modifiedVariables=null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   805
		private String environment;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   806
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   807
		public IMakerSettingsUpdater(List<String> modifiedVariables, String env) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   808
			this.modifiedVariables = modifiedVariables;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   809
			this.environment = env;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   810
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   811
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   812
		public void run(IProgressMonitor monitor)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   813
		throws InvocationTargetException, InterruptedException {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   814
			try {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   815
				IIMakerWrapper wrapper = activeEnvironment.getImakerWrapper();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   816
				ArrayList<String> parameters = new ArrayList<String>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   817
				UIConfiguration currentConfiguration = activeEnvironment.getCurrentProduct();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   818
				parameters.add(environment +
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   819
						IMakerWrapperPreferences.DEFAULT_COMMAND);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   820
				parameters.add(currentConfiguration.getFilePath());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   821
				UIConfiguration configuration=null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   822
				List<UIVariable> incVars = null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   823
				if(modifiedVariables==null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   824
					incVars = IMakerUtils.getCommandlineIncludeVariables(currentConfiguration.getVariables());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   825
					List<String> varList = IMakerUtils.convertVariablesToStrings(incVars);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   826
					parameters.addAll(varList);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   827
					configuration = wrapper.getConfiguration(parameters, monitor);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   828
				} else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   829
					incVars = IMakerUtils.convertStringsToVariables(modifiedVariables);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   830
					parameters.addAll(modifiedVariables);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   831
					configuration = wrapper.getConfiguration(parameters, monitor);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   832
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   833
				for (UIVariable variable : incVars) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   834
					UIVariable v = findVariable(configuration,variable);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   835
					if(v!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   836
						v.setInclude(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   837
					}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   838
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   839
				currentConfiguration.setVariables(configuration.getVariables());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   840
			} catch (Exception e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   841
				throw new InvocationTargetException(e);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   842
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   843
			monitor.worked(100);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   844
			monitor.done();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   845
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   846
		private UIVariable findVariable(UIConfiguration configuration,
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   847
				UIVariable var) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   848
			List<UIVariable> variables = configuration.getVariables();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   849
			for (UIVariable variable : variables) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   850
				if(var.equals(variable)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   851
					return variable;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   852
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   853
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   854
			return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   855
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   856
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   857
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   858
	public void runPressed(String item) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   859
		if(item.equals(ProjectManager.NEW_ITEM)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   860
			ImakerProperties run = activeEnvironment.getRunProperties();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   861
			run.clear();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   862
			Properties uiValues = getUIValues();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   863
			run.putAll(uiValues);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   864
			run.setActiveFile(null);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   865
		} else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   866
			savePreferencesToFile(item);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   867
			ImakerProperties run = activeEnvironment.getRunProperties();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   868
			run.setActiveFile(item);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   869
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   870
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   871
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   872
	public void setDebug(IPropertyViewer debug) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   873
		tabDebug = debug;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   874
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   875
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   876
	/**get
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   877
	 * @param item
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   878
	 * @throws InterruptedException 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   879
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   880
	public void loadImakerFile(String item) throws InvocationTargetException {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   881
		if(!item.equals(ProjectManager.NEW_ITEM)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   882
			IFile file = (IFile)projectManager.getImakerFile(new Path(item));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   883
			ImakerProperties prop = new ImakerProperties();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   884
			try {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   885
				prop.load(file.getContents());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   886
				fillUIForm(prop);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   887
			} catch (IOException e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   888
				e.printStackTrace();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   889
			} catch (CoreException e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   890
				e.printStackTrace();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   891
			};
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   892
		} else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   893
			loadDefaults();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   894
			fillUIForm(activeEnvironment.getRunProperties());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   895
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   896
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   897
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   898
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   899
	private void updateSettings(Properties content) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   900
		List<String> modified = new ArrayList<String>();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   901
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   902
		String mods = (String)content.get(IMakerKeyConstants.MODIFIED_SETTINGS);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   903
		if(mods==null) return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   904
		String[] parts;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   905
		if(mods!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   906
			parts = mods.split(ImakerProperties.SEPARATOR);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   907
			for (int i = 0; i < parts.length; i++) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   908
				modified.add(parts[i]);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   909
			}			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   910
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   911
		mods = (String) content.get(IMakerKeyConstants.ADDITIONAL_PARAMETERS);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   912
		if(mods!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   913
			parts = mods.split(ImakerProperties.SEPARATOR);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   914
			for (int i = 0; i < parts.length; i++) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   915
				modified.add(parts[i]);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   916
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   917
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   918
		String drive = activeEnvironment.getDrive();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   919
		IRunnableWithProgress op = new IMakerSettingsUpdater(modified,drive);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   920
		executeRunnable(op);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   921
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   922
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   923
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   924
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   925
	 * @throws InterruptedException 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   926
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   927
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   928
	private void loadDefaults() throws InvocationTargetException {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   929
		loadConfigurations();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   930
		tabDebug.clear();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   931
		platsimTab.clear();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   932
		updateDefaultTarget(getDefaultConfig());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   933
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   934
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   935
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   936
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   937
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   938
	public void restore() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   939
		UIConfiguration def = getDefaultConfig();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   940
		refreshProduct(def);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   941
		updateDefaultTarget(def);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   942
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   943
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   944
	/**
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   945
	 * @param def 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   946
	 * 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   947
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   948
	private void updateDefaultTarget(UIConfiguration def) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   949
		if(def==null) return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   950
		String target = "default";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   951
		addToListTarget(new String[]{target});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   952
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   953
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   954
	public void setPlatsim(PlatsimTab tabPlatsim) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   955
		this.platsimTab = tabPlatsim;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   956
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   957
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   958
	public String[] getSelectedTargets() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   959
		return listTarget.getItems();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   960
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   961
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   962
	public UIConfiguration getSelectedProduct() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   963
		return activeEnvironment.getCurrentProduct();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   964
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   965
}