plugins/org.symbian.tools.tmw.debug/src/org/symbian/tools/tmw/debug/ui/launch/WidgetBasicTab.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Mon, 23 Aug 2010 10:30:05 -0700
changeset 472 bd9f2d7c64a6
parent 471 06589bf52fa7
child 484 f5df819c1852
permissions -rw-r--r--
Debugger is now Symbian-independant
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/*******************************************************************************
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies).
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 *
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * Contributors:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * Overview:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 * Details:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
 * Failures and causes:
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
 *******************************************************************************/
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
package org.symbian.tools.tmw.debug.ui.launch;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import java.util.LinkedList;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
import org.eclipse.core.resources.IProject;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
import org.eclipse.core.resources.IResource;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.core.resources.ResourcesPlugin;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
import org.eclipse.core.runtime.CoreException;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.debug.core.ILaunchConfiguration;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
import org.eclipse.jface.viewers.ArrayContentProvider;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
import org.eclipse.jface.viewers.ComboViewer;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
import org.eclipse.jface.viewers.ISelection;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
import org.eclipse.jface.viewers.ISelectionChangedListener;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
import org.eclipse.jface.viewers.IStructuredSelection;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
import org.eclipse.jface.viewers.SelectionChangedEvent;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
import org.eclipse.jface.viewers.StructuredSelection;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
import org.eclipse.swt.SWT;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
import org.eclipse.swt.graphics.Image;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
import org.eclipse.swt.layout.FormAttachment;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
import org.eclipse.swt.layout.FormData;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
import org.eclipse.swt.layout.FormLayout;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
import org.eclipse.swt.widgets.Composite;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
import org.eclipse.swt.widgets.Label;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
import org.eclipse.ui.model.WorkbenchLabelProvider;
472
bd9f2d7c64a6 Debugger is now Symbian-independant
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 471
diff changeset
    45
import org.symbian.tools.tmw.core.TMWCore;
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
import org.symbian.tools.tmw.debug.internal.Activator;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
import org.symbian.tools.tmw.debug.internal.ChromeDebugUtils;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    48
import org.symbian.tools.tmw.debug.internal.IConstants;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
import org.symbian.tools.tmw.debug.internal.Images;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    51
public class WidgetBasicTab extends AbstractLaunchConfigurationTab {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
	private ComboViewer project;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    53
	private boolean canSave;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    54
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    55
	@Override
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    56
	public Image getImage() {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    57
		return Images.getWrtIconImage();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    58
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    59
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    60
	public void createControl(Composite parent) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    61
		Composite root = new Composite(parent, SWT.NONE);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    62
		FormLayout layout = new FormLayout();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    63
		layout.marginWidth = 5;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    64
		layout.marginHeight = 5;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    65
		layout.spacing = 5;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    66
		root.setLayout(layout);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    67
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    68
		Label label = new Label(root, SWT.NONE);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    69
		label.setText("WRT Widget Project:");
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    70
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    71
		project = new ComboViewer(root, SWT.READ_ONLY);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    72
		project.setContentProvider(new ArrayContentProvider());
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    73
		project.setLabelProvider(new WorkbenchLabelProvider());
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    74
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    75
		FormData formData = new FormData();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    76
		formData.left = new FormAttachment(label);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    77
		formData.right = new FormAttachment(100, 0);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    78
		project.getControl().setLayoutData(formData);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    79
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    80
		project.setInput(getWidgetProjects());
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    81
		project.addSelectionChangedListener(new ISelectionChangedListener() {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    82
			public void selectionChanged(SelectionChangedEvent event) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    83
				setDirty(true);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    84
				validate();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    85
			}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    86
		});
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    87
		setControl(root);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    88
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    89
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    90
	private IProject[] getWidgetProjects() {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    91
		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    92
				.getProjects();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    93
		LinkedList<IProject> filtered = new LinkedList<IProject>();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    94
		for (IProject p : projects) {
472
bd9f2d7c64a6 Debugger is now Symbian-independant
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 471
diff changeset
    95
            if (TMWCore.create(p) != null) {
471
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    96
				filtered.add(p);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    97
			}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    98
		}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    99
		return filtered.toArray(new IProject[filtered.size()]);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   100
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   101
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   102
	public String getName() {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   103
		return "WRT Widget";
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   104
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   105
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   106
	public void initializeFrom(ILaunchConfiguration configuration) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   107
		project.setSelection(getSelectedProject(configuration), true);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   108
		validate();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   109
		setErrorMessage(null);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   110
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   111
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   112
	private ISelection getSelectedProject(ILaunchConfiguration configuration) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   113
		ISelection selected = StructuredSelection.EMPTY;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   114
		try {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   115
			String projectName = configuration.getAttribute(
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   116
					IConstants.PROP_PROJECT_NAME, (String) null);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   117
			if (projectName != null) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   118
				IProject p = ResourcesPlugin.getWorkspace().getRoot()
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   119
						.getProject(projectName);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   120
				if (p.isAccessible()) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   121
					selected = new StructuredSelection(p);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   122
				}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   123
			}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   124
		} catch (CoreException e) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   125
			Activator.log(e);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   126
		}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   127
		return selected;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   128
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   129
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   130
	@Override
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   131
	public boolean canSave() {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   132
		return canSave;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   133
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   134
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   135
	private void validate() {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   136
		String error = null;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   137
		if (getWidgetProjects().length == 0) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   138
			error = "No WRT widget projects found in the workspace";
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   139
		} else if (project.getSelection().isEmpty()) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   140
			error = "Select WRT widget project to debug";
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   141
		} else if (ChromeDebugUtils.getChromeExecutible() == null) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   142
			error = "No Chrome browser configured in the preferences";
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   143
		}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   144
		canSave = error == null;
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   145
		setErrorMessage(error);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   146
		getLaunchConfigurationDialog().updateButtons();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   147
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   148
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   149
	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   150
		ISelection selection = project.getSelection();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   151
		if (selection.isEmpty()) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   152
			setDefaults(configuration);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   153
		} else {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   154
			IProject p = (IProject) ((IStructuredSelection) selection)
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   155
					.getFirstElement();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   156
			configuration.setAttribute(IConstants.PROP_PROJECT_NAME, p
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   157
					.getName());
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   158
			configuration.setMappedResources(new IResource[] { p });
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   159
		}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   160
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   161
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   162
	public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   163
		configuration.removeAttribute(IConstants.PROP_PROJECT_NAME);
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   164
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   165
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   166
	@Override
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   167
	public boolean isValid(ILaunchConfiguration launchConfig) {
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   168
		return !getSelectedProject(launchConfig).isEmpty();
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   169
	}
06589bf52fa7 Refactoring and restructuring the repository
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   170
}