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