EMMA Coverage Report (generated Mon Sep 29 15:05:28 EDT 2008)
[all classes][org.eclipse.ui.actions]

COVERAGE SUMMARY FOR SOURCE FILE [NewProjectAction.java]

nameclass, %method, %block, %line, %
NewProjectAction.java100% (1/1)33%  (1/3)27%  (30/112)30%  (12/40)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NewProjectAction100% (1/1)33%  (1/3)27%  (30/112)30%  (12/40)
NewProjectAction (): void 0%   (0/1)0%   (0/5)0%   (0/2)
run (): void 0%   (0/1)0%   (0/73)0%   (0/25)
NewProjectAction (IWorkbenchWindow): void 100% (1/1)88%  (30/34)92%  (12/13)

1/*******************************************************************************
2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *     IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.ui.actions;
12 
13import org.eclipse.jface.action.Action;
14import org.eclipse.jface.dialogs.IDialogSettings;
15import org.eclipse.jface.viewers.ISelection;
16import org.eclipse.jface.viewers.IStructuredSelection;
17import org.eclipse.jface.viewers.StructuredSelection;
18import org.eclipse.jface.wizard.WizardDialog;
19import org.eclipse.ui.ISharedImages;
20import org.eclipse.ui.IWorkbench;
21import org.eclipse.ui.IWorkbenchWindow;
22import org.eclipse.ui.PlatformUI;
23import org.eclipse.ui.internal.dialogs.NewWizard;
24import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
25import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
26import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
27 
28/**
29 * Standard action for launching the create project selection
30 * wizard.
31 * <p>
32 * This class may be instantiated; it is not intended to be subclassed.
33 * </p>
34 * @noextend This class is not intended to be subclassed by clients.
35 */
36public class NewProjectAction extends Action {
37 
38    /**
39     * The wizard dialog width
40     */
41    private static final int SIZING_WIZARD_WIDTH = 500;
42 
43    /**
44     * The wizard dialog height
45     */
46    private static final int SIZING_WIZARD_HEIGHT = 500;
47 
48    /**
49     * The workbench window this action will run in
50     */
51    private IWorkbenchWindow window;
52 
53    /**
54     * This default constructor allows the the action to be called from the welcome page.
55     */
56    public NewProjectAction() {
57        this(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
58    }
59 
60    /**
61     * Creates a new action for launching the new project
62     * selection wizard.
63     *
64     * @param window the workbench window to query the current
65     *                 selection and shell for opening the wizard.
66     */
67    public NewProjectAction(IWorkbenchWindow window) {
68        super(IDEWorkbenchMessages.NewProjectAction_text);
69        if (window == null) {
70            throw new IllegalArgumentException();
71        }
72        this.window = window;
73        ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
74        setImageDescriptor(images
75                .getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
76        setDisabledImageDescriptor(images
77                .getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD_DISABLED));
78        setToolTipText(IDEWorkbenchMessages.NewProjectAction_toolTip);
79        PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
80                                org.eclipse.ui.internal.IWorkbenchHelpContextIds.NEW_ACTION);
81    }
82 
83    /* (non-Javadoc)
84     * Method declared on IAction.
85     */
86    public void run() {
87        // Create wizard selection wizard.
88        IWorkbench workbench = PlatformUI.getWorkbench();
89        NewWizard wizard = new NewWizard();
90        wizard.setProjectsOnly(true);
91        ISelection selection = window.getSelectionService().getSelection();
92        IStructuredSelection selectionToPass = StructuredSelection.EMPTY;
93        if (selection instanceof IStructuredSelection) {
94                        selectionToPass = (IStructuredSelection) selection;
95                }
96        wizard.init(workbench, selectionToPass);
97        IDialogSettings workbenchSettings = IDEWorkbenchPlugin.getDefault()
98                .getDialogSettings();
99        IDialogSettings wizardSettings = workbenchSettings
100                .getSection("NewWizardAction");//$NON-NLS-1$
101        if (wizardSettings == null) {
102                        wizardSettings = workbenchSettings.addNewSection("NewWizardAction");//$NON-NLS-1$
103                }
104        wizard.setDialogSettings(wizardSettings);
105        wizard.setForcePreviousAndNextButtons(true);
106 
107        // Create wizard dialog.
108        WizardDialog dialog = new WizardDialog(null, wizard);
109        dialog.create();
110        dialog.getShell().setSize(
111                Math.max(SIZING_WIZARD_WIDTH, dialog.getShell().getSize().x),
112                SIZING_WIZARD_HEIGHT);
113        PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(),
114                IIDEHelpContextIds.NEW_PROJECT_WIZARD);
115 
116        // Open wizard.
117        dialog.open();
118    }
119}

[all classes][org.eclipse.ui.actions]
EMMA 2.0.5312 EclEmma Fix 1 (C) Vladimir Roubtsov