From b34301fbb04484c17335ab6c33457484b0ef6517 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 18 Mar 2016 14:16:11 -0400 Subject: [PATCH] Bug 484900: Cleanup remote launch after CDI cleanup API Breaking changes: - The old RemoteCMainTab.java was removed. RemoteCDSFMainTab should be used. Move Remote Run launch to use RemoteCDSFMainTab Remove plugin.xml definition of the tabs associated with the removed CDI Remote debug launch. Change-Id: Ie71497aa745295cc696b2679aa3047d9895d2481 --- .../org.eclipse.cdt.launch.remote/plugin.xml | 33 +- .../launching/RemoteRunLaunchDelegate.java | 4 +- .../launch/remote/tabs/RemoteCMainTab.java | 747 ------------------ 3 files changed, 2 insertions(+), 782 deletions(-) delete mode 100644 cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCMainTab.java diff --git a/cross/org.eclipse.cdt.launch.remote/plugin.xml b/cross/org.eclipse.cdt.launch.remote/plugin.xml index ded8010be4c..a89f8e996d1 100644 --- a/cross/org.eclipse.cdt.launch.remote/plugin.xml +++ b/cross/org.eclipse.cdt.launch.remote/plugin.xml @@ -43,14 +43,7 @@ Anna Dushistova (Mentor Graphics) - code restructuring id="org.eclipse.rse.remotecdt.launch.RemoteCMainTab" group="org.eclipse.cdt.launch.remoteApplicationRunLaunchTabGroup" name="Main" - class="org.eclipse.cdt.launch.remote.tabs.RemoteCMainTab"> - - - + class="org.eclipse.cdt.launch.remote.tabs.RemoteCDSFMainTab"> - - - - - - - - - - - - = 0 ? connectionCombo - .getItem(currentSelection) : ""; //$NON-NLS-1$ - if (connection_name.equals("")) { //$NON-NLS-1$ - setErrorMessage(CONNECTION_TEXT_ERROR); - retVal = false; - } - if (retVal) { - String name = remoteProgText.getText().trim(); - if (name.length() == 0) { - setErrorMessage(REMOTE_PROG_TEXT_ERROR); - retVal = false; - } - } - } - return retVal; - } - - protected void createRemoteConnectionGroup(Composite parent, int colSpan) { - Composite projComp = new Composite(parent, SWT.NONE); - GridLayout projLayout = new GridLayout(); - projLayout.numColumns = 5; - projLayout.marginHeight = 0; - projLayout.marginWidth = 0; - projComp.setLayout(projLayout); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = colSpan; - projComp.setLayoutData(gd); - - connectionLabel = new Label(projComp, SWT.NONE); - connectionLabel.setText(Messages.RemoteCMainTab_Connection); - gd = new GridData(); - gd.horizontalSpan = 1; - connectionLabel.setLayoutData(gd); - - connectionCombo = new Combo(projComp, SWT.DROP_DOWN | SWT.READ_ONLY); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 1; - connectionCombo.setLayoutData(gd); - connectionCombo.addModifyListener(new ModifyListener() { - - public void modifyText(ModifyEvent e) { - useDefaultsFromConnection(); - updateConnectionButtons(); - setDirty(true); - updateLaunchConfigurationDialog(); - } - }); - - newRemoteConnectionButton = createPushButton(projComp, - Messages.RemoteCMainTab_New, null); - newRemoteConnectionButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent evt) { - handleNewRemoteConnectionSelected(); - updateLaunchConfigurationDialog(); - updateConnectionPulldown(); - } - }); - - editRemoteConnectionButton = createPushButton(projComp, - Messages.RemoteCMainTab_Edit, null); - editRemoteConnectionButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent evt) { - handleEditRemoteConnectionSelected(); - } - }); - - remoteConnectionPropertiesButton = createPushButton(projComp, - Messages.RemoteCMainTab_Properties, null); - remoteConnectionPropertiesButton - .addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent evt) { - handleRemoteConnectionPropertiesSelected(); - } - }); - - updateConnectionPulldown(); - } - - /* - * createTargetExePath This creates the remote path user-editable textfield - * on the Main Tab. - */ - protected void createTargetExePathGroup(Composite parent) { - Composite mainComp = new Composite(parent, SWT.NONE); - GridLayout mainLayout = new GridLayout(); - mainLayout.numColumns = 2; - mainLayout.marginHeight = 0; - mainLayout.marginWidth = 0; - mainComp.setLayout(mainLayout); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - mainComp.setLayoutData(gd); - - remoteProgLabel = new Label(mainComp, SWT.NONE); - remoteProgLabel.setText(REMOTE_PROG_LABEL_TEXT); - gd = new GridData(); - gd.horizontalSpan = 2; - remoteProgLabel.setLayoutData(gd); - - remoteProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 1; - remoteProgText.setLayoutData(gd); - remoteProgText.addModifyListener(new ModifyListener() { - - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - - remoteBrowseButton = createPushButton(mainComp, - Messages.RemoteCMainTab_Remote_Path_Browse_Button, null); - remoteBrowseButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent evt) { - handleRemoteBrowseSelected(); - updateLaunchConfigurationDialog(); - } - }); - - // Commands to run before execution - preRunLabel = new Label(mainComp, SWT.NONE); - preRunLabel.setText(PRE_RUN_LABEL_TEXT); - gd = new GridData(); - gd.horizontalSpan = 2; - preRunLabel.setLayoutData(gd); - - preRunText = new Text(mainComp, SWT.MULTI | SWT.BORDER); - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - preRunText.setLayoutData(gd); - preRunText.addModifyListener(new ModifyListener() { - - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - - } - - /* - * createDownloadOption This creates the skip download check button. - */ - protected void createDownloadOption(Composite parent) { - Composite mainComp = new Composite(parent, SWT.NONE); - GridLayout mainLayout = new GridLayout(); - mainLayout.marginHeight = 0; - mainLayout.marginWidth = 0; - mainComp.setLayout(mainLayout); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - mainComp.setLayoutData(gd); - - skipDownloadButton = createCheckButton(mainComp, - SKIP_DOWNLOAD_BUTTON_TEXT); - skipDownloadButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent evt) { - updateLaunchConfigurationDialog(); - } - }); - skipDownloadButton.setEnabled(true); - } - - /* - * performApply - * - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply - */ - @Override - public void performApply(ILaunchConfigurationWorkingCopy config) { - - int currentSelection = connectionCombo.getSelectionIndex(); - config.setAttribute( - IRemoteConnectionConfigurationConstants.ATTR_REMOTE_CONNECTION, - currentSelection >= 0 ? connectionCombo - .getItem(currentSelection) : null); - config.setAttribute( - IRemoteConnectionConfigurationConstants.ATTR_REMOTE_PATH, - remoteProgText.getText()); - config - .setAttribute( - IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET, - skipDownloadButton.getSelection()); - config.setAttribute( - IRemoteConnectionConfigurationConstants.ATTR_PRERUN_COMMANDS, - preRunText.getText()); - super.performApply(config); - } - - /* - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom - */ - @Override - public void initializeFrom(ILaunchConfiguration config) { - isInitializing = true; - - String remoteConnection = null; - try { - remoteConnection = config - .getAttribute( - IRemoteConnectionConfigurationConstants.ATTR_REMOTE_CONNECTION, - ""); //$NON-NLS-1$ - } catch (CoreException ce) { - // Ignore - } - - String[] items = connectionCombo.getItems(); - int i = 0; - for (i = 0; i < items.length; i++) - if (items[i].equals(remoteConnection)) - break; - /* - * Select the last used connection in the connecion pulldown if it still - * exists. - */ - if (i < items.length) - connectionCombo.select(i); - else if (items.length > 0) - connectionCombo.select(0); - - super.initializeFrom(config); - - updateTargetProgFromConfig(config); - updateSkipDownloadFromConfig(config); - updateConnectionButtons(); - isInitializing = false; - } - - protected void handleNewRemoteConnectionSelected() { - if (action == null) { - action = new SystemNewConnectionAction(getControl().getShell(), - false, false, null); - } - - try { - action.run(); - } catch (Exception e) { - // Ignore - } - } - - /** - * Opens the SystemConnectionPropertyPage page for the selected connection. - */ - protected void handleEditRemoteConnectionSelected() { - IHost currentConnectionSelected = getCurrentConnection(); - PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getControl().getShell(), currentConnectionSelected, SYSTEM_PAGE_ID, null, null); - if (dialog != null) { - dialog.open(); - } - } - - protected IHost getCurrentConnection() { - int currentSelection = connectionCombo.getSelectionIndex(); - String remoteConnection = currentSelection >= 0 ? connectionCombo - .getItem(currentSelection) : null; - return RSEHelper.getRemoteConnectionByName(remoteConnection); - } - - protected void handleRemoteBrowseSelected() { - IHost currentConnectionSelected = getCurrentConnection(); - SystemRemoteFileDialog dlg = new SystemRemoteFileDialog(getControl() - .getShell(), - Messages.RemoteCMainTab_Remote_Path_Browse_Button_Title, - currentConnectionSelected); - dlg.setBlockOnOpen(true); - if (dlg.open() == Window.OK) { - Object retObj = dlg.getSelectedObject(); - if (retObj instanceof IRemoteFile) { - IRemoteFile selectedFile = (IRemoteFile) retObj; - remoteProgText.setText(selectedFile.getAbsolutePath()); - } - - } - } - - protected void handleRemoteConnectionPropertiesSelected() { - class RemoteConnectionPropertyDialog extends Dialog { - private IHost fHost; - boolean fbLocalHost; - private Button fSkipDownloadBtn; - private Text fWSRoot; - private String fDialogTitle; - - public RemoteConnectionPropertyDialog(Shell parentShell, - String dialogTitle, IHost host) { - super(parentShell); - fDialogTitle = dialogTitle; - fHost = host; - fbLocalHost = fHost.getSystemType().isLocal(); - } - - @Override - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(fDialogTitle); - } - - @Override - protected Control createDialogArea(Composite parent) { - // create composite - Composite composite = (Composite) super - .createDialogArea(parent); - - Label label = new Label(composite, SWT.WRAP); - label.setText(Messages.RemoteCMainTab_Properties_Location); - GridData data = new GridData(GridData.GRAB_HORIZONTAL - | GridData.GRAB_VERTICAL - | GridData.HORIZONTAL_ALIGN_FILL - | GridData.VERTICAL_ALIGN_CENTER); - data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); - label.setLayoutData(data); - label.setFont(parent.getFont()); - fWSRoot = new Text(composite, SWT.SINGLE | SWT.BORDER); - fWSRoot.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL - | GridData.HORIZONTAL_ALIGN_FILL)); - - fSkipDownloadBtn = new Button(composite, SWT.CHECK); - fSkipDownloadBtn - .setText(Messages.RemoteCMainTab_Properties_Skip_default); - if (!fbLocalHost) { - IPropertySet propertySet = fHost - .getPropertySet(IRemoteConnectionHostConstants.PI_REMOTE_CDT); - if (propertySet != null) { - String value = propertySet - .getPropertyValue(IRemoteConnectionHostConstants.REMOTE_WS_ROOT); - if (value != null) { - fWSRoot.setText(value); - } - fSkipDownloadBtn - .setSelection(Boolean - .valueOf( - propertySet - .getPropertyValue(IRemoteConnectionHostConstants.DEFAULT_SKIP_DOWNLOAD)) - .booleanValue()); - } - } else { - fSkipDownloadBtn.setEnabled(false); - fWSRoot.setEnabled(false); - } - applyDialogFont(composite); - return composite; - } - - @Override - protected void buttonPressed(int buttonId) { - if (!fbLocalHost && (buttonId == IDialogConstants.OK_ID)) { - IPropertySet propertySet = fHost - .getPropertySet(IRemoteConnectionHostConstants.PI_REMOTE_CDT); - if (propertySet == null) { - propertySet = fHost - .createPropertySet(IRemoteConnectionHostConstants.PI_REMOTE_CDT); - } - propertySet.addProperty( - IRemoteConnectionHostConstants.REMOTE_WS_ROOT, - fWSRoot.getText()); - propertySet - .addProperty( - IRemoteConnectionHostConstants.DEFAULT_SKIP_DOWNLOAD, - Boolean.toString(fSkipDownloadBtn - .getSelection())); - fHost.commit(); - } - super.buttonPressed(buttonId); - } - } - IHost currentConnectionSelected = getCurrentConnection(); - RemoteConnectionPropertyDialog dlg = new RemoteConnectionPropertyDialog( - getControl().getShell(), - Messages.RemoteCMainTab_Properties_title, - currentConnectionSelected); - dlg.setBlockOnOpen(true); - dlg.open(); - } - - protected void updateConnectionPulldown() { - if (!RSECorePlugin.isInitComplete(RSECorePlugin.INIT_MODEL)) - try { - RSECorePlugin.waitForInitCompletion(RSECorePlugin.INIT_MODEL); - } catch (InterruptedException e) { - return; - } - // already initialized - connectionCombo.removeAll(); - IHost[] connections = RSEHelper.getSuitableConnections(); - for (int i = 0; i < connections.length; i++) { - IRSESystemType sysType = connections[i].getSystemType(); - if (sysType != null && sysType.isEnabled()) { - connectionCombo.add(connections[i].getAliasName()); - } - } - - if (connections.length > 0) { - connectionCombo.select(connections.length - 1); - } - updateConnectionButtons(); - } - - private void updateConnectionButtons() { - if ((remoteConnectionPropertiesButton == null) - || remoteConnectionPropertiesButton.isDisposed()) { - return; - } - if ((editRemoteConnectionButton == null) - || editRemoteConnectionButton.isDisposed()) { - return; - } - boolean bEnable = false; - IHost currentConnectionSelected = getCurrentConnection(); - if (currentConnectionSelected != null) { - IRSESystemType sysType = currentConnectionSelected.getSystemType(); - if (sysType != null && sysType.isEnabled() && !sysType.isLocal()) { - bEnable = true; - } - } - remoteConnectionPropertiesButton.setEnabled(bEnable); - editRemoteConnectionButton.setEnabled(bEnable); - } - - protected void updateTargetProgFromConfig(ILaunchConfiguration config) { - String targetPath = null; - try { - targetPath = config.getAttribute( - IRemoteConnectionConfigurationConstants.ATTR_REMOTE_PATH, - REMOTE_PATH_DEFAULT); - } catch (CoreException e) { - // Ignore - } - remoteProgText.setText(targetPath); - - String prelaunchCmd = null; - try { - prelaunchCmd = config - .getAttribute( - IRemoteConnectionConfigurationConstants.ATTR_PRERUN_COMMANDS, - ""); //$NON-NLS-1$ - } catch (CoreException e) { - // Ignore - } - preRunText.setText(prelaunchCmd); - } - - protected void updateSkipDownloadFromConfig(ILaunchConfiguration config) { - boolean downloadToTarget = true; - try { - downloadToTarget = config - .getAttribute( - IRemoteConnectionConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET, - getDefaultSkipDownload()); - } catch (CoreException e) { - // Ignore for now - } - skipDownloadButton.setSelection(downloadToTarget); - } - - /* - * setLocalPathForRemotePath This function sets the remote path text field - * with the value of the local executable path. - */ - private void setLocalPathForRemotePath() { - String programName = fProgText.getText().trim(); - boolean bUpdateRemote = false; - - String remoteName = remoteProgText.getText().trim(); - String remoteWsRoot = getRemoteWSRoot(); - if (remoteName.length() == 0) { - bUpdateRemote = true; - } else if (remoteWsRoot.length() != 0) { - bUpdateRemote = remoteName.equals(remoteWsRoot); - } - - if (programName.length() != 0 && bUpdateRemote) { - IProject project = getCProject().getProject(); - IPath exePath = new Path(programName); - if (!exePath.isAbsolute()) { - exePath = project.getFile(programName).getLocation(); - - IPath wsRoot = project.getWorkspace().getRoot().getLocation(); - exePath = makeRelativeToWSRootLocation(exePath, remoteWsRoot, - wsRoot); - } - String path = exePath.toString(); - remoteProgText.setText(path); - } - } - - private void useDefaultsFromConnection() { - // During initialization, we don't want to use the default - // values of the connection, but we want to use the ones - // that are part of the configuration - if (isInitializing) return; - - if ((remoteProgText != null) && !remoteProgText.isDisposed()) { - String remoteName = remoteProgText.getText().trim(); - String remoteWsRoot = getRemoteWSRoot(); - if (remoteName.length() == 0) { - remoteProgText.setText(remoteWsRoot); - } else { - // try to use remote path - IPath wsRoot = getCProject().getProject().getWorkspace() - .getRoot().getLocation(); - IPath remotePath = makeRelativeToWSRootLocation(new Path( - remoteName), remoteWsRoot, wsRoot); - remoteProgText.setText(remotePath.toString()); - } - } - if ((skipDownloadButton != null) && !skipDownloadButton.isDisposed()) { - skipDownloadButton.setSelection(getDefaultSkipDownload()); - if(RSEHelper.getFileSubsystem(getCurrentConnection()) == null){ - skipDownloadButton.setEnabled(false); - } else { - skipDownloadButton.setEnabled(true); - } - } - if((remoteBrowseButton!=null) && !remoteBrowseButton.isDisposed()){ - if(RSEHelper.getFileSubsystem(getCurrentConnection()) == null){ - remoteBrowseButton.setEnabled(false); - } else { - remoteBrowseButton.setEnabled(true); - } - } - } - - private IPath makeRelativeToWSRootLocation(IPath exePath, - String remoteWsRoot, IPath wsRoot) { - if (remoteWsRoot.length() != 0) { - // use remoteWSRoot instead of Workspace Root - if (wsRoot.isPrefixOf(exePath)) { - return new Path(remoteWsRoot).append(exePath - .removeFirstSegments(wsRoot.segmentCount()).setDevice( - null)); - } - } - return exePath; - } - - private String getRemoteWSRoot() { - IHost host = getCurrentConnection(); - if (host != null) { - IPropertySet propertySet = host - .getPropertySet(IRemoteConnectionHostConstants.PI_REMOTE_CDT); - if (propertySet != null) { - String value = propertySet - .getPropertyValue(IRemoteConnectionHostConstants.REMOTE_WS_ROOT); - if (value != null) { - return value; - } - } - } - return ""; //$NON-NLS-1$ - } - - private boolean getDefaultSkipDownload() { - IHost host = getCurrentConnection(); - if (host != null) { - if(RSEHelper.getFileSubsystem(host) == null){ - return true; - } - IPropertySet propertySet = host - .getPropertySet(IRemoteConnectionHostConstants.PI_REMOTE_CDT); - if (propertySet != null) { - return Boolean - .valueOf( - propertySet - .getPropertyValue(IRemoteConnectionHostConstants.DEFAULT_SKIP_DOWNLOAD)) - .booleanValue(); - } - } - return SKIP_DOWNLOAD_TO_REMOTE_DEFAULT; - } - - @Override - public String getId() { - return "org.eclipse.rse.remotecdt.launch.RemoteCMainTab"; //$NON-NLS-1$ - } -}