plugins/org.symbian.tools.tmw.debug/src/org/symbian/tools/tmw/debug/ui/actions/DebugAction.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 02 Sep 2010 16:31:16 -0700
changeset 485 df4f55e8569e
parent 472 bd9f2d7c64a6
permissions -rw-r--r--
Fixed copyright headers and removed unneeded WRT mentions from TMW code

/**
 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Symbian Foundation - initial contribution.
 * Contributors:
 * Description:
 * Overview:
 * Details:
 * Platforms/Drives/Compatibility:
 * Assumptions/Requirement/Pre-requisites:
 * Failures and causes:
 */
package org.symbian.tools.tmw.debug.ui.actions;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.debug.internal.ui.actions.DebugLastAction;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.symbian.tools.tmw.core.TMWCore;

@SuppressWarnings("restriction")
public class DebugAction extends DebugLastAction {
    @Override
    public void run(IAction action) {
        boolean hasTmwProjects = false;
        IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
        for (IProject project : projects) {
            if (project.isAccessible() && TMWCore.create(project) != null) {
                hasTmwProjects = true;
                break;
            }
        }
        if (hasTmwProjects) {
            super.run(action);
        } else {
            MessageDialog.openInformation(getShell(), "Cannot launch debugger",
                    "There are no open projects in your workspace");
        }
    }
}