Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 283402 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-2 / +133 lines)
Lines 100-107 Link Here
100
         point="org.eclipse.cdt.managedbuilder.ui.newWizardPages">
100
         point="org.eclipse.cdt.managedbuilder.ui.newWizardPages">
101
      <wizardPage
101
      <wizardPage
102
            ID="org.eclipse.ptp.rdt.ui.serviceModelWizardPage"
102
            ID="org.eclipse.ptp.rdt.ui.serviceModelWizardPage"
103
            operationClass="org.eclipse.ptp.rdt.ui.wizards.ServiceModelWizardPageOperation"
103
            operationClass="org.eclipse.ptp.rdt.ui.newwizards.ServiceModelWizardPageOperation"
104
            pageClass="org.eclipse.ptp.rdt.ui.wizards.ServiceModelWizardPage">
104
            pageClass="org.eclipse.ptp.rdt.ui.newwizards.ServiceModelWizardPage">
105
         <nature
105
         <nature
106
               natureID="org.eclipse.ptp.rdt.core.remoteNature">
106
               natureID="org.eclipse.ptp.rdt.core.remoteNature">
107
         </nature>
107
         </nature>
Lines 116-121 Link Here
116
      <wizard
116
      <wizard
117
            canFinishEarly="false"
117
            canFinishEarly="false"
118
            category="org.eclipse.ptp.rdt.ui.wizardCategory.Remote"
118
            category="org.eclipse.ptp.rdt.ui.wizardCategory.Remote"
119
            class="org.eclipse.ptp.rdt.ui.newwizards.NewRemoteProjectWizard"
120
            hasPages="true"
121
            icon="icons/etool16/newremote_c_proj.gif"
122
            id="org.eclipse.ptp.rdt.ui.newRemoteProjectWizard2"
123
            name="Remote Project"
124
            project="true">
125
      </wizard>
126
      <wizard
127
            canFinishEarly="false"
128
            category="org.eclipse.ptp.rdt.ui.wizardCategory.Remote"
119
            class="org.eclipse.ptp.rdt.ui.wizards.NewRemoteCppProjectWizard"
129
            class="org.eclipse.ptp.rdt.ui.wizards.NewRemoteCppProjectWizard"
120
            hasPages="true"
130
            hasPages="true"
121
            icon="icons/etool16/newremote_c_proj.gif"
131
            icon="icons/etool16/newremote_c_proj.gif"
Lines 398-402 Link Here
398
           helpId="cdt_u_prop_build_environment"
408
           helpId="cdt_u_prop_build_environment"
399
           parent="org.eclipse.cdt.rdt.ui.properties.Page_Environment"/>
409
           parent="org.eclipse.cdt.rdt.ui.properties.Page_Environment"/>
400
   </extension>
410
   </extension>
411
   <extension
412
         id="org.eclipse.ptp.rdt.core.remoteNature"
413
         name="RDT Remote Project Nature"
414
         point="org.eclipse.core.resources.natures">
415
      <runtime>
416
         <run
417
               class="org.eclipse.ptp.rdt.core.resources.RemoteNature">
418
         </run>
419
      </runtime>
420
   </extension>
421
   <extension
422
		 id="org.eclipse.ptp.rdt.ui.RemoteCIndexServiceProvider"
423
		 name="RDT Remote C/C++ Indexing Service"
424
		 point="org.eclipse.ptp.services.core.providers">
425
      <provider
426
            class="org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteCIndexServiceProvider"
427
            id="org.eclipse.ptp.rdt.ui.RemoteCIndexServiceProvider"
428
            name="%RemoteCIndexingService.name"
429
            serviceId="org.eclipse.ptp.rdt.core.CIndexingService"
430
            priority="1">
431
      </provider>
432
      <provider
433
            class="org.eclipse.ptp.rdt.ui.newserviceproviders.LocalCIndexServiceProvider"
434
            id="org.eclipse.ptp.rdt.ui.LocalCIndexServiceProvider"
435
            name="%LocalCIndexingService.name"
436
            serviceId="org.eclipse.ptp.rdt.core.CIndexingService"
437
            priority="100">
438
      </provider>
439
   </extension>
440
   <extension
441
         point="org.eclipse.ptp.services.core.providers">
442
      <provider
443
            class="org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteBuildServiceProvider"
444
            id="org.eclipse.ptp.rdt.ui.RemoteBuildServiceProvider"
445
            name="%RemoteBuildService.name"
446
            serviceId="org.eclipse.ptp.rdt.core.BuildService"
447
            priority="1">
448
      </provider>
449
      <provider
450
	        class="org.eclipse.ptp.rdt.ui.newserviceproviders.LocalBuildServiceProvider"
451
	        id="org.eclipse.ptp.rdt.ui.LocalBuildServiceProvider"
452
	        name="%LocalBuildService.name"
453
	        serviceId="org.eclipse.ptp.rdt.core.BuildService"
454
	        priority="100">
455
      </provider>
456
   </extension>
457
   <extension
458
         point="org.eclipse.ptp.services.core.providers">
459
      <provider
460
            class="org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteProjectServiceProvider"
461
            id="org.eclipse.ptp.rdt.ui.RemoteProjectLocationProvider"
462
            name="%RemoteProjectLocationProvider.name"
463
            priority="1"
464
            serviceId="org.eclipse.ptp.rdt.core.ProjectLocationService">
465
      </provider>
466
      <provider
467
            class="org.eclipse.ptp.rdt.ui.newserviceproviders.LocalProjectServiceProvider"
468
            id="org.eclipse.ptp.rdt.ui.LocalProjectLocationProvider"
469
            name="%LocalProjectLocationProvider.name"
470
            priority="100"
471
            serviceId="org.eclipse.ptp.rdt.core.ProjectLocationService">
472
      </provider>
473
   </extension>
474
   <extension
475
         point="org.eclipse.ptp.services.ui.providerContributors">
476
      <providerContributor
477
            class="org.eclipse.ptp.rdt.ui.newwizards.RemoteServicesServiceProviderConfigurer"
478
            id="org.eclipse.ptp.rdt.ui.RemoteBuildServiceProvider">
479
      </providerContributor>
480
   </extension>
481
   <extension
482
         point="org.eclipse.ptp.services.ui.providerContributors">
483
      <providerContributor
484
            class="org.eclipse.ptp.rdt.ui.newwizards.RemoteCIndexServiceProviderConfigurer"
485
            id="org.eclipse.ptp.rdt.ui.RemoteCIndexServiceProvider">
486
      </providerContributor>
487
   </extension>
488
   <extension
489
         point="org.eclipse.ptp.services.ui.providerContributors">
490
      <providerContributor
491
            class="org.eclipse.ptp.rdt.ui.newwizards.RemoteProjectLocationContributor"
492
            id="org.eclipse.ptp.rdt.ui.RemoteProjectLocationProvider">
493
      </providerContributor>
494
   </extension>
495
   <extension
496
         point="org.eclipse.ptp.services.ui.serviceContributors">
497
      <serviceContributor
498
            class="org.eclipse.ptp.rdt.ui.newwizards.ProjectLocationServiceContributor"
499
            id="org.eclipse.ptp.rdt.core.ProjectLocationService">
500
      </serviceContributor>
501
   </extension>
502
   <extension
503
         point="org.eclipse.ptp.services.ui.serviceContributors">
504
      <serviceContributor
505
            class="org.eclipse.ptp.rdt.ui.newwizards.BuildServiceContributor"
506
            id="org.eclipse.ptp.rdt.core.BuildService">
507
      </serviceContributor>
508
   </extension>
509
   <extension
510
         point="org.eclipse.ptp.services.ui.serviceContributors">
511
      <serviceContributor
512
            class="org.eclipse.ptp.rdt.ui.newwizards.CIndexingServiceContributor"
513
            id="org.eclipse.ptp.rdt.core.CIndexingService">
514
      </serviceContributor>
515
   </extension>
516
   <extension
517
         point="org.eclipse.ptp.services.ui.wizardExtensions">
518
      <wizardExtension
519
            class="org.eclipse.ptp.rdt.ui.newwizards.NewHPCProjectWizard">
520
      </wizardExtension>
521
   </extension>
522
   <extension
523
         point="org.eclipse.ui.navigator.navigatorContent">
524
      <commonWizard
525
            associatedExtensionId="org.eclipse.cdt.ui.navigator.content"
526
            menuGroupId="org.eclipse.cdt.ui.newProject"
527
            type="new"
528
            wizardId="org.eclipse.ptp.rdt.ui.newRemoteProjectWizard2">
529
         <enablement></enablement>
530
      </commonWizard>
531
   </extension>
401
   
532
   
402
</plugin>
533
</plugin>
(-)plugin.properties (+6 lines)
Lines 32-37 Link Here
32
NullBuildService.name=Null Build Service
32
NullBuildService.name=Null Build Service
33
RDTRemoteCIndexingService.name=RDT Remote C/C++ Indexing Service
33
RDTRemoteCIndexingService.name=RDT Remote C/C++ Indexing Service
34
RDTRemoteBuildService.name=RDT Remote Build Service
34
RDTRemoteBuildService.name=RDT Remote Build Service
35
LocalCIndexingService.name=Local-only C/C++ Indexing Service
36
LocalBuildService.name=Local-only Build Service
37
RemoteCIndexingService.name=Remote C/C++ Indexing Service
38
RemoteBuildService.name=Remote Build Service
39
LocalProjectLocationProvider.name=Local-only Project Location
40
RemoteProjectLocationProvider.name=Remote Project Location
35
RemoteEnvironment=Remote Environment
41
RemoteEnvironment=Remote Environment
36
page.remote = Remote Development
42
page.remote = Remote Development
37
Environment = Environment
43
Environment = Environment
(-)META-INF/MANIFEST.MF (-1 / +3 lines)
Lines 34-40 Link Here
34
 org.eclipse.ptp.remote.core;bundle-version="2.0.1",
34
 org.eclipse.ptp.remote.core;bundle-version="2.0.1",
35
 org.eclipse.ptp.remote.ui;bundle-version="2.0.0",
35
 org.eclipse.ptp.remote.ui;bundle-version="2.0.0",
36
 org.eclipse.ui.console;bundle-version="3.3.0",
36
 org.eclipse.ui.console;bundle-version="3.3.0",
37
 org.eclipse.dstore.extra;bundle-version="2.1.100"
37
 org.eclipse.dstore.extra;bundle-version="2.1.100",
38
 org.eclipse.ptp.services.core;bundle-version="1.0.0",
39
 org.eclipse.ptp.services.ui;bundle-version="1.0.0"
38
Bundle-Localization: plugin
40
Bundle-Localization: plugin
39
Export-Package: org.eclipse.ptp.internal.rdt.ui,
41
Export-Package: org.eclipse.ptp.internal.rdt.ui,
40
 org.eclipse.ptp.internal.rdt.ui.actions,
42
 org.eclipse.ptp.internal.rdt.ui.actions,
(-)src/org/eclipse/ptp/rdt/ui/newwizards/ServiceModelWizardPageOperation.java (+67 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import java.lang.reflect.InvocationTargetException;
14
15
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
16
import org.eclipse.cdt.ui.wizards.ICDTCommonProjectWizard;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.runtime.IProgressMonitor;
19
import org.eclipse.core.runtime.SubProgressMonitor;
20
import org.eclipse.jface.operation.IRunnableWithProgress;
21
import org.eclipse.jface.wizard.IWizard;
22
import org.eclipse.ptp.services.core.IServiceConfiguration;
23
24
/**
25
 * An operation which handles configuring the remote portions of the Remote C/C++ Project
26
 * when the project is actually being created.
27
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
28
 * part of a work in progress. There is no guarantee that this API will work or
29
 * that it will remain the same. Please do not use this API without consulting
30
 * with the RDT team.
31
 * 
32
 * @author crecoskie
33
 *
34
 */
35
public class ServiceModelWizardPageOperation implements IRunnableWithProgress {
36
37
	/**
38
	 * 
39
	 */
40
	public ServiceModelWizardPageOperation() {
41
		// TODO Auto-generated constructor stub
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
46
	 */
47
	@SuppressWarnings("unchecked")
48
	public void run(IProgressMonitor monitor) throws InvocationTargetException,
49
			InterruptedException {
50
		
51
		monitor.beginTask("configure model services", 100); //$NON-NLS-1$
52
	
53
		IWizard wizard = MBSCustomPageManager.getPageData(ServiceModelWizardPage.SERVICE_MODEL_WIZARD_PAGE_ID).getWizardPage().getWizard();
54
		if(wizard instanceof ICDTCommonProjectWizard) {
55
			IProject project = ((ICDTCommonProjectWizard) wizard).getLastProject();
56
		
57
			IServiceConfiguration config = (IServiceConfiguration)MBSCustomPageManager.getPageProperty(
58
					ServiceModelWizardPage.SERVICE_MODEL_WIZARD_PAGE_ID,
59
					ServiceModelWizardPage.SERVICE_CONFIGURATION_PROPERTY);
60
		
61
			
62
			ConfigureRemoteServices.configure(project, config, new SubProgressMonitor(monitor,90));
63
			monitor.worked(10);
64
		}
65
		monitor.done();
66
	}
67
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/ProjectLocationServiceWizardPage.java (+59 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.ptp.services.core.IService;
14
import org.eclipse.ptp.services.ui.wizards.ServiceConfigurationWizardPage;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Label;
20
21
/**
22
 * Allows the user to select a remote or local project configuration.
23
 * 
24
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
25
 * part of a work in progress. There is no guarantee that this API will work or
26
 * that it will remain the same. Please do not use this API without consulting
27
 * with the RDT team.
28
 * 
29
 *
30
 */
31
public class ProjectLocationServiceWizardPage extends ServiceConfigurationWizardPage {
32
	public ProjectLocationServiceWizardPage(IService service, String pageName) {
33
		super(service, pageName);
34
		setTitle(pageName);
35
		setDescription("This page allows you to set the location of your project source files."); //$NON-NLS-1$
36
	}
37
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.ptp.services.ui.wizards.ServiceConfigurationWizardPage#createControl(org.eclipse.swt.widgets.Composite)
40
	 */
41
	@Override
42
	public void createControl(Composite parent) {
43
        Composite container = new Composite(parent, SWT.NONE);
44
45
        GridLayout layout = new GridLayout();
46
        layout.numColumns = 1;
47
        container.setLayout(layout);
48
49
        Label label = new Label(container, SWT.LEFT);
50
        label.setText("Choose a provider that most closely matches where your project will be located."); //$NON-NLS-1$
51
        GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
52
        label.setLayoutData(data);
53
        
54
		super.createControl(container);
55
		
56
		setControl(container);
57
	}
58
	
59
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteCommonProjectWizard.java (+422 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2002, 2008 Rational Software 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 Rational Software - Initial API and implementation
10
 * Intel corp - rework for New Project Model
11
 *******************************************************************************/
12
package org.eclipse.ptp.rdt.ui.newwizards;
13
14
15
import java.lang.reflect.InvocationTargetException;
16
import java.net.URI;
17
import java.util.ArrayList;
18
import java.util.Arrays;
19
import java.util.List;
20
21
import org.eclipse.cdt.core.CCorePlugin;
22
import org.eclipse.cdt.core.model.CoreModel;
23
import org.eclipse.cdt.core.model.ILanguage;
24
import org.eclipse.cdt.core.model.LanguageManager;
25
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
26
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
27
import org.eclipse.cdt.ui.CUIPlugin;
28
import org.eclipse.cdt.ui.newui.UIMessages;
29
import org.eclipse.cdt.ui.wizards.CWizardHandler;
30
import org.eclipse.cdt.ui.wizards.ICDTCommonProjectWizard;
31
import org.eclipse.cdt.ui.wizards.IWizardWithMemory;
32
import org.eclipse.core.filesystem.EFS;
33
import org.eclipse.core.filesystem.IFileInfo;
34
import org.eclipse.core.filesystem.IFileStore;
35
import org.eclipse.core.resources.IProject;
36
import org.eclipse.core.resources.IProjectDescription;
37
import org.eclipse.core.resources.IResource;
38
import org.eclipse.core.resources.IWorkspace;
39
import org.eclipse.core.resources.IWorkspaceRoot;
40
import org.eclipse.core.resources.IWorkspaceRunnable;
41
import org.eclipse.core.resources.ResourcesPlugin;
42
import org.eclipse.core.runtime.CoreException;
43
import org.eclipse.core.runtime.IConfigurationElement;
44
import org.eclipse.core.runtime.IExecutableExtension;
45
import org.eclipse.core.runtime.IProgressMonitor;
46
import org.eclipse.core.runtime.NullProgressMonitor;
47
import org.eclipse.core.runtime.Platform;
48
import org.eclipse.core.runtime.SubProgressMonitor;
49
import org.eclipse.core.runtime.content.IContentType;
50
import org.eclipse.core.runtime.content.IContentTypeManager;
51
import org.eclipse.jface.dialogs.MessageDialog;
52
import org.eclipse.jface.operation.IRunnableWithProgress;
53
import org.eclipse.ptp.rdt.services.core.ServiceModelManager;
54
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
55
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
56
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
57
58
public abstract class RemoteCommonProjectWizard extends BasicNewResourceWizard 
59
implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
60
{
61
	private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
62
	private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$
63
	private static final String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
64
	private static final String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
65
	private static final String[] EMPTY_ARR = new String[0]; 
66
	
67
	protected IConfigurationElement fConfigElement;
68
	protected RemoteMainWizardPage fMainPage;
69
	
70
	protected IProject newProject;
71
	private String wz_title;
72
	private String wz_desc;
73
	
74
	private boolean existingPath = false;
75
	private String lastProjectName = null;
76
	private URI lastProjectLocation = null;
77
	private CWizardHandler savedHandler = null;
78
	
79
	private ServiceModelManager manager = ServiceModelManager.getInstance();
80
81
	public RemoteCommonProjectWizard() {
82
		this(UIMessages.getString("NewModelProjectWizard.0"),UIMessages.getString("NewModelProjectWizard.1")); //$NON-NLS-1$ //$NON-NLS-2$
83
	}
84
85
	public RemoteCommonProjectWizard(String title, String desc) {
86
		super();
87
		setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
88
		setNeedsProgressMonitor(true);
89
		setForcePreviousAndNextButtons(true);
90
		setWindowTitle(title);
91
		wz_title = title;
92
		wz_desc = desc;
93
	}
94
	
95
	@Override
96
	public void addPages() {
97
		fMainPage= new RemoteMainWizardPage(CUIPlugin.getResourceString(PREFIX));
98
		fMainPage.setTitle(wz_title);
99
		fMainPage.setDescription(wz_desc);
100
		addPage(fMainPage);
101
	}
102
103
	/**
104
	 * @return true if user has changed settings since project creation
105
	 */
106
	private boolean isChanged() {
107
		if (savedHandler != fMainPage.h_selected)
108
			return true;
109
110
		if (!fMainPage.getProjectName().equals(lastProjectName))
111
			return true;
112
			
113
		URI projectLocation = fMainPage.getProjectLocation();
114
		if (projectLocation == null) {
115
			if (lastProjectLocation != null)
116
				return true;
117
		} else if (!projectLocation.equals(lastProjectLocation))
118
			return true;
119
		
120
		return savedHandler.isChanged(); 
121
	}
122
123
	public IProject getProject(boolean defaults) {
124
		return getProject(defaults, true);
125
	}
126
127
	public IProject getProject(boolean defaults, boolean onFinish) {
128
		if (newProject != null && isChanged()) 
129
			clearProject(); 
130
		if (newProject == null)	{
131
            existingPath = false;
132
		  	try {
133
		  		IFileStore fs;
134
				URI p = fMainPage.getProjectLocation();
135
			  	if (p == null) { 
136
			  		fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
137
				    fs = fs.getChild(fMainPage.getProjectName());
138
			  	} else
139
			  		fs = EFS.getStore(p);
140
		  		IFileInfo f = fs.fetchInfo();
141
		  		if (f.exists() && f.isDirectory()) {
142
		  			if (fs.getChild(".project").fetchInfo().exists()) { //$NON-NLS-1$
143
	                	if (!
144
	                		MessageDialog.openConfirm(getShell(), 
145
	        				UIMessages.getString("CDTCommonProjectWizard.0"),  //$NON-NLS-1$
146
							UIMessages.getString("CDTCommonProjectWizard.1")) //$NON-NLS-1$
147
							)
148
	                		return null;
149
	                }
150
	                existingPath = true;
151
		  		}
152
        	} catch (CoreException e) {
153
        		CUIPlugin.log(e.getStatus());
154
        	}
155
			savedHandler = fMainPage.h_selected;
156
			savedHandler.saveState();
157
			lastProjectName = fMainPage.getProjectName();
158
			lastProjectLocation = fMainPage.getProjectLocation();
159
			// start creation process
160
			invokeRunnable(getRunnable(defaults, onFinish)); 
161
		} 
162
		return newProject;
163
	}
164
165
	/**
166
	 * Remove created project either after error
167
	 * or if user returned back from config page. 
168
	 */
169
	private void clearProject() {
170
		if (lastProjectName == null) return;
171
		try {
172
			ResourcesPlugin.getWorkspace().getRoot().getProject(lastProjectName).delete(!existingPath, true, null);
173
		} catch (CoreException ignore) {}
174
		if (newProject != null) {
175
			manager.remove(newProject);
176
		}
177
		newProject = null;
178
		lastProjectName = null;
179
		lastProjectLocation = null;
180
	}
181
	
182
	private boolean invokeRunnable(IRunnableWithProgress runnable) {
183
		IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
184
		try {
185
			getContainer().run(true, true, op);
186
		} catch (InvocationTargetException e) {
187
			CUIPlugin.errorDialog(getShell(), title, message, e.getTargetException(), false);
188
			clearProject();
189
			return false;
190
		} catch  (InterruptedException e) {
191
			clearProject();
192
			return false;
193
		}
194
		return true;
195
	}
196
197
	@Override
198
	public boolean performFinish() {
199
		boolean needsPost = (newProject != null && !isChanged());
200
		// create project if it is not created yet
201
		if (getProject(fMainPage.isCurrent(), true) == null) 
202
			return false;
203
		fMainPage.h_selected.postProcess(newProject, needsPost);
204
		try {
205
			setCreated();
206
		} catch (CoreException e) {
207
			e.printStackTrace();
208
			return false;
209
		}
210
		BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
211
		selectAndReveal(newProject);
212
		return true;
213
	}
214
	
215
	protected boolean setCreated() throws CoreException {
216
		ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
217
		
218
		ICProjectDescription des = mngr.getProjectDescription(newProject, false);
219
		
220
		if(des == null ) {
221
			return false;
222
		}
223
		
224
		if(des.isCdtProjectCreating()){
225
			des = mngr.getProjectDescription(newProject, true);
226
			des.setCdtProjectCreated();
227
			mngr.setProjectDescription(newProject, des, false, null);
228
			return true;
229
		}
230
		return false;
231
	}
232
	
233
    @Override
234
	public boolean performCancel() {
235
    	clearProject();
236
        return true;
237
    }
238
239
	public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
240
		fConfigElement= config;
241
	}
242
243
	private IRunnableWithProgress getRunnable(boolean _defaults, final boolean onFinish) {
244
		final boolean defaults = _defaults;
245
		return new IRunnableWithProgress() {
246
			public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException {
247
				final Exception except[] = new Exception[1];
248
				getShell().getDisplay().syncExec(new Runnable() {
249
					public void run() {
250
						IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
251
							public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
252
								final IProgressMonitor fMonitor;
253
								if (monitor == null) {
254
									fMonitor= new NullProgressMonitor();
255
								} else {
256
									fMonitor = monitor;
257
								}
258
								fMonitor.beginTask(CUIPlugin.getResourceString("CProjectWizard.op_description"), 100); //$NON-NLS-1$
259
								fMonitor.worked(10);
260
								try {							
261
									newProject = createIProject(lastProjectName, lastProjectLocation, new SubProgressMonitor(fMonitor, 40));
262
									if (newProject != null) 
263
										fMainPage.h_selected.createProject(newProject, defaults, onFinish, new SubProgressMonitor(fMonitor, 40));
264
									fMonitor.worked(10);
265
								} catch (CoreException e) {	CUIPlugin.log(e); }
266
								finally {
267
									fMonitor.done();
268
								}
269
							}
270
						});
271
						try {
272
							getContainer().run(false, true, op);
273
						} catch (InvocationTargetException e) {
274
							except[0] = e;
275
						} catch (InterruptedException e) {
276
							except[0] = e;
277
						}
278
					}
279
				});
280
				if (except[0] != null) {
281
					if (except[0] instanceof InvocationTargetException) {
282
						throw (InvocationTargetException)except[0];
283
					}
284
					if (except[0] instanceof InterruptedException) {
285
						throw (InterruptedException)except[0];
286
					}
287
					throw new InvocationTargetException(except[0]);
288
				}					
289
			}
290
		};
291
	}
292
	
293
	public IProject createIProject(final String name, final URI location) throws CoreException{
294
		return createIProject(name, location, new NullProgressMonitor());
295
	}
296
	
297
	/**
298
	 * @since 5.1
299
	 */
300
	protected IProgressMonitor continueCreationMonitor;
301
302
	/**
303
	 * @param monitor 
304
	 * @since 5.1
305
	 * 
306
	 */	
307
	public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException{
308
		
309
		monitor.beginTask(UIMessages.getString("CDTCommonProjectWizard.creatingProject"), 100); //$NON-NLS-1$
310
		
311
		if (newProject != null)	return newProject;
312
		
313
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
314
		IWorkspaceRoot root = workspace.getRoot();
315
		final IProject newProjectHandle = root.getProject(name);
316
		
317
		if (!newProjectHandle.exists()) {
318
//			IWorkspaceDescription workspaceDesc = workspace.getDescription();
319
//			workspaceDesc.setAutoBuilding(false);
320
//			workspace.setDescription(workspaceDesc);
321
			IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
322
			if(location != null)
323
				description.setLocationURI(location);
324
			newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new SubProgressMonitor(monitor,25));
325
		} else {
326
			IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
327
				public void run(IProgressMonitor monitor) throws CoreException {
328
					newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor);
329
				}
330
			};
331
			workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor,25));
332
			newProject = newProjectHandle;
333
		}
334
        
335
		// Open the project if we have to
336
		if (!newProject.isOpen()) {
337
			newProject.open(new SubProgressMonitor(monitor,25));
338
		}
339
		
340
		continueCreationMonitor = new SubProgressMonitor(monitor,25);
341
		IProject proj = continueCreation(newProject);
342
		
343
		monitor.done();
344
		
345
		return proj;	
346
	}
347
	
348
	protected abstract IProject continueCreation(IProject prj); 
349
	public abstract String[] getNatures();
350
	
351
	@Override
352
	public void dispose() {
353
		fMainPage.dispose();
354
	}
355
	
356
    @Override
357
	public boolean canFinish() {
358
    	if (fMainPage.h_selected != null) {
359
    		if(!fMainPage.h_selected.canFinish())
360
    			return false;
361
    		String s = fMainPage.h_selected.getErrorMessage();
362
    		if (s != null) return false;
363
    	}
364
    	return super.canFinish();
365
    }
366
    /**
367
     * Returns last project name used for creation
368
     */
369
	public String getLastProjectName() {
370
		return lastProjectName;
371
	}
372
373
	public URI getLastProjectLocation() {
374
		return lastProjectLocation;
375
	}
376
377
	public IProject getLastProject() {
378
		return newProject;
379
	}
380
381
	// Methods below should provide data for language check
382
	public String[] getLanguageIDs (){
383
		String[] contentTypeIds = getContentTypeIDs();
384
		if(contentTypeIds.length > 0) {
385
			IContentTypeManager manager = Platform.getContentTypeManager();
386
			List<String> languageIDs = new ArrayList<String>();
387
			for(int i = 0; i < contentTypeIds.length; ++i) {
388
				IContentType contentType = manager.getContentType(contentTypeIds[i]);
389
				if(null != contentType) {
390
					ILanguage language = LanguageManager.getInstance().getLanguage(contentType);
391
					if(!languageIDs.contains(language.getId())) {
392
						languageIDs.add(language.getId());
393
					}
394
				}
395
			}
396
			return languageIDs.toArray(new String[languageIDs.size()]);
397
		}
398
		return EMPTY_ARR;
399
	}
400
	
401
	public String[] getContentTypeIDs (){
402
		return EMPTY_ARR;
403
	}
404
	
405
	public String[] getExtensions (){
406
		String[] contentTypeIds = getContentTypeIDs();
407
		if(contentTypeIds.length > 0) {
408
			IContentTypeManager manager = Platform.getContentTypeManager();
409
			List<String> extensions = new ArrayList<String>();
410
			for(int i = 0; i < contentTypeIds.length; ++i) {
411
				IContentType contentType = manager.getContentType(contentTypeIds[i]);
412
				if(null != contentType) {
413
					String[] thisTypeExtensions = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
414
					extensions.addAll(Arrays.asList(thisTypeExtensions));
415
				}
416
			}
417
			return extensions.toArray(new String[extensions.size()]);
418
		}
419
		return EMPTY_ARR;
420
	}
421
	
422
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteProjectConfigurationWizardPage.java (+56 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteProjectServiceProvider;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.layout.GridLayout;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Label;
19
20
/**
21
 * Allows the user to select a remote project location.
22
 * 
23
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
24
 * part of a work in progress. There is no guarantee that this API will work or
25
 * that it will remain the same. Please do not use this API without consulting
26
 * with the RDT team.
27
 * 
28
 */
29
public class RemoteProjectConfigurationWizardPage extends RemoteServicesConfigurationWizardPage {
30
	public RemoteProjectConfigurationWizardPage(RemoteProjectServiceProvider provider, String pageName) {
31
		super(provider, pageName);
32
		setTitle(pageName);
33
		setDescription("This page allows you to choose a remote (or local) provider for your project source files"); //$NON-NLS-1$
34
	}
35
	
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.ptp.rdt.ui.wizards.RemoteServicesConfigurationWizardPage#createControl(org.eclipse.swt.widgets.Composite)
38
	 */
39
	@Override
40
	public void createControl(Composite parent) {
41
        Composite container = new Composite(parent, SWT.NONE);
42
43
        GridLayout layout = new GridLayout();
44
        layout.numColumns = 1;
45
        container.setLayout(layout);
46
47
        Label label1 = new Label(container, SWT.LEFT);
48
        label1.setText("Choose a provider and a connection to access your source files."); //$NON-NLS-1$
49
        GridData data1 = new GridData(SWT.FILL, SWT.FILL, true, false);
50
        label1.setLayoutData(data1);
51
        
52
		super.createControl(container);
53
		
54
		setControl(container);
55
	}
56
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteProjectLocationContributor.java (+63 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.jface.wizard.IWizard;
14
import org.eclipse.jface.wizard.IWizardPage;
15
import org.eclipse.jface.wizard.WizardPage;
16
import org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteProjectServiceProvider;
17
import org.eclipse.ptp.services.core.IServiceProvider;
18
import org.eclipse.ptp.services.ui.IServiceProviderContributor;
19
import org.eclipse.ptp.services.ui.wizards.ServiceProviderConfigurationWizard;
20
import org.eclipse.swt.widgets.Shell;
21
22
/**
23
 * Allows the user to configure a remote project location.
24
 * 
25
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
26
 * part of a work in progress. There is no guarantee that this API will work or
27
 * that it will remain the same. Please do not use this API without consulting
28
 * with the RDT team.
29
 * 
30
 */
31
public class RemoteProjectLocationContributor implements IServiceProviderContributor {
32
33
	public RemoteProjectLocationContributor() {
34
	}
35
36
	/* (non-Javadoc)
37
	 * @see org.eclipse.ptp.services.ui.IServiceProviderContributor#configureServiceProvider(org.eclipse.ptp.services.core.IServiceProvider, org.eclipse.swt.widgets.Shell)
38
	 */
39
	public void configureServiceProvider(IServiceProvider provider, Shell parentShell) {
40
41
	}
42
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.ptp.services.ui.IServiceProviderContributor#getWizard(org.eclipse.ptp.services.core.IServiceProvider, org.eclipse.jface.wizard.IWizardPage)
45
	 */
46
	public IWizard getWizard(IServiceProvider provider, IWizardPage page) {
47
		return new ServiceProviderConfigurationWizard(provider, page);
48
	}
49
	
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.ptp.services.ui.IServiceProviderContributor#getWizardPages(org.eclipse.ptp.services.core.IServiceProvider)
52
	 */
53
	public WizardPage[] getWizardPages(IServiceProvider provider) {
54
		if (!(provider instanceof RemoteProjectServiceProvider)) {
55
			return new WizardPage[0];
56
		}
57
		return new WizardPage[]{
58
					new RemoteProjectConfigurationWizardPage((RemoteProjectServiceProvider)provider, "Remote Project Location"), //$NON-NLS-1$
59
					new RemoteProjectDirectoryWizardPage("Project Directory") //$NON-NLS-1$
60
				};
61
	}
62
63
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/BuildServiceWizardPage.java (+59 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.ptp.services.core.IService;
14
import org.eclipse.ptp.services.ui.wizards.ServiceConfigurationWizardPage;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Label;
20
21
/**
22
 * Allows the user to select a remote or local project configuration.
23
 * 
24
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
25
 * part of a work in progress. There is no guarantee that this API will work or
26
 * that it will remain the same. Please do not use this API without consulting
27
 * with the RDT team.
28
 * 
29
 *
30
 */
31
public class BuildServiceWizardPage extends ServiceConfigurationWizardPage {
32
	public BuildServiceWizardPage(IService service, String pageName) {
33
		super(service, pageName);
34
		setTitle(pageName);
35
		setDescription("This page allows you to set the location where your project will be built."); //$NON-NLS-1$
36
	}
37
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.ptp.services.ui.wizards.ServiceConfigurationWizardPage#createControl(org.eclipse.swt.widgets.Composite)
40
	 */
41
	@Override
42
	public void createControl(Composite parent) {
43
        Composite container = new Composite(parent, SWT.NONE);
44
45
        GridLayout layout = new GridLayout();
46
        layout.numColumns = 1;
47
        container.setLayout(layout);
48
49
        Label label = new Label(container, SWT.LEFT);
50
        label.setText("Choose a provider that most closely matches where your project will be built."); //$NON-NLS-1$
51
        GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
52
        label.setLayoutData(data);
53
        
54
		super.createControl(container);
55
		
56
		setControl(container);
57
	}
58
	
59
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/ConfigureRemoteServices.java (+76 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import java.io.IOException;
14
import java.util.Properties;
15
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.core.model.ICProject;
18
import org.eclipse.cdt.internal.core.model.CModelManager;
19
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
20
import org.eclipse.core.resources.IProject;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.ptp.internal.rdt.core.index.RemoteFastIndexer;
23
import org.eclipse.ptp.rdt.ui.messages.Messages;
24
import org.eclipse.ptp.services.core.IServiceConfiguration;
25
import org.eclipse.ptp.services.core.ServiceModelManager;
26
import org.eclipse.rse.internal.connectorservice.dstore.Activator;
27
28
/**
29
 * Configure remote services for a project with the available services and service providers
30
 * 
31
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
32
 * part of a work in progress. There is no guarantee that this API will work or
33
 * that it will remain the same. Please do not use this API without consulting
34
 * with the RDT team.
35
 * 
36
 * @author vkong
37
 *
38
 */
39
public class ConfigureRemoteServices {
40
	
41
	public static String DEFAULT_CONFIG = Messages.getString("ConfigureRemoteServices.0"); //$NON-NLS-1$
42
	
43
	/**
44
	 * @throws NullPointerException if any of the parameters are null
45
	 */
46
	public static void configure(IProject project, IServiceConfiguration config, IProgressMonitor monitor) {
47
		
48
		monitor.beginTask("actual Configure remote services", 100); //$NON-NLS-1$
49
		
50
		if(project == null || config == null) {
51
			throw new NullPointerException();
52
		}
53
				
54
		final ServiceModelManager serviceModelManager = ServiceModelManager.getInstance();
55
56
		//have to set it as active
57
		serviceModelManager.setConfiguration(project, config);
58
		serviceModelManager.setActiveConfiguration(project, config);
59
		monitor.worked(10);
60
		
61
		try {
62
			serviceModelManager.saveModelConfiguration();
63
		} catch (IOException e) {
64
			Activator.logError(e.toString(), e);
65
		}
66
		monitor.worked(80);
67
		
68
		ICProject cProject = CModelManager.getDefault().getCModel().getCProject(project);
69
		CCorePlugin.getIndexManager().setIndexerId(cProject, RemoteFastIndexer.ID);
70
		Properties properties = new Properties();
71
		properties.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, ""); //$NON-NLS-1$
72
		IndexerPreferences.setProperties(project, IndexerPreferences.SCOPE_PROJECT_PRIVATE, properties);
73
		monitor.worked(10);
74
		monitor.done();		
75
	}
76
}
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/LocalCIndexServiceProvider.java (+290 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
import java.util.Collections;
14
import java.util.List;
15
import java.util.Set;
16
17
import org.eclipse.cdt.core.model.ICElement;
18
import org.eclipse.cdt.core.model.ICProject;
19
import org.eclipse.cdt.core.model.ISourceReference;
20
import org.eclipse.cdt.core.model.ITranslationUnit;
21
import org.eclipse.cdt.core.model.IWorkingCopy;
22
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
23
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.OperationCanceledException;
27
import org.eclipse.core.runtime.Status;
28
import org.eclipse.jface.resource.ImageDescriptor;
29
import org.eclipse.jface.text.ITextSelection;
30
import org.eclipse.ptp.internal.rdt.core.callhierarchy.CalledByResult;
31
import org.eclipse.ptp.internal.rdt.core.callhierarchy.CallsToResult;
32
import org.eclipse.ptp.internal.rdt.core.callhierarchy.ICallHierarchyService;
33
import org.eclipse.ptp.internal.rdt.core.contentassist.Proposal;
34
import org.eclipse.ptp.internal.rdt.core.index.IIndexLifecycleService;
35
import org.eclipse.ptp.internal.rdt.core.index.RemoteIndexerTask;
36
import org.eclipse.ptp.internal.rdt.core.model.Scope;
37
import org.eclipse.ptp.internal.rdt.core.navigation.INavigationService;
38
import org.eclipse.ptp.internal.rdt.core.navigation.OpenDeclarationResult;
39
import org.eclipse.ptp.internal.rdt.core.typehierarchy.ITypeHierarchyService;
40
import org.eclipse.ptp.internal.rdt.core.typehierarchy.THGraph;
41
import org.eclipse.ptp.internal.rdt.ui.contentassist.IContentAssistService;
42
import org.eclipse.ptp.internal.rdt.ui.search.ISearchService;
43
import org.eclipse.ptp.rdt.ui.messages.Messages;
44
import org.eclipse.ptp.rdt.ui.serviceproviders.IIndexServiceProvider2;
45
import org.eclipse.rse.core.model.IHost;
46
import org.eclipse.search.ui.ISearchQuery;
47
import org.eclipse.search.ui.ISearchResult;
48
import org.eclipse.search.ui.ISearchResultListener;
49
50
/**
51
 * A C/C++ indexing service provider that does nothing.
52
 * 
53
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
54
 * part of a work in progress. There is no guarantee that this API will work or
55
 * that it will remain the same. Please do not use this API without consulting
56
 * with the RDT team.
57
 * 
58
 * @author vkong
59
 * @author crecoskie
60
 *
61
 */
62
public class LocalCIndexServiceProvider extends
63
		AbstractRemoteCIndexServiceProvider implements IIndexServiceProvider2 {
64
65
	private final class NullSearchQuery implements ISearchQuery {		
66
		
67
		private final class NullSearchResult implements ISearchResult {
68
			private ISearchQuery fQuery = null;
69
			
70
			public NullSearchResult(ISearchQuery query) {
71
				fQuery = query;
72
			}
73
74
			public void addListener(ISearchResultListener l) {
75
				// do nothing
76
			}
77
78
			public ImageDescriptor getImageDescriptor() {
79
				// no image
80
				return null;
81
			}
82
83
			public String getLabel() {
84
				return Messages.getString("LocalCIndexServiceProvider.1"); //$NON-NLS-1$
85
			}
86
87
			public ISearchQuery getQuery() {
88
				return fQuery;
89
			}
90
91
			public String getTooltip() {
92
				return null;
93
			}
94
95
			public void removeListener(ISearchResultListener l) {
96
				// do nothing
97
			}
98
		}
99
100
		public boolean canRerun() {
101
			return false;
102
		}
103
104
		public boolean canRunInBackground() {
105
			return true;
106
		}
107
108
		public String getLabel() {
109
			return Messages.getString("LocalCIndexServiceProvider.0"); //$NON-NLS-1$
110
		}
111
112
		public ISearchResult getSearchResult() {
113
			return new NullSearchResult(this);
114
		}
115
116
		public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
117
			return Status.OK_STATUS;
118
		}
119
	}
120
121
	public static final String ID = "org.eclipse.ptp.rdt.ui.LocalCIndexServiceProvider"; //$NON-NLS-1$
122
	public static final String SERVICE_ID = "org.eclipse.ptp.rdt.core.CIndexingService"; //$NON-NLS-1$
123
124
	public LocalCIndexServiceProvider() {
125
	}
126
	
127
	/* (non-Javadoc)
128
	 * @see org.eclipse.ptp.internal.rdt.core.serviceproviders.AbstractRemoteCIndexServiceProvider#getCallHierarchyService()
129
	 */
130
	@Override
131
	public ICallHierarchyService getCallHierarchyService() {
132
		return new ICallHierarchyService () {
133
134
			public CalledByResult findCalledBy(Scope scope, ICElement callee, IProgressMonitor pm) throws CoreException,
135
					InterruptedException {
136
				return new CalledByResult();
137
			}
138
139
			public CallsToResult findCalls(Scope scope, ICElement caller, IProgressMonitor pm) throws CoreException,
140
					InterruptedException {
141
				return new CallsToResult();
142
			}
143
144
			public ICElement[] findDefinitions(Scope scope, ICElement input, IProgressMonitor pm) {
145
				return new ICElement[0];
146
			}
147
148
			public ICElement[] findDefinitions(Scope scope, ICProject project, IWorkingCopy workingCopy, int selectionStart,
149
					int selectionLength, IProgressMonitor pm) throws CoreException {
150
				return new ICElement[0];
151
			}
152
			
153
		}; 
154
	}
155
156
	/* (non-Javadoc)
157
	 * @see org.eclipse.ptp.internal.rdt.core.serviceproviders.AbstractRemoteCIndexServiceProvider#getHost()
158
	 */
159
	@Override
160
	public IHost getHost() {
161
		return null;
162
	}
163
164
	/* (non-Javadoc)
165
	 * @see org.eclipse.ptp.internal.rdt.core.serviceproviders.AbstractRemoteCIndexServiceProvider#getIndexLifeCycleService()
166
	 */
167
	@Override
168
	public synchronized IIndexLifecycleService getIndexLifeCycleService() {
169
		return new IIndexLifecycleService () {
170
171
			public Scope createScope(String name, List<ICElement> elements, IProgressMonitor monitor) {
172
				return null;
173
			}
174
175
			public Scope getScope(String name) {
176
				return null;
177
			}
178
179
			public Set<Scope> getScopes() {
180
				return Collections.emptySet();
181
			}
182
183
			public void reindex(Scope scope, List<ICElement> elements, IProgressMonitor monitor, RemoteIndexerTask task) {
184
				// do nothing
185
				
186
			}
187
188
			public void reindex(Scope scope, IProgressMonitor monitor, RemoteIndexerTask task) {
189
				// do nothing
190
				
191
			}
192
193
			public void update(Scope scope, List<ICElement> asList,
194
					List<ICElement> asList2, List<ICElement> asList3,
195
					IProgressMonitor monitor, RemoteIndexerTask task) {
196
				// do nothing
197
				
198
			}
199
			
200
		};
201
	}
202
203
	/* (non-Javadoc)
204
	 * @see org.eclipse.ptp.internal.rdt.core.serviceproviders.AbstractRemoteCIndexServiceProvider#getNavigationService()
205
	 */
206
	@Override
207
	public INavigationService getNavigationService() {
208
		return new INavigationService() {
209
210
			public OpenDeclarationResult openDeclaration(Scope scope,
211
					ITranslationUnit workingCopy, String selectedText,
212
					int selectionStart, int selectionLength,
213
					IProgressMonitor monitor) {
214
				
215
				return null;
216
			}
217
			
218
		};
219
	}
220
221
	/* (non-Javadoc)
222
	 * @see org.eclipse.ptp.internal.rdt.core.serviceproviders.AbstractRemoteCIndexServiceProvider#getTypeHierarchyService()
223
	 */
224
	@Override
225
	public ITypeHierarchyService getTypeHierarchyService() {
226
		return new ITypeHierarchyService () {
227
228
			public THGraph computeGraph(Scope scope, ICElement input, IProgressMonitor monitor) throws CoreException,
229
					InterruptedException {
230
				return new THGraph();
231
			}
232
233
			public ICElement[] findInput(Scope scope, ICElement memberInput, IProgressMonitor monitor) {
234
				return new ICElement[0];
235
			}
236
237
			public ICElement[] findInput(Scope scope, ICProject project, IWorkingCopy workingCopy, int selectionStart,
238
					int selectionLength, IProgressMonitor monitor) throws CoreException {
239
				return new ICElement[0];
240
			}
241
			
242
		};
243
	}
244
245
	/* (non-Javadoc)
246
	 * @see org.eclipse.ptp.rdt.ui.serviceproviders.IIndexServiceProvider2#getContentAssistService()
247
	 */
248
	public IContentAssistService getContentAssistService() {
249
		return new IContentAssistService() {
250
251
			public List<Proposal> computeCompletionProposals(Scope scope, ContentAssistInvocationContext context,
252
					ITranslationUnit unit) {
253
				return Collections.emptyList();
254
			}
255
			
256
		};
257
	}
258
259
	/* (non-Javadoc)
260
	 * @see org.eclipse.ptp.rdt.ui.serviceproviders.IIndexServiceProvider2#getSearchService()
261
	 */
262
	public ISearchService getSearchService() {
263
		return new ISearchService () {
264
265
			public ISearchQuery createSearchElementQuery(Scope indexScope, ICElement[] searchScope, ISourceReference object,
266
					int limitTo) {
267
				return new NullSearchQuery();
268
			}
269
270
			public ISearchQuery createSearchPatternQuery(Scope indexScope, ICElement[] searchScope, String scopeDescription,
271
					String patternStr, boolean isCaseSensitive, int searchFlags) {
272
				return new NullSearchQuery();
273
			}
274
275
			public ISearchQuery createSearchTextSelectionQuery(Scope indexScope, ICElement[] searchScope,
276
					ITranslationUnit element, ITextSelection selNode, int limitTo) {
277
				return new NullSearchQuery();
278
			}
279
			
280
		};
281
	}
282
283
	/* (non-Javadoc)
284
	 * @see org.eclipse.ptp.internal.rdt.core.serviceproviders.AbstractRemoteCIndexServiceProvider#isConfigured()
285
	 */
286
	@Override
287
	public boolean isConfigured() {
288
		return true;
289
	}
290
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteServicesServiceProviderConfigurer.java (+63 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.jface.wizard.IWizard;
14
import org.eclipse.jface.wizard.IWizardPage;
15
import org.eclipse.jface.wizard.WizardPage;
16
import org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteBuildServiceProvider;
17
import org.eclipse.ptp.services.core.IServiceProvider;
18
import org.eclipse.ptp.services.ui.IServiceProviderContributor;
19
import org.eclipse.ptp.services.ui.wizards.ServiceProviderConfigurationWizard;
20
import org.eclipse.swt.widgets.Shell;
21
22
/**
23
 * Allows the user to select a provider of Remote Services for a RemoteBuildServiceProvider.
24
 * 
25
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
26
 * part of a work in progress. There is no guarantee that this API will work or
27
 * that it will remain the same. Please do not use this API without consulting
28
 * with the RDT team.
29
 * 
30
 * @author crecoskie
31
 * @see org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider
32
 *
33
 */
34
public class RemoteServicesServiceProviderConfigurer implements IServiceProviderContributor {
35
36
	public RemoteServicesServiceProviderConfigurer() {
37
	}
38
39
	/* (non-Javadoc)
40
	 * @see org.eclipse.ptp.rdt.services.ui.IServiceProviderConfiguration#configureServiceProvider(org.eclipse.ptp.rdt.services.core.IServiceProvider, org.eclipse.swt.widgets.Shell)
41
	 */
42
	public void configureServiceProvider(IServiceProvider provider, Shell parentShell) {
43
44
	}
45
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.ptp.services.ui.IServiceProviderContributor#getWizard(org.eclipse.ptp.services.core.IServiceProvider, org.eclipse.jface.wizard.IWizardPage)
48
	 */
49
	public IWizard getWizard(IServiceProvider provider, IWizardPage page) {
50
		return new ServiceProviderConfigurationWizard(provider, page);
51
	}
52
	
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.ptp.services.ui.IServiceProviderContributor#getWizardPages(org.eclipse.ptp.services.core.IServiceProvider)
55
	 */
56
	public WizardPage[] getWizardPages(IServiceProvider provider) {
57
		if (!(provider instanceof RemoteBuildServiceProvider)) {
58
			return new WizardPage[0];
59
		}
60
		return new WizardPage[]{new RemoteServicesConfigurationWizardPage((RemoteBuildServiceProvider)provider, "Remote Build Services Configuration")}; //$NON-NLS-1$
61
	}
62
63
}
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/RemoteProjectServiceProvider.java (+25 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
14
/**
15
 * A project location service provider that is remote.
16
 * 
17
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
18
 * part of a work in progress. There is no guarantee that this API will work or
19
 * that it will remain the same. Please do not use this API without consulting
20
 * with the RDT team.
21
 * 
22
 */
23
public class RemoteProjectServiceProvider extends AbstractRemoteServicesProvider {
24
	public final static String ID = "org.eclipse.ptp.rdt.ui.RemoteProjectLocationProvider"; //$NON-NLS-1$
25
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/NewRemoteProjectWizard.java (+75 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.cdt.core.CCProjectNature;
14
import org.eclipse.cdt.core.CProjectNature;
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.NullProgressMonitor;
18
import org.eclipse.ptp.internal.rdt.ui.RDTPluginImages;
19
import org.eclipse.ptp.rdt.core.resources.RemoteNature;
20
21
/**
22
 * A wizard for creating new Remote C/C++ Projects
23
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
24
 * part of a work in progress. There is no guarantee that this API will work or
25
 * that it will remain the same. Please do not use this API without consulting
26
 * with the RDT team.
27
 * 
28
 * @author crecoskie
29
 *
30
 */
31
public class NewRemoteProjectWizard extends RemoteCommonProjectWizard {
32
	private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
33
	private static final String wz_title = "New Remote Project"; //$NON-NLS-1$
34
	private static final String wz_desc = "Create remote project of the selected type"; //$NON-NLS-1$
35
	
36
	/**
37
	 * 
38
	 */
39
	public NewRemoteProjectWizard() {
40
		super(wz_title, wz_desc);
41
	}
42
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#continueCreation(org.eclipse.core.resources.IProject)
46
	 */
47
	
48
	@Override
49
	protected IProject continueCreation(IProject prj) {
50
		try {
51
			CProjectNature.addCNature(prj, new NullProgressMonitor());
52
			CCProjectNature.addCCNature(prj, new NullProgressMonitor());
53
			RemoteNature.addRemoteNature(prj, new NullProgressMonitor());
54
		} catch (CoreException e) {}
55
		return prj;
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#getNatures()
60
	 */
61
	@Override
62
	public String[] getNatures() {
63
		return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID, RemoteNature.REMOTE_NATURE_ID};
64
	}
65
66
67
	/* (non-Javadoc)
68
	 * @see org.eclipse.ui.wizards.newresource.BasicNewResourceWizard#initializeDefaultPageImageDescriptor()
69
	 */
70
	@Override
71
	protected void initializeDefaultPageImageDescriptor() {
72
		setDefaultPageImageDescriptor(RDTPluginImages.DESC_WIZBAN_NEW_REMOTE_C_PROJ);
73
	}
74
75
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/CIndexingServiceContributor.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.jface.wizard.WizardPage;
14
import org.eclipse.ptp.services.core.IService;
15
import org.eclipse.ptp.services.ui.IServiceContributor;
16
17
/**
18
 * Allows the user to configure a project location.
19
 * 
20
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
21
 * part of a work in progress. There is no guarantee that this API will work or
22
 * that it will remain the same. Please do not use this API without consulting
23
 * with the RDT team.
24
 * 
25
 */
26
public class CIndexingServiceContributor implements IServiceContributor {
27
28
	public CIndexingServiceContributor() {
29
	}
30
31
	public WizardPage[] getWizardPages(IService service) {
32
		return new WizardPage[]{
33
				new CIndexingServiceWizardPage(service, "C/C++ Indexing Service Configuration") //$NON-NLS-1$
34
			}; 
35
	}
36
37
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/BuildServiceContributor.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.jface.wizard.WizardPage;
14
import org.eclipse.ptp.services.core.IService;
15
import org.eclipse.ptp.services.ui.IServiceContributor;
16
17
/**
18
 * Allows the user to configure a project location.
19
 * 
20
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
21
 * part of a work in progress. There is no guarantee that this API will work or
22
 * that it will remain the same. Please do not use this API without consulting
23
 * with the RDT team.
24
 * 
25
 */
26
public class BuildServiceContributor implements IServiceContributor {
27
28
	public BuildServiceContributor() {
29
	}
30
31
	public WizardPage[] getWizardPages(IService service) {
32
		return new WizardPage[]{
33
				new BuildServiceWizardPage(service, "Build Service Configuration") //$NON-NLS-1$
34
			}; 
35
	}
36
37
}
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/AbstractRemoteCIndexServiceProvider.java (+125 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
import org.eclipse.ptp.internal.rdt.core.callhierarchy.ICallHierarchyService;
14
import org.eclipse.ptp.internal.rdt.core.callhierarchy.RemoteCallHierarchyService;
15
import org.eclipse.ptp.internal.rdt.core.includebrowser.IIncludeBrowserService;
16
import org.eclipse.ptp.internal.rdt.core.includebrowser.RemoteIncludeBrowserService;
17
import org.eclipse.ptp.internal.rdt.core.index.IIndexLifecycleService;
18
import org.eclipse.ptp.internal.rdt.core.index.RemoteIndexLifecycleService;
19
import org.eclipse.ptp.internal.rdt.core.navigation.INavigationService;
20
import org.eclipse.ptp.internal.rdt.core.navigation.RemoteNavigationService;
21
import org.eclipse.ptp.internal.rdt.core.typehierarchy.ITypeHierarchyService;
22
import org.eclipse.ptp.internal.rdt.core.typehierarchy.RemoteTypeHierarchyService;
23
import org.eclipse.ptp.rdt.core.serviceproviders.IIndexServiceProvider;
24
import org.eclipse.rse.core.model.IHost;
25
import org.eclipse.rse.core.subsystems.IConnectorService;
26
27
/**
28
 * Abstract class which forms the basis of a remote C/C++ indexing provider.
29
 * 
30
 * @author crecoskie
31
 * @noextend
32
 * @see org.eclipse.ptp.rdt.ui.serviceproviders.RemoteCIndexServiceProvider
33
 */
34
public abstract class AbstractRemoteCIndexServiceProvider extends AbstractRemoteServicesProvider implements IIndexServiceProvider {
35
	private static final String HOST_NAME_KEY = "host-name"; //$NON-NLS-1$
36
37
	protected boolean fIsConfigured;
38
	protected IHost fHost;
39
	protected IConnectorService fConnectorService;
40
	protected IIndexLifecycleService fIndexLifecycleService;
41
	protected INavigationService fNavigationService;
42
	protected ICallHierarchyService fCallHierarchyService;
43
	protected ITypeHierarchyService fTypeHierarchyService;
44
	protected IIncludeBrowserService fIncludeBrowserService;
45
	
46
	public AbstractRemoteCIndexServiceProvider() {
47
	}
48
	
49
	public String getHostName() {
50
		return getString(HOST_NAME_KEY);
51
	}
52
	
53
	public void setConnection(IHost host, IConnectorService connectorService) {
54
		fHost = host;
55
		fConnectorService = connectorService;
56
		putString(HOST_NAME_KEY, host.getAliasName());
57
		setConfigured(true);
58
	}
59
	
60
	public boolean isConfigured() {
61
		return fIsConfigured;
62
	}
63
64
	public void setConfigured(boolean isConfigured) {
65
		fIsConfigured = isConfigured;
66
	}
67
	
68
	public synchronized IIndexLifecycleService getIndexLifeCycleService() {
69
		if(!isConfigured())
70
			return null;
71
		
72
		if(fIndexLifecycleService == null)
73
			fIndexLifecycleService = new RemoteIndexLifecycleService(fHost, fConnectorService);
74
		
75
		return fIndexLifecycleService;
76
	}
77
	
78
	public synchronized INavigationService getNavigationService() {
79
		if(!isConfigured())
80
			return null;
81
		
82
		if(fNavigationService== null)
83
			fNavigationService = new RemoteNavigationService(fHost, fConnectorService);
84
		
85
		return fNavigationService;
86
	}
87
	
88
	public synchronized ICallHierarchyService getCallHierarchyService() {
89
		if(!isConfigured())
90
			return null;
91
		
92
		if(fCallHierarchyService== null)
93
			fCallHierarchyService = new RemoteCallHierarchyService(fHost, fConnectorService);
94
		
95
		return fCallHierarchyService;
96
	}
97
	
98
	public synchronized ITypeHierarchyService getTypeHierarchyService() {
99
		if(!isConfigured())
100
			return null;
101
		
102
		if(fTypeHierarchyService== null)
103
			fTypeHierarchyService = new RemoteTypeHierarchyService(fHost, fConnectorService);
104
		
105
		return fTypeHierarchyService;
106
	}
107
108
	public synchronized IIncludeBrowserService getIncludeBrowserService() {
109
		if(!isConfigured())
110
			return null;
111
		
112
		if(fIncludeBrowserService== null)
113
			fIncludeBrowserService = new RemoteIncludeBrowserService(fHost, fConnectorService);
114
		
115
		return fIncludeBrowserService;
116
	}
117
118
	/**
119
	 * @return the system connection for this service provider
120
	 */
121
	public IHost getHost() {
122
		return fHost;
123
	}
124
125
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteProjectDirectoryWizardPage.java (+73 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.ptp.services.ui.wizards.ServiceProviderConfigurationWizardPage;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.layout.GridLayout;
17
import org.eclipse.swt.widgets.Button;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Label;
20
import org.eclipse.swt.widgets.Text;
21
22
/**
23
 * Allows the user to select a remote project location.
24
 * 
25
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
26
 * part of a work in progress. There is no guarantee that this API will work or
27
 * that it will remain the same. Please do not use this API without consulting
28
 * with the RDT team.
29
 * 
30
 */
31
public class RemoteProjectDirectoryWizardPage extends ServiceProviderConfigurationWizardPage {
32
	public RemoteProjectDirectoryWizardPage(String pageName) {
33
		super(pageName);
34
		setTitle(pageName);
35
		setDescription("This page allows you to choose the directory for your project source files"); //$NON-NLS-1$
36
	}
37
	
38
	/* (non-Javadoc)
39
	 * @see org.eclipse.ptp.rdt.ui.wizards.RemoteServicesConfigurationWizardPage#createControl(org.eclipse.swt.widgets.Composite)
40
	 */
41
	@Override
42
	public void createControl(Composite parent) {
43
        Composite container = new Composite(parent, SWT.NONE);
44
45
        GridLayout layout = new GridLayout();
46
        layout.numColumns = 3;
47
        container.setLayout(layout);
48
		setControl(container);
49
50
        Label label1 = new Label(container, SWT.LEFT);
51
        label1.setText("Choose a directory for your project."); //$NON-NLS-1$
52
        GridData data1 = new GridData(SWT.FILL, SWT.FILL, true, false);
53
        data1.horizontalSpan = 3;
54
        label1.setLayoutData(data1);
55
        
56
        Label label2 = new Label(container, SWT.NONE);
57
		label2.setText("Directory:"); //$NON-NLS-1$
58
		GridData gd = new GridData();
59
		gd.horizontalSpan = 1;
60
		label2.setLayoutData(gd);
61
62
		Text text = new Text(container, SWT.SINGLE | SWT.BORDER);
63
		gd = new GridData(GridData.FILL_HORIZONTAL);
64
		gd.horizontalSpan = 1;
65
		gd.grabExcessHorizontalSpace = true;
66
		gd.widthHint = 100;
67
		text.setLayoutData(gd);
68
		
69
		Button browseButton = new Button(container, SWT.PUSH);
70
		browseButton.setText("Browse..."); //$NON-NLS-1$
71
72
	}
73
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/NewRemoteProjectCreationPage.java (+354 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 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
 *     Jakub Jurkiewicz <jakub.jurkiewicz@gmail.com> - Fix for Bug 174737
11
 *     [IDE] New Plug-in Project wizard status handling is inconsistent
12
 *     Oakland Software Incorporated (Francis Upton) <francisu@ieee.org>
13
 *		    Bug 224997 [Workbench] Impossible to copy project
14
 *******************************************************************************/
15
package org.eclipse.ptp.rdt.ui.newwizards;
16
17
import java.net.URI;
18
19
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.IWorkspace;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.Path;
26
import org.eclipse.jface.dialogs.Dialog;
27
import org.eclipse.jface.viewers.IStructuredSelection;
28
import org.eclipse.ptp.rdt.ui.newwizards.RemoteProjectContentsLocationArea.IErrorMessageReporter;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.layout.GridData;
31
import org.eclipse.swt.layout.GridLayout;
32
import org.eclipse.swt.widgets.Button;
33
import org.eclipse.swt.widgets.Composite;
34
import org.eclipse.swt.widgets.Event;
35
import org.eclipse.swt.widgets.Label;
36
import org.eclipse.swt.widgets.Listener;
37
import org.eclipse.swt.widgets.Text;
38
import org.eclipse.ui.PlatformUI;
39
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
40
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
41
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
42
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
43
44
/**
45
 * Standard main page for a wizard that is creates a project resource.
46
 * <p>
47
 * This page may be used by clients as-is; it may be also be subclassed to suit.
48
 * </p>
49
 * <p>
50
 * Example usage:
51
 * <pre>
52
 * mainPage = new NewRemoteProjectCreationPage("basicNewProjectPage");
53
 * mainPage.setTitle("Project");
54
 * mainPage.setDescription("Create a new project resource.");
55
 * </pre>
56
 * </p>
57
 */
58
public class NewRemoteProjectCreationPage extends WizardNewProjectCreationPage {
59
60
       // initial value stores
61
    private String initialProjectFieldValue;
62
63
    // widgets
64
    private Text projectNameField;
65
66
    private Listener nameModifyListener = new Listener() {
67
        public void handleEvent(Event e) {
68
        	setLocationForSelection();
69
            boolean valid = validatePage();
70
            setPageComplete(valid);
71
                
72
        }
73
    };
74
75
	private RemoteProjectContentsLocationArea locationArea;
76
77
//	private WorkingSetGroup workingSetGroup;
78
79
    // constants
80
    private static final int SIZING_TEXT_FIELD_WIDTH = 250;
81
82
    /**
83
     * Creates a new project creation wizard page.
84
     *
85
     * @param pageName the name of this page
86
     */
87
    public NewRemoteProjectCreationPage(String pageName) {
88
    	super(pageName);
89
	    setPageComplete(false);
90
    }
91
92
    /**
93
	 * Creates a new project creation wizard page.
94
	 * 
95
	 * @param pageName
96
	 * @param selection
97
	 * @param workingSetTypes
98
	 * 
99
	 * @deprecated default placement of the working set group has been removed.
100
	 *             If you wish to use the working set block please call
101
	 *             {@link #createWorkingSetGroup(Composite, IStructuredSelection, String[])}
102
	 *             in your overridden {@link #createControl(Composite)}
103
	 *             implementation.
104
	 * @since 3.4
105
	 */
106
	public NewRemoteProjectCreationPage(String pageName,
107
			IStructuredSelection selection, String[] workingSetTypes) {
108
		this(pageName);
109
	}
110
111
	/** (non-Javadoc)
112
     * Method declared on IDialogPage.
113
     */
114
    public void createControl(Composite parent) {
115
        Composite composite = new Composite(parent, SWT.NULL);
116
117
        initializeDialogUnits(parent);
118
119
        PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
120
                IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE);
121
122
        composite.setLayout(new GridLayout());
123
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
124
125
        createProjectNameGroup(composite);
126
        locationArea = new RemoteProjectContentsLocationArea(getErrorReporter(), composite);
127
        if(initialProjectFieldValue != null) {
128
			locationArea.updateProjectName(initialProjectFieldValue);
129
		}
130
        
131
		// Scale the buttons based on the rest of the dialog
132
        for (Button button : locationArea.getButtons()) {
133
        	setButtonLayoutData(button);
134
        }
135
		
136
        setPageComplete(validatePage());
137
        // Show description on opening
138
        setErrorMessage(null);
139
        setMessage(null);
140
        setControl(composite);
141
        Dialog.applyDialogFont(composite);
142
    }
143
    
144
    /**
145
	 * Get an error reporter for the receiver.
146
	 * @return IErrorMessageReporter
147
	 */
148
	private IErrorMessageReporter getErrorReporter() {
149
		return new IErrorMessageReporter(){
150
			/* (non-Javadoc)
151
			 * @see org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter#reportError(java.lang.String)
152
			 */
153
			public void reportError(String errorMessage, boolean infoOnly) {
154
				if (infoOnly) {
155
					setMessage(errorMessage, IStatus.INFO);
156
					setErrorMessage(null);
157
				}
158
				else
159
					setErrorMessage(errorMessage);
160
				boolean valid = errorMessage == null;
161
				if(valid) {
162
					valid = validatePage();
163
				}
164
				
165
				setPageComplete(valid);
166
			}
167
		};
168
	}
169
170
    /**
171
     * Creates the project name specification controls.
172
     *
173
     * @param parent the parent composite
174
     */
175
    private final void createProjectNameGroup(Composite parent) {
176
        // project specification group
177
        Composite projectGroup = new Composite(parent, SWT.NONE);
178
        GridLayout layout = new GridLayout();
179
        layout.numColumns = 2;
180
        projectGroup.setLayout(layout);
181
        projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
182
183
        // new project label
184
        Label projectLabel = new Label(projectGroup, SWT.NONE);
185
        projectLabel.setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel);
186
        projectLabel.setFont(parent.getFont());
187
188
        // new project name entry field
189
        projectNameField = new Text(projectGroup, SWT.BORDER);
190
        GridData data = new GridData(GridData.FILL_HORIZONTAL);
191
        data.widthHint = SIZING_TEXT_FIELD_WIDTH;
192
        projectNameField.setLayoutData(data);
193
        projectNameField.setFont(parent.getFont());
194
195
        // Set the initial value first before listener
196
        // to avoid handling an event during the creation.
197
        if (initialProjectFieldValue != null) {
198
			projectNameField.setText(initialProjectFieldValue);
199
		}
200
        projectNameField.addListener(SWT.Modify, nameModifyListener);
201
    }
202
203
    /**
204
     * Returns the current project location path as entered by 
205
     * the user, or its anticipated initial value.
206
     * Note that if the default has been returned the path
207
     * in a project description used to create a project
208
     * should not be set.
209
     *
210
     * @return the project location path or its anticipated initial value.
211
     */
212
    public IPath getLocationPath() {
213
        return new Path(locationArea.getProjectLocation());
214
    }
215
216
    /**
217
     * Returns the current project location URI as entered by 
218
     * the user, or <code>null</code> if a valid project location
219
     * has not been entered.
220
     *
221
     * @return the project location URI, or <code>null</code>
222
     * @since 3.2
223
     */
224
    public URI getLocationURI() {
225
    	return locationArea.getProjectLocationURI();
226
    }
227
228
    /**
229
     * Returns the current project name as entered by the user, or its anticipated
230
     * initial value.
231
     *
232
     * @return the project name, its anticipated initial value, or <code>null</code>
233
     *   if no project name is known
234
     */
235
    public String getProjectName() {
236
        if (projectNameField == null) {
237
			return initialProjectFieldValue;
238
		}
239
240
        return getProjectNameFieldValue();
241
    }
242
243
    /**
244
     * Returns the value of the project name field
245
     * with leading and trailing spaces removed.
246
     * 
247
     * @return the project name in the field
248
     */
249
    private String getProjectNameFieldValue() {
250
        if (projectNameField == null) {
251
			return ""; //$NON-NLS-1$
252
		}
253
254
        return projectNameField.getText().trim();
255
    }
256
257
    /**
258
     * Sets the initial project name that this page will use when
259
     * created. The name is ignored if the createControl(Composite)
260
     * method has already been called. Leading and trailing spaces
261
     * in the name are ignored.
262
     * Providing the name of an existing project will not necessarily 
263
     * cause the wizard to warn the user.  Callers of this method 
264
     * should first check if the project name passed already exists 
265
     * in the workspace.
266
     * 
267
     * @param name initial project name for this page
268
     * 
269
     * @see IWorkspace#validateName(String, int)
270
     * 
271
     */
272
    public void setInitialProjectName(String name) {
273
        if (name == null) {
274
			initialProjectFieldValue = null;
275
		} else {
276
            initialProjectFieldValue = name.trim();
277
            if(locationArea != null) {
278
				locationArea.updateProjectName(name.trim());
279
			}
280
        }
281
    }
282
283
    /**
284
     * Set the location to the default location if we are set to useDefaults.
285
     */
286
    private void setLocationForSelection() {
287
    	locationArea.updateProjectName(getProjectNameFieldValue());
288
    }
289
290
  
291
    /**
292
     * Returns whether this page's controls currently all contain valid 
293
     * values.
294
     *
295
     * @return <code>true</code> if all controls are valid, and
296
     *   <code>false</code> if at least one is invalid
297
     */
298
    protected boolean validatePage() {
299
        IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
300
301
        String projectFieldContents = getProjectNameFieldValue();
302
        if (projectFieldContents.equals("")) { //$NON-NLS-1$
303
            setErrorMessage(null);
304
            setMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty);
305
            return false;
306
        }
307
308
        IStatus nameStatus = workspace.validateName(projectFieldContents,
309
                IResource.PROJECT);
310
        if (!nameStatus.isOK()) {
311
            setErrorMessage(nameStatus.getMessage());
312
            return false;
313
        }
314
315
        IProject handle = getProjectHandle();
316
        if (handle.exists()) {
317
            setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage);
318
            return false;
319
        }
320
                
321
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
322
				getProjectNameFieldValue());
323
		locationArea.setExistingProject(project);
324
		
325
		String validLocationMessage = locationArea.checkValidLocation();
326
		if (validLocationMessage != null) { // there is no destination location given
327
			setErrorMessage(validLocationMessage);
328
			return false;
329
		}
330
331
        setErrorMessage(null);
332
        setMessage(null);
333
        return true;
334
    }
335
336
    /*
337
     * see @DialogPage.setVisible(boolean)
338
     */
339
    public void setVisible(boolean visible) {
340
        getControl().setVisible(visible);
341
        if (visible) {
342
			projectNameField.setFocus();
343
		}
344
    }
345
346
    /**
347
     * Returns the useDefaults.
348
     * @return boolean
349
     */
350
    public boolean useDefaults() {
351
        return locationArea.isDefault();
352
    }
353
354
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/ProjectLocationServiceContributor.java (+39 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.jface.wizard.WizardPage;
14
import org.eclipse.ptp.services.core.IService;
15
import org.eclipse.ptp.services.ui.IServiceContributor;
16
17
/**
18
 * Allows the user to configure a project location.
19
 * 
20
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
21
 * part of a work in progress. There is no guarantee that this API will work or
22
 * that it will remain the same. Please do not use this API without consulting
23
 * with the RDT team.
24
 * 
25
 */
26
public class ProjectLocationServiceContributor implements IServiceContributor {
27
28
	public final static String SERVICE_ID = "org.eclipse.ptp.rdt.core.ProjectLocationService"; //$NON-NLS-1$
29
	
30
	public ProjectLocationServiceContributor() {
31
	}
32
33
	public WizardPage[] getWizardPages(IService service) {
34
		return new WizardPage[]{
35
				new ProjectLocationServiceWizardPage(service, "Project Location Configuration") //$NON-NLS-1$
36
			}; 
37
	}
38
39
}
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/RemoteCIndexServiceProvider.java (+96 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
import org.eclipse.ptp.internal.rdt.ui.contentassist.IContentAssistService;
14
import org.eclipse.ptp.internal.rdt.ui.contentassist.RemoteContentAssistService;
15
import org.eclipse.ptp.internal.rdt.ui.search.ISearchService;
16
import org.eclipse.ptp.internal.rdt.ui.search.RemoteSearchService;
17
import org.eclipse.ptp.rdt.ui.serviceproviders.IIndexServiceProvider2;
18
import org.eclipse.rse.connectorservice.dstore.DStoreConnectorService;
19
import org.eclipse.rse.core.model.IHost;
20
import org.eclipse.rse.core.model.SystemStartHere;
21
import org.eclipse.rse.core.subsystems.IConnectorService;
22
23
/**
24
 * An RSE-based provider of C/C++ indexing services.
25
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
26
 * part of a work in progress. There is no guarantee that this API will work or
27
 * that it will remain the same. Please do not use this API without consulting
28
 * with the RDT team.
29
 * 
30
 * @author crecoskie
31
 *
32
 */
33
public class RemoteCIndexServiceProvider extends AbstractRemoteCIndexServiceProvider implements IIndexServiceProvider2 {
34
35
	public static final String SERVICE_ID = "org.eclipse.ptp.rdt.ui.RemoteCIndexService"; //$NON-NLS-1$
36
	public static final String ID = "org.eclipse.ptp.rdt.ui.RemoteCIndexServiceProvider"; //$NON-NLS-1$
37
	
38
	private RemoteSearchService fSearchService;
39
	private IContentAssistService fContentAssistService;
40
	
41
	public RemoteCIndexServiceProvider() {
42
	}
43
44
	public synchronized ISearchService getSearchService() {
45
		if(!isConfigured())
46
			return null;
47
		
48
		if(fSearchService == null)
49
			fSearchService = new RemoteSearchService(fHost, fConnectorService);
50
		
51
		return fSearchService;
52
	}
53
54
	public synchronized IContentAssistService getContentAssistService() {
55
		if(!isConfigured())
56
			return null;
57
		
58
		if(fContentAssistService == null)
59
			fContentAssistService = new RemoteContentAssistService(fHost, fConnectorService);
60
		
61
		return fContentAssistService;
62
	}
63
	
64
	@Override
65
	public boolean isConfigured() {
66
		String hostName = getHostName();
67
		if (fHost == null && hostName != null) {
68
			IHost[] hosts = SystemStartHere.getConnections();
69
			for (IHost host : hosts) {
70
				if (host.getAliasName().equals(hostName)) {
71
					setConnection(host, getDStoreConnectorService(host));
72
				}
73
			}
74
		}
75
		return super.isConfigured();
76
	}
77
	
78
	public static IConnectorService getDStoreConnectorService(IHost host) {
79
		IConnectorService[] connectorServices = host.getConnectorServices();
80
		
81
		for(int k = 0; k < connectorServices.length; k++) {
82
			if(connectorServices[k] instanceof DStoreConnectorService)
83
				return connectorServices[k];
84
		}
85
		
86
		return null;
87
	}
88
	
89
	public String toString() {
90
		String hostName = getHostName();
91
		if (hostName == null) {
92
			hostName = "<not_configured>"; //$NON-NLS-1$
93
		}
94
		return "RemoteCIndexServiceProvider(" + hostName + ")"; //$NON-NLS-1$ //$NON-NLS-2$
95
	}
96
}
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/IRemoteServiceProvider.java (+58 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
import org.eclipse.ptp.remote.core.IRemoteConnection;
14
import org.eclipse.ptp.remote.core.IRemoteServices;
15
import org.eclipse.ptp.services.core.IServiceProvider;
16
17
/**
18
 * Provides execution services for shell commands over a remote connection, 
19
 * and remote file manipulation services.
20
 * 
21
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
22
 * part of a work in progress. There is no guarantee that this API will work or
23
 * that it will remain the same. Please do not use this API without consulting
24
 * with the RDT team.
25
 * 
26
 * @author crecoskie
27
 */
28
public interface IRemoteServiceProvider extends IServiceProvider {
29
	
30
	/**
31
	 * Gets the provider of remote services.
32
	 * 
33
	 * @return IRemoteServices
34
	 */
35
	public IRemoteServices getRemoteServices();
36
	
37
	/**
38
	 * Gets the connection to use for this service.  The connection may not be open, so
39
	 * clients should check to make sure it is open before using it.
40
	 * 
41
	 * @return IRemoteConnection
42
	 */
43
	public IRemoteConnection getConnection();
44
	
45
	/**
46
	 * Sets the connection that this provider should use for its execution services.
47
	 * 
48
	 * @param connection
49
	 */
50
	public void setRemoteConnectionName(String name);
51
52
	/**
53
	 * Sets the ID of the Remote Tools provider that this provider should use for its execution services.
54
	 * 
55
	 * @param id
56
	 */
57
	public void setRemoteServicesID(String id);
58
}
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/LocalBuildServiceProvider.java (+40 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
import org.eclipse.ptp.services.core.ServiceProvider;
14
15
/**
16
 * A build service provider that does nothing.
17
 * 
18
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
19
 * part of a work in progress. There is no guarantee that this API will work or
20
 * that it will remain the same. Please do not use this API without consulting
21
 * with the RDT team.
22
 * 
23
 * @author vkong
24
 *
25
 */
26
public class LocalBuildServiceProvider extends ServiceProvider {
27
	
28
	public static final String ID = "org.eclipse.ptp.rdt.ui.LocalBuildServiceProvider"; //$NON-NLS-1$
29
	public static final String SERVICE_ID = "org.eclipse.ptp.rdt.core.BuildService"; //$NON-NLS-1$
30
31
	public LocalBuildServiceProvider() {
32
	}
33
	
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.ptp.services.core.IServiceProvider#isConfigured()
36
	 */
37
	public boolean isConfigured() {
38
		return true;
39
	}
40
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/NewHPCProjectWizard.java (+93 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.cdt.core.CCProjectNature;
14
import org.eclipse.cdt.core.CProjectNature;
15
import org.eclipse.cdt.ui.CUIPlugin;
16
import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.NullProgressMonitor;
20
import org.eclipse.ptp.internal.rdt.ui.RDTPluginImages;
21
import org.eclipse.ptp.rdt.core.resources.RemoteNature;
22
import org.eclipse.ptp.rdt.ui.wizards.RDTMainWizardPage;
23
24
/**
25
 * A wizard for creating new Remote C/C++ Projects
26
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
27
 * part of a work in progress. There is no guarantee that this API will work or
28
 * that it will remain the same. Please do not use this API without consulting
29
 * with the RDT team.
30
 * 
31
 * @author crecoskie
32
 *
33
 */
34
public class NewHPCProjectWizard extends CDTCommonProjectWizard {
35
	private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
36
	private static final String wz_title = "New HPC Project"; //$NON-NLS-1$
37
	private static final String wz_desc = "Create HPC Project of the selected type"; //$NON-NLS-1$
38
	
39
	/**
40
	 * 
41
	 */
42
	public NewHPCProjectWizard() {
43
		
44
		super(wz_title, wz_desc);
45
	}
46
47
48
	/* (non-Javadoc)
49
	 * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#continueCreation(org.eclipse.core.resources.IProject)
50
	 */
51
	
52
	@Override
53
	protected IProject continueCreation(IProject prj) {
54
		try {
55
			CProjectNature.addCNature(prj, new NullProgressMonitor());
56
			CCProjectNature.addCCNature(prj, new NullProgressMonitor());
57
			RemoteNature.addRemoteNature(prj, new NullProgressMonitor());
58
		} catch (CoreException e) {}
59
		return prj;
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#getNatures()
64
	 */
65
	@Override
66
	public String[] getNatures() {
67
		return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID, RemoteNature.REMOTE_NATURE_ID};
68
	}
69
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.ui.wizards.newresource.BasicNewResourceWizard#initializeDefaultPageImageDescriptor()
73
	 */
74
	@Override
75
	protected void initializeDefaultPageImageDescriptor() {
76
		setDefaultPageImageDescriptor(RDTPluginImages.DESC_WIZBAN_NEW_REMOTE_C_PROJ);
77
	}
78
79
80
	/* (non-Javadoc)
81
	 * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#addPages()
82
	 */
83
	@Override
84
	public void addPages() {
85
		fMainPage= new RDTMainWizardPage(CUIPlugin.getResourceString(PREFIX));
86
		fMainPage.setTitle(wz_title);
87
		fMainPage.setDescription(wz_desc);
88
		addPage(fMainPage);
89
	}
90
	
91
	
92
93
}
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/LocalProjectServiceProvider.java (+32 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
14
/**
15
 * A project location service provider that is local.
16
 * 
17
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
18
 * part of a work in progress. There is no guarantee that this API will work or
19
 * that it will remain the same. Please do not use this API without consulting
20
 * with the RDT team.
21
 * 
22
 */
23
public class LocalProjectServiceProvider extends AbstractRemoteServicesProvider {
24
	public final static String ID = "org.eclipse.ptp.rdt.ui.LocalProjectLocationProvider"; //$NON-NLS-1$
25
26
	/* (non-Javadoc)
27
	 * @see org.eclipse.ptp.services.core.IServiceProvider#isConfigured()
28
	 */
29
	public boolean isConfigured() {
30
		return true;
31
	}
32
}
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/RemoteBuildServiceProvider.java (+44 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
import org.eclipse.ptp.rdt.ui.messages.Messages;
14
import org.eclipse.ptp.remote.core.IRemoteConnection;
15
16
/**
17
 * A build service provider that uses the Remote Tools API to provide execution services.
18
 *  
19
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
20
 * part of a work in progress. There is no guarantee that this API will work or
21
 * that it will remain the same. Please do not use this API without consulting
22
 * with the RDT team.
23
 * 
24
 * @author crecoskie
25
 */
26
public class RemoteBuildServiceProvider extends AbstractRemoteServicesProvider  {
27
	
28
	public static final String ID = "org.eclipse.ptp.rdt.ui.RemoteBuildServiceProvider"; //$NON-NLS-1$
29
	public static final String SERVICE_ID = "org.eclipse.ptp.rdt.core.BuildService"; //$NON-NLS-1$
30
	public static final String NAME = Messages.getString("RemoteBuildServiceProvider.0"); //$NON-NLS-1$
31
32
	public RemoteBuildServiceProvider() {
33
	}
34
	
35
	public String toString() {
36
		IRemoteConnection conn = getConnection();
37
		String name = "<not_configured>"; //$NON-NLS-1$
38
		if (conn != null) {
39
			name = conn.getName();
40
		}
41
		return "RemoteBuildServiceProvider(" + name + ")"; //$NON-NLS-1$ //$NON-NLS-2$
42
	}
43
44
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/ServiceModelWizardPage.java (+274 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import java.net.URI;
14
15
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage;
16
import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager;
17
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.wizard.IWizard;
19
import org.eclipse.ptp.internal.rdt.ui.RDTHelpContextIds;
20
import org.eclipse.ptp.rdt.core.services.IRDTServiceConstants;
21
import org.eclipse.ptp.rdt.ui.messages.Messages;
22
import org.eclipse.ptp.rdt.ui.newserviceproviders.IRemoteServiceProvider;
23
import org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteBuildServiceProvider;
24
import org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteCIndexServiceProvider;
25
import org.eclipse.ptp.rdt.ui.newserviceproviders.RemoteProjectServiceProvider;
26
import org.eclipse.ptp.remote.core.IRemoteConnection;
27
import org.eclipse.ptp.remote.core.IRemoteServices;
28
import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin;
29
import org.eclipse.ptp.services.core.IService;
30
import org.eclipse.ptp.services.core.IServiceConfiguration;
31
import org.eclipse.ptp.services.core.ServiceModelManager;
32
import org.eclipse.ptp.services.ui.wizards.ServiceModelWidget;
33
import org.eclipse.swt.graphics.Image;
34
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Control;
36
import org.eclipse.swt.widgets.Event;
37
import org.eclipse.swt.widgets.Listener;
38
import org.eclipse.ui.PlatformUI;
39
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
40
41
/**
42
 * 
43
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
44
 * part of a work in progress. There is no guarantee that this API will work or
45
 * that it will remain the same. Please do not use this API without consulting
46
 * with the RDT team.
47
 * 
48
 * @author crecoskie
49
 *
50
 */
51
public class ServiceModelWizardPage extends MBSCustomPage {
52
53
	public static final String SERVICE_MODEL_WIZARD_PAGE_ID = "org.eclipse.ptp.rdt.ui.serviceModelWizardPage"; //$NON-NLS-1$
54
	public static final String SERVICE_CONFIGURATION_PROPERTY = "org.eclipse.ptp.rdt.ui.ServiceModelWizardPage.serviceConfiguration"; //$NON-NLS-1$
55
56
	boolean fbVisited;
57
	
58
	private String fTitle;
59
	
60
	private String fDescription;
61
	
62
	private ImageDescriptor fImageDescriptor;
63
	
64
	private Image fImage;
65
	
66
	private Control fCanvas;
67
	
68
	ServiceModelWidget fModelWidget;
69
	
70
	/**
71
	 * @param pageID
72
	 */
73
	public ServiceModelWizardPage(String pageID) {
74
		super(pageID);
75
		fModelWidget = new ServiceModelWidget(null);
76
		fModelWidget.setConfigChangeListener(new Listener() {
77
			public void handleEvent(Event event) {
78
				getWizard().getContainer().updateButtons();				
79
			}			
80
		});
81
	}
82
83
	/**
84
	 * 
85
	 */
86
	public ServiceModelWizardPage() {
87
		this(SERVICE_MODEL_WIZARD_PAGE_ID);
88
	}
89
90
	/* (non-Javadoc)
91
	 * @see org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage#isCustomPageComplete()
92
	 */
93
	protected boolean isCustomPageComplete() {
94
		return fbVisited && fModelWidget.isConfigured();
95
	}
96
97
	/* (non-Javadoc)
98
	 * @see org.eclipse.jface.wizard.IWizardPage#getName()
99
	 */
100
	public String getName() {
101
		return Messages.getString("ServiceModelWizardPage_0"); //$NON-NLS-1$
102
	}
103
104
	/* (non-Javadoc)
105
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
106
	 */
107
	public void createControl(Composite parent) {
108
		fCanvas = fModelWidget.createContents(parent);
109
		IServiceConfiguration config = createServiceConfiguration();
110
		fModelWidget.setServiceConfiguration(config);
111
		MBSCustomPageManager.addPageProperty(pageID, SERVICE_CONFIGURATION_PROPERTY, config);
112
		Control control = fCanvas.getParent().getShell(); //get the shell or doesn't display help correctly
113
		PlatformUI.getWorkbench().getHelpSystem().setHelp(control,RDTHelpContextIds.SERVICE_MODEL_WIZARD);
114
	}
115
116
	/* (non-Javadoc)
117
	 * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
118
	 */
119
	public void dispose() {
120
		// TODO Auto-generated method stub
121
122
	}
123
124
	/* (non-Javadoc)
125
	 * @see org.eclipse.jface.dialogs.IDialogPage#getControl()
126
	 */
127
	public Control getControl() {
128
		return fCanvas;
129
	}
130
131
	/* (non-Javadoc)
132
	 * @see org.eclipse.jface.dialogs.IDialogPage#getDescription()
133
	 */
134
	public String getDescription() {
135
		if (fDescription == null)
136
			fDescription = Messages.getString("ServiceModelWizardPage_description"); //$NON-NLS-1$
137
		return fDescription;
138
	}
139
140
	/* (non-Javadoc)
141
	 * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
142
	 */
143
	public String getErrorMessage() {
144
		// TODO Auto-generated method stub
145
		return null;
146
	}
147
148
	/* (non-Javadoc)
149
	 * @see org.eclipse.jface.dialogs.IDialogPage#getImage()
150
	 */
151
	public Image getImage() {
152
		if(fImage == null && fImageDescriptor != null)
153
			fImage = fImageDescriptor.createImage();
154
		
155
		if (fImage == null && wizard != null) {
156
			fImage = wizard.getDefaultPageImage();
157
		}
158
		
159
		return fImage;
160
	}
161
162
	/* (non-Javadoc)
163
	 * @see org.eclipse.jface.dialogs.IDialogPage#getMessage()
164
	 */
165
	public String getMessage() {
166
		// TODO Auto-generated method stub
167
		return null;
168
	}
169
170
	/* (non-Javadoc)
171
	 * @see org.eclipse.jface.dialogs.IDialogPage#getTitle()
172
	 */
173
	public String getTitle() {
174
		if (fTitle == null)
175
			fTitle = Messages.getString("ServiceModelWizardPage_0"); //$NON-NLS-1$
176
		return fTitle;
177
	}
178
179
	/* (non-Javadoc)
180
	 * @see org.eclipse.jface.dialogs.IDialogPage#performHelp()
181
	 */
182
	public void performHelp() {
183
		// TODO Auto-generated method stub
184
185
	}
186
187
	/* (non-Javadoc)
188
	 * @see org.eclipse.jface.dialogs.IDialogPage#setDescription(java.lang.String)
189
	 */
190
	public void setDescription(String description) {
191
		fDescription = description;
192
	}
193
194
	/* (non-Javadoc)
195
	 * @see org.eclipse.jface.dialogs.IDialogPage#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
196
	 */
197
	public void setImageDescriptor(ImageDescriptor image) {
198
		fImageDescriptor = image;
199
200
	}
201
202
	/* (non-Javadoc)
203
	 * @see org.eclipse.jface.dialogs.IDialogPage#setTitle(java.lang.String)
204
	 */
205
	public void setTitle(String title) {
206
		fTitle = title;
207
208
	}
209
210
	/* (non-Javadoc)
211
	 * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
212
	 */
213
	public void setVisible(boolean visible) {
214
		if(visible) {
215
			fbVisited = true;
216
		}
217
		fCanvas.setVisible(visible);
218
	}
219
220
	private IServiceConfiguration createServiceConfiguration() {
221
		ServiceModelManager manager = ServiceModelManager.getInstance();
222
		IWizard wizard = getWizard();
223
		if (!(wizard.getStartingPage() instanceof WizardNewProjectCreationPage)) {
224
			return null;
225
		}
226
		
227
		String name = ((WizardNewProjectCreationPage)wizard.getStartingPage()).getProjectName();
228
		URI location = ((WizardNewProjectCreationPage)wizard.getStartingPage()).getLocationURI();
229
230
		/*
231
		 * Create a new service configuration
232
		 * 
233
		 * XXX: this should check if a service configuration has already
234
		 * 		been selected, in which case it should use that one.
235
		 */
236
		IServiceConfiguration config = manager.newServiceConfiguration(name);
237
		
238
		/*
239
		 * Set default service providers based on location of project
240
		 */
241
		IRemoteServices remServ = PTPRemoteCorePlugin.getDefault().getRemoteServices(location);
242
		IRemoteConnection remConn = PTPRemoteCorePlugin.getDefault().getConnection(location);
243
		
244
		/*
245
		 * Project location
246
		 */
247
		IService projectService = manager.getService(IRDTServiceConstants.SERVICE_PROJECT);
248
		IRemoteServiceProvider projectProvider = (IRemoteServiceProvider) manager.getServiceProvider(projectService.getProviderDescriptor(RemoteProjectServiceProvider.ID));
249
		projectProvider.setRemoteServicesID(remServ.getId());
250
		projectProvider.setRemoteConnectionName(remConn.getName());
251
		config.setServiceProvider(projectService, projectProvider);
252
253
		/*
254
		 * Build service
255
		 */
256
		IService buildService = manager.getService(IRDTServiceConstants.SERVICE_BUILD);
257
		IRemoteServiceProvider buildProvider = (IRemoteServiceProvider) manager.getServiceProvider(buildService.getProviderDescriptor(RemoteBuildServiceProvider.ID));
258
		buildProvider.setRemoteServicesID(remServ.getId());
259
		buildProvider.setRemoteConnectionName(remConn.getName());
260
		config.setServiceProvider(buildService, buildProvider);
261
262
		/*
263
		 * Index service
264
		 */
265
		IService indexService = manager.getService(IRDTServiceConstants.SERVICE_C_INDEX);
266
		IRemoteServiceProvider indexProvider = (IRemoteServiceProvider) manager.getServiceProvider(indexService.getProviderDescriptor(RemoteCIndexServiceProvider.ID));
267
		indexProvider.setRemoteServicesID(remServ.getId());
268
		indexProvider.setRemoteConnectionName(remConn.getName());
269
		config.setServiceProvider(indexService, indexProvider);
270
		
271
		return config;
272
	}
273
274
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/CIndexingServiceWizardPage.java (+98 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.ptp.rdt.ui.newserviceproviders.LocalCIndexServiceProvider;
14
import org.eclipse.ptp.rdt.ui.newserviceproviders.LocalProjectServiceProvider;
15
import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteCIndexServiceProvider;
16
import org.eclipse.ptp.services.core.IService;
17
import org.eclipse.ptp.services.core.IServiceConfiguration;
18
import org.eclipse.ptp.services.core.IServiceProvider;
19
import org.eclipse.ptp.services.core.ServiceModelManager;
20
import org.eclipse.ptp.services.ui.wizards.ServiceConfigurationWizard;
21
import org.eclipse.ptp.services.ui.wizards.ServiceConfigurationWizardPage;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridLayout;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Label;
27
28
/**
29
 * Allows the user to select remote or local indexing.
30
 * 
31
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
32
 * part of a work in progress. There is no guarantee that this API will work or
33
 * that it will remain the same. Please do not use this API without consulting
34
 * with the RDT team.
35
 * 
36
 *
37
 */
38
public class CIndexingServiceWizardPage extends ServiceConfigurationWizardPage {
39
	public CIndexingServiceWizardPage(IService service, String pageName) {
40
		super(service, pageName);
41
		setTitle(pageName);
42
		setDescription("This page allows you to set the location where your project will be indexed."); //$NON-NLS-1$
43
	}
44
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.ptp.services.ui.wizards.ServiceConfigurationWizardPage#createControl(org.eclipse.swt.widgets.Composite)
47
	 */
48
	@Override
49
	public void createControl(Composite parent) {
50
        Composite container = new Composite(parent, SWT.NONE);
51
52
        GridLayout layout = new GridLayout();
53
        layout.numColumns = 1;
54
        container.setLayout(layout);
55
56
        Label label = new Label(container, SWT.LEFT);
57
        label.setText("The index location should normally be the same as the location of the project source files, which is the default."); //$NON-NLS-1$
58
        GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
59
        label.setLayoutData(data);
60
        
61
        Label label2 = new Label(container, SWT.LEFT);
62
        label2.setText("Only change this if you know what your are doing."); //$NON-NLS-1$
63
        GridData data2 = new GridData(SWT.FILL, SWT.FILL, true, false);
64
        label.setLayoutData(data2);
65
66
        super.createControl(container);
67
		
68
		setControl(container);
69
		
70
		setDefaultProvider(getService());
71
	}
72
	
73
	/**
74
	 * Set the default service provider based on the project location service
75
	 * 
76
	 * @param service
77
	 */
78
	private void setDefaultProvider(IService service) {
79
		IServiceConfiguration config = ((ServiceConfigurationWizard)getWizard()).getServiceConfiguration();
80
		IService projectLocationService = ServiceModelManager.getInstance().getService(ProjectLocationServiceContributor.SERVICE_ID);
81
		if (projectLocationService != null) {
82
			String providerID = null;
83
			IServiceProvider projectLocationProvider = config.getServiceProvider(projectLocationService);
84
			if (projectLocationProvider.getId().equals(LocalProjectServiceProvider.ID)) {
85
				providerID = LocalCIndexServiceProvider.ID;
86
			} else if (projectLocationProvider.getId().equals(LocalProjectServiceProvider.ID)) {
87
				providerID = RemoteCIndexServiceProvider.ID;
88
			}
89
			if (providerID != null) {
90
				IServiceProvider provider = ServiceModelManager.getInstance().getServiceProvider(service.getProviderDescriptor(providerID));
91
				if (provider != null) {
92
					config.setServiceProvider(service, provider);
93
				}
94
			}
95
		}
96
	}
97
	
98
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteCIndexConfigurationWizardPage.java (+168 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
16
import org.eclipse.jface.wizard.IWizard;
17
import org.eclipse.jface.wizard.WizardDialog;
18
import org.eclipse.ptp.rdt.ui.messages.Messages;
19
import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteCIndexServiceProvider;
20
import org.eclipse.ptp.services.ui.wizards.ServiceProviderConfigurationWizardPage;
21
import org.eclipse.rse.connectorservice.dstore.DStoreConnectorService;
22
import org.eclipse.rse.core.model.IHost;
23
import org.eclipse.rse.core.model.SystemStartHere;
24
import org.eclipse.rse.core.subsystems.IConnectorService;
25
import org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard;
26
import org.eclipse.rse.ui.wizards.newconnection.RSEMainNewConnectionWizard;
27
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.events.SelectionAdapter;
29
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridLayout;
33
import org.eclipse.swt.widgets.Button;
34
import org.eclipse.swt.widgets.Combo;
35
import org.eclipse.swt.widgets.Composite;
36
import org.eclipse.swt.widgets.Label;
37
38
/**
39
 * Allows the configure a RemoteCIndexServiceProvider.
40
 * 
41
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
42
 * part of a work in progress. There is no guarantee that this API will work or
43
 * that it will remain the same. Please do not use this API without consulting
44
 * with the RDT team.
45
 * 
46
 * @author crecoskie
47
 * @see org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider
48
 *
49
 */
50
public class RemoteCIndexConfigurationWizardPage extends ServiceProviderConfigurationWizardPage {
51
	private Map<Integer, IHost> fHostComboIndexToHostMap = new HashMap<Integer, IHost>();
52
	private IHost fSelectedHost;
53
	private RemoteCIndexServiceProvider fProvider;
54
55
	public RemoteCIndexConfigurationWizardPage(RemoteCIndexServiceProvider provider, String pageName) {
56
		super(pageName);
57
		this.fProvider = provider;
58
		setTitle(pageName);
59
		setDescription(Messages.getString("HostSelectionDialog.1")); //$NON-NLS-1$
60
	}
61
62
	@Override
63
	public void createControl(Composite parent) {
64
        Composite container = new Composite(parent, SWT.NONE);
65
66
        GridLayout layout = new GridLayout();
67
        layout.numColumns = 3;
68
        container.setLayout(layout);
69
        setControl(container);
70
   
71
        Label label1 = new Label(container, SWT.LEFT);
72
        label1.setText("The Remote C/C++ Indexer currently only supports RSE connections."); //$NON-NLS-1$
73
        GridData data = new GridData();
74
        data.horizontalSpan = 3;
75
        label1.setLayoutData(data);
76
77
        Label label2 = new Label(container, SWT.LEFT);
78
        label2.setText("Select a host from the list below, or create a new host by selecting the \"New\" button."); //$NON-NLS-1$
79
        GridData data2 = new GridData();
80
        data2.horizontalSpan = 3;
81
        label2.setLayoutData(data2);
82
        
83
        // Label for "Host:"
84
        Label hostLabel = new Label(container, SWT.LEFT);
85
        hostLabel.setText(Messages.getString("HostSelectionDialog_0")); //$NON-NLS-1$
86
        
87
        // combo for hosts
88
        final Combo hostCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
89
        // set layout to grab horizontal space
90
        hostCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
91
        
92
        //attempt to restore settings from saved state
93
        IHost hostSelected = fProvider.getHost();
94
        
95
        // populate the combo with a list of hosts
96
        IHost[] hosts = SystemStartHere.getConnections();
97
        int toSelect = 0;
98
        
99
        for(int k = 0; k < hosts.length; k++) {
100
        	hostCombo.add(hosts[k].getAliasName(), k);
101
        	fHostComboIndexToHostMap.put(k, hosts[k]);
102
        	
103
        	if (hostSelected != null && hostSelected.getAliasName().compareTo(hosts[k].getAliasName()) == 0) {
104
        		toSelect = k;
105
        	}
106
        }
107
        
108
        // set selected host to be the first one if we're not restoring from settings
109
        hostCombo.select(toSelect);
110
        fSelectedHost = fHostComboIndexToHostMap.get(toSelect);
111
        
112
        
113
        hostCombo.addSelectionListener(new SelectionListener() {
114
115
			public void widgetDefaultSelected(SelectionEvent e) {
116
				widgetSelected(e);
117
			}
118
119
			public void widgetSelected(SelectionEvent e) {
120
				int selectionIndex = hostCombo.getSelectionIndex();
121
				fSelectedHost = fHostComboIndexToHostMap.get(selectionIndex);
122
				fProvider.setConnection(fSelectedHost, getDStoreConnectorService(fSelectedHost));
123
				fProvider.setConfigured(true);
124
			}
125
        	
126
        });
127
        
128
        // button for creating new connections
129
        Button newConnectionButton = new Button(container, SWT.PUSH);
130
        newConnectionButton.setText(Messages.getString("HostSelectionDialog.0")); //$NON-NLS-1$
131
        newConnectionButton.addSelectionListener(new SelectionAdapter() {
132
133
			public void widgetSelected(SelectionEvent e) {
134
				// launch the RSE New Connection Wizard
135
				RSEMainNewConnectionWizard wizard = new RSEMainNewConnectionWizard();
136
				WizardDialog wizardDialog = new WizardDialog(getShell(), wizard);
137
				wizardDialog.open();
138
				
139
				IWizard actualWizard = wizard.getSelectedWizard();
140
				if(actualWizard instanceof RSEDefaultNewConnectionWizard) {
141
					// get the new host, if any
142
					IHost host = ((RSEDefaultNewConnectionWizard)actualWizard).getCreatedHost();
143
					
144
					// add the host
145
					int index = hostCombo.getItemCount() - 1;
146
					hostCombo.add(host.getAliasName(), index);
147
		        	fHostComboIndexToHostMap.put(index, host);
148
		        	
149
		        	// select the new host
150
		        	hostCombo.select(index);
151
		            fSelectedHost = host;
152
				}
153
			}
154
        	
155
        });
156
	}
157
	
158
	private IConnectorService getDStoreConnectorService(IHost host) {
159
		IConnectorService[] connectorServices = host.getConnectorServices();
160
		
161
		for(int k = 0; k < connectorServices.length; k++) {
162
			if(connectorServices[k] instanceof DStoreConnectorService)
163
				return connectorServices[k];
164
		}
165
		
166
		return null;
167
	}
168
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteServicesConfigurationWizardPage.java (+211 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import java.util.HashMap;
14
import java.util.Map;
15
16
import org.eclipse.ptp.rdt.ui.messages.Messages;
17
import org.eclipse.ptp.rdt.ui.newserviceproviders.AbstractRemoteServicesProvider;
18
import org.eclipse.ptp.remote.core.IRemoteConnection;
19
import org.eclipse.ptp.remote.core.IRemoteServices;
20
import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin;
21
import org.eclipse.ptp.remote.ui.IRemoteUIConnectionManager;
22
import org.eclipse.ptp.remote.ui.PTPRemoteUIPlugin;
23
import org.eclipse.ptp.services.ui.wizards.ServiceProviderConfigurationWizardPage;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.SelectionEvent;
26
import org.eclipse.swt.events.SelectionListener;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Combo;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Label;
33
34
/**
35
 * Allows the user to select a provider of Remote Services for a RemoteBuildServiceProvider.
36
 * 
37
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
38
 * part of a work in progress. There is no guarantee that this API will work or
39
 * that it will remain the same. Please do not use this API without consulting
40
 * with the RDT team.
41
 * 
42
 * @author crecoskie
43
 * @see org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider
44
 *
45
 */
46
public class RemoteServicesConfigurationWizardPage extends ServiceProviderConfigurationWizardPage {
47
	private AbstractRemoteServicesProvider fProvider;
48
	private Map<Integer, IRemoteServices> fComboIndexToRemoteServicesProviderMap = new HashMap<Integer, IRemoteServices>();
49
	private IRemoteServices fSelectedProvider;
50
	private Map<Integer, IRemoteConnection> fComboIndexToRemoteConnectionMap = new HashMap<Integer, IRemoteConnection>();
51
	private IRemoteConnection fSelectedConnection;
52
53
	public RemoteServicesConfigurationWizardPage(AbstractRemoteServicesProvider provider, String pageName) {
54
		super(pageName);
55
		this.fProvider = provider;
56
		setTitle(pageName);
57
		setDescription(Messages.getString("RemoteServicesProviderSelectionDialog_0")); //$NON-NLS-1$
58
	}
59
60
	@Override
61
	public void createControl(Composite parent) {
62
        Composite container = new Composite(parent, SWT.NONE);
63
64
        GridLayout layout = new GridLayout();
65
        layout.numColumns = 3;
66
        container.setLayout(layout);
67
        setControl(container);
68
        
69
        // Label for "Provider:"
70
        Label providerLabel = new Label(container, SWT.LEFT);
71
        providerLabel.setText(Messages.getString("RemoteServicesProviderSelectionDialog_1")); //$NON-NLS-1$
72
        
73
        // combo for providers
74
        final Combo providerCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
75
        // set layout to grab horizontal space
76
        GridData data = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
77
        data.horizontalSpan = 2;
78
        providerCombo.setLayoutData(data);
79
        
80
        //attempt to restore settings from saved state
81
        IRemoteServices providerSelected = fProvider.getRemoteServices();
82
        
83
        // populate the combo with a list of providers
84
        IRemoteServices[] providers = PTPRemoteCorePlugin.getDefault().getAllRemoteServices();
85
        int toSelect = 0;
86
        
87
        for(int k = 0; k < providers.length; k++) {
88
        	providerCombo.add(providers[k].getName(), k);
89
        	fComboIndexToRemoteServicesProviderMap.put(k, providers[k]);
90
        	
91
        	if (providerSelected != null && providerSelected.getName().compareTo(providers[k].getName()) == 0) {
92
        		toSelect = k;
93
        	}
94
        }
95
        
96
        // set selected host to be the first one if we're not restoring from settings
97
        providerCombo.select(toSelect);
98
        fSelectedProvider = fComboIndexToRemoteServicesProviderMap.get(toSelect);
99
            
100
        // connection combo
101
        // Label for "Connection:"
102
        Label connectionLabel = new Label(container, SWT.LEFT);
103
        connectionLabel.setText(Messages.getString("RemoteServicesProviderSelectionDialog.0")); //$NON-NLS-1$
104
        
105
        // combo for providers
106
        final Combo connectionCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
107
        // set layout to grab horizontal space
108
        connectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
109
        
110
        // populate the combo with a list of providers
111
        populateConnectionCombo(connectionCombo);
112
           
113
        // new connection button
114
        final Button newConnectionButton = new Button(container, SWT.PUSH);
115
        newConnectionButton.setText(Messages.getString("RemoteServicesProviderSelectionDialog.1")); //$NON-NLS-1$
116
        updateNewConnectionButtonEnabled(newConnectionButton);
117
        
118
        newConnectionButton.addSelectionListener(new SelectionListener() {
119
120
			public void widgetDefaultSelected(SelectionEvent e) {
121
				widgetSelected(e);
122
			}
123
124
			public void widgetSelected(SelectionEvent e) {
125
				
126
				IRemoteUIConnectionManager connectionManager = getUIConnectionManager();
127
				if(connectionManager != null) {
128
					connectionManager.newConnection(getShell());
129
				}
130
				
131
				// refresh list of connections
132
				populateConnectionCombo(connectionCombo);
133
			}
134
        	
135
        });
136
        
137
        providerCombo.addSelectionListener(new SelectionListener() {
138
139
			public void widgetDefaultSelected(SelectionEvent e) {
140
				widgetSelected(e);
141
			}
142
143
			public void widgetSelected(SelectionEvent e) {
144
				int selectionIndex = providerCombo.getSelectionIndex();
145
				fSelectedProvider = fComboIndexToRemoteServicesProviderMap.get(selectionIndex);
146
				
147
				populateConnectionCombo(connectionCombo);
148
				updateNewConnectionButtonEnabled(newConnectionButton);
149
				fProvider.setRemoteServicesID(fSelectedProvider.getId());
150
				if (fSelectedConnection != null) {
151
					fProvider.setRemoteConnectionName(fSelectedConnection.getName());
152
					setPageComplete(true);
153
				}
154
			}
155
        	
156
        });
157
        
158
        connectionCombo.addSelectionListener(new SelectionListener() {
159
160
			public void widgetDefaultSelected(SelectionEvent e) {
161
				widgetSelected(e);
162
			}
163
164
			public void widgetSelected(SelectionEvent e) {
165
				int selectionIndex = connectionCombo.getSelectionIndex();
166
				fSelectedConnection = fComboIndexToRemoteConnectionMap.get(selectionIndex);
167
				updateNewConnectionButtonEnabled(newConnectionButton);
168
				fProvider.setRemoteConnectionName(fSelectedConnection.getName());
169
				setPageComplete(true);
170
			}
171
        	
172
        });
173
	}
174
	
175
	private IRemoteUIConnectionManager getUIConnectionManager() {
176
		IRemoteUIConnectionManager connectionManager = PTPRemoteUIPlugin.getDefault().getRemoteUIServices(fSelectedProvider)
177
				.getUIConnectionManager();
178
		return connectionManager;
179
	}
180
	
181
	/**
182
	 * @param connectionCombo
183
	 */
184
	private void populateConnectionCombo(final Combo connectionCombo) {
185
		connectionCombo.removeAll();
186
		
187
		//attempt to restore settings from saved state
188
        IRemoteConnection connectionSelected = fProvider.getConnection();
189
		
190
		IRemoteConnection[] connections = fSelectedProvider.getConnectionManager().getConnections();
191
		int toSelect = 0;
192
        
193
        for(int k = 0; k < connections.length; k++) {
194
        	connectionCombo.add(connections[k].getName(), k);
195
        	fComboIndexToRemoteConnectionMap.put(k, connections[k]);
196
        	
197
        	if (connectionSelected != null && connectionSelected.getName().compareTo(connections[k].getName()) == 0) {
198
        		toSelect = k;
199
        	}
200
        }
201
        
202
        // set selected connection to be the first one if we're not restoring from settings
203
        connectionCombo.select(toSelect);
204
        fSelectedConnection = fComboIndexToRemoteConnectionMap.get(toSelect);
205
	}
206
	
207
	private void updateNewConnectionButtonEnabled(Button button) {
208
		IRemoteUIConnectionManager connectionManager = getUIConnectionManager();
209
		button.setEnabled(connectionManager != null);  	
210
	}
211
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteProjectContentsLocationArea.java (+475 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.net.URI;
15
import java.util.HashMap;
16
import java.util.Map;
17
18
import org.eclipse.core.filesystem.URIUtil;
19
import org.eclipse.core.resources.IProject;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.Path;
24
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.jface.dialogs.ErrorDialog;
27
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
28
import org.eclipse.jface.operation.IRunnableWithProgress;
29
import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider;
30
import org.eclipse.ptp.remote.core.IRemoteConnection;
31
import org.eclipse.ptp.remote.core.IRemoteServices;
32
import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin;
33
import org.eclipse.ptp.remote.core.exception.RemoteConnectionException;
34
import org.eclipse.ptp.remote.ui.IRemoteUIConnectionManager;
35
import org.eclipse.ptp.remote.ui.IRemoteUIFileManager;
36
import org.eclipse.ptp.remote.ui.IRemoteUIServices;
37
import org.eclipse.ptp.remote.ui.PTPRemoteUIPlugin;
38
import org.eclipse.ptp.services.ui.Activator;
39
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.events.ModifyEvent;
41
import org.eclipse.swt.events.ModifyListener;
42
import org.eclipse.swt.events.SelectionEvent;
43
import org.eclipse.swt.events.SelectionListener;
44
import org.eclipse.swt.layout.GridData;
45
import org.eclipse.swt.layout.GridLayout;
46
import org.eclipse.swt.widgets.Button;
47
import org.eclipse.swt.widgets.Combo;
48
import org.eclipse.swt.widgets.Composite;
49
import org.eclipse.swt.widgets.Control;
50
import org.eclipse.swt.widgets.Group;
51
import org.eclipse.swt.widgets.Label;
52
import org.eclipse.swt.widgets.Text;
53
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
54
import org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils;
55
56
/**
57
 * Allows the user to select a provider of Remote Services for a RemoteBuildServiceProvider.
58
 * 
59
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
60
 * part of a work in progress. There is no guarantee that this API will work or
61
 * that it will remain the same. Please do not use this API without consulting
62
 * with the RDT team.
63
 * 
64
 * @author crecoskie
65
 * @see org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider
66
 */
67
public class RemoteProjectContentsLocationArea {
68
69
	/**
70
	 * IErrorMessageReporter is an interface for type that allow message
71
	 * reporting.
72
	 * 
73
	 */
74
	public interface IErrorMessageReporter {
75
		/**
76
		 * Report the error message
77
		 * 
78
		 * @param errorMessage
79
		 *            String or <code>null</code>. If the errorMessage is
80
		 *            null then clear any error state.
81
		 * @param infoOnly
82
		 *            the message is an informational message, but the dialog
83
		 *            cannot continue
84
		 * 
85
		 */
86
		public void reportError(String errorMessage, boolean infoOnly);
87
	}
88
	
89
	private static final String FILE_SCHEME = "file"; //$NON-NLS-1$
90
91
	private IProject fExistingProject;
92
93
	private IErrorMessageReporter fErrorReporter;
94
95
	private RemoteBuildServiceProvider fProvider;
96
	
97
	private Map<Integer, IRemoteServices> fComboIndexToRemoteServicesProviderMap = new HashMap<Integer, IRemoteServices>();
98
	
99
	private IRemoteServices fSelectedProvider;
100
101
	private Map<Integer, IRemoteConnection> fComboIndexToRemoteConnectionMap = new HashMap<Integer, IRemoteConnection>();
102
103
	private IRemoteConnection fSelectedConnection;
104
105
	private String fProjectName = IDEResourceInfoUtils.EMPTY_STRING;
106
	
107
	private Button fBrowseButton;
108
	
109
	private Button fNewConnectionButton;
110
	
111
	private Combo fProviderCombo;
112
	
113
	private Combo fConnectionCombo;
114
	
115
	private Text fLocationText;
116
117
//	public RemoteProjectContentsLocationArea(IServiceProvider provider, Composite composite) {
118
//		if(provider instanceof RemoteBuildServiceProvider)
119
//			fProvider = (RemoteBuildServiceProvider) provider;
120
//		else
121
//			throw new IllegalArgumentException(); // should never happen
122
//		createContents(composite);
123
//	}
124
	public RemoteProjectContentsLocationArea(IErrorMessageReporter reporter, Composite composite) {
125
		fErrorReporter = reporter;
126
		createContents(composite);
127
	}
128
	
129
    /**
130
	 * Check if the entry in the widget location is valid. If it is valid return
131
	 * null. Otherwise return a string that indicates the problem.
132
	 * 
133
	 * @return String
134
	 */
135
	public String checkValidLocation() {
136
137
		String locationFieldContents = fLocationText.getText();
138
		if (locationFieldContents.length() == 0) {
139
			return IDEWorkbenchMessages.WizardNewProjectCreationPage_projectLocationEmpty;
140
		}
141
142
		URI newPath = getProjectLocationURI();
143
		if (newPath == null) {
144
			return IDEWorkbenchMessages.ProjectLocationSelectionDialog_locationError;
145
		}
146
147
		if (fExistingProject != null) {
148
			URI projectPath = fExistingProject.getLocationURI();
149
			if (projectPath != null && URIUtil.equals(projectPath, newPath)) {
150
				return IDEWorkbenchMessages.ProjectLocationSelectionDialog_locationIsSelf;
151
			}
152
		}
153
154
		return null;
155
	}
156
    
157
    /**
158
	 * Return the browse button. Usually referenced in order to set the layout
159
	 * data for a dialog.
160
	 * 
161
	 * @return Button
162
	 */
163
	public Button[] getButtons() {
164
		return new Button[]{fBrowseButton, fNewConnectionButton};
165
	}
166
167
	/**
168
	 * Get the URI for the location field if possible.
169
	 * 
170
	 * @return URI or <code>null</code> if it is not valid.
171
	 */
172
	public URI getProjectLocationURI() {
173
		return fSelectedProvider.getFileManager(fSelectedConnection).toURI(new Path(fLocationText.getText()));
174
	}
175
176
	/**
177
	 * Return whether or not we are currently showing the default location for
178
	 * the project.
179
	 * 
180
	 * @return boolean
181
	 */
182
	public boolean isDefault() {
183
//		return useDefaultsButton.getSelection();
184
		return false;
185
	}
186
    
187
	/**
188
	 * Set the project to base the contents off of.
189
	 *
190
	 * @param existingProject
191
	 */
192
	public void setExistingProject(IProject existingProject) {
193
		fProjectName = existingProject.getName();
194
		fExistingProject = existingProject;
195
	}
196
197
	/**
198
	 * Set the text to the default or clear it if not using the defaults.
199
	 * 
200
	 * @param newName
201
	 *            the name of the project to use. If <code>null</code> use the
202
	 *            existing project name.
203
	 */
204
	public void updateProjectName(String newName) {
205
		fProjectName = newName;
206
		if (isDefault()) {
207
//			locationPathField.setText(TextProcessor
208
//					.process(getDefaultPathDisplayString()));
209
		}
210
211
	}
212
	
213
	/**
214
	 * Attempt to open a connection.
215
	 */
216
	private void checkConnection() {
217
		if (!fSelectedConnection.isOpen()) {
218
			IRunnableWithProgress op = new IRunnableWithProgress() {
219
				public void run(IProgressMonitor monitor)
220
						throws InvocationTargetException,
221
						InterruptedException {
222
					try {
223
						fSelectedConnection.open(monitor);
224
						if (monitor.isCanceled()) {
225
							throw new InterruptedException("Cancelled by user"); //$NON-NLS-1$
226
						}
227
					} catch (RemoteConnectionException e) {
228
						throw new InvocationTargetException(e);
229
					}
230
				}
231
				
232
			};
233
			try {
234
				new ProgressMonitorDialog(fConnectionCombo.getShell()).run(true, true, op);
235
			} catch (InvocationTargetException e) {
236
				ErrorDialog.openError(fConnectionCombo.getShell(), "Connection error", //$NON-NLS-1$
237
						"Could not open connection", //$NON-NLS-1$
238
						new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getCause().getMessage()));
239
			} catch (InterruptedException e) {
240
				ErrorDialog.openError(fConnectionCombo.getShell(), "Connection error", //$NON-NLS-1$
241
						"Could not open connection", //$NON-NLS-1$
242
						new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()));
243
			}
244
		}
245
	}
246
	
247
	/**
248
	 * Return the path we are going to display. If it is a file URI then remove
249
	 * the file prefix.
250
	 * 
251
	 * @return String
252
	 */
253
	private String getDefaultPathDisplayString() {
254
255
		URI defaultURI = null;
256
		if (fExistingProject != null) {
257
			defaultURI = fExistingProject.getLocationURI();
258
		}
259
260
		// Handle files specially. Assume a file if there is no project to query
261
		if (defaultURI == null || defaultURI.getScheme().equals(FILE_SCHEME)) {
262
			return Platform.getLocation().append(fProjectName).toOSString();
263
		}
264
		return defaultURI.toString();
265
266
	}
267
	
268
	/**
269
	 * @return
270
	 */
271
	private IRemoteUIConnectionManager getUIConnectionManager() {
272
		IRemoteUIConnectionManager connectionManager = PTPRemoteUIPlugin.getDefault().getRemoteUIServices(fSelectedProvider)
273
				.getUIConnectionManager();
274
		return connectionManager;
275
	}
276
	
277
278
	/**
279
	 * @param connectionCombo
280
	 */
281
	private void populateConnectionCombo(final Combo connectionCombo) {
282
		connectionCombo.removeAll();
283
		
284
		//attempt to restore settings from saved state
285
//        IRemoteConnection connectionSelected = fProvider.getConnection();
286
		
287
		IRemoteConnection[] connections = fSelectedProvider.getConnectionManager().getConnections();
288
		int toSelect = 0;
289
        
290
        for(int k = 0; k < connections.length; k++) {
291
        	connectionCombo.add(connections[k].getName(), k);
292
        	fComboIndexToRemoteConnectionMap .put(k, connections[k]);
293
        	
294
//        	if (connectionSelected != null && connectionSelected.getName().compareTo(connections[k].getName()) == 0) {
295
//        		toSelect = k;
296
//        	}
297
        }
298
        
299
        // set selected connection to be the first one if we're not restoring from settings
300
        connectionCombo.select(toSelect);
301
        fSelectedConnection = fComboIndexToRemoteConnectionMap.get(toSelect);
302
	}
303
	
304
	/**
305
     * @param button
306
     */
307
    private void updateNewConnectionButtonEnabled(Button button) {
308
    	IRemoteUIConnectionManager connectionManager = getUIConnectionManager();
309
    	button.setEnabled(connectionManager != null);  	
310
    }
311
312
	protected Control createContents(Composite parent) {
313
    	Group container = new Group(parent, SWT.SHADOW_ETCHED_IN);
314
    	
315
        GridLayout layout = new GridLayout();
316
        layout.numColumns = 3;
317
        container.setLayout(layout);
318
        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
319
        container.setLayoutData(gd);
320
        
321
        // Label for "Provider:"
322
        Label providerLabel = new Label(container, SWT.LEFT);
323
        providerLabel.setText("Remote Provider:"); //$NON-NLS-1$
324
        
325
        // combo for providers
326
        fProviderCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
327
        // set layout to grab horizontal space
328
        fProviderCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
329
        gd = new GridData();
330
        gd.horizontalSpan = 2;
331
        fProviderCombo.setLayoutData(gd);
332
        fProviderCombo.addSelectionListener(new SelectionListener() {
333
			public void widgetDefaultSelected(SelectionEvent e) {
334
				widgetSelected(e);
335
			}
336
337
			public void widgetSelected(SelectionEvent e) {
338
				int selectionIndex = fProviderCombo.getSelectionIndex();
339
				fSelectedProvider = fComboIndexToRemoteServicesProviderMap.get(selectionIndex);
340
				
341
				populateConnectionCombo(fConnectionCombo);
342
				updateNewConnectionButtonEnabled(fNewConnectionButton);
343
			}
344
        });
345
    
346
        //attempt to restore settings from saved state
347
//        IRemoteServices providerSelected = fProvider.getRemoteServices(); 
348
        
349
        // populate the combo with a list of providers
350
        IRemoteServices[] providers = PTPRemoteCorePlugin.getDefault().getAllRemoteServices();
351
        int toSelect = 0;
352
        
353
        for(int k = 0; k < providers.length; k++) {
354
        	fProviderCombo.add(providers[k].getName(), k);
355
        	fComboIndexToRemoteServicesProviderMap.put(k, providers[k]);
356
        	
357
//        	if (providerSelected != null && providerSelected.getName().compareTo(providers[k].getName()) == 0) {
358
//        		toSelect = k;
359
//        	}
360
        }
361
        
362
        // set selected host to be the first one if we're not restoring from settings
363
        fProviderCombo.select(toSelect);
364
        fSelectedProvider = fComboIndexToRemoteServicesProviderMap.get(toSelect);
365
        
366
        // connection combo
367
        // Label for "Connection:"
368
        Label connectionLabel = new Label(container, SWT.LEFT);
369
        connectionLabel.setText("Connection:"); //$NON-NLS-1$
370
        
371
        // combo for providers
372
        fConnectionCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY);
373
        // set layout to grab horizontal space
374
        fConnectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
375
        fConnectionCombo.addSelectionListener(new SelectionListener() {
376
			public void widgetDefaultSelected(SelectionEvent e) {
377
				widgetSelected(e);
378
			}
379
380
			public void widgetSelected(SelectionEvent e) {
381
				int selectionIndex = fConnectionCombo.getSelectionIndex();
382
				fSelectedConnection = fComboIndexToRemoteConnectionMap.get(selectionIndex);
383
				updateNewConnectionButtonEnabled(fNewConnectionButton);
384
			}
385
        });
386
        
387
        // populate the combo with a list of providers
388
        populateConnectionCombo(fConnectionCombo);
389
           
390
        // new connection button
391
        fNewConnectionButton = new Button(container, SWT.PUSH);
392
        fNewConnectionButton.setText("New..."); //$NON-NLS-1$
393
        updateNewConnectionButtonEnabled(fNewConnectionButton);
394
        fNewConnectionButton.addSelectionListener(new SelectionListener() {
395
			public void widgetDefaultSelected(SelectionEvent e) {
396
				widgetSelected(e);
397
			}
398
399
			public void widgetSelected(SelectionEvent e) {
400
				IRemoteUIConnectionManager connectionManager = getUIConnectionManager();
401
				if(connectionManager != null) {
402
					connectionManager.newConnection(fNewConnectionButton.getShell());
403
				}
404
				// refresh list of connections
405
				populateConnectionCombo(fConnectionCombo);
406
			}
407
        });
408
        
409
        Label locationLabel = new Label(container, SWT.LEFT);
410
        locationLabel.setText("Location:"); //$NON-NLS-1$
411
        
412
        fLocationText = new Text(container, SWT.SINGLE | SWT.BORDER);
413
		gd = new GridData(GridData.FILL_HORIZONTAL);
414
		gd.horizontalSpan = 1;
415
		gd.grabExcessHorizontalSpace = true;
416
		gd.widthHint = 250;
417
		fLocationText.setLayoutData(gd);
418
		fLocationText.addModifyListener(new ModifyListener() {
419
			public void modifyText(ModifyEvent e) {
420
				fErrorReporter.reportError(checkValidLocation(), false);
421
			}
422
		});
423
		
424
        // new connection button
425
        fBrowseButton = new Button(container, SWT.PUSH);
426
        fBrowseButton.setText("Browse..."); //$NON-NLS-1$
427
        fBrowseButton.addSelectionListener(new SelectionListener() {
428
			public void widgetDefaultSelected(SelectionEvent e) {
429
				widgetSelected(e);
430
			}
431
432
			public void widgetSelected(SelectionEvent e) {
433
				if (fSelectedConnection != null) {
434
					checkConnection();
435
					if (fSelectedConnection.isOpen()) {
436
						IRemoteUIServices remoteUIServices = PTPRemoteUIPlugin.getDefault().getRemoteUIServices(fSelectedProvider);
437
						if (remoteUIServices != null) {
438
							IRemoteUIFileManager fileMgr = remoteUIServices.getUIFileManager();
439
							if (fileMgr != null) {
440
								fileMgr.setConnection(fSelectedConnection);
441
								String correctPath = fLocationText.getText();
442
								IPath selectedPath = fileMgr.browseDirectory(fLocationText.getShell(), "Project Location", correctPath); //$NON-NLS-1$
443
								if (selectedPath != null) {
444
									fLocationText.setText(selectedPath.toString());
445
								}
446
							}
447
						}
448
					}
449
				}
450
			}
451
        });
452
453
        return container;
454
    }
455
	
456
	/* (non-Javadoc)
457
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
458
	 */
459
	protected void okPressed() {
460
		
461
		// set the provider
462
		fProvider.setRemoteToolsProviderID(fSelectedProvider.getId());
463
		fProvider.setRemoteToolsConnection(fSelectedConnection);
464
465
	}
466
	
467
	/**
468
	 * Return the location for the project. 
469
	 * 
470
	 * @return String
471
	 */
472
	public String getProjectLocation() {
473
		return fLocationText.getText();
474
	}
475
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteMainWizardPage.java (+543 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2008 Intel 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
 *     Intel Corporation - initial API and implementation
10
 *     IBM Corporation
11
 *******************************************************************************/
12
package org.eclipse.ptp.rdt.ui.newwizards;
13
import java.net.URI;
14
import java.util.ArrayList;
15
import java.util.Iterator;
16
import java.util.LinkedList;
17
import java.util.List;
18
19
import org.eclipse.cdt.internal.ui.CPluginImages;
20
import org.eclipse.cdt.ui.CUIPlugin;
21
import org.eclipse.cdt.ui.newui.CDTPrefUtil;
22
import org.eclipse.cdt.ui.newui.PageLayout;
23
import org.eclipse.cdt.ui.newui.UIMessages;
24
import org.eclipse.cdt.ui.wizards.CNewWizard;
25
import org.eclipse.cdt.ui.wizards.CWizardHandler;
26
import org.eclipse.cdt.ui.wizards.EntryDescriptor;
27
import org.eclipse.cdt.ui.wizards.IWizardItemsListListener;
28
import org.eclipse.cdt.ui.wizards.IWizardWithMemory;
29
import org.eclipse.core.filesystem.EFS;
30
import org.eclipse.core.filesystem.IFileInfo;
31
import org.eclipse.core.filesystem.IFileStore;
32
import org.eclipse.core.resources.IProject;
33
import org.eclipse.core.resources.ResourcesPlugin;
34
import org.eclipse.core.runtime.CoreException;
35
import org.eclipse.core.runtime.IConfigurationElement;
36
import org.eclipse.core.runtime.IExtension;
37
import org.eclipse.core.runtime.IExtensionPoint;
38
import org.eclipse.core.runtime.IStatus;
39
import org.eclipse.core.runtime.Platform;
40
import org.eclipse.jface.wizard.IWizard;
41
import org.eclipse.jface.wizard.IWizardPage;
42
import org.eclipse.osgi.util.TextProcessor;
43
import org.eclipse.ptp.internal.rdt.ui.RDTHelpContextIds;
44
import org.eclipse.ptp.services.core.IServiceConfiguration;
45
import org.eclipse.swt.SWT;
46
import org.eclipse.swt.accessibility.AccessibleAdapter;
47
import org.eclipse.swt.accessibility.AccessibleEvent;
48
import org.eclipse.swt.events.SelectionAdapter;
49
import org.eclipse.swt.events.SelectionEvent;
50
import org.eclipse.swt.graphics.Image;
51
import org.eclipse.swt.layout.GridData;
52
import org.eclipse.swt.layout.GridLayout;
53
import org.eclipse.swt.widgets.Button;
54
import org.eclipse.swt.widgets.Composite;
55
import org.eclipse.swt.widgets.Label;
56
import org.eclipse.swt.widgets.Shell;
57
import org.eclipse.swt.widgets.Tree;
58
import org.eclipse.swt.widgets.TreeItem;
59
import org.eclipse.ui.PlatformUI;
60
61
public class RemoteMainWizardPage extends NewRemoteProjectCreationPage implements IWizardItemsListListener {
62
	private static final Image IMG_CATEGORY = CPluginImages.get(CPluginImages.IMG_OBJS_SEARCHFOLDER);
63
	private static final Image IMG_ITEM = CPluginImages.get(CPluginImages.IMG_OBJS_VARIABLE);
64
65
	public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.NewModelProjectWizardPage"; //$NON-NLS-1$
66
67
	private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CDTWizard"; //$NON-NLS-1$
68
	private static final String ELEMENT_NAME = "wizard"; //$NON-NLS-1$
69
	private static final String CLASS_NAME = "class"; //$NON-NLS-1$
70
	public static final String DESC = "EntryDescriptor"; //$NON-NLS-1$ 
71
72
    // widgets
73
    private Tree tree;
74
    private Composite right;
75
    private Button show_sup;
76
    private Label right_label;
77
   
78
    public CWizardHandler h_selected = null;
79
	private Label categorySelectedLabel;
80
	
81
	private IServiceConfiguration defaultConfig = null;
82
83
	    /**
84
     * Creates a new project creation wizard page.
85
     *
86
     * @param pageName the name of this page
87
     */
88
    public RemoteMainWizardPage(String pageName) {
89
        super(pageName);
90
        setPageComplete(false);
91
		// default to view all toolchains
92
		CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOSUPP, true);
93
    }
94
95
    /** (non-Javadoc)
96
     * Method declared on IDialogPage.
97
     */
98
    @Override
99
	public void createControl(Composite parent) {
100
    	super.createControl(parent);
101
    	
102
    	createDynamicGroup((Composite)getControl()); 
103
		switchTo(updateData(tree, right, show_sup, RemoteMainWizardPage.this, getWizard()),
104
				getDescriptor(tree));
105
106
		setPageComplete(validatePage());
107
        setErrorMessage(null);
108
        setMessage(null);
109
        
110
		Shell shell = getContainer().getShell(); //if not created on the shell, will not display properly
111
		PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, RDTHelpContextIds.CREATING_A_REMOTE_PROJECT);
112
    }
113
    
114
    private void createDynamicGroup(Composite parent) {
115
        Composite c = new Composite(parent, SWT.NONE);
116
        c.setLayoutData(new GridData(GridData.FILL_BOTH));
117
    	c.setLayout(new GridLayout(2, true));
118
    	
119
        Label l1 = new Label(c, SWT.NONE);
120
        l1.setText(UIMessages.getString("CMainWizardPage.0")); //$NON-NLS-1$
121
        l1.setFont(parent.getFont());
122
        l1.setLayoutData(new GridData(GridData.BEGINNING));
123
        
124
        right_label = new Label(c, SWT.NONE);
125
        right_label.setFont(parent.getFont());
126
        right_label.setLayoutData(new GridData(GridData.BEGINNING));
127
    	
128
        tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
129
        tree.setLayoutData(new GridData(GridData.FILL_BOTH));
130
        tree.addSelectionListener(new SelectionAdapter() {
131
			@Override
132
			public void widgetSelected(SelectionEvent e) {
133
				TreeItem[] tis = tree.getSelection();
134
				if (tis == null || tis.length == 0) return;
135
				switchTo((CWizardHandler)tis[0].getData(), (EntryDescriptor)tis[0].getData(DESC));
136
				setPageComplete(validatePage());
137
			}});
138
        tree.getAccessible().addAccessibleListener(
139
				 new AccessibleAdapter() {                       
140
	                 @Override
141
					public void getName(AccessibleEvent e) {
142
	                	 for (int i = 0; i < tree.getItemCount(); i++) {
143
	                		 if (tree.getItem(i).getText().compareTo(e.result) == 0)
144
	                			 return;
145
	                	 }
146
                         e.result = UIMessages.getString("CMainWizardPage.0"); //$NON-NLS-1$
147
	                 }
148
	             }
149
			 );
150
        right = new Composite(c, SWT.NONE);
151
        right.setLayoutData(new GridData(GridData.FILL_BOTH));
152
        right.setLayout(new PageLayout());
153
154
        show_sup = new Button(c, SWT.CHECK);
155
        show_sup.setText(UIMessages.getString("CMainWizardPage.1")); //$NON-NLS-1$
156
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
157
        gd.horizontalSpan = 2;
158
        show_sup.setLayoutData(gd);
159
        show_sup.addSelectionListener(new SelectionAdapter() {
160
			@Override
161
			public void widgetSelected(SelectionEvent e) {
162
				if (h_selected != null)
163
					h_selected.setSupportedOnly(show_sup.getSelection());
164
				switchTo(updateData(tree, right, show_sup, RemoteMainWizardPage.this, getWizard()),
165
						getDescriptor(tree));
166
			}} );
167
168
        // restore settings from preferences
169
		show_sup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP));
170
    }
171
    
172
    @Override
173
	public IWizardPage getNextPage() {
174
		return (h_selected == null) ? null : h_selected.getSpecificPage();
175
    }		
176
177
    public URI getProjectLocation() {
178
    	return useDefaults() ? null : getLocationURI();
179
    }
180
181
    /**
182
     * Returns whether this page's controls currently all contain valid 
183
     * values.
184
     *
185
     * @return <code>true</code> if all controls are valid, and
186
     *   <code>false</code> if at least one is invalid
187
     */
188
    @Override
189
	protected boolean validatePage() {
190
		setMessage(null);
191
    	if (!super.validatePage())
192
    		return false;
193
194
        if (getProjectName().indexOf('#') >= 0) {
195
            setErrorMessage(UIMessages.getString("RemoteMainWizardPage.0")); //$NON-NLS-1$
196
            return false;
197
        }
198
        
199
        boolean bad = true; // should we treat existing project as error
200
        
201
        IProject handle = getProjectHandle();
202
        if (handle.exists()) {
203
        	if (getWizard() instanceof IWizardWithMemory) {
204
        		IWizardWithMemory w = (IWizardWithMemory)getWizard();
205
        		if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName()))
206
        			bad = false;
207
        	}
208
        	if (bad) { 
209
        		setErrorMessage(UIMessages.getString("CMainWizardPage.10")); //$NON-NLS-1$
210
        	    return false;
211
        	}
212
        }
213
214
        if (bad) { // skip this check if project already created 
215
        	try {
216
        		IFileStore fs;
217
	        	URI p = getProjectLocation();
218
	        	if (p == null) {
219
	        		fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
220
	        		fs = fs.getChild(getProjectName());
221
	        	} else
222
	        		fs = EFS.getStore(p);
223
        		IFileInfo f = fs.fetchInfo();
224
	        	if (f.exists() && f.isDirectory()) {
225
		  			if (fs.getChild(".project").fetchInfo().exists()) { //$NON-NLS-1$
226
						setMessage("Existing project settings will be overridden"); //$NON-NLS-1$
227
						return true;
228
		  			}
229
	        	}
230
        	} catch (CoreException e) {
231
        		CUIPlugin.log(e.getStatus());
232
        	}
233
        }
234
        
235
        if (!useDefaults()) {
236
            IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle,
237
            		getLocationURI());
238
            if (!locationStatus.isOK()) {
239
                setErrorMessage(locationStatus.getMessage());
240
                return false;
241
            }
242
        }
243
244
        if (tree.getItemCount() == 0) {
245
        	setErrorMessage(UIMessages.getString("CMainWizardPage.3")); //$NON-NLS-1$
246
        	return false;
247
        }
248
        
249
        // it is not an error, but we cannot continue
250
        if (h_selected == null) {
251
            setErrorMessage(null);
252
	        return false;	        	
253
        }
254
255
        String s = h_selected.getErrorMessage(); 
256
		if (s != null) {
257
    		setErrorMessage(s);
258
    		return false;
259
        }
260
		
261
        setErrorMessage(null);
262
        return true;
263
    }
264
265
    /**
266
     * 
267
     * @param tree
268
     * @param right
269
     * @param show_sup
270
     * @param ls
271
     * @param wizard
272
     * @return : selected Wizard Handler.
273
     */
274
	public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup, IWizardItemsListListener ls, IWizard wizard) {
275
		// remember selected item
276
		TreeItem[] sel = tree.getSelection();
277
		String savedStr = (sel.length > 0) ? sel[0].getText() : null; 
278
		
279
		tree.removeAll();
280
		IExtensionPoint extensionPoint =
281
			    Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
282
		if (extensionPoint == null) return null;
283
		IExtension[] extensions = extensionPoint.getExtensions();
284
		if (extensions == null) return null;
285
		
286
		List<EntryDescriptor> items = new ArrayList<EntryDescriptor>();
287
		for (int i = 0; i < extensions.length; ++i)	{
288
			IConfigurationElement[] elements = extensions[i].getConfigurationElements();
289
			for (IConfigurationElement element : elements) {
290
				if (element.getName().equals(ELEMENT_NAME)) {
291
					CNewWizard w = null;
292
					try {
293
						w = (CNewWizard) element.createExecutableExtension(CLASS_NAME);
294
					} catch (CoreException e) {
295
						System.out.println(UIMessages.getString("CMainWizardPage.5") + e.getLocalizedMessage()); //$NON-NLS-1$
296
						return null; 
297
					}
298
					if (w == null) return null;
299
					w.setDependentControl(right, ls);
300
					for (EntryDescriptor ed : w.createItems(show_sup.getSelection(), wizard))	
301
						items.add(ed);
302
				}
303
			}
304
		}
305
		// If there is a EntryDescriptor which is default for category, make sure it 
306
		// is in the front of the list.
307
		for (int i = 0; i < items.size(); ++i)
308
		{
309
			EntryDescriptor ed = items.get(i);
310
			if (ed.isDefaultForCategory())
311
			{
312
				items.remove(i);
313
				items.add(0, ed);
314
				break;
315
			}				
316
		}
317
		
318
		// bug # 211935 : allow items filtering.
319
		if (ls != null) // NULL means call from prefs
320
			items = ls.filterItems(items);
321
		addItemsToTree(tree, items);
322
		
323
		if (tree.getItemCount() > 0) {
324
			TreeItem target = null;
325
			// try to search item which was selected before
326
			if (savedStr != null) {
327
				TreeItem[] all = tree.getItems();
328
				for (TreeItem element : all) {
329
					if (savedStr.equals(element.getText())) {
330
						target = element;
331
						break;
332
					}
333
				}
334
			}
335
			if (target == null)
336
			{
337
				target = tree.getItem(0);
338
				if (target.getItemCount() != 0)
339
					target = target.getItem(0);
340
			}
341
			tree.setSelection(target);
342
			return (CWizardHandler)target.getData();
343
		}
344
		return null;
345
	}
346
347
	private static void addItemsToTree(Tree tree, List<EntryDescriptor> items) {
348
	//  Sorting is disabled because of users requests	
349
	//	Collections.sort(items, CDTListComparator.getInstance());
350
		
351
		ArrayList<TreeItem> placedTreeItemsList = new ArrayList<TreeItem>(items.size());
352
		ArrayList<EntryDescriptor> placedEntryDescriptorsList = new ArrayList<EntryDescriptor>(items.size());
353
		for (EntryDescriptor wd : items) {
354
			if (wd.getParentId() == null) {
355
				wd.setPath(wd.getId());
356
				TreeItem ti = new TreeItem(tree, SWT.NONE);
357
				ti.setText(TextProcessor.process(wd.getName()));
358
				ti.setData(wd.getHandler());
359
				ti.setData(DESC, wd);
360
				ti.setImage(calcImage(wd));
361
				placedTreeItemsList.add(ti);
362
				placedEntryDescriptorsList.add(wd);
363
			}
364
		}
365
		while(true) {
366
			boolean found = false;
367
			Iterator<EntryDescriptor> it2 = items.iterator();
368
			while (it2.hasNext()) {
369
				EntryDescriptor wd1 = it2.next();
370
				if (wd1.getParentId() == null) continue;
371
				for (int i = 0; i< placedEntryDescriptorsList.size(); i++) {
372
					EntryDescriptor wd2 = placedEntryDescriptorsList.get(i);
373
					if (wd2.getId().equals(wd1.getParentId())) {
374
						found = true;
375
						wd1.setParentId(null);
376
						CWizardHandler h = wd2.getHandler();
377
						/* If neither wd1 itself, nor its parent (wd2) have a handler
378
						 * associated with them, and the item is not a category,
379
						 * then skip it. If it's category, then it's possible that
380
						 * children will have a handler associated with them.
381
						 */
382
						if (h == null && wd1.getHandler() == null && !wd1.isCategory())
383
							break;
384
385
						wd1.setPath(wd2.getPath() + "/" + wd1.getId()); //$NON-NLS-1$
386
						wd1.setParent(wd2);
387
						if (h != null) {
388
							if (wd1.getHandler() == null && !wd1.isCategory())
389
								wd1.setHandler((CWizardHandler)h.clone());
390
							if (!h.isApplicable(wd1))
391
								break;
392
						}
393
						
394
						TreeItem p = placedTreeItemsList.get(i);
395
						TreeItem ti = new TreeItem(p, SWT.NONE);
396
						ti.setText(wd1.getName());
397
						ti.setData(wd1.getHandler());
398
						ti.setData(DESC, wd1);
399
						ti.setImage(calcImage(wd1));
400
						placedTreeItemsList.add(ti);
401
						placedEntryDescriptorsList.add(wd1);
402
						break;
403
					}
404
				}
405
			}
406
			// repeat iterations until all items are placed.
407
			if (!found) break;
408
		}
409
		// orphan elements (with not-existing parentId) are ignored
410
	}
411
412
	private void switchTo(CWizardHandler h, EntryDescriptor ed) {
413
		if (h == null) 
414
			h = ed.getHandler();
415
		if (ed.isCategory())
416
			h = null;
417
		try {
418
			if (h != null) 
419
				h.initialize(ed);
420
		} catch (CoreException e) { 
421
			h = null;
422
		}
423
		if (h_selected != null) 
424
			h_selected.handleUnSelection();
425
		h_selected = h;
426
		if (h == null) {
427
			if (ed.isCategory()) {
428
				if (categorySelectedLabel == null) {
429
					categorySelectedLabel = new Label(right, SWT.WRAP);
430
					categorySelectedLabel.setText(
431
							UIMessages.getString("RemoteMainWizardPage.1"));  //$NON-NLS-1$
432
					right.layout();
433
				}
434
				categorySelectedLabel.setVisible(true);
435
			}
436
			return;
437
		}
438
		right_label.setText(h_selected.getHeader());
439
		if (categorySelectedLabel != null)
440
			categorySelectedLabel.setVisible(false);
441
		h_selected.handleSelection();
442
		h_selected.setSupportedOnly(show_sup.getSelection());
443
	}
444
445
446
	public static EntryDescriptor getDescriptor(Tree _tree) {
447
		TreeItem[] sel = _tree.getSelection();
448
		if (sel == null || sel.length == 0) 
449
			return null;
450
		return (EntryDescriptor)sel[0].getData(DESC);
451
	}
452
	
453
	public void toolChainListChanged(int count) {
454
		setPageComplete(validatePage());
455
		getWizard().getContainer().updateButtons();
456
	}
457
458
	public boolean isCurrent() { return isCurrentPage(); }
459
	
460
	private static Image calcImage(EntryDescriptor ed) {
461
		if (ed.getImage() != null) return ed.getImage();
462
		if (ed.isCategory()) return IMG_CATEGORY;
463
		return IMG_ITEM;
464
	}
465
466
	@SuppressWarnings("unchecked")
467
	public List filterItems(List items) {
468
		/// iterate through the list, removing entry descriptors we don't care about
469
		Iterator iterator = items.iterator();
470
		
471
		List<EntryDescriptor> filteredList = new LinkedList<EntryDescriptor>();
472
		
473
		while(iterator.hasNext()) {
474
			EntryDescriptor ed = (EntryDescriptor) iterator.next();
475
			if(ed.getId().startsWith("org.eclipse.ptp.rdt")) {  // both the category and the template start with this //$NON-NLS-1$
476
				filteredList.add(ed);
477
			}
478
		}
479
		
480
		return filteredList;
481
	}
482
483
//	public void pageChanged(PageChangedEvent event) {
484
//		if (event.getSelectedPage().equals(this)) {
485
//			if (defaultConfig == null) {
486
//				ServiceModelManager manager = ServiceModelManager.getInstance();
487
//				
488
//				/*
489
//				 * Create a new service configuration
490
//				 * 
491
//				 * XXX: this should check if a service configuration has already
492
//				 * 		been selected, in which case it should use that one.
493
//				 */
494
//				IServiceConfiguration config = manager.newServiceConfiguration(handle.getName());
495
//				
496
//				/*
497
//				 * Make this configuration active for this project.
498
//				 */
499
//				manager.setConfiguration(handle, config);
500
//				
501
//				/*
502
//				 * Set default service providers based on location of project
503
//				 */
504
//				URI location = getLocationURI();
505
//				IRemoteServices remServ = PTPRemoteCorePlugin.getDefault().getRemoteServices(location);
506
//				IRemoteConnection remConn = PTPRemoteCorePlugin.getDefault().getConnection(location);
507
//				
508
//				/*
509
//				 * Project location
510
//				 */
511
//				IRemoteServiceProvider projectProvider = new RemoteProjectServiceProvider();
512
//				projectProvider.setRemoteServicesID(remServ.getId());
513
//				projectProvider.setRemoteConnectionName(remConn.getName());
514
//				config.setServiceProvider(manager.getService(RemoteProjectServiceProvider.ID), projectProvider);
515
//
516
//				/*
517
//				 * Build service
518
//				 */
519
//				IRemoteServiceProvider buildProvider = new RemoteBuildServiceProvider();
520
//				buildProvider.setRemoteServicesID(remServ.getId());
521
//				buildProvider.setRemoteConnectionName(remConn.getName());
522
//				config.setServiceProvider(manager.getService(RemoteBuildServiceProvider.ID), buildProvider);
523
//
524
//				/*
525
//				 * Index service
526
//				 */
527
//				IRemoteServiceProvider indexProvider = new RemoteCIndexServiceProvider();
528
//				indexProvider.setRemoteServicesID(remServ.getId());
529
//				indexProvider.setRemoteConnectionName(remConn.getName());
530
//				config.setServiceProvider(manager.getService(RemoteCIndexServiceProvider.ID), indexProvider);
531
//				
532
//				defaultConfig = config;
533
//				
534
//				/*
535
//				 * Pass configuration to ServiceModelWizardPage
536
//				 */
537
//				MBSCustomPageManager.addPageProperty(ServiceModelWizardPage.SERVICE_MODEL_WIZARD_PAGE_ID, 
538
//						ServiceModelWizardPage.SERVICE_CONFIGURATION_PROPERTY, config);
539
//			}
540
//		}
541
//	}
542
}
543
(-)src/org/eclipse/ptp/rdt/ui/newserviceproviders/AbstractRemoteServicesProvider.java (+92 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newserviceproviders;
12
13
import org.eclipse.ptp.remote.core.IRemoteConnection;
14
import org.eclipse.ptp.remote.core.IRemoteConnectionManager;
15
import org.eclipse.ptp.remote.core.IRemoteServices;
16
import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin;
17
import org.eclipse.ptp.services.core.ServiceProvider;
18
19
/**
20
 * A service provider that uses the Remote Services API to provide execution services.
21
 *  
22
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
23
 * part of a work in progress. There is no guarantee that this API will work or
24
 * that it will remain the same. Please do not use this API without consulting
25
 * with the RDT team.
26
 * 
27
 * @author crecoskie
28
 */
29
public abstract class AbstractRemoteServicesProvider extends ServiceProvider implements IRemoteServiceProvider {
30
	
31
	public static final String REMOTE_SERVICES_ID = "remoteServicesID"; //$NON-NLS-1$
32
	public static final String REMOTE_CONNECTION_NAME = "remoteConnectionName"; //$NON-NLS-1$
33
	
34
	private IRemoteServices fRemoteServices = null;
35
	private IRemoteConnection fRemoteConnection = null;
36
	
37
	public AbstractRemoteServicesProvider() {
38
	}
39
40
	public IRemoteConnection getConnection() {
41
		if (fRemoteConnection == null) {
42
			String connectionName = getString(REMOTE_CONNECTION_NAME);
43
			if (connectionName != null) {
44
				IRemoteServices services = getRemoteServices();
45
				if (services != null) {
46
					IRemoteConnectionManager connMgr = services.getConnectionManager();
47
					if (connMgr != null) {
48
						fRemoteConnection = connMgr.getConnection(connectionName);
49
					}
50
				}
51
			}
52
		}
53
		return fRemoteConnection;
54
	}
55
		
56
	public IRemoteServices getRemoteServices() {
57
		if (fRemoteServices == null) {
58
	        String remoteServicesID = getString(REMOTE_SERVICES_ID); 
59
	        if (remoteServicesID != null) {
60
	        	fRemoteServices = PTPRemoteCorePlugin.getDefault().getRemoteServices(remoteServicesID);
61
	        }
62
		}
63
        return fRemoteServices;
64
	}
65
66
	/* (non-Javadoc)
67
	 * @see org.eclipse.ptp.rdt.services.core.IServiceProvider#isConfigured()
68
	 */
69
	public boolean isConfigured() {
70
		return (getRemoteServices() != null && getConnection() != null);
71
	}
72
73
	/**
74
	 * Sets the connection that this provider should use for its execution services.
75
	 * 
76
	 * @param connection
77
	 */
78
	public void setRemoteConnectionName(String name) {
79
		putString(REMOTE_CONNECTION_NAME, name);
80
		fRemoteConnection = null; // remove cache
81
	}
82
83
	/**
84
	 * Sets the ID of the Remote Tools provider that this provider should use for its execution services.
85
	 * 
86
	 * @param id
87
	 */
88
	public void setRemoteServicesID(String id) {
89
		putString(REMOTE_SERVICES_ID, id);
90
		fRemoteServices = null; // remove cache
91
	}
92
}
(-)src/org/eclipse/ptp/rdt/ui/newwizards/RemoteCIndexServiceProviderConfigurer.java (+62 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.ui.newwizards;
12
13
import org.eclipse.jface.wizard.IWizard;
14
import org.eclipse.jface.wizard.IWizardPage;
15
import org.eclipse.jface.wizard.WizardPage;
16
import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteCIndexServiceProvider;
17
import org.eclipse.ptp.services.core.IServiceProvider;
18
import org.eclipse.ptp.services.ui.IServiceProviderContributor;
19
import org.eclipse.ptp.services.ui.wizards.ServiceProviderConfigurationWizard;
20
import org.eclipse.swt.widgets.Shell;
21
22
/**
23
 * Provides configuration UI for the RemoteCIndexServiceProvider by allowing an RSE
24
 * host to be selected.
25
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
26
 * part of a work in progress. There is no guarantee that this API will work or
27
 * that it will remain the same. Please do not use this API without consulting
28
 * with the RDT team.
29
 * 
30
 * @author crecoskie
31
 *
32
 */
33
public class RemoteCIndexServiceProviderConfigurer implements IServiceProviderContributor {
34
35
	/**
36
	 * 
37
	 */
38
	public RemoteCIndexServiceProviderConfigurer() {
39
		// TODO Auto-generated constructor stub
40
	}
41
42
	public void configureServiceProvider(IServiceProvider provider,
43
			Shell parentShell) {
44
	}
45
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.ptp.services.ui.IServiceProviderContributor#getWizard(org.eclipse.ptp.services.core.IServiceProvider, org.eclipse.jface.wizard.IWizardPage)
48
	 */
49
	public IWizard getWizard(IServiceProvider provider, IWizardPage page) {
50
		return new ServiceProviderConfigurationWizard(provider, page);
51
	}
52
53
	/* (non-Javadoc)
54
	 * @see org.eclipse.ptp.services.ui.IServiceProviderContributor#getWizardPages(org.eclipse.ptp.services.core.IServiceProvider)
55
	 */
56
	public WizardPage[] getWizardPages(IServiceProvider provider) {
57
		if (!(provider instanceof RemoteCIndexServiceProvider)) {
58
			return new WizardPage[0];
59
		}
60
		return new WizardPage[]{new RemoteCIndexConfigurationWizardPage((RemoteCIndexServiceProvider)provider, "Remote C/C++ Indexing Configuration")}; //$NON-NLS-1$
61
	}
62
}
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 14-20 Link Here
14
 org.eclipse.core.filesystem;bundle-version="1.2.0",
14
 org.eclipse.core.filesystem;bundle-version="1.2.0",
15
 org.eclipse.cdt.managedbuilder.core;bundle-version="5.0.1",
15
 org.eclipse.cdt.managedbuilder.core;bundle-version="5.0.1",
16
 org.eclipse.ptp.remote.core;bundle-version="2.0.1",
16
 org.eclipse.ptp.remote.core;bundle-version="2.0.1",
17
 org.eclipse.dstore.extra;bundle-version="2.1.100"
17
 org.eclipse.dstore.extra;bundle-version="2.1.100",
18
 org.eclipse.ptp.services.core;bundle-version="1.0.0"
18
Export-Package: org.eclipse.ptp.internal.rdt.core,
19
Export-Package: org.eclipse.ptp.internal.rdt.core,
19
 org.eclipse.ptp.internal.rdt.core.callhierarchy;x-friends:="org.eclipse.ptp.rdt.ui",
20
 org.eclipse.ptp.internal.rdt.core.callhierarchy;x-friends:="org.eclipse.ptp.rdt.ui",
20
 org.eclipse.ptp.internal.rdt.core.contentassist;x-friends:="org.eclipse.ptp.rdt.ui",
21
 org.eclipse.ptp.internal.rdt.core.contentassist;x-friends:="org.eclipse.ptp.rdt.ui",
(-)plugin.properties (+1 lines)
Lines 14-19 Link Here
14
14
15
remoteIndexer.name = RDT Remote Indexer
15
remoteIndexer.name = RDT Remote Indexer
16
CIndexingService.name = C/C++ Indexing
16
CIndexingService.name = C/C++ Indexing
17
projectLocationService.name = Project Location
17
BuildService.name = Build
18
BuildService.name = Build
18
RemoteMakeBuilder.name = Remote Make Builder
19
RemoteMakeBuilder.name = Remote Make Builder
19
20
(-)plugin.xml (+30 lines)
Lines 87-90 Link Here
87
         </run>
87
         </run>
88
      </runtime>
88
      </runtime>
89
   </extension>
89
   </extension>
90
      <extension
91
         point="org.eclipse.ptp.services.core.services">
92
      <service
93
            id="org.eclipse.ptp.rdt.core.CIndexingService"
94
            name="%CIndexingService.name"
95
            priority="100">
96
         <nature
97
               id="org.eclipse.cdt.core.cnature">
98
         </nature>
99
         <nature
100
               id="org.eclipse.cdt.core.ccnature">
101
         </nature>
102
      </service>
103
      <service
104
            id="org.eclipse.ptp.rdt.core.BuildService"
105
            name="%BuildService.name"
106
            priority="200">
107
         <nature
108
               id="org.eclipse.cdt.core.cnature">
109
         </nature>
110
         <nature
111
               id="org.eclipse.cdt.core.ccnature">
112
         </nature>
113
      </service>
114
      <service
115
            id="org.eclipse.ptp.rdt.core.ProjectLocationService"
116
            name="%projectLocationService.name"
117
            priority="10">
118
      </service>
119
   </extension>
90
</plugin>
120
</plugin>
(-)src/org/eclipse/ptp/rdt/core/services/IRDTServiceConstants.java (+1 lines)
Lines 23-26 Link Here
23
public interface IRDTServiceConstants {
23
public interface IRDTServiceConstants {
24
	public static final String SERVICE_C_INDEX = "org.eclipse.ptp.rdt.core.CIndexingService"; //$NON-NLS-1$
24
	public static final String SERVICE_C_INDEX = "org.eclipse.ptp.rdt.core.CIndexingService"; //$NON-NLS-1$
25
	public static final String SERVICE_BUILD = "org.eclipse.ptp.rdt.core.BuildService"; //$NON-NLS-1$
25
	public static final String SERVICE_BUILD = "org.eclipse.ptp.rdt.core.BuildService"; //$NON-NLS-1$
26
	public static final String SERVICE_PROJECT = "org.eclipse.ptp.rdt.core.ProjectLocationService"; //$NON-NLS-1$
26
}
27
}
(-)src/org/eclipse/ptp/rdt/core/serviceproviders/IProjectLocationServiceProvider.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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 - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ptp.rdt.core.serviceproviders;
12
13
import java.net.URI;
14
15
16
/**
17
 * Project location service provider interface.
18
 * 
19
 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
20
 * part of a work in progress. There is no guarantee that this API will work or
21
 * that it will remain the same. Please do not use this API without consulting
22
 * with the RDT team.
23
 * 
24
 */
25
public interface IProjectLocationServiceProvider extends IRemoteExecutionServiceProvider {
26
	/**
27
	 * @return
28
	 */
29
	public boolean isLocal();
30
	
31
	/**
32
	 * @return
33
	 */
34
	public URI getProjectLocationURI();
35
}

Return to bug 283402