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