imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/DebugTab.java
author haismail <hussein.ismail@nokia.com>
Wed, 28 Apr 2010 13:50:48 +0300
changeset 11 217e69fc5beb
parent 6 7f60f3388609
permissions -rw-r--r--
iMaker 3.1.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     1
/*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     3
* All rights reserved.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     4
* This component and the accompanying materials are made available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     6
* which accompanies this distribution, and is available
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     8
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
     9
* Initial Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    11
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    12
* Contributors:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    13
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    14
* Description:
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    15
*
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    16
*/
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    17
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    18
package com.nokia.s60tools.imaker.internal.viewers;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    19
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    20
import java.io.File;
5
d5efbe6c22e8 Ticket #1245: Update target selection required to avoid yellow warnings on content tab
haismail <hussein.ismail@nokia.com>
parents: 2
diff changeset
    21
import java.util.ArrayList;
6
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
    22
import java.util.Iterator;
1
7ff23301fe22 iMaker plugin updated:
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
    23
import java.util.List;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    24
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    25
import org.eclipse.emf.common.util.EList;
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
    26
import org.eclipse.jface.dialogs.MessageDialog;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    27
import org.eclipse.jface.resource.ImageRegistry;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    28
import org.eclipse.jface.viewers.ColumnLabelProvider;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    29
import org.eclipse.jface.viewers.ISelection;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    30
import org.eclipse.jface.viewers.IStructuredContentProvider;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    31
import org.eclipse.jface.viewers.IStructuredSelection;
6
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
    32
import org.eclipse.jface.viewers.StructuredSelection;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    33
import org.eclipse.jface.viewers.TableViewer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    34
import org.eclipse.jface.viewers.TableViewerColumn;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    35
import org.eclipse.jface.viewers.Viewer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    36
import org.eclipse.jface.window.Window;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    37
import org.eclipse.swt.SWT;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    38
import org.eclipse.swt.custom.CTabFolder;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    39
import org.eclipse.swt.custom.CTabItem;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    40
import org.eclipse.swt.events.KeyEvent;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    41
import org.eclipse.swt.events.KeyListener;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    42
import org.eclipse.swt.events.SelectionEvent;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    43
import org.eclipse.swt.events.SelectionListener;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    44
import org.eclipse.swt.graphics.Image;
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.widgets.Button;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    48
import org.eclipse.swt.widgets.Composite;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    49
import org.eclipse.swt.widgets.Control;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    50
import org.eclipse.swt.widgets.Table;
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
    51
import org.eclipse.ui.PlatformUI;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    52
6
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
    53
import com.nokia.s60tools.imaker.IMakerKeyConstants;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    54
import com.nokia.s60tools.imaker.IMakerPlugin;
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
    55
import com.nokia.s60tools.imaker.ImageFlasherHelpContextIDs;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    56
import com.nokia.s60tools.imaker.Messages;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    57
import com.nokia.s60tools.imaker.UIConfiguration;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    58
import com.nokia.s60tools.imaker.UITarget;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    59
import com.nokia.s60tools.imaker.internal.managers.ProjectManager;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    60
import com.nokia.s60tools.imaker.internal.model.FileToImage;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    61
import com.nokia.s60tools.imaker.internal.model.ImakerProperties;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    62
import com.nokia.s60tools.imaker.internal.model.iContent.IContentFactory;
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
    63
import com.nokia.s60tools.imaker.internal.model.iContent.IMAGESECTION;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    64
import com.nokia.s60tools.imaker.internal.model.iContent.IbyEntry;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    65
import com.nokia.s60tools.imaker.internal.model.iContent.ImageContent;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    66
import com.nokia.s60tools.imaker.internal.providers.CheckBoxEditingSupport;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    67
import com.nokia.s60tools.imaker.internal.providers.ComboEditingSupport;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    68
import com.nokia.s60tools.imaker.internal.providers.TextEditingSupport;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    69
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    70
public class DebugTab extends CTabItem implements IPropertyViewer {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    71
	public static final String CHECKED_IMAGE 	= "checked";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    72
	public static final String UNCHECKED_IMAGE  = "unchecked";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    73
	public static final String WARNING_IMAGE    = "warning";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    74
	public static final String ERROR_IMAGE      = "error";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    75
	public static final String REL_PATTERN      = ".*epoc32.release.+?(urel).*";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    76
	public static final String DEBUG_PATTERN    = ".*epoc32.release.+?(udeb).*";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    77
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    78
	// For the checkbox images
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    79
	private static ImageRegistry imageRegistry = IMakerPlugin.getDefault().getImageRegistry();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    80
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    81
	private IMakerTabsViewer tabsViewer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    82
	private ProjectManager projectManager;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    83
	private TableViewer tableViewer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    84
	private PreferencesTab mainTab;
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
    85
	private IContentFactory factory;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    86
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    87
	static {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    88
		String iconPath = "icons/"; 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    89
		imageRegistry.put(CHECKED_IMAGE, IMakerPlugin.getImageDescriptor( 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    90
				iconPath + CHECKED_IMAGE + ".gif"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    91
		)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    92
		);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    93
		imageRegistry.put(UNCHECKED_IMAGE, IMakerPlugin.getImageDescriptor( 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    94
				iconPath + UNCHECKED_IMAGE + ".gif"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    95
		)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    96
		);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    97
		imageRegistry.put(WARNING_IMAGE, IMakerPlugin.getImageDescriptor( 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    98
				iconPath + WARNING_IMAGE + ".gif"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
    99
		)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   100
		);	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   101
		imageRegistry.put(ERROR_IMAGE, IMakerPlugin.getImageDescriptor( 
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   102
				iconPath + ERROR_IMAGE + ".gif"
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   103
		)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   104
		);	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   105
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   106
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   107
	public DebugTab(CTabFolder parent, int style, IMakerTabsViewer viewer, PreferencesTab main) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   108
		super(parent, style);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   109
		this.tabsViewer = viewer;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   110
		this.projectManager = tabsViewer.getProjectManager();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   111
		setControl(createControl(parent));
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   112
		this.mainTab = main;
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   113
		this.factory = IContentFactory.eINSTANCE;
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   114
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   115
	
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   116
	private void duplicateSelection() {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   117
		ISelection selection = tableViewer.getSelection();
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   118
		if(selection!=null) {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   119
			IStructuredSelection ss = (IStructuredSelection) selection;
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   120
			IbyEntry item = (IbyEntry) ss.getFirstElement();
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   121
			IbyEntry copy = factory.createIbyEntry();
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   122
			copy.setAction(item.getAction());
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   123
			copy.setEnabled(item.isEnabled());
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   124
			copy.setFile(item.getFile());
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   125
			copy.setTarget(item.getTarget());
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   126
			copy.setLocation(item.getLocation());
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   127
			ImageContent ic = getInput();
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   128
			int index = ic.getEntries().indexOf(item);
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   129
			ic.getEntries().add(index+1, copy);
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   130
			tableViewer.refresh();
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   131
		}
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   132
	}
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   133
	private void deleteSelection() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   134
		ISelection selection = tableViewer.getSelection();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   135
		if(selection!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   136
			IStructuredSelection ss = (IStructuredSelection) selection;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   137
			Object[] objects = ss.toArray();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   138
			for (int i = 0; i < objects.length; i++) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   139
				IbyEntry fe = (IbyEntry) objects[i];
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   140
				ImageContent ic = getInput();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   141
				ic.getEntries().remove(fe);						
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   142
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   143
			tableViewer.refresh();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   144
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   145
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   146
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   147
	private Control createControl(CTabFolder parent) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   148
		Composite top = new Composite(parent,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   149
		top.setLayout(new GridLayout(2,false));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   150
		top.setLayoutData(new GridData(GridData.FILL_BOTH));
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   151
		setHelpForControl(top, ImageFlasherHelpContextIDs.IMAKERDIALOG_CONTENTTAB);
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   152
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   153
		// create table
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   154
		Composite tableComp = getNewComposite(top);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   155
		Table table = new Table(tableComp,SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   156
		GridData gridData = new GridData(GridData.FILL,GridData.FILL,true,true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   157
		gridData.heightHint = 180;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   158
		table.setLayoutData(gridData);
6
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   159
		table.addKeyListener(new KeyListener() {
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   160
			
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   161
			public void keyReleased(KeyEvent e) {
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   162
				if ((e.character == ' ')) {
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   163
					StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   164
					Iterator it = ss.iterator();
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   165
					while (it.hasNext()) {
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   166
						IbyEntry entry = (IbyEntry)it.next();
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   167
						entry.setEnabled(!entry.isEnabled());
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   168
						tableViewer.refresh(entry);						
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   169
					}
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   170
				}
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   171
			}
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   172
			
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   173
			public void keyPressed(KeyEvent e) {}
7f60f3388609 Ticket #1099: As a developer I want to enable/disable selected files so that I don't need to manually select each one separately
haismail <hussein.ismail@nokia.com>
parents: 5
diff changeset
   174
		});
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   175
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   176
		// create controls
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   177
		Composite controls = getNewComposite(top);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   178
		Button button = new Button(controls,SWT.PUSH|SWT.LEFT);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   179
		button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   180
		button.setText(Messages.getString("DebugTab.2"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   181
		button.setToolTipText(Messages.getString("DebugTab.3"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   182
		button.addSelectionListener(new SelectionListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   183
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   184
			public void widgetSelected(SelectionEvent e) {
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   185
				IbyEntry entry = factory.createIbyEntry();
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   186
				ImageContent input = getInput();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   187
				FileToImage file = new FileToImage();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   188
				AddEditFileToTransferDialog dialog= new AddEditFileToTransferDialog(getControl().getShell(), file);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   189
				dialog.setTitle(Messages.getString("FileTransferTab.8"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   190
				if (dialog.open() != Window.OK) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   191
					return;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   192
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   193
				entry.setEnabled(file.getEnabled());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   194
				entry.setFile(file.getHostPath().substring(2));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   195
				entry.setTarget(file.getTargetPath());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   196
				input.getEntries().add(entry);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   197
				tableViewer.refresh();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   198
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   199
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   200
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   201
			public void widgetDefaultSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   202
				widgetSelected(e);
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
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   206
		button = new Button(controls,SWT.PUSH|SWT.LEFT);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   207
		button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   208
		button.setText(Messages.getString("DebugTab.4"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   209
		button.setToolTipText(Messages.getString("DebugTab.5"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   210
		button.addSelectionListener(new SelectionListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   211
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   212
			public void widgetSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   213
				deleteSelection();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   214
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   215
			
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   216
			public void widgetDefaultSelected(SelectionEvent e) {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   217
				widgetSelected(e);
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   218
			}
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   219
		});
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   220
		
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   221
		button = new Button(controls,SWT.PUSH|SWT.LEFT);
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   222
		button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   223
		button.setText(Messages.getString("DebugTab.24"));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   224
		button.setToolTipText(Messages.getString("DebugTab.25"));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   225
		button.addSelectionListener(new SelectionListener() {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   226
			
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   227
			public void widgetSelected(SelectionEvent e) {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   228
				duplicateSelection();
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   229
			}
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   230
			
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   231
			public void widgetDefaultSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   232
				widgetSelected(e);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   233
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   234
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   235
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   236
		button = new Button(controls,SWT.PUSH|SWT.LEFT);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   237
		button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   238
		button.setText(Messages.getString("DebugTab.6"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   239
		button.setToolTipText(Messages.getString("DebugTab.7"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   240
		button.addSelectionListener(new SelectionListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   241
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   242
			public void widgetSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   243
				ImageContent input = getInput();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   244
				if(input!=null) {
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   245
					
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   246
					if (!input.getEntries().isEmpty()) {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   247
						boolean confirm = MessageDialog
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   248
								.openQuestion(
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   249
										getControl().getShell(),
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   250
										"Remove Entries",
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   251
										"Clear the list before adding new entries, if any?");
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   252
						if (confirm) {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   253
							input.getEntries().clear();							
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   254
						}
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   255
					}
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   256
					projectManager.populate(input);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   257
					tableViewer.refresh();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   258
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   259
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   260
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   261
			public void widgetDefaultSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   262
				widgetSelected(e);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   263
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   264
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   265
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   266
		Composite enableButtons = new Composite(top,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   267
		GridLayout layout = new GridLayout(2, false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   268
		layout.marginWidth = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   269
		layout.marginHeight = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   270
		enableButtons.setLayout(layout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   271
		enableButtons.setLayoutData(new GridData());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   272
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   273
		button = new Button(enableButtons,SWT.PUSH|SWT.LEFT);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   274
		button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   275
		button.setText(Messages.getString("DebugTab.8"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   276
		button.setToolTipText(Messages.getString("DebugTab.9"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   277
		button.addSelectionListener(new SelectionListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   278
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   279
			public void widgetSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   280
				ImageContent ic = getInput();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   281
				if(ic!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   282
					for (IbyEntry entry: ic.getEntries()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   283
						entry.setEnabled(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   284
					}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   285
					tableViewer.refresh();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   286
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   287
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   288
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   289
			public void widgetDefaultSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   290
				widgetSelected(e);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   291
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   292
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   293
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   294
		button = new Button(enableButtons,SWT.PUSH|SWT.LEFT);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   295
		button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   296
		button.setText(Messages.getString("DebugTab.10"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   297
		button.setToolTipText(Messages.getString("DebugTab.11"));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   298
		button.addSelectionListener(new SelectionListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   299
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   300
			public void widgetSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   301
				ImageContent ic = getInput();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   302
				if(ic!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   303
					for (IbyEntry entry: ic.getEntries()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   304
						entry.setEnabled(false);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   305
					}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   306
					tableViewer.refresh();
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
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   310
			public void widgetDefaultSelected(SelectionEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   311
				widgetSelected(e);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   312
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   313
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   314
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   315
		tableViewer = new TableViewer(table);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   316
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   317
		tableViewer.getTable().setHeaderVisible(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   318
		tableViewer.getTable().setLinesVisible(true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   319
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   320
		tableViewer.setContentProvider(new DebugContentProvider());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   321
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   322
		createColumns(tableViewer);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   323
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   324
		tableViewer.getTable().addKeyListener(new KeyListener() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   325
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   326
			public void keyReleased(KeyEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   327
				if(e.character == SWT.DEL) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   328
					deleteSelection();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   329
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   330
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   331
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   332
			public void keyPressed(KeyEvent e) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   333
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   334
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   335
		tableViewer.setInput(getDefaultInput());
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   336
		return top;	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   337
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   338
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   339
	private void setHelpForControl(Control container, String id) {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   340
		PlatformUI.getWorkbench().getHelpSystem().setHelp(container, id);
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   341
	}
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   342
	private Object getDefaultInput() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   343
		IContentFactory factory = IContentFactory.eINSTANCE;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   344
		ImageContent ic = factory.createImageContent();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   345
		return ic;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   346
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   347
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   348
	private Composite getNewComposite(Composite top) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   349
		Composite comp = new Composite(top,SWT.NONE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   350
		GridLayout layout = new GridLayout(1, true);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   351
		layout.marginWidth = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   352
		layout.marginHeight = 0;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   353
		comp.setLayout(layout);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   354
		GridData layoutData = new GridData(GridData.FILL_BOTH);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   355
		layoutData.grabExcessHorizontalSpace = true;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   356
		comp.setLayoutData(layoutData);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   357
		return comp;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   358
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   359
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   360
	private void createColumns(TableViewer viewer) {
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   361
		int columnSizes[] = {20,50,130,130,60,60};
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   362
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   363
		TableViewerColumn column = new TableViewerColumn(viewer,SWT.NONE);
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   364
		column.getColumn().setText(Messages.getString("DebugTab.12"));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   365
		column.getColumn().setToolTipText(Messages.getString("DebugTab.13"));
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   366
		column.getColumn().setWidth(columnSizes[0]);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   367
		column.setLabelProvider(new ColumnLabelProvider() {	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   368
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   369
			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   370
			public Image getImage(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   371
				if(isWarning(element)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   372
					return imageRegistry.get(WARNING_IMAGE);					
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   373
				} else if(isError(element)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   374
					return imageRegistry.get(ERROR_IMAGE);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   375
				} else {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   376
					return null;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   377
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   378
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   379
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   380
			private IbyEntry getEntry(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   381
				return (IbyEntry) element;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   382
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   383
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   384
			private boolean isWarning(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   385
				IbyEntry entry = getEntry(element);
2
a91cb670dd8e iMaker plugin updated
haismail <hussein.ismail@nokia.com>
parents: 1
diff changeset
   386
				String location = " "+entry.getLocation().toString().toUpperCase()+" ";
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   387
				String targets[] = mainTab.getSelectedTargets();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   388
				UIConfiguration pr = mainTab.getSelectedProduct();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   389
				for (int i = 0; i < targets.length; i++) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   390
					String t = targets[i];
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   391
					UITarget target = pr.getTarget(t);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   392
					if(target!=null&&target.getSteps()!=null) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   393
						int index = target.getSteps().indexOf(location);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   394
						if(index!=-1) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   395
							return false;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   396
						}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   397
					}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   398
				}
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   399
				if(entry.getLocation()!=IMAGESECTION.ANY) {
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   400
					mainTab.addTarget(entry.getLocation().getName());					
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   401
				}
5
d5efbe6c22e8 Ticket #1245: Update target selection required to avoid yellow warnings on content tab
haismail <hussein.ismail@nokia.com>
parents: 2
diff changeset
   402
				return false;
0
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
			private boolean isError(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   406
				IbyEntry entry = getEntry(element);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   407
				String path = projectManager.getRoot()+entry.getFile();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   408
				File f = new File(path);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   409
				if(!f.exists()) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   410
					String message = Messages.getString("DebugTab.1");
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   411
					entry.setStatusMessage(message.replace("xxx", f.getAbsolutePath()));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   412
					return true;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   413
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   414
				return false;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   415
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   416
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   417
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   418
			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   419
			public String getText(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   420
				if(isWarning(element) || isError(element)) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   421
					return getEntry(element).getStatusMessage();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   422
				}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   423
				return "";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   424
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   425
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   426
		});
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   427
//		column.setEditingSupport(new CheckBoxEditingSupport(viewer, 0));
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   428
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   429
		column = new TableViewerColumn(viewer,SWT.CENTER);
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   430
		column.getColumn().setText(Messages.getString("DebugTab.14"));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   431
		column.getColumn().setToolTipText(Messages.getString("DebugTab.15"));
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   432
		column.getColumn().setWidth(columnSizes[1]);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   433
		column.setLabelProvider( new ColumnLabelProvider() {	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   434
			
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   435
			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   436
			public Image getImage(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   437
				IbyEntry ie = (IbyEntry) element;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   438
				String key = ie.isEnabled() ? CHECKED_IMAGE : UNCHECKED_IMAGE;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   439
				return imageRegistry.get(key);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   440
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   441
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   442
			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   443
			public String getText(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   444
				return "";
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   445
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   446
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   447
		column.setEditingSupport(new CheckBoxEditingSupport(viewer, 1));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   448
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   449
		column = new TableViewerColumn(viewer,SWT.NONE);
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   450
		column.getColumn().setText(Messages.getString("DebugTab.16"));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   451
		column.getColumn().setToolTipText(Messages.getString("DebugTab.17"));
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   452
		column.getColumn().setWidth(columnSizes[2]);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   453
		column.setLabelProvider(new ColumnLabelProvider() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   454
			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   455
			public String getText(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   456
				IbyEntry e = (IbyEntry) element;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   457
				return e.getFile();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   458
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   459
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   460
		column.setEditingSupport(new TextEditingSupport(viewer,2));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   461
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   462
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   463
		column = new TableViewerColumn(viewer,SWT.NONE);
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   464
		column.getColumn().setText(Messages.getString("DebugTab.18"));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   465
		column.getColumn().setToolTipText(Messages.getString("DebugTab.19"));
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   466
		column.getColumn().setWidth(columnSizes[3]);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   467
		column.setLabelProvider(new ColumnLabelProvider() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   468
			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   469
			public String getText(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   470
				IbyEntry e = (IbyEntry) element;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   471
				return e.getTarget();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   472
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   473
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   474
		column.setEditingSupport(new TextEditingSupport(viewer,3));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   475
		
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   476
		column = new TableViewerColumn(viewer,SWT.NONE);
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   477
		column.getColumn().setText(Messages.getString("DebugTab.20"));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   478
		column.getColumn().setToolTipText(Messages.getString("DebugTab.21"));
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   479
		column.getColumn().setWidth(columnSizes[4]);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   480
		column.setLabelProvider(new ColumnLabelProvider() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   481
			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   482
			public String getText(Object element) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   483
				IbyEntry e = (IbyEntry) element;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   484
				return e.getLocation().getLiteral();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   485
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   486
		});
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   487
		column.setEditingSupport(new ComboEditingSupport(viewer,4));
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   488
		
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   489
		column = new TableViewerColumn(viewer,SWT.LEFT);
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   490
		column.getColumn().setText(Messages.getString("DebugTab.22"));
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   491
		column.getColumn().setToolTipText(Messages.getString("DebugTab.23"));
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   492
		column.getColumn().setWidth(columnSizes[5]);
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   493
		column.setLabelProvider( new ColumnLabelProvider() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   494
			@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   495
			public String getText(Object element) {
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   496
				IbyEntry e = (IbyEntry) element;
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   497
				return e.getAction().getLiteral();
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   498
			}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   499
		});
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   500
		column.setEditingSupport(new ComboEditingSupport(viewer,5));		
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   501
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   502
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   503
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   504
	private class DebugContentProvider  implements IStructuredContentProvider {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   505
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   506
		public Object[] getElements(Object inputElement) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   507
			ImageContent ic = (ImageContent) inputElement;
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   508
			return ic.getEntries().toArray();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   509
		}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   510
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   511
		public void dispose() {}
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   512
11
217e69fc5beb iMaker 3.1.0
haismail <hussein.ismail@nokia.com>
parents: 6
diff changeset
   513
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
0
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
	/* (non-Javadoc)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   517
	 * @see com.nokia.s60tools.imaker.internal.viewers.IPropertyViewer#addToProperties(com.nokia.s60tools.imaker.internal.model.ImakerProperties)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   518
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   519
	public void addToProperties(ImakerProperties prop) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   520
		ImageContent input = getInput();
5
d5efbe6c22e8 Ticket #1245: Update target selection required to avoid yellow warnings on content tab
haismail <hussein.ismail@nokia.com>
parents: 2
diff changeset
   521
		List<IbyEntry> ls = new ArrayList<IbyEntry>();
d5efbe6c22e8 Ticket #1245: Update target selection required to avoid yellow warnings on content tab
haismail <hussein.ismail@nokia.com>
parents: 2
diff changeset
   522
		ls.addAll(input.getEntries());
d5efbe6c22e8 Ticket #1245: Update target selection required to avoid yellow warnings on content tab
haismail <hussein.ismail@nokia.com>
parents: 2
diff changeset
   523
		prop.put(IMakerKeyConstants.DEBUGFILES, ls);			
1
7ff23301fe22 iMaker plugin updated:
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
   524
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   525
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   526
	
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   527
	/* (non-Javadoc)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   528
	 * @see com.nokia.s60tools.imaker.internal.viewers.IPropertyViewer#restoreFromProperties(com.nokia.s60tools.imaker.internal.model.ImakerProperties)
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   529
	 */
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   530
	public void restoreFromProperties(ImakerProperties prop) {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   531
		ImageContent input = getInput();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   532
		EList<IbyEntry> entries = input.getEntries();
1
7ff23301fe22 iMaker plugin updated:
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
   533
		entries.clear();
7ff23301fe22 iMaker plugin updated:
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
   534
		Object ents = prop.get(IMakerKeyConstants.DEBUGFILES);
7ff23301fe22 iMaker plugin updated:
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
   535
		if(ents!=null) {
7ff23301fe22 iMaker plugin updated:
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
   536
			List<IbyEntry> ls = (List<IbyEntry>) ents;
7ff23301fe22 iMaker plugin updated:
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
   537
			entries.addAll(ls);
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   538
		}
1
7ff23301fe22 iMaker plugin updated:
haismail <hussein.ismail@nokia.com>
parents: 0
diff changeset
   539
		tableViewer.refresh();
0
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   540
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   541
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   542
	private ImageContent getInput() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   543
		return (ImageContent) tableViewer.getInput();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   544
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   545
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   546
	public void refesh() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   547
		tableViewer.refresh();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   548
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   549
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   550
//	@Override
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   551
	public void clear() {
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   552
		getInput().getEntries().clear();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   553
		refesh();
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   554
	}
61163b28edca initial EPL conversion
dpodwall
parents:
diff changeset
   555
}