Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d2d5a24554ae7a5c62b1700f6157e648b093c660 (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
/*******************************************************************************
 * Copyright (c) 2002, 2015 IBM Corporation 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:
 * IBM Rational Software - Initial API and implementation
 * Red Hat Inc. - Fix Bug 406711
 *******************************************************************************/
package org.eclipse.cdt.internal.autotools.ui.wizards;

import java.util.Iterator;
import java.util.List;

import org.eclipse.cdt.internal.autotools.ui.ErrorParserBlock;
import org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderUIPlugin;
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
import org.eclipse.cdt.ui.newui.CDTHelpContextIds;
import org.eclipse.cdt.ui.wizards.NewCProjectWizardOptionPage;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.ui.PlatformUI;


@SuppressWarnings("deprecation")
public class NewAutotoolsProjectOptionPage extends NewCProjectWizardOptionPage {
	
	public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.projectOptionsPage"; //$NON-NLS-1$
	
	public static class ManagedWizardOptionBlock extends ManagedProjectOptionBlock {
		
		NewAutotoolsProjectOptionPage parent;
		

		public ManagedWizardOptionBlock(NewAutotoolsProjectOptionPage parentPage) {
			super(parentPage);
			parent = parentPage;
		}

		public static class AutotoolsReferenceBlock extends ReferenceBlock {
			AutotoolsReferenceBlock() {
				super();
			}
			
			@Override
			public void performApply(IProgressMonitor monitor) {
				try {
					super.performApply(monitor);
				} catch (RuntimeException e) {
					// TODO: Fix ReferenceBlock not to generate NullPointerException
					//       when no projects are referenced
				}
			}
		}
		public void updateProjectTypeProperties() {
		}

		@Override
		protected void addTabs() {
			addTab(new AutotoolsReferenceBlock());
			// Bug 406711 - Remove the IndexerBlock as this causes an exception to occur
			//             because the project handle isn't set up.  It is not needed.
		}
		
		public void setupHelpContextIds(){
			List<ICOptionPage> pages = getOptionPages();
			
			Iterator<ICOptionPage> iter = pages.iterator();
			for( int i = 0; i < 3 && iter.hasNext(); i++ ) {
				ICOptionPage page = iter.next();
				
				String id = null;
				if (page instanceof ReferenceBlock) {
					id = CDTHelpContextIds.MAN_PROJ_WIZ_PROJECTS_TAB;
				} else if (page instanceof ErrorParserBlock) {
					id = CDTHelpContextIds.MAN_PROJ_WIZ_ERRORPARSERS_TAB;
				}
				PlatformUI.getWorkbench().getHelpSystem().setHelp(page.getControl(), id);
			}
		}
	}
	
	protected ManagedWizardOptionBlock optionBlock;

	/**
	 * @param pageName
	 */
	public NewAutotoolsProjectOptionPage(String pageName) {
		super(pageName);
		optionBlock = new ManagedWizardOptionBlock(this);
	}

	@Override
	protected TabFolderOptionBlock createOptionBlock() {
		return optionBlock;
	}

	@Override
	public IProject getProject() {
		if (getWizard() instanceof ConvertToAutotoolsProjectWizard)
			return ((ConvertToAutotoolsProjectWizard)getWizard()).getProject();
		return null;
	}

	@Override
	public Preferences getPreferences() {
		return ManagedBuilderUIPlugin.getDefault().getPluginPreferences();
	}
	
	public void updateProjectTypeProperties() {
		//  Update the error parser list
		optionBlock.updateProjectTypeProperties();
	}
	
	public void setupHelpContextIds(){
		optionBlock.setupHelpContextIds();
	}
	
	@Override
	public IWizardPage getNextPage()
	{
		return MBSCustomPageManager.getNextPage(PAGE_ID); // get first custom page, if any
	}
	
}

Back to the top