Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 12e603146dfdc530d5e6a6b42e18f3b55a21c555 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*******************************************************************************
 * Copyright (c) 2000, 2007 QNX Software Systems and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     QNX Software Systems - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.ui.wizards.conversion;

 
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbench;

import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;

/**
 * ConversionWizard  This wizard provides a method by which the user can
 * change the nature of their projects. This class cannot be implemented.  It
 * is meant to be subclassed, with the subclasses providing the new labels,
 * and pages.
 * 
 * @author Judy N. Green
 * @since Aug 8, 2002
 */
public abstract class ConversionWizard
    extends NewCProjectWizard {

    // Titles and descriptions may be overwritten by subclasses through the accessor methods.
    private static final String WZ_TITLE = "ConversionWizard.title"; //$NON-NLS-1$
    private static final String WZ_DESC = "ConversionWizard.description"; //$NON-NLS-1$
    private static final String PREFIX = "ConversionWizard"; //$NON-NLS-1$

    // Window Title should be overwritten by subclasses
    private static final String WINDOW_TITLE = "ConversionWizard.windowTitle"; //$NON-NLS-1$

    // the wizards main page containing the list of projects that the user may select for conversion.
    protected ConvertProjectWizardPage mainPage;

    /**
     * Conversion Wizard constructor
     */
    public ConversionWizard() {
        this(getWindowTitleResource(), getWzDescriptionResource());
    }

    /**
     * Conversion Wizard constructor
     * 
     * @param title
     * @param desc
     */
    public ConversionWizard(String title, String desc) {
        super(title, desc);
    }

    /* (non-Javadoc)
     * Method declared on IWorkbenchWizard.
     */
    @Override
	public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
        super.init(workbench, currentSelection);
        setWindowTitle(getWindowTitleResource());
    }
    
    /**
     * Method getWindowTitleResource, allows Wizard Title label value to be
     * changed by subclasses
     * 
     * @return String
     */
    protected static String getWindowTitleResource() {

        return CUIPlugin.getResourceString(WINDOW_TITLE);
    }

    /**
     * Method getWzDescriptionResource,  allows Wizard description label value
     * to be changed by subclasses
     * 
     * @return String
     */
    protected static String getWzDescriptionResource() {

        return CUIPlugin.getResourceString(WZ_DESC);
    }
    
    /**
     * Method getWzTitleResource,  allows Wizard description label value
     * to be changed by subclasses
     * 
     * @return String
     */
    protected static String getWzTitleResource() {

        return CUIPlugin.getResourceString(WZ_TITLE);
    }

    /**
     * Method getPrefix,  allows prefix value to be changed by subclasses
     * 
     * @return String
     */
    protected static String getPrefix() {

        return PREFIX;
    }

    /**
     * Method doRun calls the doRunPrologue and mainPage's  doRun method and the
     * doRunEpliogue. Subclasses may overwrite to add further actions
     */
    @Override
	protected void doRun(IProgressMonitor monitor) throws CoreException {
        try{
            mainPage.doRun(monitor, getProjectID(), getBuildSystemId());
        } catch (CoreException ce){
            CUIPlugin.log(ce);
            throw ce;
        } finally{
            doRunEpilogue(monitor);
            monitor.isCanceled();
        }
    }
    /**
     * Return the type of project that it is being converted to
     * The default if a make project
     */
    @Override
	public abstract String getProjectID();

    /**
     * Method addPages allows subclasses to add as many pages as they need. Overwrite
     * to create at least one conversion specific page. <p>
     * 
     * i.e. <br>
     *<pre> 
     *   mainPage = new ConvertToStdMakeProjectWizardPage(getPrefix());
     *   addPage(mainPage);
     *</pre>
     * 
     * @see NewCProjectWizard#addPages
     */
    @Override
	public abstract void addPages();

    /**
     * Required by superclass but with no implementation here
     * 
     * @param monitor 
     */
    @Override
	protected void doRunPrologue(IProgressMonitor monitor) {}

    /**
     * Required by superclass but with no implementation here
     * 
     * @param monitor 
     */
    @Override
	protected void doRunEpilogue(IProgressMonitor monitor) {}
}

Back to the top