Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 148169 Details for
Bug 283402
Prototype new project wizard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
preliminary patch 1
283402_preliminary_patch_1.txt (text/plain), 163.73 KB, created by
Mike Kucera
on 2009-09-25 16:32:04 EDT
(
hide
)
Description:
preliminary patch 1
Filename:
MIME Type:
Creator:
Mike Kucera
Created:
2009-09-25 16:32:04 EDT
Size:
163.73 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ptp.services.ui >Index: src/org/eclipse/ptp/services/ui/widgets/NewServiceModelWidgetDialog.java >=================================================================== >RCS file: src/org/eclipse/ptp/services/ui/widgets/NewServiceModelWidgetDialog.java >diff -N src/org/eclipse/ptp/services/ui/widgets/NewServiceModelWidgetDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/services/ui/widgets/NewServiceModelWidgetDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,113 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Mike Kucera (IBM Corporation) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ptp.services.ui.widgets; >+ >+import org.eclipse.ptp.services.core.IServiceConfiguration; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Dialog; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * Launches a dialog that contains the NewServiceModelWidget >+ * with OK and Cancel buttons. >+ * >+ * >+ * >+ */ >+public class NewServiceModelWidgetDialog extends Dialog { >+ >+ private Shell shell; >+ private NewServiceModelWidget serviceModelWidget; >+ >+ >+ public NewServiceModelWidgetDialog(Shell parent, int style) { >+ super(parent, style); >+ } >+ >+ public NewServiceModelWidgetDialog(Shell parent) { >+ super(parent); >+ } >+ >+ >+ public void open(IServiceConfiguration config) { >+ Shell parent = getParent(); >+ shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE); >+ shell.setText(getText()); >+ shell.setLayout(new GridLayout(1, false)); >+ >+ serviceModelWidget = new NewServiceModelWidget(shell, SWT.NONE); >+ serviceModelWidget.setServiceConfiguration(config); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ data.minimumHeight = 400; >+ serviceModelWidget.setLayoutData(data); >+ >+ Composite buttonComp = new Composite(shell, SWT.NONE); >+ buttonComp.setLayout(new GridLayout(2, true)); >+ data = new GridData(GridData.FILL_BOTH); >+ data.horizontalAlignment = SWT.END; >+ buttonComp.setLayoutData(data); >+ >+ Button okButton = new Button(buttonComp, SWT.PUSH); >+ okButton.setText("OK"); //$NON-NLS-1$ >+ data = new GridData(GridData.FILL_BOTH); >+ data.widthHint = 80; >+ okButton.setLayoutData(data); >+ okButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ performOk(); >+ } >+ }); >+ >+ Button cancelButton = new Button(buttonComp, SWT.PUSH); >+ cancelButton.setText("Cancel"); //$NON-NLS-1$ >+ data = new GridData(GridData.FILL_BOTH); >+ data.widthHint = 80; >+ cancelButton.setLayoutData(data); >+ cancelButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ performCancel(); >+ } >+ }); >+ >+ >+ shell.pack(); >+ >+ // center window >+ Rectangle r1 = parent.getBounds(); >+ Rectangle r2 = shell.getBounds(); >+ int x = r1.x + (r1.width - r2.width) / 2; >+ int y = r1.y + (r1.height - r2.height) / 2; >+ shell.setBounds(x, y, r2.width, r2.height); >+ >+ shell.open(); >+ Display display = parent.getDisplay(); >+ while (!shell.isDisposed()) { >+ if (!display.readAndDispatch()) display.sleep(); >+ } >+ } >+ >+ private void performCancel() { >+ shell.dispose(); >+ } >+ >+ private void performOk() { >+ serviceModelWidget.applyChangesToConfiguration(); >+ shell.dispose(); >+ } >+} >#P org.eclipse.ptp.remote.rse.ui >Index: src/org/eclipse/ptp/remote/rse/ui/RSEUIFileManager.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/core/org.eclipse.ptp.remote.rse.ui/src/org/eclipse/ptp/remote/rse/ui/RSEUIFileManager.java,v >retrieving revision 1.4 >diff -u -r1.4 RSEUIFileManager.java >--- src/org/eclipse/ptp/remote/rse/ui/RSEUIFileManager.java 24 Aug 2008 00:45:16 -0000 1.4 >+++ src/org/eclipse/ptp/remote/rse/ui/RSEUIFileManager.java 25 Sep 2009 20:06:08 -0000 >@@ -37,7 +37,8 @@ > * @see org.eclipse.ptp.remote.IRemoteFileManager#browseDirectory(org.eclipse.swt.widgets.Shell, java.lang.String, java.lang.String) > */ > public IPath browseDirectory(Shell shell, String message, String filterPath) { >- SystemRemoteFolderDialog dlg = new SystemRemoteFolderDialog(shell, message, connHost); >+ SystemRemoteFolderDialog dlg = new SystemRemoteFolderDialog(shell, message); >+ dlg.setDefaultSystemConnection(connHost, true); > dlg.setBlockOnOpen(true); > if(dlg.open() == Window.OK) { > connHost = dlg.getSelectedConnection(); >@@ -55,7 +56,8 @@ > * @see org.eclipse.ptp.remote.IRemoteFileManager#browseFile(org.eclipse.swt.widgets.Shell, java.lang.String, java.lang.String) > */ > public IPath browseFile(Shell shell, String message, String filterPath) { >- SystemRemoteFileDialog dlg = new SystemRemoteFileDialog(shell, message, connHost); >+ SystemRemoteFileDialog dlg = new SystemRemoteFileDialog(shell, message); >+ dlg.setDefaultSystemConnection(connHost, true); > dlg.setBlockOnOpen(true); > if(dlg.open() == Window.OK) { > connHost = dlg.getSelectedConnection(); >#P org.eclipse.ptp.rdt.ui >Index: src/org/eclipse/ptp/rdt/ui/wizards/RemoteServicesServiceProviderConfigurer.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/RemoteServicesServiceProviderConfigurer.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/RemoteServicesServiceProviderConfigurer.java >--- src/org/eclipse/ptp/rdt/ui/wizards/RemoteServicesServiceProviderConfigurer.java 17 Sep 2009 15:51:49 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,38 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM - Initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.ptp.services.core.IServiceProvider; >-import org.eclipse.ptp.services.ui.IServiceProviderConfiguration; >-import org.eclipse.swt.widgets.Shell; >- >-/** >- * Allows the user to select a provider of Remote Services for a RemoteBuildServiceProvider. >- * >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * >- * @author crecoskie >- * @see org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider >- * @deprecated >- */ >-public class RemoteServicesServiceProviderConfigurer implements IServiceProviderConfiguration { >- >- >- public void configureServiceProvider(IServiceProvider provider, Shell parentShell) { >- Dialog configDialog = new RemoteServicesProviderSelectionDialog(provider, parentShell); >- configDialog.open(); >- } >- >-} >Index: src/org/eclipse/ptp/rdt/ui/wizards/ConvertToRemoteWizardPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/ConvertToRemoteWizardPage.java,v >retrieving revision 1.9 >diff -u -r1.9 ConvertToRemoteWizardPage.java >--- src/org/eclipse/ptp/rdt/ui/wizards/ConvertToRemoteWizardPage.java 1 Sep 2009 15:52:38 -0000 1.9 >+++ src/org/eclipse/ptp/rdt/ui/wizards/ConvertToRemoteWizardPage.java 25 Sep 2009 20:06:11 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >+ * Copyright (c) 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -11,8 +11,11 @@ > > package org.eclipse.ptp.rdt.ui.wizards; > >+ >+import java.io.IOException; > import java.lang.reflect.InvocationTargetException; > import java.text.MessageFormat; >+import java.util.HashMap; > import java.util.Map; > > import org.eclipse.cdt.ui.wizards.conversion.ConvertProjectWizardPage; >@@ -25,11 +28,16 @@ > import org.eclipse.jface.viewers.ISelectionChangedListener; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.SelectionChangedEvent; >-import org.eclipse.ptp.internal.rdt.ui.RDTHelpContextIds; > import org.eclipse.ptp.rdt.core.RDTLog; > import org.eclipse.ptp.rdt.core.resources.RemoteNature; >-import org.eclipse.ptp.rdt.ui.messages.Messages; >+import org.eclipse.ptp.services.core.IServiceConfiguration; >+import org.eclipse.ptp.services.core.IServiceModelManager; > import org.eclipse.ptp.services.core.IServiceProvider; >+import org.eclipse.ptp.services.core.ServiceModelManager; >+import org.eclipse.ptp.services.ui.widgets.NewServiceModelWidget; >+ >+import org.eclipse.ptp.rdt.ui.UIPlugin; >+import org.eclipse.ptp.rdt.ui.messages.Messages; > import org.eclipse.swt.SWT; > import org.eclipse.swt.layout.FillLayout; > import org.eclipse.swt.layout.GridData; >@@ -37,8 +45,6 @@ > import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Group; > import org.eclipse.swt.widgets.Listener; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.PlatformUI; > > /** > * Converts existing CDT projects to RDT projects. >@@ -54,21 +60,17 @@ > > private static final String WZ_TITLE = "WizardProjectConversion.title"; //$NON-NLS-1$ > private static final String WZ_DESC = "WizardProjectConversion.description"; //$NON-NLS-1$ >- ConvertToRemoteServiceModelWidget fServiceModelWidget; >+ NewServiceModelWidget fServiceModelWidget; > Group remoteServices; > >+ Map<IProject, IServiceConfiguration> projectConfigs = new HashMap<IProject, IServiceConfiguration>(); >+ > /** > * Constructor for ConvertToRemoteWizardPage. > * @param pageName > */ > public ConvertToRemoteWizardPage(String pageName) { > super(pageName); >- fServiceModelWidget = new ConvertToRemoteServiceModelWidget(); >- fServiceModelWidget.setConfigChangeListener(new Listener() { >- public void handleEvent(Event event) { >- setPageComplete(validatePage()); >- } >- }); > } > > /** >@@ -102,7 +104,7 @@ > b = !project.hasNature(RemoteNature.REMOTE_NATURE_ID); > c = !project.hasNature("org.eclipse.rse.ui.remoteSystemsTempNature"); //$NON-NLS-1$ > } catch (CoreException e) { >- RDTLog.logError(e); >+ RDTLog.logError(e); > } > return a && b && c; > } >@@ -116,9 +118,9 @@ > RemoteNature.addRemoteNature(project, monitor); > configureServicesForRemoteProject(project); > } catch (InvocationTargetException e) { >- RDTLog.logError(e); >+ RDTLog.logError(e); > } catch (InterruptedException e) { >- RDTLog.logError(e); >+ RDTLog.logError(e); > } finally { > monitor.done(); > } >@@ -134,9 +136,9 @@ > RemoteNature.addRemoteNature(project, monitor); > configureServicesForRemoteProject(project); > } catch (InvocationTargetException e) { >- RDTLog.logError(e); >+ RDTLog.logError(e); > } catch (InterruptedException e) { >- RDTLog.logError(e); >+ RDTLog.logError(e); > } finally { > monitor.done(); > } >@@ -147,23 +149,17 @@ > remoteServices = new Group(container, SWT.SHADOW_IN); > remoteServices.setText(Messages.getString("WizardProjectConversion.servicesTableLabel")); //$NON-NLS-1$ > remoteServices.setLayout(new FillLayout()); >- remoteServices.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); >+ data.heightHint = 300; >+ remoteServices.setLayoutData(data); > >- //create the table for remote services >- fServiceModelWidget.createContents(remoteServices); >- //remove all the services in the table for now and add them back as project gets selected in the project list >- fServiceModelWidget.emptyTable(); >- } >- >- public void createControl(Composite parent) { >- super.createControl(parent); >+ >+ fServiceModelWidget = new NewServiceModelWidget(remoteServices, SWT.NONE); > tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { > public void selectionChanged(SelectionChangedEvent e) { > IProject project = (IProject) ((IStructuredSelection)e.getSelection()).getFirstElement(); > if (project != null) { >- //update the table with remote services available for the project selected >- fServiceModelWidget.addServicesToTable(project); >- remoteServices.setText(MessageFormat.format(Messages.getString("WizardProjectConversion.servicesTableForProjectLabel"), new Object[] {project.getName()})); //$NON-NLS-1$ >+ changeProject(project); > } > } > }); >@@ -171,32 +167,52 @@ > public void checkStateChanged(CheckStateChangedEvent e) { > IProject project = (IProject) e.getElement(); > if (e.getChecked() && project != null) { >- //update the table with remote services available for the project selected >- fServiceModelWidget.addServicesToTable(project); >- remoteServices.setText(MessageFormat.format(Messages.getString("WizardProjectConversion.servicesTableForProjectLabel"), new Object[] {project.getName()})); //$NON-NLS-1$ >+ changeProject(project); > } > } > }); >- Shell shell = getContainer().getShell(); >- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell,RDTHelpContextIds.CONVERTING_TO_REMOTE_PROJECT); >- } >- >- private void configureServicesForRemoteProject(IProject project) throws InvocationTargetException, >- InterruptedException { >- Map<IProject, Map<String,String>> projectToServices = fServiceModelWidget.getProjectToServices(); >- Map<IProject, Map<String,IServiceProvider>> projectToProviders = fServiceModelWidget.getProjectToProviders(); > >- Map<String, String> serviceIDToProviderIDMap = projectToServices.get(project); >- Map<String, IServiceProvider> providerIDToProviderMap = projectToProviders.get(project); > >- ConfigureRemoteServices.configure(project, serviceIDToProviderIDMap, providerIDToProviderMap, new NullProgressMonitor()); > } > >- /* (non-Javadoc) >- * @see org.eclipse.cdt.ui.wizards.conversion.ConvertProjectWizardPage#validatePage() >- */ >+ > @Override >- protected boolean validatePage() { >- return super.validatePage() && fServiceModelWidget.isConfigured(getCheckedElements()); >+ public void doRun(IProgressMonitor monitor, String projectID, String bsId)throws CoreException { >+ fServiceModelWidget.applyChangesToConfiguration(); >+ super.doRun(monitor, projectID, bsId); >+ try { >+ ServiceModelManager.getInstance().saveModelConfiguration(); >+ } catch (IOException e) { >+ UIPlugin.log(e); >+ } > } >+ >+ >+ private IServiceConfiguration getConfig(IProject project) { >+ IServiceConfiguration config = projectConfigs.get(project); >+ if(config == null) { >+ config = ServiceModelManager.getInstance().newServiceConfiguration(project.getName()); >+ projectConfigs.put(project, config); >+ } >+ return config; >+ } >+ >+ >+ private void changeProject(IProject project) { >+ IServiceConfiguration config = getConfig(project); >+ fServiceModelWidget.applyChangesToConfiguration(); >+ fServiceModelWidget.setServiceConfiguration(config); >+ remoteServices.setText(MessageFormat.format(Messages.getString("WizardProjectConversion.servicesTableForProjectLabel"), new Object[] {project.getName()})); //$NON-NLS-1$ >+ setPageComplete(true); >+ } >+ >+ >+ >+ >+ private void configureServicesForRemoteProject(IProject project) throws InvocationTargetException, InterruptedException { >+ ServiceModelManager.getInstance().addConfiguration(project, getConfig(project)); >+ } >+ >+ >+ > } >Index: src/org/eclipse/ptp/rdt/ui/wizards/RDTMainWizardPage.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/RDTMainWizardPage.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/RDTMainWizardPage.java >--- src/org/eclipse/ptp/rdt/ui/wizards/RDTMainWizardPage.java 4 Jun 2009 19:47:08 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,71 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM - Initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import java.util.Iterator; >-import java.util.LinkedList; >-import java.util.List; >- >-import org.eclipse.cdt.ui.newui.CDTPrefUtil; >-import org.eclipse.cdt.ui.wizards.CDTMainWizardPage; >-import org.eclipse.cdt.ui.wizards.EntryDescriptor; >-import org.eclipse.jface.wizard.IWizardPage; >-import org.eclipse.ptp.internal.rdt.ui.RDTHelpContextIds; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.PlatformUI; >- >-/** >- * Main page of the RDT wizard, which filters out local project types. >- * >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * @author crecoskie >- * >- */ >-public class RDTMainWizardPage extends CDTMainWizardPage { >- >- public RDTMainWizardPage(String pageName) { >- super(pageName); >- >- // default to view all toolchains >- CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOSUPP, true); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.cdt.ui.wizards.IWizardItemsListListener#filterItems(java.util.List) >- */ >- @SuppressWarnings("unchecked") >- public List filterItems(List items) { >- /// iterate through the list, removing entry descriptors we don't care about >- Iterator iterator = items.iterator(); >- >- List<EntryDescriptor> filteredList = new LinkedList<EntryDescriptor>(); >- >- while(iterator.hasNext()) { >- EntryDescriptor ed = (EntryDescriptor) iterator.next(); >- if(ed.getId().startsWith("org.eclipse.ptp.rdt")) { // both the category and the template start with this //$NON-NLS-1$ >- filteredList.add(ed); >- } >- } >- >- return filteredList; >- } >- >- public void createControl(Composite parent){ >- super.createControl(parent); >- Shell shell = getContainer().getShell(); //if not created on the shell, will not display properly >- PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, RDTHelpContextIds.CREATING_A_REMOTE_PROJECT); >- } >- >-} >Index: src/org/eclipse/ptp/rdt/ui/wizards/RemoteCIndexServiceProviderConfigurer.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/RemoteCIndexServiceProviderConfigurer.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/RemoteCIndexServiceProviderConfigurer.java >--- src/org/eclipse/ptp/rdt/ui/wizards/RemoteCIndexServiceProviderConfigurer.java 17 Sep 2009 15:51:49 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,36 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM - Initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.ptp.services.core.IServiceProvider; >-import org.eclipse.ptp.services.ui.IServiceProviderConfiguration; >-import org.eclipse.swt.widgets.Shell; >- >-/** >- * Provides configuration UI for the RemoteCIndexServiceProvider by allowing an RSE >- * host to be selected. >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * >- * @author crecoskie >- * @deprecated >- */ >-public class RemoteCIndexServiceProviderConfigurer implements IServiceProviderConfiguration { >- >- public void configureServiceProvider(IServiceProvider provider, Shell parentShell) { >- Dialog configDialog = new HostSelectionDialog(provider, parentShell); >- configDialog.open(); >- } >- >-} >Index: src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWizardPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWizardPage.java,v >retrieving revision 1.8 >diff -u -r1.8 ServiceModelWizardPage.java >--- src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWizardPage.java 25 Sep 2009 01:41:46 -0000 1.8 >+++ src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWizardPage.java 25 Sep 2009 20:06:11 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.ptp.rdt.ui.wizards; > >+import java.util.HashSet; > import java.util.LinkedHashSet; > import java.util.Set; > >@@ -17,20 +18,36 @@ > import org.eclipse.cdt.core.CProjectNature; > import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPage; > import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager; >-import org.eclipse.cdt.ui.wizards.CDTMainWizardPage; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.wizard.IWizardPage; >-import org.eclipse.ptp.internal.rdt.ui.RDTHelpContextIds; >+import org.eclipse.ptp.internal.rdt.ui.RSEUtils; >+import org.eclipse.ptp.rdt.core.services.IRDTServiceConstants; > import org.eclipse.ptp.rdt.ui.messages.Messages; >+import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider; >+import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteCIndexServiceProvider; >+import org.eclipse.ptp.remote.core.IRemoteConnection; >+import org.eclipse.ptp.remote.core.IRemoteServices; > import org.eclipse.ptp.services.core.IService; > import org.eclipse.ptp.services.core.IServiceConfiguration; >+import org.eclipse.ptp.services.core.IServiceModelManager; >+import org.eclipse.ptp.services.core.IServiceProviderDescriptor; > import org.eclipse.ptp.services.core.ServiceModelManager; >-import org.eclipse.ptp.services.ui.widgets.NewServiceModelWidget; >+import org.eclipse.ptp.services.ui.widgets.NewServiceModelWidgetDialog; >+import org.eclipse.rse.connectorservice.dstore.DStoreConnectorService; >+import org.eclipse.rse.core.model.IHost; >+import org.eclipse.rse.core.subsystems.IConnectorService; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >-import org.eclipse.ui.PlatformUI; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; > > /** > * >@@ -39,7 +56,6 @@ > * that it will remain the same. Please do not use this API without consulting > * with the RDT team. > * >- * @author crecoskie > * > */ > public class ServiceModelWizardPage extends MBSCustomPage { >@@ -47,20 +63,24 @@ > public static final String SERVICE_MODEL_WIZARD_PAGE_ID = "org.eclipse.ptp.rdt.ui.serviceModelWizardPage"; //$NON-NLS-1$ > public static final String DEFAULT_CONFIG = Messages.getString("ConfigureRemoteServices.0"); //$NON-NLS-1$ > >- public static final String SERVICE_MODEL_WIDGET_PROPERTY = "org.eclipse.ptp.rdt.ui.ServiceModelWizardPage.serviceModelWidget"; //$NON-NLS-1$ >+ public static final String CONFIG_PROPERTY = "org.eclipse.ptp.rdt.ui.ServiceModelWizardPage.serviceConfig"; //$NON-NLS-1$ > > boolean fbVisited; > private String fTitle; > private String fDescription; > private ImageDescriptor fImageDescriptor; > private Image fImage; >- private Control fCanvas; >- private IServiceConfiguration fConfig; >- private NewServiceModelWidget fModelWidget; >+ private IServiceConfiguration fNewConfig; >+ private Control pageControl; >+ >+ private Text newConfigNameText; >+ private Combo configCombo; >+ > >- > public ServiceModelWizardPage(String pageID) { > super(pageID); >+ >+ > } > > /** >@@ -81,6 +101,7 @@ > return allApplicableServices; > } > >+ > /** > * > */ >@@ -105,27 +126,219 @@ > /* (non-Javadoc) > * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) > */ >- public void createControl(Composite parent) { >- fCanvas = parent; // TODO >- fModelWidget = new NewServiceModelWidget(parent, SWT.NONE); >+ public void createControl(final Composite parent) { >+ Composite comp = new Composite(parent, SWT.NONE); >+ comp.setLayout(new GridLayout(1, false)); >+ pageControl = comp; >+ >+ final Button newConfigButton = new Button(comp, SWT.RADIO); >+ newConfigButton.setText("Create a new Service Configuration for the project"); //$NON-NLS-1$ >+ newConfigButton.setSelection(true); >+ newConfigButton.setLayoutData(new GridData()); >+ >+ Composite newComp = new Composite(comp, SWT.NONE); >+ newComp.setLayoutData(new GridData()); >+ GridLayout layout = new GridLayout(1, false); >+ layout.marginLeft = 10; >+ newComp.setLayout(layout); >+ >+ final Label label1 = new Label(newComp, SWT.NONE); >+ label1.setText("Service Configuration Name:"); //$NON-NLS-1$ >+ label1.setLayoutData(new GridData()); >+ >+ newConfigNameText = new Text(newComp, SWT.BORDER); >+ newConfigNameText.setText(getDefaultConfigName()); >+ GridData data = new GridData(); >+ data.widthHint = 150; >+ newConfigNameText.setLayoutData(data); >+ >+ new Label(comp, SWT.NONE); >+ >+ Button existingConfigButton = new Button(comp, SWT.RADIO); >+ existingConfigButton.setText("Add the project to an existing Service Configuration"); //$NON-NLS-1$ >+ existingConfigButton.setLayoutData(new GridData()); >+ >+ Composite existingComp = new Composite(comp, SWT.NONE); >+ layout = new GridLayout(1, false); >+ layout.marginLeft = 10; >+ existingComp.setLayoutData(new GridData()); >+ existingComp.setLayout(layout); >+ >+ final Label label2 = new Label(existingComp, SWT.NONE); >+ label2.setText("Service Configuration:"); //$NON-NLS-1$ >+ label2.setLayoutData(new GridData()); > >- MBSCustomPageManager.addPageProperty(pageID, SERVICE_MODEL_WIDGET_PROPERTY, fModelWidget); >+ configCombo = new Combo(existingComp, SWT.NONE); >+ data = new GridData(); >+ data.widthHint = 150; >+ configCombo.setLayoutData(data); >+ label2.setEnabled(false); >+ configCombo.setEnabled(false); >+ >+ // if there are no existing configurations, then you can't choose one >+ if(!populateCombo()) { >+ existingConfigButton.setEnabled(false); >+ } >+ >+ updateConfigPageProperty(true); >+ >+ newConfigButton.addSelectionListener(new SelectionAdapter() { >+ @Override public void widgetSelected(SelectionEvent e) { >+ label1.setEnabled(true); >+ newConfigNameText.setEnabled(true); >+ label2.setEnabled(false); >+ configCombo.setEnabled(false); >+ updateConfigPageProperty(true); >+ } >+ }); >+ >+ existingConfigButton.addSelectionListener(new SelectionAdapter() { >+ @Override public void widgetSelected(SelectionEvent e) { >+ label1.setEnabled(false); >+ newConfigNameText.setEnabled(false); >+ label2.setEnabled(true); >+ configCombo.setEnabled(true); >+ updateConfigPageProperty(false); >+ } >+ }); >+ >+ configCombo.addSelectionListener(new SelectionAdapter() { >+ @Override public void widgetSelected(SelectionEvent e) { >+ updateConfigPageProperty(false); >+ } >+ >+ }); >+ >+ Button advanced = new Button(comp, SWT.PUSH); >+ data = new GridData(); >+ data.horizontalAlignment = SWT.END; >+ data.grabExcessHorizontalSpace = true; >+ data.grabExcessVerticalSpace = true; >+ data.verticalAlignment = SWT.END; >+ >+ advanced.setText("Advanced Settings..."); //$NON-NLS-1$ >+ advanced.setLayoutData(data); >+ >+ advanced.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ NewServiceModelWidgetDialog dialog = new NewServiceModelWidgetDialog(parent.getShell()); >+ IServiceConfiguration config = newConfigButton.getSelection() ? getNewConfiguration() : getExistingConfiguration(); >+ dialog.setText("Editing Service Configuration: " + config.getName()); //$NON-NLS-1$ >+ dialog.open(config); >+ } >+ }); >+ >+ >+// Control control = fModelWidget.getParent().getShell(); //get the shell or doesn't display help correctly >+// PlatformUI.getWorkbench().getHelpSystem().setHelp(control,RDTHelpContextIds.SERVICE_MODEL_WIZARD); >+ } >+ >+ >+ private void updateConfigPageProperty(boolean useNew) { >+ IServiceConfiguration config = useNew ? getNewConfiguration() : getExistingConfiguration(); >+ MBSCustomPageManager.addPageProperty( >+ SERVICE_MODEL_WIZARD_PAGE_ID, CONFIG_PROPERTY, config); > >- String configName = DEFAULT_CONFIG; >+ } >+ >+ private boolean populateCombo() { >+ IServiceModelManager smm = ServiceModelManager.getInstance(); >+ Set<IServiceConfiguration> configSet = smm.getConfigurations(); >+ IServiceConfiguration[] configs = configSet.toArray(new IServiceConfiguration[configSet.size()]); >+ for(IServiceConfiguration config : configs) { >+ configCombo.add(config.getName()); >+ } >+ if(!configSet.isEmpty()) { >+ configCombo.select(0); >+ } >+ >+ configCombo.setData(configs); >+ return !configSet.isEmpty(); >+ } >+ >+ >+ >+ >+ >+ private String getDefaultConfigName() { >+ String candidateName = DEFAULT_CONFIG; > IWizardPage page = getWizard().getStartingPage(); >- if(page instanceof CDTMainWizardPage) { >- CDTMainWizardPage cdtPage = (CDTMainWizardPage) page; >- configName = cdtPage.getProjectName(); >+ if(page instanceof NewRemoteProjectCreationPage) { >+ NewRemoteProjectCreationPage cdtPage = (NewRemoteProjectCreationPage) page; >+ candidateName = cdtPage.getRemoteConnection().getName(); > } > >- fConfig = ServiceModelManager.getInstance().newServiceConfiguration(configName); >+ Set<IServiceConfiguration> configs = ServiceModelManager.getInstance().getConfigurations(); >+ Set<String> existingNames = new HashSet<String>(); >+ for(IServiceConfiguration config : configs) { >+ existingNames.add(config.getName()); >+ } > >- fModelWidget.setServiceConfiguration(fConfig); >+ int i = 2; >+ String newConfigName = candidateName; >+ while(existingNames.contains(newConfigName)) { >+ newConfigName = candidateName + " (" + (i++) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ >+ } > >- Control control = fModelWidget.getParent().getShell(); //get the shell or doesn't display help correctly >- PlatformUI.getWorkbench().getHelpSystem().setHelp(control,RDTHelpContextIds.SERVICE_MODEL_WIZARD); >+ return newConfigName; > } > >+ >+ private IServiceConfiguration getExistingConfiguration() { >+ return ((IServiceConfiguration[])configCombo.getData())[configCombo.getSelectionIndex()]; >+ } >+ >+ /** >+ * Creates a new configuration with the RDT defaults. >+ */ >+ private IServiceConfiguration getNewConfiguration() { >+ if(fNewConfig == null) { >+ String configName = newConfigNameText.getText(); // TODO error check >+ >+ IServiceModelManager smm = ServiceModelManager.getInstance(); >+ fNewConfig = smm.newServiceConfiguration(configName); >+ >+ IWizardPage page = getWizard().getStartingPage(); >+ if(page instanceof NewRemoteProjectCreationPage) { >+ NewRemoteProjectCreationPage cdtPage = (NewRemoteProjectCreationPage) page; >+ IRemoteServices remoteServices = cdtPage.getRemoteServices(); >+ IRemoteConnection remoteConnection = cdtPage.getRemoteConnection(); >+ >+ IService buildService = smm.getService(IRDTServiceConstants.SERVICE_BUILD); >+ IServiceProviderDescriptor descriptor = buildService.getProviderDescriptor(RemoteBuildServiceProvider.ID); >+ RemoteBuildServiceProvider rbsp = (RemoteBuildServiceProvider)smm.getServiceProvider(descriptor); >+ rbsp.setRemoteToolsProviderID(remoteServices.getId()); >+ rbsp.setRemoteToolsConnection(remoteConnection); >+ fNewConfig.setServiceProvider(buildService, rbsp); >+ >+ if(remoteServices.getId().equals("org.eclipse.ptp.remote.RSERemoteServices") ) { //$NON-NLS-1$ >+ IService indexingService = smm.getService(IRDTServiceConstants.SERVICE_C_INDEX); >+ descriptor = indexingService.getProviderDescriptor(RemoteCIndexServiceProvider.ID); >+ RemoteCIndexServiceProvider rcisp = (RemoteCIndexServiceProvider) smm.getServiceProvider(descriptor); >+ >+ String hostName = remoteConnection.getAddress(); >+ IHost host = RSEUtils.getConnection(hostName); >+ String configPath = RSEUtils.getDefaultConfigDirectory(host); >+ >+ rcisp.setConnection(host, getDStoreConnectorService(host)); >+ rcisp.setIndexLocation(configPath); >+ rcisp.setConfigured(true); >+ fNewConfig.setServiceProvider(indexingService, rcisp); >+ } >+ } >+ } >+ >+ return fNewConfig; >+ } >+ >+ private IConnectorService getDStoreConnectorService(IHost host) { >+ for(IConnectorService cs : host.getConnectorServices()) { >+ if(cs instanceof DStoreConnectorService) >+ return cs; >+ } >+ return null; >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.jface.dialogs.IDialogPage#dispose() > */ >@@ -138,7 +351,7 @@ > * @see org.eclipse.jface.dialogs.IDialogPage#getControl() > */ > public Control getControl() { >- return fModelWidget; >+ return pageControl; > } > > /* (non-Javadoc) >@@ -227,7 +440,6 @@ > if(visible) { > fbVisited = true; > } >- fCanvas.setVisible(visible); > } > > >Index: src/org/eclipse/ptp/rdt/ui/wizards/RemoteServicesProviderSelectionDialog.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/RemoteServicesProviderSelectionDialog.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/RemoteServicesProviderSelectionDialog.java >--- src/org/eclipse/ptp/rdt/ui/wizards/RemoteServicesProviderSelectionDialog.java 1 Sep 2009 15:52:38 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,270 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM - Initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import java.util.HashMap; >-import java.util.Map; >- >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.dialogs.IDialogConstants; >-import org.eclipse.ptp.rdt.ui.messages.Messages; >-import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider; >-import org.eclipse.ptp.remote.core.IRemoteConnection; >-import org.eclipse.ptp.remote.core.IRemoteServices; >-import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; >-import org.eclipse.ptp.remote.ui.IRemoteUIConnectionManager; >-import org.eclipse.ptp.remote.ui.PTPRemoteUIPlugin; >-import org.eclipse.ptp.services.core.IServiceProvider; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.events.SelectionListener; >-import org.eclipse.swt.graphics.Point; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Combo; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Shell; >- >-/** >- * Allows the user to select a provider of Remote Services for a RemoteBuildServiceProvider. >- * >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * >- * @author crecoskie >- * @see org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider >- */ >-public class RemoteServicesProviderSelectionDialog extends Dialog { >- >- >- private RemoteBuildServiceProvider fProvider; >- >- private Map<Integer, IRemoteServices> fComboIndexToRemoteServicesProviderMap = new HashMap<Integer, IRemoteServices>(); >- >- private IRemoteServices fSelectedProvider; >- >- private Map<Integer, IRemoteConnection> fComboIndexToRemoteConnectionMap = new HashMap<Integer, IRemoteConnection>(); >- >- private IRemoteConnection fSelectedConnection; >- >- public RemoteServicesProviderSelectionDialog(IServiceProvider provider, Shell parentShell) { >- super(parentShell); >- >- if(provider instanceof RemoteBuildServiceProvider) >- fProvider = (RemoteBuildServiceProvider) provider; >- else >- throw new IllegalArgumentException(); // should never happen >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >- */ >- protected Control createDialogArea(Composite parent) { >- Composite container = (Composite) super.createDialogArea(parent); >- >- getShell().setText(Messages.getString("RemoteServicesProviderSelectionDialog_0")); //$NON-NLS-1$ >- >- GridLayout layout = new GridLayout(); >- layout.numColumns = 5; >- container.setLayout(layout); >- >- // Label for "Provider:" >- Label providerLabel = new Label(container, SWT.LEFT); >- providerLabel.setText(Messages.getString("RemoteServicesProviderSelectionDialog_1")); //$NON-NLS-1$ >- >- // combo for providers >- final Combo providerCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); >- // set layout to grab horizontal space >- providerCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); >- >- //attempt to restore settings from saved state >- IRemoteServices providerSelected = fProvider.getRemoteServices(); >- >- // populate the combo with a list of providers >- IRemoteServices[] providers = PTPRemoteCorePlugin.getDefault().getAllRemoteServices(); >- int toSelect = 0; >- >- for(int k = 0; k < providers.length; k++) { >- providerCombo.add(providers[k].getName(), k); >- fComboIndexToRemoteServicesProviderMap.put(k, providers[k]); >- >- if (providerSelected != null && providerSelected.getName().compareTo(providers[k].getName()) == 0) { >- toSelect = k; >- } >- } >- >- // set selected host to be the first one if we're not restoring from settings >- providerCombo.select(toSelect); >- fSelectedProvider = fComboIndexToRemoteServicesProviderMap.get(toSelect); >- >- // connection combo >- // Label for "Connection:" >- Label connectionLabel = new Label(container, SWT.LEFT); >- connectionLabel.setText(Messages.getString("RemoteServicesProviderSelectionDialog.0")); //$NON-NLS-1$ >- >- // combo for providers >- final Combo connectionCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); >- // set layout to grab horizontal space >- connectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); >- >- // populate the combo with a list of providers >- populateConnectionCombo(connectionCombo); >- >- // new connection button >- final Button newConnectionButton = new Button(container, SWT.PUSH); >- newConnectionButton.setText(Messages.getString("RemoteServicesProviderSelectionDialog.1")); //$NON-NLS-1$ >- updateNewConnectionButtonEnabled(newConnectionButton); >- >- >- newConnectionButton.addSelectionListener(new SelectionListener() { >- >- public void widgetDefaultSelected(SelectionEvent e) { >- widgetSelected(e); >- >- } >- >- public void widgetSelected(SelectionEvent e) { >- >- IRemoteUIConnectionManager connectionManager = getUIConnectionManager(); >- if(connectionManager != null) { >- connectionManager.newConnection(getShell()); >- } >- >- // refresh list of connections >- populateConnectionCombo(connectionCombo); >- >- } >- >- }); >- >- providerCombo.addSelectionListener(new SelectionListener() { >- >- public void widgetDefaultSelected(SelectionEvent e) { >- widgetSelected(e); >- >- } >- >- public void widgetSelected(SelectionEvent e) { >- int selectionIndex = providerCombo.getSelectionIndex(); >- fSelectedProvider = fComboIndexToRemoteServicesProviderMap.get(selectionIndex); >- >- populateConnectionCombo(connectionCombo); >- updateNewConnectionButtonEnabled(newConnectionButton); >- >- } >- >- }); >- >- connectionCombo.addSelectionListener(new SelectionListener() { >- >- public void widgetDefaultSelected(SelectionEvent e) { >- widgetSelected(e); >- >- } >- >- public void widgetSelected(SelectionEvent e) { >- int selectionIndex = connectionCombo.getSelectionIndex(); >- fSelectedConnection = fComboIndexToRemoteConnectionMap.get(selectionIndex); >- updateNewConnectionButtonEnabled(newConnectionButton); >- } >- >- }); >- >- >- return container; >- } >- >- >- private void updateNewConnectionButtonEnabled(Button button) { >- IRemoteUIConnectionManager connectionManager = getUIConnectionManager(); >- button.setEnabled(connectionManager != null); >- } >- >- /** >- * @return >- */ >- private IRemoteUIConnectionManager getUIConnectionManager() { >- IRemoteUIConnectionManager connectionManager = PTPRemoteUIPlugin.getDefault().getRemoteUIServices(fSelectedProvider) >- .getUIConnectionManager(); >- return connectionManager; >- } >- >- /** >- * @param connectionCombo >- */ >- private void populateConnectionCombo(final Combo connectionCombo) { >- connectionCombo.removeAll(); >- >- //attempt to restore settings from saved state >- IRemoteConnection connectionSelected = fProvider.getConnection(); >- >- IRemoteConnection[] connections = fSelectedProvider.getConnectionManager().getConnections(); >- int toSelect = 0; >- >- for(int k = 0; k < connections.length; k++) { >- connectionCombo.add(connections[k].getName(), k); >- fComboIndexToRemoteConnectionMap .put(k, connections[k]); >- >- if (connectionSelected != null && connectionSelected.getName().compareTo(connections[k].getName()) == 0) { >- toSelect = k; >- } >- } >- >- // set selected connection to be the first one if we're not restoring from settings >- connectionCombo.select(toSelect); >- fSelectedConnection = fComboIndexToRemoteConnectionMap.get(toSelect); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) >- */ >- protected void createButtonsForButtonBar(Composite parent) { >- createButton(parent, IDialogConstants.OK_ID, >- IDialogConstants.OK_LABEL, true); >- createButton(parent, IDialogConstants.CANCEL_ID, >- IDialogConstants.CANCEL_LABEL, false); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#isResizable() >- */ >- @Override >- protected boolean isResizable() { >- return true; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() >- */ >- protected Point getInitialSize() { >- return new Point(750, 125); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#okPressed() >- */ >- @Override >- protected void okPressed() { >- super.okPressed(); >- >- // set the provider >- fProvider.setRemoteToolsProviderID(fSelectedProvider.getId()); >- fProvider.setRemoteToolsConnection(fSelectedConnection); >- >- } >- >- >-} >Index: src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteCppProjectWizard.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteCppProjectWizard.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteCppProjectWizard.java >--- src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteCppProjectWizard.java 18 Nov 2008 16:40:37 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,96 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM - Initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import org.eclipse.cdt.core.CCProjectNature; >-import org.eclipse.cdt.core.CProjectNature; >-import org.eclipse.cdt.ui.CUIPlugin; >-import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard; >-import org.eclipse.cdt.ui.wizards.CDTMainWizardPage; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.jface.resource.ImageDescriptor; >-import org.eclipse.ptp.internal.rdt.ui.RDTPluginImages; >-import org.eclipse.ptp.rdt.core.resources.RemoteNature; >-import org.eclipse.ptp.rdt.ui.messages.Messages; >-import org.eclipse.swt.widgets.Composite; >- >-/** >- * A wizard for creating new Remote C/C++ Projects >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * >- * @author crecoskie >- * >- */ >-public class NewRemoteCppProjectWizard extends CDTCommonProjectWizard { >- private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$ >- private static final String wz_title = Messages.getString("NewRemoteCppProjectWizard_0"); //$NON-NLS-1$ >- private static final String wz_desc = Messages.getString("NewRemoteCppProjectWizard_1"); //$NON-NLS-1$ >- >- /** >- * >- */ >- public NewRemoteCppProjectWizard() { >- >- super(wz_title, wz_desc); >- } >- >- >- /* (non-Javadoc) >- * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#continueCreation(org.eclipse.core.resources.IProject) >- */ >- >- @Override >- protected IProject continueCreation(IProject prj) { >- try { >- CProjectNature.addCNature(prj, new NullProgressMonitor()); >- CCProjectNature.addCCNature(prj, new NullProgressMonitor()); >- RemoteNature.addRemoteNature(prj, new NullProgressMonitor()); >- } catch (CoreException e) {} >- return prj; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#getNatures() >- */ >- @Override >- public String[] getNatures() { >- return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID, RemoteNature.REMOTE_NATURE_ID}; >- } >- >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.wizards.newresource.BasicNewResourceWizard#initializeDefaultPageImageDescriptor() >- */ >- @Override >- protected void initializeDefaultPageImageDescriptor() { >- setDefaultPageImageDescriptor(RDTPluginImages.DESC_WIZBAN_NEW_REMOTE_C_PROJ); >- } >- >- >- /* (non-Javadoc) >- * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#addPages() >- */ >- @Override >- public void addPages() { >- fMainPage= new RDTMainWizardPage(CUIPlugin.getResourceString(PREFIX)); >- fMainPage.setTitle(wz_title); >- fMainPage.setDescription(wz_desc); >- addPage(fMainPage); >- } >- >- >- >-} >Index: src/org/eclipse/ptp/rdt/ui/wizards/HostSelectionDialog.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/HostSelectionDialog.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/HostSelectionDialog.java >--- src/org/eclipse/ptp/rdt/ui/wizards/HostSelectionDialog.java 1 Sep 2009 15:52:38 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,212 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM - Initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import java.util.HashMap; >-import java.util.Map; >- >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.dialogs.IDialogConstants; >-import org.eclipse.jface.wizard.IWizard; >-import org.eclipse.jface.wizard.WizardDialog; >-import org.eclipse.ptp.rdt.ui.messages.Messages; >-import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteCIndexServiceProvider; >-import org.eclipse.ptp.services.core.IServiceProvider; >-import org.eclipse.rse.connectorservice.dstore.DStoreConnectorService; >-import org.eclipse.rse.core.model.IHost; >-import org.eclipse.rse.core.model.SystemStartHere; >-import org.eclipse.rse.core.subsystems.IConnectorService; >-import org.eclipse.rse.ui.wizards.newconnection.RSEDefaultNewConnectionWizard; >-import org.eclipse.rse.ui.wizards.newconnection.RSEMainNewConnectionWizard; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.events.SelectionListener; >-import org.eclipse.swt.graphics.Point; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Combo; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Label; >-import org.eclipse.swt.widgets.Shell; >- >-/** >- * Provides a dialog which allows you to select an RSE host for the RemoteCIndexServiceProvider. >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * >- * @author crecoskie >- * >- */ >-public class HostSelectionDialog extends Dialog { >- >- private RemoteCIndexServiceProvider fProvider; >- >- private Map<Integer, IHost> fHostComboIndexToHostMap = new HashMap<Integer, IHost>(); >- >- private IHost fSelectedHost; >- private String configPath; >- >- public HostSelectionDialog(IServiceProvider provider, Shell parentShell) { >- super(parentShell); >- >- if(provider instanceof RemoteCIndexServiceProvider) >- fProvider = (RemoteCIndexServiceProvider) provider; >- else >- throw new IllegalArgumentException(); // should never happen >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) >- */ >- protected Control createDialogArea(Composite parent) { >- Composite container = (Composite) super.createDialogArea(parent); >- getShell().setText(Messages.getString("HostSelectionDialog.1")); //$NON-NLS-1$ >- >- GridLayout layout = new GridLayout(); >- layout.numColumns = 3; >- container.setLayout(layout); >- >- // Label for "Host:" >- Label hostLabel = new Label(container, SWT.LEFT); >- hostLabel.setText(Messages.getString("HostSelectionDialog_0")); //$NON-NLS-1$ >- >- // combo for hosts >- final Combo hostCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); >- hostCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); // set layout to grab horizontal space >- >- //attempt to restore settings from saved state >- IHost hostSelected = fProvider.getHost(); >- >- // populate the combo with a list of hosts >- IHost[] hosts = SystemStartHere.getConnections(); >- int toSelect = 0; >- >- for(int k = 0; k < hosts.length; k++) { >- hostCombo.add(hosts[k].getAliasName(), k); >- fHostComboIndexToHostMap.put(k, hosts[k]); >- >- if (hostSelected != null && hostSelected.getAliasName().compareTo(hosts[k].getAliasName()) == 0) { >- toSelect = k; >- } >- } >- >- // set selected host to be the first one if we're not restoring from settings >- hostCombo.select(toSelect); >- fSelectedHost = fHostComboIndexToHostMap.get(toSelect); >- >- >- >- // button for creating new connections >- Button newConnectionButton = new Button(container, SWT.PUSH); >- newConnectionButton.setText(Messages.getString("HostSelectionDialog.0")); //$NON-NLS-1$ >- newConnectionButton.addSelectionListener(new SelectionAdapter() { >- >- public void widgetSelected(SelectionEvent e) { >- // launch the RSE New Connection Wizard >- RSEMainNewConnectionWizard wizard = new RSEMainNewConnectionWizard(); >- WizardDialog wizardDialog = new WizardDialog(getShell(), wizard); >- wizardDialog.open(); >- >- IWizard actualWizard = wizard.getSelectedWizard(); >- if(actualWizard instanceof RSEDefaultNewConnectionWizard) { >- // get the new host, if any >- IHost host = ((RSEDefaultNewConnectionWizard)actualWizard).getCreatedHost(); >- >- // add the host >- int index = hostCombo.getItemCount() - 1; >- hostCombo.add(host.getAliasName(), index); >- fHostComboIndexToHostMap.put(index, host); >- >- // select the new host >- hostCombo.select(index); >- fSelectedHost = host; >- } >- } >- >- }); >- >- configPath = fProvider.getIndexLocation(); >- if(fProvider.isConfigured() && configPath == null) // happens if the project was created before the index location feature was added >- configPath = ""; //$NON-NLS-1$ >- >- final IndexFileLocationWidget scopeWidget = new IndexFileLocationWidget(container, SWT.NONE, fSelectedHost, configPath); >- GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); >- data.horizontalSpan = 3; >- scopeWidget.setLayoutData(data); // set layout to grab horizontal space >- scopeWidget.addPathListener(new IIndexFilePathChangeListener() { >- public void pathChanged(String newPath) { >- configPath = newPath; >- } >- }); >- >- >- hostCombo.addSelectionListener(new SelectionListener() { >- public void widgetDefaultSelected(SelectionEvent e) { >- widgetSelected(e); >- } >- >- public void widgetSelected(SelectionEvent e) { >- int selectionIndex = hostCombo.getSelectionIndex(); >- fSelectedHost = fHostComboIndexToHostMap.get(selectionIndex); >- scopeWidget.setHost(fSelectedHost); >- } >- }); >- >- return container; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) >- */ >- protected void createButtonsForButtonBar(Composite parent) { >- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); >- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#getInitialSize() >- */ >- protected Point getInitialSize() { >- return new Point(500,300); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#okPressed() >- */ >- @Override >- protected void okPressed() { >- super.okPressed(); >- >- // set the host for the service provider >- fProvider.setConnection(fSelectedHost, getDStoreConnectorService(fSelectedHost)); >- fProvider.setIndexLocation(configPath); >- fProvider.setConfigured(true); >- } >- >- private IConnectorService getDStoreConnectorService(IHost host) { >- IConnectorService[] connectorServices = host.getConnectorServices(); >- >- for(int k = 0; k < connectorServices.length; k++) { >- if(connectorServices[k] instanceof DStoreConnectorService) >- return connectorServices[k]; >- } >- >- return null; >- } >- >- >- >-} >Index: src/org/eclipse/ptp/rdt/ui/wizards/ConfigureRemoteServices.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/ConfigureRemoteServices.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/ConfigureRemoteServices.java >--- src/org/eclipse/ptp/rdt/ui/wizards/ConfigureRemoteServices.java 1 Sep 2009 15:52:39 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,85 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM - Initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import java.io.IOException; >-import java.util.Map; >- >-import org.eclipse.cdt.core.CCorePlugin; >-import org.eclipse.cdt.core.model.ICProject; >-import org.eclipse.cdt.internal.core.model.CModelManager; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.ptp.internal.rdt.core.index.RemoteFastIndexer; >-import org.eclipse.ptp.rdt.ui.messages.Messages; >-import org.eclipse.ptp.services.core.IService; >-import org.eclipse.ptp.services.core.IServiceConfiguration; >-import org.eclipse.ptp.services.core.IServiceProvider; >-import org.eclipse.ptp.services.core.ServiceModelManager; >-import org.eclipse.rse.internal.connectorservice.dstore.Activator; >- >-/** >- * Configure remote services for a project with the available services and service providers >- * >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * >- * @author vkong >- * >- */ >-public class ConfigureRemoteServices { >- >- public static String DEFAULT_CONFIG = Messages.getString("ConfigureRemoteServices.0"); //$NON-NLS-1$ >- >- /** >- * @throws NullPointerException if any of the parameters are null >- */ >- public static void configure(IProject project, Map<String, String> serviceIDToProviderIDMap, >- Map<String, IServiceProvider> providerIDToProviderMap, IProgressMonitor monitor) { >- >- monitor.beginTask("actual Configure remote services", 100); //$NON-NLS-1$ >- >- if(project == null) >- throw new NullPointerException(); >- >- final ServiceModelManager serviceModelManager = ServiceModelManager.getInstance(); >- >- IServiceConfiguration config = serviceModelManager.newServiceConfiguration(DEFAULT_CONFIG); >- >- int workUnit = 90/serviceIDToProviderIDMap.size(); >- >- for(String serviceID : serviceIDToProviderIDMap.keySet()) { >- IService service = serviceModelManager.getService(serviceID); >- String serviceProviderID = serviceIDToProviderIDMap.get(serviceID); >- IServiceProvider provider = providerIDToProviderMap.get(serviceProviderID); >- config.setServiceProvider(service, provider); >- >- monitor.worked(workUnit); >- >- //have to set it as active >- serviceModelManager.addConfiguration(project, config); >- serviceModelManager.setActiveConfiguration(project, config); >- } >- >- try { >- serviceModelManager.saveModelConfiguration(); >- } catch (IOException e) { >- Activator.logError(e.toString(), e); >- } >- >- ICProject cProject = CModelManager.getDefault().getCModel().getCProject(project); >- CCorePlugin.getIndexManager().setIndexerId(cProject, RemoteFastIndexer.ID); >- monitor.worked(10); >- monitor.done(); >- } >-} >Index: src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWizardPageOperation.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.ui/src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWizardPageOperation.java,v >retrieving revision 1.8 >diff -u -r1.8 ServiceModelWizardPageOperation.java >--- src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWizardPageOperation.java 25 Sep 2009 01:41:46 -0000 1.8 >+++ src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWizardPageOperation.java 25 Sep 2009 20:06:11 -0000 >@@ -10,7 +10,7 @@ > *******************************************************************************/ > package org.eclipse.ptp.rdt.ui.wizards; > >-import static org.eclipse.ptp.rdt.ui.wizards.ServiceModelWizardPage.SERVICE_MODEL_WIDGET_PROPERTY; >+import static org.eclipse.ptp.rdt.ui.wizards.ServiceModelWizardPage.CONFIG_PROPERTY; > > import java.io.IOException; > import java.lang.reflect.InvocationTargetException; >@@ -19,7 +19,7 @@ > import org.eclipse.cdt.core.model.ICProject; > import org.eclipse.cdt.internal.core.model.CModelManager; > import org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager; >-import org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard; >+import org.eclipse.cdt.ui.wizards.ICDTCommonProjectWizard; > import org.eclipse.core.resources.IProject; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jface.operation.IRunnableWithProgress; >@@ -27,7 +27,6 @@ > import org.eclipse.ptp.internal.rdt.core.index.RemoteFastIndexer; > import org.eclipse.ptp.services.core.IServiceConfiguration; > import org.eclipse.ptp.services.core.ServiceModelManager; >-import org.eclipse.ptp.services.ui.widgets.NewServiceModelWidget; > import org.eclipse.rse.internal.connectorservice.dstore.Activator; > > /** >@@ -38,30 +37,19 @@ > * that it will remain the same. Please do not use this API without consulting > * with the RDT team. > * >- * @author crecoskie > * > */ > public class ServiceModelWizardPageOperation implements IRunnableWithProgress { > >- /** >- * >- */ >- public ServiceModelWizardPageOperation() { >- // TODO Auto-generated constructor stub >- } > >- /* (non-Javadoc) >- * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor) >- */ >+ > public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >- monitor.beginTask("configure model services", 100); //$NON-NLS-1$ >- >+ monitor.beginTask("configure model services", 100); //$NON-NLS-1$ >+ > IWizard wizard = MBSCustomPageManager.getPageData(ServiceModelWizardPage.SERVICE_MODEL_WIZARD_PAGE_ID).getWizardPage().getWizard(); >- IProject project = ((CDTCommonProjectWizard) wizard).getLastProject(); >+ IProject project = ((ICDTCommonProjectWizard) wizard).getLastProject(); > >- NewServiceModelWidget widget = (NewServiceModelWidget)getMBSProperty(SERVICE_MODEL_WIDGET_PROPERTY); >- widget.applyChangesToConfiguration(); >- IServiceConfiguration config = widget.getServiceConfiguration(); >+ IServiceConfiguration config = (IServiceConfiguration)getMBSProperty(CONFIG_PROPERTY); > > ServiceModelManager smm = ServiceModelManager.getInstance(); > smm.addConfiguration(project, config); >Index: src/org/eclipse/ptp/rdt/ui/wizards/ConvertToRemoteServiceModelWidget.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/ConvertToRemoteServiceModelWidget.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/ConvertToRemoteServiceModelWidget.java >--- src/org/eclipse/ptp/rdt/ui/wizards/ConvertToRemoteServiceModelWidget.java 1 Sep 2009 15:52:38 -0000 1.6 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,205 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - Initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.Map; >-import java.util.Set; >- >-import org.eclipse.core.resources.IProject; >-import org.eclipse.ptp.rdt.ui.messages.Messages; >-import org.eclipse.ptp.rdt.ui.serviceproviders.NullBuildServiceProvider; >-import org.eclipse.ptp.rdt.ui.serviceproviders.NullCIndexServiceProvider; >-import org.eclipse.ptp.services.core.IService; >-import org.eclipse.ptp.services.core.IServiceProvider; >-import org.eclipse.ptp.services.core.IServiceProviderDescriptor; >-import org.eclipse.ptp.services.core.ServiceModelManager; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.widgets.Event; >-import org.eclipse.swt.widgets.Listener; >-import org.eclipse.swt.widgets.TableItem; >- >-/** >- * A table widget listing remote services and service providers. This widget is used in >- * ConvertToRemoteWizardPage and it stores information on the remote service model for the >- * projects to be converted. >- * >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * >- * @author vkong >- * >- */ >-public class ConvertToRemoteServiceModelWidget extends ServiceModelWidget { >- >- IProject fCurrentProject; >- >- Map<IProject, Map<String,String>> projectToServices = new HashMap<IProject, Map<String,String>>(); >- Map<IProject, Map<String,IServiceProvider>> projectToProviders = new HashMap<IProject, Map<String,IServiceProvider>>(); >- >- public class ConfigureListener2 extends ConfigureListener { >- public void handleEvent(Event event) { >- super.handleEvent(event); >- //users have to configure the services manually by clicking the configure button, not done automatically >- //once the services have been configured, they will be saved >- projectToServices.put(fCurrentProject, fServiceIDToSelectedProviderID); >- projectToProviders.put(fCurrentProject, fProviderIDToProviderMap); >- } >- } >- >- /** >- * Find available remote services and service providers for the given project and >- * add them to the table >- * @param project >- */ >- public void addServicesToTable(IProject project) { >- fProviderIDToProviderMap = new HashMap<String, IServiceProvider>(); >- fServiceIDToSelectedProviderID = new HashMap<String, String>(); >- fCurrentProject = project; >- createTableContent(project); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.ptp.rdt.ui.wizards.ServiceModelWidget#createTableContent(org.eclipse.core.resources.IProject) >- */ >- @Override >- protected void createTableContent(IProject project) { >- fTable.removeAll(); >- if (project == null) { >- super.createTableContent(project); >- } else if (projectToServices.get(project) == null && projectToProviders.get(project) == null) { >- super.createTableContent(project); >- } else { >- Set<IService> services = getContributedServices(project); >- Iterator<IService> iterator = services.iterator(); >- >- Map<String, String> serviceIDToSelectedProviderID = projectToServices.get(fCurrentProject); >- Map<String, IServiceProvider> providerIDToProviderMap = projectToProviders.get(fCurrentProject); >- >- while(iterator.hasNext()) { >- final IService service = iterator.next(); >- >- TableItem item = new TableItem (fTable, SWT.NONE); >- >- // column 0 lists the name of the service >- item.setText (0, service.getName()); >- item.setData(SERVICE_KEY, service); >- >- String providerID = serviceIDToSelectedProviderID.get(service.getId()); >- IServiceProvider provider= providerIDToProviderMap.get(providerID); >- String configString; >- >- //remember user's selection and restore >- if (provider != null) { >- // column 1 holds a dropdown with a list of providers >- item.setText(1, provider.getName()); >- item.setData(PROVIDER_KEY, provider); >- >- configString = provider.getConfigurationString(); >- } else { //no previous user selection >- >- // column 1 holds a dropdown with a list of providers >- // default entry is the null provider if there is one >- IServiceProviderDescriptor descriptor; >- if (service.getId().compareTo(NullBuildServiceProvider.SERVICE_ID) == 0) >- descriptor = service.getProviderDescriptor(NullBuildServiceProvider.ID); >- else if (service.getId().compareTo(NullCIndexServiceProvider.SERVICE_ID) == 0) >- descriptor = service.getProviderDescriptor(NullCIndexServiceProvider.ID); >- else >- descriptor = service.getProviders().iterator().next(); >- item.setText(1, descriptor.getName()); >- item.setData(PROVIDER_KEY, descriptor); >- >- //No actual providers are created yet so there's no configuration >- configString = Messages.getString("ServiceModelWidget.4"); //$NON-NLS-1$ >- >- if (descriptor.getId().compareTo(NullBuildServiceProvider.ID) == 0 || >- descriptor.getId().compareTo(NullCIndexServiceProvider.ID) == 0) { >- >- //since the null providers are choosen, setup the service provider mappings >- ServiceModelManager manager = ServiceModelManager.getInstance(); >- IServiceProvider serviceProvider = manager.getServiceProvider(descriptor); >- >- configString = serviceProvider.getConfigurationString(); >- // column 2 holds the configuration string of the provider's current configuration >- if (configString == null) { >- configString = Messages.getString("ServiceModelWidget.4"); //$NON-NLS-1$ >- } >- fServiceIDToSelectedProviderID.put(service.getId(), descriptor.getId()); >- fProviderIDToProviderMap.put(descriptor.getId(), serviceProvider); >- } >- } >- >- // column 2 holds the configuration string of the provider's current configuration >- if (configString == null) { >- configString = Messages.getString("ServiceModelWidget.4"); //$NON-NLS-1$ >- } >- item.setText(2, configString); >- } >- >- fServiceIDToSelectedProviderID.putAll(serviceIDToSelectedProviderID); >- fProviderIDToProviderMap.putAll(providerIDToProviderMap); >- } >- projectToServices.put(project, fServiceIDToSelectedProviderID); >- projectToProviders.put(project, fProviderIDToProviderMap); >- >- if (fConfigChangeListener != null) >- fConfigChangeListener.handleEvent(null); >- >- //reset the configuration button >- if (fConfigureButton != null) >- fConfigureButton.setEnabled(false); >- } >- >- public void emptyTable() { >- fTable.removeAll(); >- } >- >- protected Listener getConfigureListener() { >- return new ConfigureListener2(); >- } >- >- /** >- * @return the projectToServices >- */ >- public Map<IProject, Map<String, String>> getProjectToServices() { >- return projectToServices; >- } >- >- /** >- * @return the projectToProviders >- */ >- public Map<IProject, Map<String, IServiceProvider>> getProjectToProviders() { >- return projectToProviders; >- } >- >- public boolean isConfigured(Object[] selectedProjects) { >- boolean configured = true; >- if (selectedProjects == null || selectedProjects.length < 1) >- return false; >- for (int i = 0; i < selectedProjects.length; i++) { >- IProject project = (IProject) selectedProjects[i]; >- Map<String, String> serviceIDToSelectedProviderID = projectToServices.get(project); >- Map<String, IServiceProvider> providerIDToProviderMap = projectToProviders.get(project); >- if (serviceIDToSelectedProviderID == null || providerIDToProviderMap == null) >- return false; >- configured = configured && isConfigured(project, serviceIDToSelectedProviderID, providerIDToProviderMap); >- } >- >- return configured; >- >- } >- >-} >Index: src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWidget.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWidget.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWidget.java >--- src/org/eclipse/ptp/rdt/ui/wizards/ServiceModelWidget.java 17 Sep 2009 15:51:49 -0000 1.10 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,459 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2008, 2009 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - Initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.ptp.rdt.ui.wizards; >- >-import java.util.HashMap; >-import java.util.Iterator; >-import java.util.LinkedHashSet; >-import java.util.LinkedList; >-import java.util.List; >-import java.util.Map; >-import java.util.Set; >- >-import org.eclipse.cdt.core.CCProjectNature; >-import org.eclipse.cdt.core.CProjectNature; >-import org.eclipse.core.resources.IProject; >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.jface.layout.TableColumnLayout; >-import org.eclipse.jface.viewers.ColumnWeightData; >-import org.eclipse.ptp.rdt.core.RDTLog; >-import org.eclipse.ptp.rdt.ui.messages.Messages; >-import org.eclipse.ptp.rdt.ui.serviceproviders.NullBuildServiceProvider; >-import org.eclipse.ptp.rdt.ui.serviceproviders.NullCIndexServiceProvider; >-import org.eclipse.ptp.services.core.IService; >-import org.eclipse.ptp.services.core.IServiceProvider; >-import org.eclipse.ptp.services.core.IServiceProviderDescriptor; >-import org.eclipse.ptp.services.core.ServiceModelManager; >-import org.eclipse.ptp.services.ui.IServiceProviderConfiguration; >-import org.eclipse.ptp.services.ui.IServiceProviderContributor; >-import org.eclipse.ptp.services.ui.ServiceModelUIManager; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.CCombo; >-import org.eclipse.swt.custom.TableEditor; >-import org.eclipse.swt.layout.FillLayout; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Event; >-import org.eclipse.swt.widgets.Listener; >-import org.eclipse.swt.widgets.Table; >-import org.eclipse.swt.widgets.TableColumn; >-import org.eclipse.swt.widgets.TableItem; >- >-/** >- * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >- * part of a work in progress. There is no guarantee that this API will work or >- * that it will remain the same. Please do not use this API without consulting >- * with the RDT team. >- * >- * @deprecated >- * @see org.eclipse.ptp.services.ui.wizards.ServiceModelWidget >- */ >-public class ServiceModelWidget{ >- >- protected static final String PROVIDER_KEY = "provider-id"; //$NON-NLS-1$ >- protected static final String SERVICE_KEY = "service-id"; //$NON-NLS-1$ >- >- protected Map<String, String> fServiceIDToSelectedProviderID; >- protected Map<String, IServiceProvider> fProviderIDToProviderMap; >- >- protected Table fTable; >- protected Button fConfigureButton; >- protected Listener fConfigChangeListener = null; >- >- public ServiceModelWidget() { >- fServiceIDToSelectedProviderID = new HashMap<String, String>(); >- fProviderIDToProviderMap = new HashMap<String, IServiceProvider>(); >- } >- >- public Control createContents(Composite parent) { >- Composite canvas = new Composite(parent, SWT.NONE); >- GridLayout canvasLayout = new GridLayout(2, false); >- canvas.setLayout(canvasLayout); >- >- Composite tableParent = new Composite(canvas, SWT.NONE); >- tableParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >- >- fTable = new Table (tableParent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL); >- fTable.setLinesVisible (true); >- fTable.setHeaderVisible (true); >- >- TableColumnLayout layout = new TableColumnLayout(); >- // create the columns and headers... note fourth column holds "Configure..." buttons and hence has no title. >- String[] titles = {Messages.getString("ServiceModelWidget.0"), Messages.getString("ServiceModelWidget.1"), Messages.getString("ServiceModelWidget.3")}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- for (int i=0; i<titles.length; i++) { >- TableColumn column = new TableColumn (fTable, SWT.NONE); >- column.setText (titles [i]); >- int width = ColumnWeightData.MINIMUM_WIDTH; >- >- // set the column widths >- switch (i) { >- case 0: // Service name... usually short >- width = 100; >- break; >- >- case 1: // provider name... typically long >- case 2: // configuration string... typically long >- width = 250; >- break; >- >- } >- >- layout.setColumnData(column, new ColumnWeightData(1, width, true)); >- >- >- } >- tableParent.setLayout(layout); >- fTable.setLayout(new FillLayout()); >- >- createTableContent(null); >- >- fTable.setVisible(true); >- >- final TableEditor editor = new TableEditor(fTable); >- editor.horizontalAlignment = SWT.BEGINNING; >- editor.grabHorizontal = true; >- fTable.addListener(SWT.Selection, new Listener() { >- public void handleEvent(Event event) { >- int selectionIndex = fTable.getSelectionIndex(); >- if (selectionIndex == -1) { >- fConfigureButton.setEnabled(false); >- return; >- } >- final TableItem item = fTable.getItem(selectionIndex); >- IService service = (IService) item.getData(SERVICE_KEY); >- IServiceProviderDescriptor provider = (IServiceProviderDescriptor) item.getData(PROVIDER_KEY); >- >- updateConfigureButton(provider); >- >- final CCombo combo = new CCombo(fTable, SWT.READ_ONLY); >- >- // populate with list of providers >- Set<IServiceProviderDescriptor> providers = service.getProviders(); >- Iterator<IServiceProviderDescriptor> providerIterator = providers.iterator(); >- >- int index = 0; >- final List<IServiceProviderDescriptor> providerIds = new LinkedList<IServiceProviderDescriptor>(); >- while(providerIterator.hasNext()) { >- IServiceProviderDescriptor descriptor = providerIterator.next(); >- combo.add(descriptor.getName(), index); >- providerIds.add(descriptor); >- if (descriptor.equals(provider)) { >- combo.select(index); >- } >- ++index; >- } >- >- combo.setFocus(); >- Listener listener = new Listener() { >- public void handleEvent(Event event) { >- switch (event.type) { >- case SWT.FocusOut: >- combo.dispose(); >- break; >- case SWT.Selection: >- int selection = combo.getSelectionIndex(); >- if (selection == -1) { >- return; >- } >- IServiceProviderDescriptor descriptor = providerIds.get(selection); >- item.setText(1, descriptor.getName()); >- IService service = (IService) item.getData(SERVICE_KEY); >- item.setData(PROVIDER_KEY, descriptor); >- >- updateConfigureButton(descriptor); >- >- //look in cache to see if there is a service provider that is already setup >- IServiceProvider provider = fProviderIDToProviderMap.get(descriptor.getId()); >- String configString = Messages.getString("ServiceModelWidget.4"); //$NON-NLS-1$ >- if (provider != null) { //a service provider was already setup >- configString = provider.getConfigurationString(); >- } >- >- item.setText(2, configString); >- >- if (descriptor.getId().compareTo(NullBuildServiceProvider.ID) == 0 || >- descriptor.getId().compareTo(NullCIndexServiceProvider.ID) == 0) { >- >- //since the null providers are chosen, setup the service provider and the mappings >- ServiceModelManager manager = ServiceModelManager.getInstance(); >- IServiceProvider serviceProvider = manager.getServiceProvider(descriptor); >- >- configString = serviceProvider.getConfigurationString(); >- if (configString == null) { >- configString = Messages.getString("ServiceModelWidget.4"); //$NON-NLS-1$ >- } >- item.setText(2, configString); >- fProviderIDToProviderMap.put(descriptor.getId(), serviceProvider); >- } >- >- fServiceIDToSelectedProviderID.put(service.getId(), descriptor.getId()); >- >- // allow container page to check if configurations are set >- if (fConfigChangeListener != null) >- fConfigChangeListener.handleEvent(null); >- >- combo.dispose(); >- break; >- } >- } >- }; >- combo.addListener(SWT.FocusOut, listener); >- combo.addListener(SWT.Selection, listener); >- >- editor.setEditor(combo, item, 1); >- } >- }); >- >- fConfigureButton = new Button(canvas, SWT.PUSH); >- fConfigureButton.setEnabled(false); >- fConfigureButton.setText(Messages.getString("ServiceModelWidget.2")); //$NON-NLS-1$ >- fConfigureButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); >- Listener configureListener = getConfigureListener(); >- fConfigureButton.addListener(SWT.Selection, configureListener); >- return canvas; >- } >- >- public class ConfigureListener implements Listener { >- public void handleEvent(Event event) { >- // launch the configuration UI for the service provider >- TableItem[] selection = fTable.getSelection(); >- if (selection.length == 0) { >- return; >- } >- TableItem item = selection[0]; >- ServiceModelManager manager = ServiceModelManager.getInstance(); >- IServiceProviderDescriptor descriptor = (IServiceProviderDescriptor) item.getData(PROVIDER_KEY); >- >- //look in cache first >- IServiceProvider serviceProvider = fProviderIDToProviderMap.get(descriptor.getId()); >- >- if (serviceProvider == null) { >- serviceProvider = manager.getServiceProvider(descriptor); >- fProviderIDToProviderMap.put(descriptor.getId(), serviceProvider); >- } >- >- IServiceProviderConfiguration configUI = ServiceModelUIManager.getInstance().getServiceProviderConfigurationUI(serviceProvider); >- configUI.configureServiceProvider(serviceProvider, fConfigureButton.getShell()); >- >- String configString = serviceProvider.getConfigurationString(); >- // column 2 holds the configuration string of the provider's current configuration >- if (configString == null) { >- configString = Messages.getString("ServiceModelWidget.4"); //$NON-NLS-1$ >- } >- item.setText(2, configString); >- >- // allow container page to check if configurations are set >- if (fConfigChangeListener != null) >- fConfigChangeListener.handleEvent(null); >- } >- } >- >- //sub class may override to change behaviour >- protected Listener getConfigureListener() { >- return new ConfigureListener(); >- } >- >- /** >- * Generate the services, providers and provider configuration available for >- * the given project in the table >- * >- * Sub-classes may override its behaviour >- * @param project >- */ >- protected void createTableContent(IProject project) { >- fTable.removeAll(); >- Set<IService> allApplicableServices = getContributedServices(project); >- >- Iterator<IService> iterator = allApplicableServices.iterator(); >- >- // get the contributed services... we need one row for each >- while(iterator.hasNext()) { >- final IService service = iterator.next(); >- >- TableItem item = new TableItem (fTable, SWT.NONE); >- >- // column 0 lists the name of the service >- item.setText (0, service.getName()); >- item.setData(SERVICE_KEY, service); >- >- // column 1 holds a dropdown with a list of providers >- // default entry is the null provider if there is one >- IServiceProviderDescriptor descriptor; >-// if (service.getId().compareTo(NullBuildServiceProvider.SERVICE_ID) == 0) >-// descriptor = service.getProviderDescriptor(NullBuildServiceProvider.ID); >-// else if (service.getId().compareTo(NullCIndexServiceProvider.SERVICE_ID) == 0) >-// descriptor = service.getProviderDescriptor(NullCIndexServiceProvider.ID); >-// else >- descriptor = service.getProviders().iterator().next(); >- item.setText(1, descriptor.getName()); >- item.setData(PROVIDER_KEY, descriptor); >- >- // No actual providers are created yet so there's no configuration >- String configString = Messages.getString("ServiceModelWidget.4"); //$NON-NLS-1$ >- >- if (descriptor.getId().compareTo(NullBuildServiceProvider.ID) == 0 || >- descriptor.getId().compareTo(NullCIndexServiceProvider.ID) == 0) { >- >- //since the null providers are chosen, setup the service provider and the mappings >- ServiceModelManager manager = ServiceModelManager.getInstance(); >- IServiceProvider serviceProvider = manager.getServiceProvider(descriptor); >- >- configString = serviceProvider.getConfigurationString(); >- if (configString == null) { >- configString = Messages.getString("ServiceModelWidget.4"); //$NON-NLS-1$ >- } >- >- fProviderIDToProviderMap.put(descriptor.getId(), serviceProvider); >- } >- >- // column 2 holds the configuration string of the provider's current configuration >- item.setText(2, configString); >- >- fServiceIDToSelectedProviderID.put(service.getId(), descriptor.getId()); >- >- // allow container page to check if configurations are set >- if (fConfigChangeListener != null) >- fConfigChangeListener.handleEvent(null); >- } >- } >- >- /** >- * Find available remote services and service providers for a given project >- * >- * If project is null, the C and C++ natures are used to determine which services >- * are available >- */ >- protected Set<IService> getContributedServices(IProject project) { >- ServiceModelManager modelManager = ServiceModelManager.getInstance(); >- Set<IService> allApplicableServices = new LinkedHashSet<IService>(); >- >- if (project != null) { >- >- String[] natureIds = new String[] {}; >- try { >- //get the project natures of the project >- natureIds = project.getDescription().getNatureIds(); >- } catch (CoreException e) { >- RDTLog.logError(e); >- } >- >- for (int i = 0; i < natureIds.length; i++) { >- String natureId = natureIds[i]; >- Set<IService> services = modelManager.getServices(natureId); >- if (services != null) >- allApplicableServices.addAll(services); >- } >- } >- else { >- Set<IService> cppServices = modelManager.getServices(CCProjectNature.CC_NATURE_ID); >- Set<IService> cServices = modelManager.getServices(CProjectNature.C_NATURE_ID); >- >- allApplicableServices.addAll(cppServices); >- allApplicableServices.addAll(cServices); >- } >- return allApplicableServices; >- } >- >- public Map<String, String> getServiceIDToSelectedProviderID() { >- return fServiceIDToSelectedProviderID; >- } >- >- public Table getTable() { >- return fTable; >- } >- >- public void setTable(Table table) { >- fTable = table; >- } >- >- public void setServiceIDToSelectedProviderID( >- Map<String, String> serviceIDToSelectedProviderID) { >- fServiceIDToSelectedProviderID = serviceIDToSelectedProviderID; >- } >- >- public Map<String, IServiceProvider> getProviderIDToProviderMap() { >- return fProviderIDToProviderMap; >- } >- >- public void setProviderIDToProviderMap( >- Map<String, IServiceProvider> providerIDToProviderMap) { >- fProviderIDToProviderMap = providerIDToProviderMap; >- } >- >- /** >- * Sub-class may override behaviour >- * @return true if all available services have been configured >- */ >- public boolean isConfigured() { >- return isConfigured(null, fServiceIDToSelectedProviderID, fProviderIDToProviderMap); >- } >- >- /** >- * Determine if all service providers have been configured >- * @param project >- * @param serviceIDToSelectedProviderID >- * @param providerIDToProviderMap >- * @return true if all service providers have been configured >- */ >- protected boolean isConfigured(IProject project, Map<String, String> serviceIDToSelectedProviderID, Map<String, IServiceProvider> providerIDToProviderMap) { >- Set<IService> allApplicableServices = getContributedServices(project); >- Iterator<IService> iterator = allApplicableServices.iterator(); >- boolean configured = true; >- while (iterator.hasNext()) { >- String providerID = serviceIDToSelectedProviderID.get(iterator.next().getId()); >- if (providerID == null) >- return false; >- else { >- IServiceProvider provider = providerIDToProviderMap.get(providerID); >- if (provider == null) >- return false; >- else >- configured = configured && provider.isConfigured(); >- } >- } >- return configured; >- } >- >- >- /** >- * @return the configuration change listener >- */ >- public Listener getConfigChangeListener() { >- return fConfigChangeListener; >- } >- >- /** >- * Listens for changes in service provider configuration >- * @param configChangeListener the configuration change listener to set >- */ >- public void setConfigChangeListener(Listener configChangeListener) { >- fConfigChangeListener = configChangeListener; >- } >- >- /** >- * Enable/disable the configure button in this widget based on the service provider descriptor selected >- * @param enabled >- */ >- protected void updateConfigureButton(IServiceProviderDescriptor descriptor) { >- //no need to configure the null providers so disable the configure button >- >- if (descriptor.getId().compareTo(NullBuildServiceProvider.ID) == 0 || >- descriptor.getId().compareTo(NullCIndexServiceProvider.ID) == 0) >- >- fConfigureButton.setEnabled(false); >- else >- fConfigureButton.setEnabled(true); >- } >-} >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.ui/plugin.xml,v >retrieving revision 1.31 >diff -u -r1.31 plugin.xml >--- plugin.xml 24 Sep 2009 18:42:32 -0000 1.31 >+++ plugin.xml 25 Sep 2009 20:06:11 -0000 >@@ -116,37 +116,19 @@ > <wizard > canFinishEarly="false" > category="org.eclipse.ptp.rdt.ui.wizardCategory.Remote" >- class="org.eclipse.ptp.rdt.ui.wizards.NewRemoteCppProjectWizard" >+ class="org.eclipse.ptp.rdt.ui.wizards.NewRemoteProjectWizard" > finalPerspective="org.eclipse.ptp.rdt.ui.remoteCPerspective" > hasPages="true" > icon="icons/etool16/newremote_c_proj.gif" > id="org.eclipse.ptp.rdt.ui.newRemoteProjectWizard" > name="%wizard.name.0" > project="true"> >- <description> >- %remoteCCPPproject.desc >- </description> > </wizard> > > <wizard >- canFinishEarly="false" >- category="org.eclipse.cdt.ui.newCWizards" >- class="org.eclipse.ptp.rdt.ui.wizards.NewRemoteCppProjectWizard" >- finalPerspective="org.eclipse.ptp.rdt.ui.remoteCPerspective" >- hasPages="true" >- icon="icons/etool16/newremote_c_proj.gif" >- id="org.eclipse.ptp.rdt.ui.newCRemoteProjectWizard" >- name="%wizard.name.0" >- project="true"> >- <description> >- %remoteCCPPproject.desc >- </description> >- </wizard> >- >- <wizard > category="org.eclipse.ptp.rdt.ui.wizardCategory.Remote" > class="org.eclipse.ptp.rdt.ui.wizards.ConvertToRemoteWizard" >- finalPerspective="org.eclipse.ptp.rdt.ui.remoteCPerspective" >+ finalPerspective="org.eclipse.cdt.ui.CPerspective" > hasPages="true" > icon="icons/obj16/convert-normal.gif" > id="org.eclipse.ptp.rdt.ui.wizards.ConvertToMakeWizard" >@@ -158,7 +140,7 @@ > <selection > class="org.eclipse.core.resources.IProject"> > </selection> >- </wizard> >+ </wizard> > </extension> > <extension > point="org.eclipse.cdt.ui.IndexerPage"> >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rdt/org.eclipse.ptp.rdt.ui/plugin.properties,v >retrieving revision 1.20 >diff -u -r1.20 plugin.properties >--- plugin.properties 24 Sep 2009 17:02:58 -0000 1.20 >+++ plugin.properties 25 Sep 2009 20:06:11 -0000 >@@ -33,6 +33,12 @@ > NullBuildService.name=Null Build Service > RDTRemoteCIndexingService.name=RDT Remote C/C++ Indexing Service > RDTRemoteBuildService.name=RDT Remote Build Service >+LocalCIndexingService.name=Local-only C/C++ Indexing Service >+LocalBuildService.name=Local-only Build Service >+RemoteCIndexingService.name=Remote C/C++ Indexing Service >+RemoteBuildService.name=Remote Build Service >+LocalProjectLocationProvider.name=Local-only Project Location >+RemoteProjectLocationProvider.name=Remote Project Location > RemoteEnvironment=Remote Environment > page.remote = Remote Development > Environment = Environment >Index: src/org/eclipse/ptp/rdt/ui/wizards/RemoteMainWizardPage.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/RemoteMainWizardPage.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/RemoteMainWizardPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/rdt/ui/wizards/RemoteMainWizardPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,543 @@ >+/******************************************************************************* >+ * Copyright (c) 2007, 2008 Intel Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Intel Corporation - initial API and implementation >+ * IBM Corporation >+ *******************************************************************************/ >+package org.eclipse.ptp.rdt.ui.wizards; >+import java.net.URI; >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.eclipse.cdt.internal.ui.CPluginImages; >+import org.eclipse.cdt.ui.CUIPlugin; >+import org.eclipse.cdt.ui.newui.CDTPrefUtil; >+import org.eclipse.cdt.ui.newui.PageLayout; >+import org.eclipse.cdt.ui.newui.UIMessages; >+import org.eclipse.cdt.ui.wizards.CNewWizard; >+import org.eclipse.cdt.ui.wizards.CWizardHandler; >+import org.eclipse.cdt.ui.wizards.EntryDescriptor; >+import org.eclipse.cdt.ui.wizards.IWizardItemsListListener; >+import org.eclipse.cdt.ui.wizards.IWizardWithMemory; >+import org.eclipse.core.filesystem.EFS; >+import org.eclipse.core.filesystem.IFileInfo; >+import org.eclipse.core.filesystem.IFileStore; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.wizard.IWizard; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.osgi.util.TextProcessor; >+import org.eclipse.ptp.internal.rdt.ui.RDTHelpContextIds; >+import org.eclipse.ptp.services.core.IServiceConfiguration; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.accessibility.AccessibleAdapter; >+import org.eclipse.swt.accessibility.AccessibleEvent; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.swt.widgets.TreeItem; >+import org.eclipse.ui.PlatformUI; >+ >+public class RemoteMainWizardPage extends NewRemoteProjectCreationPage implements IWizardItemsListListener { >+ private static final Image IMG_CATEGORY = CPluginImages.get(CPluginImages.IMG_OBJS_SEARCHFOLDER); >+ private static final Image IMG_ITEM = CPluginImages.get(CPluginImages.IMG_OBJS_VARIABLE); >+ >+ public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.NewModelProjectWizardPage"; //$NON-NLS-1$ >+ >+ private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CDTWizard"; //$NON-NLS-1$ >+ private static final String ELEMENT_NAME = "wizard"; //$NON-NLS-1$ >+ private static final String CLASS_NAME = "class"; //$NON-NLS-1$ >+ public static final String DESC = "EntryDescriptor"; //$NON-NLS-1$ >+ >+ // widgets >+ private Tree tree; >+ private Composite right; >+ private Button show_sup; >+ private Label right_label; >+ >+ public CWizardHandler h_selected = null; >+ private Label categorySelectedLabel; >+ >+ private IServiceConfiguration defaultConfig = null; >+ >+ /** >+ * Creates a new project creation wizard page. >+ * >+ * @param pageName the name of this page >+ */ >+ public RemoteMainWizardPage(String pageName) { >+ super(pageName); >+ setPageComplete(false); >+ // default to view all toolchains >+ CDTPrefUtil.setBool(CDTPrefUtil.KEY_NOSUPP, true); >+ } >+ >+ /** (non-Javadoc) >+ * Method declared on IDialogPage. >+ */ >+ @Override >+ public void createControl(Composite parent) { >+ super.createControl(parent); >+ >+ createDynamicGroup((Composite)getControl()); >+ switchTo(updateData(tree, right, show_sup, RemoteMainWizardPage.this, getWizard()), >+ getDescriptor(tree)); >+ >+ setPageComplete(validatePage()); >+ setErrorMessage(null); >+ setMessage(null); >+ >+ Shell shell = getContainer().getShell(); //if not created on the shell, will not display properly >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, RDTHelpContextIds.CREATING_A_REMOTE_PROJECT); >+ } >+ >+ private void createDynamicGroup(Composite parent) { >+ Composite c = new Composite(parent, SWT.NONE); >+ c.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ c.setLayout(new GridLayout(2, true)); >+ >+ Label l1 = new Label(c, SWT.NONE); >+ l1.setText(UIMessages.getString("CMainWizardPage.0")); //$NON-NLS-1$ >+ l1.setFont(parent.getFont()); >+ l1.setLayoutData(new GridData(GridData.BEGINNING)); >+ >+ right_label = new Label(c, SWT.NONE); >+ right_label.setFont(parent.getFont()); >+ right_label.setLayoutData(new GridData(GridData.BEGINNING)); >+ >+ tree = new Tree(c, SWT.SINGLE | SWT.BORDER); >+ tree.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ tree.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ TreeItem[] tis = tree.getSelection(); >+ if (tis == null || tis.length == 0) return; >+ switchTo((CWizardHandler)tis[0].getData(), (EntryDescriptor)tis[0].getData(DESC)); >+ setPageComplete(validatePage()); >+ }}); >+ tree.getAccessible().addAccessibleListener( >+ new AccessibleAdapter() { >+ @Override >+ public void getName(AccessibleEvent e) { >+ for (int i = 0; i < tree.getItemCount(); i++) { >+ if (tree.getItem(i).getText().compareTo(e.result) == 0) >+ return; >+ } >+ e.result = UIMessages.getString("CMainWizardPage.0"); //$NON-NLS-1$ >+ } >+ } >+ ); >+ right = new Composite(c, SWT.NONE); >+ right.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ right.setLayout(new PageLayout()); >+ >+ show_sup = new Button(c, SWT.CHECK); >+ show_sup.setText(UIMessages.getString("CMainWizardPage.1")); //$NON-NLS-1$ >+ GridData gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 2; >+ show_sup.setLayoutData(gd); >+ show_sup.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ if (h_selected != null) >+ h_selected.setSupportedOnly(show_sup.getSelection()); >+ switchTo(updateData(tree, right, show_sup, RemoteMainWizardPage.this, getWizard()), >+ getDescriptor(tree)); >+ }} ); >+ >+ // restore settings from preferences >+ show_sup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP)); >+ } >+ >+ @Override >+ public IWizardPage getNextPage() { >+ return (h_selected == null) ? null : h_selected.getSpecificPage(); >+ } >+ >+ public URI getProjectLocation() { >+ return useDefaults() ? null : getLocationURI(); >+ } >+ >+ /** >+ * Returns whether this page's controls currently all contain valid >+ * values. >+ * >+ * @return <code>true</code> if all controls are valid, and >+ * <code>false</code> if at least one is invalid >+ */ >+ @Override >+ protected boolean validatePage() { >+ setMessage(null); >+ if (!super.validatePage()) >+ return false; >+ >+ if (getProjectName().indexOf('#') >= 0) { >+ setErrorMessage(UIMessages.getString("RemoteMainWizardPage.0")); //$NON-NLS-1$ >+ return false; >+ } >+ >+ boolean bad = true; // should we treat existing project as error >+ >+ IProject handle = getProjectHandle(); >+ if (handle.exists()) { >+ if (getWizard() instanceof IWizardWithMemory) { >+ IWizardWithMemory w = (IWizardWithMemory)getWizard(); >+ if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName())) >+ bad = false; >+ } >+ if (bad) { >+ setErrorMessage(UIMessages.getString("CMainWizardPage.10")); //$NON-NLS-1$ >+ return false; >+ } >+ } >+ >+ if (bad) { // skip this check if project already created >+ try { >+ IFileStore fs; >+ URI p = getProjectLocation(); >+ if (p == null) { >+ fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI()); >+ fs = fs.getChild(getProjectName()); >+ } else >+ fs = EFS.getStore(p); >+ IFileInfo f = fs.fetchInfo(); >+ if (f.exists() && f.isDirectory()) { >+ if (fs.getChild(".project").fetchInfo().exists()) { //$NON-NLS-1$ >+ setMessage("Existing project settings will be overridden"); //$NON-NLS-1$ >+ return true; >+ } >+ } >+ } catch (CoreException e) { >+ CUIPlugin.log(e.getStatus()); >+ } >+ } >+ >+ if (!useDefaults()) { >+ IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle, >+ getLocationURI()); >+ if (!locationStatus.isOK()) { >+ setErrorMessage(locationStatus.getMessage()); >+ return false; >+ } >+ } >+ >+ if (tree.getItemCount() == 0) { >+ setErrorMessage(UIMessages.getString("CMainWizardPage.3")); //$NON-NLS-1$ >+ return false; >+ } >+ >+ // it is not an error, but we cannot continue >+ if (h_selected == null) { >+ setErrorMessage(null); >+ return false; >+ } >+ >+ String s = h_selected.getErrorMessage(); >+ if (s != null) { >+ setErrorMessage(s); >+ return false; >+ } >+ >+ setErrorMessage(null); >+ return true; >+ } >+ >+ /** >+ * >+ * @param tree >+ * @param right >+ * @param show_sup >+ * @param ls >+ * @param wizard >+ * @return : selected Wizard Handler. >+ */ >+ public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup, IWizardItemsListListener ls, IWizard wizard) { >+ // remember selected item >+ TreeItem[] sel = tree.getSelection(); >+ String savedStr = (sel.length > 0) ? sel[0].getText() : null; >+ >+ tree.removeAll(); >+ IExtensionPoint extensionPoint = >+ Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID); >+ if (extensionPoint == null) return null; >+ IExtension[] extensions = extensionPoint.getExtensions(); >+ if (extensions == null) return null; >+ >+ List<EntryDescriptor> items = new ArrayList<EntryDescriptor>(); >+ for (int i = 0; i < extensions.length; ++i) { >+ IConfigurationElement[] elements = extensions[i].getConfigurationElements(); >+ for (IConfigurationElement element : elements) { >+ if (element.getName().equals(ELEMENT_NAME)) { >+ CNewWizard w = null; >+ try { >+ w = (CNewWizard) element.createExecutableExtension(CLASS_NAME); >+ } catch (CoreException e) { >+ System.out.println(UIMessages.getString("CMainWizardPage.5") + e.getLocalizedMessage()); //$NON-NLS-1$ >+ return null; >+ } >+ if (w == null) return null; >+ w.setDependentControl(right, ls); >+ for (EntryDescriptor ed : w.createItems(show_sup.getSelection(), wizard)) >+ items.add(ed); >+ } >+ } >+ } >+ // If there is a EntryDescriptor which is default for category, make sure it >+ // is in the front of the list. >+ for (int i = 0; i < items.size(); ++i) >+ { >+ EntryDescriptor ed = items.get(i); >+ if (ed.isDefaultForCategory()) >+ { >+ items.remove(i); >+ items.add(0, ed); >+ break; >+ } >+ } >+ >+ // bug # 211935 : allow items filtering. >+ if (ls != null) // NULL means call from prefs >+ items = ls.filterItems(items); >+ addItemsToTree(tree, items); >+ >+ if (tree.getItemCount() > 0) { >+ TreeItem target = null; >+ // try to search item which was selected before >+ if (savedStr != null) { >+ TreeItem[] all = tree.getItems(); >+ for (TreeItem element : all) { >+ if (savedStr.equals(element.getText())) { >+ target = element; >+ break; >+ } >+ } >+ } >+ if (target == null) >+ { >+ target = tree.getItem(0); >+ if (target.getItemCount() != 0) >+ target = target.getItem(0); >+ } >+ tree.setSelection(target); >+ return (CWizardHandler)target.getData(); >+ } >+ return null; >+ } >+ >+ private static void addItemsToTree(Tree tree, List<EntryDescriptor> items) { >+ // Sorting is disabled because of users requests >+ // Collections.sort(items, CDTListComparator.getInstance()); >+ >+ ArrayList<TreeItem> placedTreeItemsList = new ArrayList<TreeItem>(items.size()); >+ ArrayList<EntryDescriptor> placedEntryDescriptorsList = new ArrayList<EntryDescriptor>(items.size()); >+ for (EntryDescriptor wd : items) { >+ if (wd.getParentId() == null) { >+ wd.setPath(wd.getId()); >+ TreeItem ti = new TreeItem(tree, SWT.NONE); >+ ti.setText(TextProcessor.process(wd.getName())); >+ ti.setData(wd.getHandler()); >+ ti.setData(DESC, wd); >+ ti.setImage(calcImage(wd)); >+ placedTreeItemsList.add(ti); >+ placedEntryDescriptorsList.add(wd); >+ } >+ } >+ while(true) { >+ boolean found = false; >+ Iterator<EntryDescriptor> it2 = items.iterator(); >+ while (it2.hasNext()) { >+ EntryDescriptor wd1 = it2.next(); >+ if (wd1.getParentId() == null) continue; >+ for (int i = 0; i< placedEntryDescriptorsList.size(); i++) { >+ EntryDescriptor wd2 = placedEntryDescriptorsList.get(i); >+ if (wd2.getId().equals(wd1.getParentId())) { >+ found = true; >+ wd1.setParentId(null); >+ CWizardHandler h = wd2.getHandler(); >+ /* If neither wd1 itself, nor its parent (wd2) have a handler >+ * associated with them, and the item is not a category, >+ * then skip it. If it's category, then it's possible that >+ * children will have a handler associated with them. >+ */ >+ if (h == null && wd1.getHandler() == null && !wd1.isCategory()) >+ break; >+ >+ wd1.setPath(wd2.getPath() + "/" + wd1.getId()); //$NON-NLS-1$ >+ wd1.setParent(wd2); >+ if (h != null) { >+ if (wd1.getHandler() == null && !wd1.isCategory()) >+ wd1.setHandler((CWizardHandler)h.clone()); >+ if (!h.isApplicable(wd1)) >+ break; >+ } >+ >+ TreeItem p = placedTreeItemsList.get(i); >+ TreeItem ti = new TreeItem(p, SWT.NONE); >+ ti.setText(wd1.getName()); >+ ti.setData(wd1.getHandler()); >+ ti.setData(DESC, wd1); >+ ti.setImage(calcImage(wd1)); >+ placedTreeItemsList.add(ti); >+ placedEntryDescriptorsList.add(wd1); >+ break; >+ } >+ } >+ } >+ // repeat iterations until all items are placed. >+ if (!found) break; >+ } >+ // orphan elements (with not-existing parentId) are ignored >+ } >+ >+ private void switchTo(CWizardHandler h, EntryDescriptor ed) { >+ if (h == null) >+ h = ed.getHandler(); >+ if (ed.isCategory()) >+ h = null; >+ try { >+ if (h != null) >+ h.initialize(ed); >+ } catch (CoreException e) { >+ h = null; >+ } >+ if (h_selected != null) >+ h_selected.handleUnSelection(); >+ h_selected = h; >+ if (h == null) { >+ if (ed.isCategory()) { >+ if (categorySelectedLabel == null) { >+ categorySelectedLabel = new Label(right, SWT.WRAP); >+ categorySelectedLabel.setText( >+ UIMessages.getString("RemoteMainWizardPage.1")); //$NON-NLS-1$ >+ right.layout(); >+ } >+ categorySelectedLabel.setVisible(true); >+ } >+ return; >+ } >+ right_label.setText(h_selected.getHeader()); >+ if (categorySelectedLabel != null) >+ categorySelectedLabel.setVisible(false); >+ h_selected.handleSelection(); >+ h_selected.setSupportedOnly(show_sup.getSelection()); >+ } >+ >+ >+ public static EntryDescriptor getDescriptor(Tree _tree) { >+ TreeItem[] sel = _tree.getSelection(); >+ if (sel == null || sel.length == 0) >+ return null; >+ return (EntryDescriptor)sel[0].getData(DESC); >+ } >+ >+ public void toolChainListChanged(int count) { >+ setPageComplete(validatePage()); >+ getWizard().getContainer().updateButtons(); >+ } >+ >+ public boolean isCurrent() { return isCurrentPage(); } >+ >+ private static Image calcImage(EntryDescriptor ed) { >+ if (ed.getImage() != null) return ed.getImage(); >+ if (ed.isCategory()) return IMG_CATEGORY; >+ return IMG_ITEM; >+ } >+ >+ @SuppressWarnings("unchecked") >+ public List filterItems(List items) { >+ /// iterate through the list, removing entry descriptors we don't care about >+ Iterator iterator = items.iterator(); >+ >+ List<EntryDescriptor> filteredList = new LinkedList<EntryDescriptor>(); >+ >+ while(iterator.hasNext()) { >+ EntryDescriptor ed = (EntryDescriptor) iterator.next(); >+ if(ed.getId().startsWith("org.eclipse.ptp.rdt")) { // both the category and the template start with this //$NON-NLS-1$ >+ filteredList.add(ed); >+ } >+ } >+ >+ return filteredList; >+ } >+ >+// public void pageChanged(PageChangedEvent event) { >+// if (event.getSelectedPage().equals(this)) { >+// if (defaultConfig == null) { >+// ServiceModelManager manager = ServiceModelManager.getInstance(); >+// >+// /* >+// * Create a new service configuration >+// * >+// * XXX: this should check if a service configuration has already >+// * been selected, in which case it should use that one. >+// */ >+// IServiceConfiguration config = manager.newServiceConfiguration(handle.getName()); >+// >+// /* >+// * Make this configuration active for this project. >+// */ >+// manager.setConfiguration(handle, config); >+// >+// /* >+// * Set default service providers based on location of project >+// */ >+// URI location = getLocationURI(); >+// IRemoteServices remServ = PTPRemoteCorePlugin.getDefault().getRemoteServices(location); >+// IRemoteConnection remConn = PTPRemoteCorePlugin.getDefault().getConnection(location); >+// >+// /* >+// * Project location >+// */ >+// IRemoteServiceProvider projectProvider = new RemoteProjectServiceProvider(); >+// projectProvider.setRemoteServicesID(remServ.getId()); >+// projectProvider.setRemoteConnectionName(remConn.getName()); >+// config.setServiceProvider(manager.getService(RemoteProjectServiceProvider.ID), projectProvider); >+// >+// /* >+// * Build service >+// */ >+// IRemoteServiceProvider buildProvider = new RemoteBuildServiceProvider(); >+// buildProvider.setRemoteServicesID(remServ.getId()); >+// buildProvider.setRemoteConnectionName(remConn.getName()); >+// config.setServiceProvider(manager.getService(RemoteBuildServiceProvider.ID), buildProvider); >+// >+// /* >+// * Index service >+// */ >+// IRemoteServiceProvider indexProvider = new RemoteCIndexServiceProvider(); >+// indexProvider.setRemoteServicesID(remServ.getId()); >+// indexProvider.setRemoteConnectionName(remConn.getName()); >+// config.setServiceProvider(manager.getService(RemoteCIndexServiceProvider.ID), indexProvider); >+// >+// defaultConfig = config; >+// >+// /* >+// * Pass configuration to ServiceModelWizardPage >+// */ >+// MBSCustomPageManager.addPageProperty(ServiceModelWizardPage.SERVICE_MODEL_WIZARD_PAGE_ID, >+// ServiceModelWizardPage.SERVICE_CONFIGURATION_PROPERTY, config); >+// } >+// } >+// } >+} >+ >Index: src/org/eclipse/ptp/rdt/ui/wizards/RemoteCommonProjectWizard.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/RemoteCommonProjectWizard.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/RemoteCommonProjectWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/rdt/ui/wizards/RemoteCommonProjectWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,422 @@ >+/******************************************************************************* >+ * Copyright (c) 2002, 2008 Rational Software Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Rational Software - Initial API and implementation >+ * Intel corp - rework for New Project Model >+ *******************************************************************************/ >+package org.eclipse.ptp.rdt.ui.wizards; >+ >+ >+import java.lang.reflect.InvocationTargetException; >+import java.net.URI; >+import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.List; >+ >+import org.eclipse.cdt.core.CCorePlugin; >+import org.eclipse.cdt.core.model.CoreModel; >+import org.eclipse.cdt.core.model.ILanguage; >+import org.eclipse.cdt.core.model.LanguageManager; >+import org.eclipse.cdt.core.settings.model.ICProjectDescription; >+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; >+import org.eclipse.cdt.ui.CUIPlugin; >+import org.eclipse.cdt.ui.newui.UIMessages; >+import org.eclipse.cdt.ui.wizards.CWizardHandler; >+import org.eclipse.cdt.ui.wizards.ICDTCommonProjectWizard; >+import org.eclipse.cdt.ui.wizards.IWizardWithMemory; >+import org.eclipse.core.filesystem.EFS; >+import org.eclipse.core.filesystem.IFileInfo; >+import org.eclipse.core.filesystem.IFileStore; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IProjectDescription; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.resources.IWorkspaceRunnable; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExecutableExtension; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.core.runtime.content.IContentType; >+import org.eclipse.core.runtime.content.IContentTypeManager; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.ptp.services.core.ServiceModelManager; >+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; >+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; >+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; >+ >+public abstract class RemoteCommonProjectWizard extends BasicNewResourceWizard >+implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard >+{ >+ private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$ >+ private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$ >+ private static final String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$ >+ private static final String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$ >+ private static final String[] EMPTY_ARR = new String[0]; >+ >+ protected IConfigurationElement fConfigElement; >+ protected RemoteMainWizardPage fMainPage; >+ >+ protected IProject newProject; >+ private String wz_title; >+ private String wz_desc; >+ >+ private boolean existingPath = false; >+ private String lastProjectName = null; >+ private URI lastProjectLocation = null; >+ private CWizardHandler savedHandler = null; >+ >+ private ServiceModelManager manager = ServiceModelManager.getInstance(); >+ >+ public RemoteCommonProjectWizard() { >+ this(UIMessages.getString("NewModelProjectWizard.0"),UIMessages.getString("NewModelProjectWizard.1")); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ >+ public RemoteCommonProjectWizard(String title, String desc) { >+ super(); >+ setDialogSettings(CUIPlugin.getDefault().getDialogSettings()); >+ setNeedsProgressMonitor(true); >+ setForcePreviousAndNextButtons(true); >+ setWindowTitle(title); >+ wz_title = title; >+ wz_desc = desc; >+ } >+ >+ @Override >+ public void addPages() { >+ fMainPage= new RemoteMainWizardPage(CUIPlugin.getResourceString(PREFIX)); >+ fMainPage.setTitle(wz_title); >+ fMainPage.setDescription(wz_desc); >+ addPage(fMainPage); >+ } >+ >+ /** >+ * @return true if user has changed settings since project creation >+ */ >+ private boolean isChanged() { >+ if (savedHandler != fMainPage.h_selected) >+ return true; >+ >+ if (!fMainPage.getProjectName().equals(lastProjectName)) >+ return true; >+ >+ URI projectLocation = fMainPage.getProjectLocation(); >+ if (projectLocation == null) { >+ if (lastProjectLocation != null) >+ return true; >+ } else if (!projectLocation.equals(lastProjectLocation)) >+ return true; >+ >+ return savedHandler.isChanged(); >+ } >+ >+ public IProject getProject(boolean defaults) { >+ return getProject(defaults, true); >+ } >+ >+ public IProject getProject(boolean defaults, boolean onFinish) { >+ if (newProject != null && isChanged()) >+ clearProject(); >+ if (newProject == null) { >+ existingPath = false; >+ try { >+ IFileStore fs; >+ URI p = fMainPage.getProjectLocation(); >+ if (p == null) { >+ fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI()); >+ fs = fs.getChild(fMainPage.getProjectName()); >+ } else >+ fs = EFS.getStore(p); >+ IFileInfo f = fs.fetchInfo(); >+ if (f.exists() && f.isDirectory()) { >+ if (fs.getChild(".project").fetchInfo().exists()) { //$NON-NLS-1$ >+ if (! >+ MessageDialog.openConfirm(getShell(), >+ UIMessages.getString("CDTCommonProjectWizard.0"), //$NON-NLS-1$ >+ UIMessages.getString("CDTCommonProjectWizard.1")) //$NON-NLS-1$ >+ ) >+ return null; >+ } >+ existingPath = true; >+ } >+ } catch (CoreException e) { >+ CUIPlugin.log(e.getStatus()); >+ } >+ savedHandler = fMainPage.h_selected; >+ savedHandler.saveState(); >+ lastProjectName = fMainPage.getProjectName(); >+ lastProjectLocation = fMainPage.getProjectLocation(); >+ // start creation process >+ invokeRunnable(getRunnable(defaults, onFinish)); >+ } >+ return newProject; >+ } >+ >+ /** >+ * Remove created project either after error >+ * or if user returned back from config page. >+ */ >+ private void clearProject() { >+ if (lastProjectName == null) return; >+ try { >+ ResourcesPlugin.getWorkspace().getRoot().getProject(lastProjectName).delete(!existingPath, true, null); >+ } catch (CoreException ignore) {} >+ if (newProject != null) { >+ manager.remove(newProject); >+ } >+ newProject = null; >+ lastProjectName = null; >+ lastProjectLocation = null; >+ } >+ >+ private boolean invokeRunnable(IRunnableWithProgress runnable) { >+ IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable); >+ try { >+ getContainer().run(true, true, op); >+ } catch (InvocationTargetException e) { >+ CUIPlugin.errorDialog(getShell(), title, message, e.getTargetException(), false); >+ clearProject(); >+ return false; >+ } catch (InterruptedException e) { >+ clearProject(); >+ return false; >+ } >+ return true; >+ } >+ >+ @Override >+ public boolean performFinish() { >+ boolean needsPost = (newProject != null && !isChanged()); >+ // create project if it is not created yet >+ if (getProject(fMainPage.isCurrent(), true) == null) >+ return false; >+ fMainPage.h_selected.postProcess(newProject, needsPost); >+ try { >+ setCreated(); >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ return false; >+ } >+ BasicNewProjectResourceWizard.updatePerspective(fConfigElement); >+ selectAndReveal(newProject); >+ return true; >+ } >+ >+ protected boolean setCreated() throws CoreException { >+ ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); >+ >+ ICProjectDescription des = mngr.getProjectDescription(newProject, false); >+ >+ if(des == null ) { >+ return false; >+ } >+ >+ if(des.isCdtProjectCreating()){ >+ des = mngr.getProjectDescription(newProject, true); >+ des.setCdtProjectCreated(); >+ mngr.setProjectDescription(newProject, des, false, null); >+ return true; >+ } >+ return false; >+ } >+ >+ @Override >+ public boolean performCancel() { >+ clearProject(); >+ return true; >+ } >+ >+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { >+ fConfigElement= config; >+ } >+ >+ private IRunnableWithProgress getRunnable(boolean _defaults, final boolean onFinish) { >+ final boolean defaults = _defaults; >+ return new IRunnableWithProgress() { >+ public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException { >+ final Exception except[] = new Exception[1]; >+ getShell().getDisplay().syncExec(new Runnable() { >+ public void run() { >+ IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ final IProgressMonitor fMonitor; >+ if (monitor == null) { >+ fMonitor= new NullProgressMonitor(); >+ } else { >+ fMonitor = monitor; >+ } >+ fMonitor.beginTask(CUIPlugin.getResourceString("CProjectWizard.op_description"), 100); //$NON-NLS-1$ >+ fMonitor.worked(10); >+ try { >+ newProject = createIProject(lastProjectName, lastProjectLocation, new SubProgressMonitor(fMonitor, 40)); >+ if (newProject != null) >+ fMainPage.h_selected.createProject(newProject, defaults, onFinish, new SubProgressMonitor(fMonitor, 40)); >+ fMonitor.worked(10); >+ } catch (CoreException e) { CUIPlugin.log(e); } >+ finally { >+ fMonitor.done(); >+ } >+ } >+ }); >+ try { >+ getContainer().run(false, true, op); >+ } catch (InvocationTargetException e) { >+ except[0] = e; >+ } catch (InterruptedException e) { >+ except[0] = e; >+ } >+ } >+ }); >+ if (except[0] != null) { >+ if (except[0] instanceof InvocationTargetException) { >+ throw (InvocationTargetException)except[0]; >+ } >+ if (except[0] instanceof InterruptedException) { >+ throw (InterruptedException)except[0]; >+ } >+ throw new InvocationTargetException(except[0]); >+ } >+ } >+ }; >+ } >+ >+ public IProject createIProject(final String name, final URI location) throws CoreException{ >+ return createIProject(name, location, new NullProgressMonitor()); >+ } >+ >+ /** >+ * @since 5.1 >+ */ >+ protected IProgressMonitor continueCreationMonitor; >+ >+ /** >+ * @param monitor >+ * @since 5.1 >+ * >+ */ >+ public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException{ >+ >+ monitor.beginTask(UIMessages.getString("CDTCommonProjectWizard.creatingProject"), 100); //$NON-NLS-1$ >+ >+ if (newProject != null) return newProject; >+ >+ IWorkspace workspace = ResourcesPlugin.getWorkspace(); >+ IWorkspaceRoot root = workspace.getRoot(); >+ final IProject newProjectHandle = root.getProject(name); >+ >+ if (!newProjectHandle.exists()) { >+// IWorkspaceDescription workspaceDesc = workspace.getDescription(); >+// workspaceDesc.setAutoBuilding(false); >+// workspace.setDescription(workspaceDesc); >+ IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); >+ if(location != null) >+ description.setLocationURI(location); >+ newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new SubProgressMonitor(monitor,25)); >+ } else { >+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() { >+ public void run(IProgressMonitor monitor) throws CoreException { >+ newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor); >+ } >+ }; >+ workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor,25)); >+ newProject = newProjectHandle; >+ } >+ >+ // Open the project if we have to >+ if (!newProject.isOpen()) { >+ newProject.open(new SubProgressMonitor(monitor,25)); >+ } >+ >+ continueCreationMonitor = new SubProgressMonitor(monitor,25); >+ IProject proj = continueCreation(newProject); >+ >+ monitor.done(); >+ >+ return proj; >+ } >+ >+ protected abstract IProject continueCreation(IProject prj); >+ public abstract String[] getNatures(); >+ >+ @Override >+ public void dispose() { >+ fMainPage.dispose(); >+ } >+ >+ @Override >+ public boolean canFinish() { >+ if (fMainPage.h_selected != null) { >+ if(!fMainPage.h_selected.canFinish()) >+ return false; >+ String s = fMainPage.h_selected.getErrorMessage(); >+ if (s != null) return false; >+ } >+ return super.canFinish(); >+ } >+ /** >+ * Returns last project name used for creation >+ */ >+ public String getLastProjectName() { >+ return lastProjectName; >+ } >+ >+ public URI getLastProjectLocation() { >+ return lastProjectLocation; >+ } >+ >+ public IProject getLastProject() { >+ return newProject; >+ } >+ >+ // Methods below should provide data for language check >+ public String[] getLanguageIDs (){ >+ String[] contentTypeIds = getContentTypeIDs(); >+ if(contentTypeIds.length > 0) { >+ IContentTypeManager manager = Platform.getContentTypeManager(); >+ List<String> languageIDs = new ArrayList<String>(); >+ for(int i = 0; i < contentTypeIds.length; ++i) { >+ IContentType contentType = manager.getContentType(contentTypeIds[i]); >+ if(null != contentType) { >+ ILanguage language = LanguageManager.getInstance().getLanguage(contentType); >+ if(!languageIDs.contains(language.getId())) { >+ languageIDs.add(language.getId()); >+ } >+ } >+ } >+ return languageIDs.toArray(new String[languageIDs.size()]); >+ } >+ return EMPTY_ARR; >+ } >+ >+ public String[] getContentTypeIDs (){ >+ return EMPTY_ARR; >+ } >+ >+ public String[] getExtensions (){ >+ String[] contentTypeIds = getContentTypeIDs(); >+ if(contentTypeIds.length > 0) { >+ IContentTypeManager manager = Platform.getContentTypeManager(); >+ List<String> extensions = new ArrayList<String>(); >+ for(int i = 0; i < contentTypeIds.length; ++i) { >+ IContentType contentType = manager.getContentType(contentTypeIds[i]); >+ if(null != contentType) { >+ String[] thisTypeExtensions = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); >+ extensions.addAll(Arrays.asList(thisTypeExtensions)); >+ } >+ } >+ return extensions.toArray(new String[extensions.size()]); >+ } >+ return EMPTY_ARR; >+ } >+ >+} >Index: src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteProjectCreationPage.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteProjectCreationPage.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteProjectCreationPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteProjectCreationPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,365 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ * Jakub Jurkiewicz <jakub.jurkiewicz@gmail.com> - Fix for Bug 174737 >+ * [IDE] New Plug-in Project wizard status handling is inconsistent >+ * Oakland Software Incorporated (Francis Upton) <francisu@ieee.org> >+ * Bug 224997 [Workbench] Impossible to copy project >+ *******************************************************************************/ >+package org.eclipse.ptp.rdt.ui.wizards; >+ >+import java.net.URI; >+ >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ptp.rdt.ui.wizards.RemoteProjectContentsLocationArea.IErrorMessageReporter; >+import org.eclipse.ptp.remote.core.IRemoteConnection; >+import org.eclipse.ptp.remote.core.IRemoteServices; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage; >+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; >+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; >+import org.eclipse.ui.internal.ide.IIDEHelpContextIds; >+ >+/** >+ * Standard main page for a wizard that is creates a project resource. >+ * <p> >+ * This page may be used by clients as-is; it may be also be subclassed to suit. >+ * </p> >+ * <p> >+ * Example usage: >+ * <pre> >+ * mainPage = new NewRemoteProjectCreationPage("basicNewProjectPage"); >+ * mainPage.setTitle("Project"); >+ * mainPage.setDescription("Create a new project resource."); >+ * </pre> >+ * </p> >+ */ >+public class NewRemoteProjectCreationPage extends WizardNewProjectCreationPage { >+ >+ // initial value stores >+ private String initialProjectFieldValue; >+ >+ // widgets >+ private Text projectNameField; >+ >+ private Listener nameModifyListener = new Listener() { >+ public void handleEvent(Event e) { >+ setLocationForSelection(); >+ boolean valid = validatePage(); >+ setPageComplete(valid); >+ >+ } >+ }; >+ >+ private RemoteProjectContentsLocationArea locationArea; >+ >+// private WorkingSetGroup workingSetGroup; >+ >+ // constants >+ private static final int SIZING_TEXT_FIELD_WIDTH = 250; >+ >+ /** >+ * Creates a new project creation wizard page. >+ * >+ * @param pageName the name of this page >+ */ >+ public NewRemoteProjectCreationPage(String pageName) { >+ super(pageName); >+ setPageComplete(false); >+ } >+ >+ /** >+ * Creates a new project creation wizard page. >+ * >+ * @param pageName >+ * @param selection >+ * @param workingSetTypes >+ * >+ * @deprecated default placement of the working set group has been removed. >+ * If you wish to use the working set block please call >+ * {@link #createWorkingSetGroup(Composite, IStructuredSelection, String[])} >+ * in your overridden {@link #createControl(Composite)} >+ * implementation. >+ * @since 3.4 >+ */ >+ public NewRemoteProjectCreationPage(String pageName, >+ IStructuredSelection selection, String[] workingSetTypes) { >+ this(pageName); >+ } >+ >+ /** (non-Javadoc) >+ * Method declared on IDialogPage. >+ */ >+ public void createControl(Composite parent) { >+ Composite composite = new Composite(parent, SWT.NULL); >+ >+ initializeDialogUnits(parent); >+ >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, >+ IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE); >+ >+ composite.setLayout(new GridLayout()); >+ composite.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ >+ createProjectNameGroup(composite); >+ locationArea = new RemoteProjectContentsLocationArea(getErrorReporter(), composite); >+ if(initialProjectFieldValue != null) { >+ locationArea.updateProjectName(initialProjectFieldValue); >+ } >+ >+ // Scale the buttons based on the rest of the dialog >+ for (Button button : locationArea.getButtons()) { >+ setButtonLayoutData(button); >+ } >+ >+ setPageComplete(validatePage()); >+ // Show description on opening >+ setErrorMessage(null); >+ setMessage(null); >+ setControl(composite); >+ Dialog.applyDialogFont(composite); >+ } >+ >+ /** >+ * Get an error reporter for the receiver. >+ * @return IErrorMessageReporter >+ */ >+ private IErrorMessageReporter getErrorReporter() { >+ return new IErrorMessageReporter(){ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter#reportError(java.lang.String) >+ */ >+ public void reportError(String errorMessage, boolean infoOnly) { >+ if (infoOnly) { >+ setMessage(errorMessage, IStatus.INFO); >+ setErrorMessage(null); >+ } >+ else >+ setErrorMessage(errorMessage); >+ boolean valid = errorMessage == null; >+ if(valid) { >+ valid = validatePage(); >+ } >+ >+ setPageComplete(valid); >+ } >+ }; >+ } >+ >+ /** >+ * Creates the project name specification controls. >+ * >+ * @param parent the parent composite >+ */ >+ private final void createProjectNameGroup(Composite parent) { >+ // project specification group >+ Composite projectGroup = new Composite(parent, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 2; >+ projectGroup.setLayout(layout); >+ projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ // new project label >+ Label projectLabel = new Label(projectGroup, SWT.NONE); >+ projectLabel.setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel); >+ projectLabel.setFont(parent.getFont()); >+ >+ // new project name entry field >+ projectNameField = new Text(projectGroup, SWT.BORDER); >+ GridData data = new GridData(GridData.FILL_HORIZONTAL); >+ data.widthHint = SIZING_TEXT_FIELD_WIDTH; >+ projectNameField.setLayoutData(data); >+ projectNameField.setFont(parent.getFont()); >+ >+ // Set the initial value first before listener >+ // to avoid handling an event during the creation. >+ if (initialProjectFieldValue != null) { >+ projectNameField.setText(initialProjectFieldValue); >+ } >+ projectNameField.addListener(SWT.Modify, nameModifyListener); >+ } >+ >+ /** >+ * Returns the current project location path as entered by >+ * the user, or its anticipated initial value. >+ * Note that if the default has been returned the path >+ * in a project description used to create a project >+ * should not be set. >+ * >+ * @return the project location path or its anticipated initial value. >+ */ >+ public IPath getLocationPath() { >+ return new Path(locationArea.getProjectLocation()); >+ } >+ >+ /** >+ * Returns the current project location URI as entered by >+ * the user, or <code>null</code> if a valid project location >+ * has not been entered. >+ * >+ * @return the project location URI, or <code>null</code> >+ * @since 3.2 >+ */ >+ public URI getLocationURI() { >+ return locationArea.getProjectLocationURI(); >+ } >+ >+ /** >+ * Returns the current project name as entered by the user, or its anticipated >+ * initial value. >+ * >+ * @return the project name, its anticipated initial value, or <code>null</code> >+ * if no project name is known >+ */ >+ public String getProjectName() { >+ if (projectNameField == null) { >+ return initialProjectFieldValue; >+ } >+ >+ return getProjectNameFieldValue(); >+ } >+ >+ /** >+ * Returns the value of the project name field >+ * with leading and trailing spaces removed. >+ * >+ * @return the project name in the field >+ */ >+ private String getProjectNameFieldValue() { >+ if (projectNameField == null) { >+ return ""; //$NON-NLS-1$ >+ } >+ >+ return projectNameField.getText().trim(); >+ } >+ >+ >+ public IRemoteConnection getRemoteConnection() { >+ return locationArea.getRemoteConnection(); >+ } >+ >+ >+ public IRemoteServices getRemoteServices() { >+ return locationArea.getRemoteServices(); >+ } >+ >+ /** >+ * Sets the initial project name that this page will use when >+ * created. The name is ignored if the createControl(Composite) >+ * method has already been called. Leading and trailing spaces >+ * in the name are ignored. >+ * Providing the name of an existing project will not necessarily >+ * cause the wizard to warn the user. Callers of this method >+ * should first check if the project name passed already exists >+ * in the workspace. >+ * >+ * @param name initial project name for this page >+ * >+ * @see IWorkspace#validateName(String, int) >+ * >+ */ >+ public void setInitialProjectName(String name) { >+ if (name == null) { >+ initialProjectFieldValue = null; >+ } else { >+ initialProjectFieldValue = name.trim(); >+ if(locationArea != null) { >+ locationArea.updateProjectName(name.trim()); >+ } >+ } >+ } >+ >+ /** >+ * Set the location to the default location if we are set to useDefaults. >+ */ >+ private void setLocationForSelection() { >+ locationArea.updateProjectName(getProjectNameFieldValue()); >+ } >+ >+ >+ /** >+ * Returns whether this page's controls currently all contain valid >+ * values. >+ * >+ * @return <code>true</code> if all controls are valid, and >+ * <code>false</code> if at least one is invalid >+ */ >+ protected boolean validatePage() { >+ IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); >+ >+ String projectFieldContents = getProjectNameFieldValue(); >+ if (projectFieldContents.equals("")) { //$NON-NLS-1$ >+ setErrorMessage(null); >+ setMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty); >+ return false; >+ } >+ >+ IStatus nameStatus = workspace.validateName(projectFieldContents, >+ IResource.PROJECT); >+ if (!nameStatus.isOK()) { >+ setErrorMessage(nameStatus.getMessage()); >+ return false; >+ } >+ >+ IProject handle = getProjectHandle(); >+ if (handle.exists()) { >+ setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage); >+ return false; >+ } >+ >+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( >+ getProjectNameFieldValue()); >+ locationArea.setExistingProject(project); >+ >+ String validLocationMessage = locationArea.checkValidLocation(); >+ if (validLocationMessage != null) { // there is no destination location given >+ setErrorMessage(validLocationMessage); >+ return false; >+ } >+ >+ setErrorMessage(null); >+ setMessage(null); >+ return true; >+ } >+ >+ /* >+ * see @DialogPage.setVisible(boolean) >+ */ >+ public void setVisible(boolean visible) { >+ getControl().setVisible(visible); >+ if (visible) { >+ projectNameField.setFocus(); >+ } >+ } >+ >+ /** >+ * Returns the useDefaults. >+ * @return boolean >+ */ >+ public boolean useDefaults() { >+ return locationArea.isDefault(); >+ } >+} >Index: src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteProjectWizard.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteProjectWizard.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteProjectWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/rdt/ui/wizards/NewRemoteProjectWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,75 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ptp.rdt.ui.wizards; >+ >+import org.eclipse.cdt.core.CCProjectNature; >+import org.eclipse.cdt.core.CProjectNature; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.ptp.internal.rdt.ui.RDTPluginImages; >+import org.eclipse.ptp.rdt.core.resources.RemoteNature; >+ >+/** >+ * A wizard for creating new Remote C/C++ Projects >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is no guarantee that this API will work or >+ * that it will remain the same. Please do not use this API without consulting >+ * with the RDT team. >+ * >+ * @author crecoskie >+ * >+ */ >+public class NewRemoteProjectWizard extends RemoteCommonProjectWizard { >+ private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$ >+ private static final String wz_title = "New Remote Project"; //$NON-NLS-1$ >+ private static final String wz_desc = "Create remote project of the selected type"; //$NON-NLS-1$ >+ >+ /** >+ * >+ */ >+ public NewRemoteProjectWizard() { >+ super(wz_title, wz_desc); >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#continueCreation(org.eclipse.core.resources.IProject) >+ */ >+ >+ @Override >+ protected IProject continueCreation(IProject prj) { >+ try { >+ CProjectNature.addCNature(prj, new NullProgressMonitor()); >+ CCProjectNature.addCCNature(prj, new NullProgressMonitor()); >+ RemoteNature.addRemoteNature(prj, new NullProgressMonitor()); >+ } catch (CoreException e) {} >+ return prj; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.cdt.ui.wizards.CDTCommonProjectWizard#getNatures() >+ */ >+ @Override >+ public String[] getNatures() { >+ return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID, RemoteNature.REMOTE_NATURE_ID}; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.wizards.newresource.BasicNewResourceWizard#initializeDefaultPageImageDescriptor() >+ */ >+ @Override >+ protected void initializeDefaultPageImageDescriptor() { >+ setDefaultPageImageDescriptor(RDTPluginImages.DESC_WIZBAN_NEW_REMOTE_C_PROJ); >+ } >+ >+} >Index: src/org/eclipse/ptp/rdt/ui/wizards/RemoteProjectContentsLocationArea.java >=================================================================== >RCS file: src/org/eclipse/ptp/rdt/ui/wizards/RemoteProjectContentsLocationArea.java >diff -N src/org/eclipse/ptp/rdt/ui/wizards/RemoteProjectContentsLocationArea.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/rdt/ui/wizards/RemoteProjectContentsLocationArea.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,490 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ptp.rdt.ui.wizards; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.net.URI; >+import java.util.HashMap; >+import java.util.Map; >+ >+import org.eclipse.core.filesystem.URIUtil; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.jface.dialogs.ProgressMonitorDialog; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.ptp.rdt.ui.UIPlugin; >+import org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider; >+import org.eclipse.ptp.remote.core.IRemoteConnection; >+import org.eclipse.ptp.remote.core.IRemoteServices; >+import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; >+import org.eclipse.ptp.remote.core.exception.RemoteConnectionException; >+import org.eclipse.ptp.remote.ui.IRemoteUIConnectionManager; >+import org.eclipse.ptp.remote.ui.IRemoteUIFileManager; >+import org.eclipse.ptp.remote.ui.IRemoteUIServices; >+import org.eclipse.ptp.remote.ui.PTPRemoteUIPlugin; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; >+import org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils; >+ >+/** >+ * Allows the user to select a provider of Remote Services for a RemoteBuildServiceProvider. >+ * >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is no guarantee that this API will work or >+ * that it will remain the same. Please do not use this API without consulting >+ * with the RDT team. >+ * >+ * @author crecoskie >+ * @see org.eclipse.ptp.rdt.ui.serviceproviders.RemoteBuildServiceProvider >+ */ >+public class RemoteProjectContentsLocationArea { >+ >+ /** >+ * IErrorMessageReporter is an interface for type that allow message >+ * reporting. >+ * >+ */ >+ public interface IErrorMessageReporter { >+ /** >+ * Report the error message >+ * >+ * @param errorMessage >+ * String or <code>null</code>. If the errorMessage is >+ * null then clear any error state. >+ * @param infoOnly >+ * the message is an informational message, but the dialog >+ * cannot continue >+ * >+ */ >+ public void reportError(String errorMessage, boolean infoOnly); >+ } >+ >+ private static final String FILE_SCHEME = "file"; //$NON-NLS-1$ >+ >+ private IProject fExistingProject; >+ >+ private IErrorMessageReporter fErrorReporter; >+ >+ private RemoteBuildServiceProvider fProvider; >+ >+ private Map<Integer, IRemoteServices> fComboIndexToRemoteServicesProviderMap = new HashMap<Integer, IRemoteServices>(); >+ >+ private IRemoteServices fSelectedProvider; >+ >+ private Map<Integer, IRemoteConnection> fComboIndexToRemoteConnectionMap = new HashMap<Integer, IRemoteConnection>(); >+ >+ private IRemoteConnection fSelectedConnection; >+ >+ private String fProjectName = IDEResourceInfoUtils.EMPTY_STRING; >+ >+ private Button fBrowseButton; >+ >+ private Button fNewConnectionButton; >+ >+ private Combo fProviderCombo; >+ >+ private Combo fConnectionCombo; >+ >+ private Text fLocationText; >+ >+// public RemoteProjectContentsLocationArea(IServiceProvider provider, Composite composite) { >+// if(provider instanceof RemoteBuildServiceProvider) >+// fProvider = (RemoteBuildServiceProvider) provider; >+// else >+// throw new IllegalArgumentException(); // should never happen >+// createContents(composite); >+// } >+ public RemoteProjectContentsLocationArea(IErrorMessageReporter reporter, Composite composite) { >+ fErrorReporter = reporter; >+ createContents(composite); >+ } >+ >+ /** >+ * Check if the entry in the widget location is valid. If it is valid return >+ * null. Otherwise return a string that indicates the problem. >+ * >+ * @return String >+ */ >+ public String checkValidLocation() { >+ >+ String locationFieldContents = fLocationText.getText(); >+ if (locationFieldContents.length() == 0) { >+ return IDEWorkbenchMessages.WizardNewProjectCreationPage_projectLocationEmpty; >+ } >+ >+ URI newPath = getProjectLocationURI(); >+ if (newPath == null) { >+ return IDEWorkbenchMessages.ProjectLocationSelectionDialog_locationError; >+ } >+ >+ if (fExistingProject != null) { >+ URI projectPath = fExistingProject.getLocationURI(); >+ if (projectPath != null && URIUtil.equals(projectPath, newPath)) { >+ return IDEWorkbenchMessages.ProjectLocationSelectionDialog_locationIsSelf; >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Return the browse button. Usually referenced in order to set the layout >+ * data for a dialog. >+ * >+ * @return Button >+ */ >+ public Button[] getButtons() { >+ return new Button[]{fBrowseButton, fNewConnectionButton}; >+ } >+ >+ /** >+ * Get the URI for the location field if possible. >+ * >+ * @return URI or <code>null</code> if it is not valid. >+ */ >+ public URI getProjectLocationURI() { >+ return fSelectedProvider.getFileManager(fSelectedConnection).toURI(new Path(fLocationText.getText())); >+ } >+ >+ /** >+ * Return whether or not we are currently showing the default location for >+ * the project. >+ * >+ * @return boolean >+ */ >+ public boolean isDefault() { >+// return useDefaultsButton.getSelection(); >+ return false; >+ } >+ >+ /** >+ * Set the project to base the contents off of. >+ * >+ * @param existingProject >+ */ >+ public void setExistingProject(IProject existingProject) { >+ fProjectName = existingProject.getName(); >+ fExistingProject = existingProject; >+ } >+ >+ /** >+ * Set the text to the default or clear it if not using the defaults. >+ * >+ * @param newName >+ * the name of the project to use. If <code>null</code> use the >+ * existing project name. >+ */ >+ public void updateProjectName(String newName) { >+ fProjectName = newName; >+ if (isDefault()) { >+// locationPathField.setText(TextProcessor >+// .process(getDefaultPathDisplayString())); >+ } >+ >+ } >+ >+ /** >+ * Attempt to open a connection. >+ */ >+ private void checkConnection() { >+ if (!fSelectedConnection.isOpen()) { >+ IRunnableWithProgress op = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) >+ throws InvocationTargetException, >+ InterruptedException { >+ try { >+ fSelectedConnection.open(monitor); >+ if (monitor.isCanceled()) { >+ throw new InterruptedException("Cancelled by user"); //$NON-NLS-1$ >+ } >+ } catch (RemoteConnectionException e) { >+ throw new InvocationTargetException(e); >+ } >+ } >+ >+ }; >+ try { >+ new ProgressMonitorDialog(fConnectionCombo.getShell()).run(true, true, op); >+ } catch (InvocationTargetException e) { >+ ErrorDialog.openError(fConnectionCombo.getShell(), "Connection error", //$NON-NLS-1$ >+ "Could not open connection", //$NON-NLS-1$ >+ new Status(IStatus.ERROR, UIPlugin.PLUGIN_ID, e.getCause().getMessage())); >+ } catch (InterruptedException e) { >+ ErrorDialog.openError(fConnectionCombo.getShell(), "Connection error", //$NON-NLS-1$ >+ "Could not open connection", //$NON-NLS-1$ >+ new Status(IStatus.ERROR, UIPlugin.PLUGIN_ID, e.getMessage())); >+ } >+ } >+ } >+ >+ /** >+ * Return the path we are going to display. If it is a file URI then remove >+ * the file prefix. >+ * >+ * @return String >+ */ >+ private String getDefaultPathDisplayString() { >+ >+ URI defaultURI = null; >+ if (fExistingProject != null) { >+ defaultURI = fExistingProject.getLocationURI(); >+ } >+ >+ // Handle files specially. Assume a file if there is no project to query >+ if (defaultURI == null || defaultURI.getScheme().equals(FILE_SCHEME)) { >+ return Platform.getLocation().append(fProjectName).toOSString(); >+ } >+ return defaultURI.toString(); >+ >+ } >+ >+ /** >+ * @return >+ */ >+ private IRemoteUIConnectionManager getUIConnectionManager() { >+ IRemoteUIConnectionManager connectionManager = PTPRemoteUIPlugin.getDefault().getRemoteUIServices(fSelectedProvider) >+ .getUIConnectionManager(); >+ return connectionManager; >+ } >+ >+ >+ /** >+ * @param connectionCombo >+ */ >+ private void populateConnectionCombo(final Combo connectionCombo) { >+ connectionCombo.removeAll(); >+ >+ //attempt to restore settings from saved state >+// IRemoteConnection connectionSelected = fProvider.getConnection(); >+ >+ IRemoteConnection[] connections = fSelectedProvider.getConnectionManager().getConnections(); >+ int toSelect = 0; >+ >+ for(int k = 0; k < connections.length; k++) { >+ connectionCombo.add(connections[k].getName(), k); >+ fComboIndexToRemoteConnectionMap .put(k, connections[k]); >+ >+// if (connectionSelected != null && connectionSelected.getName().compareTo(connections[k].getName()) == 0) { >+// toSelect = k; >+// } >+ } >+ >+ // set selected connection to be the first one if we're not restoring from settings >+ connectionCombo.select(toSelect); >+ fSelectedConnection = fComboIndexToRemoteConnectionMap.get(toSelect); >+ } >+ >+ /** >+ * @param button >+ */ >+ private void updateNewConnectionButtonEnabled(Button button) { >+ IRemoteUIConnectionManager connectionManager = getUIConnectionManager(); >+ button.setEnabled(connectionManager != null); >+ } >+ >+ protected Control createContents(Composite parent) { >+ Group container = new Group(parent, SWT.SHADOW_ETCHED_IN); >+ >+ GridLayout layout = new GridLayout(); >+ layout.numColumns = 3; >+ container.setLayout(layout); >+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ container.setLayoutData(gd); >+ >+ // Label for "Provider:" >+ Label providerLabel = new Label(container, SWT.LEFT); >+ providerLabel.setText("Remote Provider:"); //$NON-NLS-1$ >+ >+ // combo for providers >+ fProviderCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); >+ // set layout to grab horizontal space >+ fProviderCombo.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); >+ gd = new GridData(); >+ gd.horizontalSpan = 2; >+ fProviderCombo.setLayoutData(gd); >+ fProviderCombo.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ widgetSelected(e); >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ int selectionIndex = fProviderCombo.getSelectionIndex(); >+ fSelectedProvider = fComboIndexToRemoteServicesProviderMap.get(selectionIndex); >+ >+ populateConnectionCombo(fConnectionCombo); >+ updateNewConnectionButtonEnabled(fNewConnectionButton); >+ } >+ }); >+ >+ //attempt to restore settings from saved state >+// IRemoteServices providerSelected = fProvider.getRemoteServices(); >+ >+ // populate the combo with a list of providers >+ IRemoteServices[] providers = PTPRemoteCorePlugin.getDefault().getAllRemoteServices(); >+ int toSelect = 0; >+ >+ for(int k = 0; k < providers.length; k++) { >+ fProviderCombo.add(providers[k].getName(), k); >+ fComboIndexToRemoteServicesProviderMap.put(k, providers[k]); >+ >+// if (providerSelected != null && providerSelected.getName().compareTo(providers[k].getName()) == 0) { >+// toSelect = k; >+// } >+ } >+ >+ // set selected host to be the first one if we're not restoring from settings >+ fProviderCombo.select(toSelect); >+ fSelectedProvider = fComboIndexToRemoteServicesProviderMap.get(toSelect); >+ >+ // connection combo >+ // Label for "Connection:" >+ Label connectionLabel = new Label(container, SWT.LEFT); >+ connectionLabel.setText("Connection:"); //$NON-NLS-1$ >+ >+ // combo for providers >+ fConnectionCombo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); >+ // set layout to grab horizontal space >+ fConnectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); >+ fConnectionCombo.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ widgetSelected(e); >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ int selectionIndex = fConnectionCombo.getSelectionIndex(); >+ fSelectedConnection = fComboIndexToRemoteConnectionMap.get(selectionIndex); >+ updateNewConnectionButtonEnabled(fNewConnectionButton); >+ } >+ }); >+ >+ // populate the combo with a list of providers >+ populateConnectionCombo(fConnectionCombo); >+ >+ // new connection button >+ fNewConnectionButton = new Button(container, SWT.PUSH); >+ fNewConnectionButton.setText("New..."); //$NON-NLS-1$ >+ updateNewConnectionButtonEnabled(fNewConnectionButton); >+ fNewConnectionButton.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ widgetSelected(e); >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ IRemoteUIConnectionManager connectionManager = getUIConnectionManager(); >+ if(connectionManager != null) { >+ connectionManager.newConnection(fNewConnectionButton.getShell()); >+ } >+ // refresh list of connections >+ populateConnectionCombo(fConnectionCombo); >+ } >+ }); >+ >+ Label locationLabel = new Label(container, SWT.LEFT); >+ locationLabel.setText("Location:"); //$NON-NLS-1$ >+ >+ fLocationText = new Text(container, SWT.SINGLE | SWT.BORDER); >+ gd = new GridData(GridData.FILL_HORIZONTAL); >+ gd.horizontalSpan = 1; >+ gd.grabExcessHorizontalSpace = true; >+ gd.widthHint = 250; >+ fLocationText.setLayoutData(gd); >+ fLocationText.addModifyListener(new ModifyListener() { >+ public void modifyText(ModifyEvent e) { >+ fErrorReporter.reportError(checkValidLocation(), false); >+ } >+ }); >+ >+ // new connection button >+ fBrowseButton = new Button(container, SWT.PUSH); >+ fBrowseButton.setText("Browse..."); //$NON-NLS-1$ >+ fBrowseButton.addSelectionListener(new SelectionListener() { >+ public void widgetDefaultSelected(SelectionEvent e) { >+ widgetSelected(e); >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ if (fSelectedConnection != null) { >+ checkConnection(); >+ if (fSelectedConnection.isOpen()) { >+ IRemoteUIServices remoteUIServices = PTPRemoteUIPlugin.getDefault().getRemoteUIServices(fSelectedProvider); >+ if (remoteUIServices != null) { >+ IRemoteUIFileManager fileMgr = remoteUIServices.getUIFileManager(); >+ if (fileMgr != null) { >+ fileMgr.setConnection(fSelectedConnection); >+ String correctPath = fLocationText.getText(); >+ IPath selectedPath = fileMgr.browseDirectory(fLocationText.getShell(), "Project Location (" + fSelectedConnection.getName() + ")", correctPath); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (selectedPath != null) { >+ fLocationText.setText(selectedPath.toString()); >+ } >+ } >+ } >+ } >+ } >+ } >+ }); >+ >+ return container; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.Dialog#okPressed() >+ */ >+ protected void okPressed() { >+ >+ // set the provider >+ fProvider.setRemoteToolsProviderID(fSelectedProvider.getId()); >+ fProvider.setRemoteToolsConnection(fSelectedConnection); >+ >+ } >+ >+ public IRemoteServices getRemoteServices() { >+ return fSelectedProvider; >+ } >+ >+ public IRemoteConnection getRemoteConnection() { >+ return fSelectedConnection; >+ } >+ >+ /** >+ * Return the location for the project. >+ * >+ * @return String >+ */ >+ public String getProjectLocation() { >+ return fLocationText.getText(); >+ } >+ >+ /** >+ * Returns the name of the selected connection. >+ */ >+ public IRemoteConnection getConnection() { >+ return fSelectedConnection; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 283402
:
141504
|
141505
| 148169 |
151066