1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 23:35:48 +02:00

[231827][remotecdt]Auto-compute default for Remote path

This commit is contained in:
Martin Oberhuber 2008-05-20 19:58:22 +00:00
parent f9470bfb50
commit 72b783e77d
6 changed files with 255 additions and 62 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.rse.remotecdt;singleton:=true
Bundle-Version: 3.0.0.qualifier
Bundle-Version: 2.1.0.qualifier
Bundle-Activator: org.eclipse.rse.internal.remotecdt.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)",

View file

@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2008 Wind River Systems, Inc.
* 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:
* Johann Draschwandtner (Wind River) - initial API and implementation
*******************************************************************************/
package org.eclipse.rse.internal.remotecdt;
/**
* Constants used for Remote CDT connection properties.
*
* <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 <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team.
* </p>
*
* @noimplement This interface is not intended to be implemented by clients.
* @since org.eclipse.rse.remotecdt 2.1
*/
public interface IRemoteConnectionHostConstants {
public static final String PI_REMOTE_CDT = "org.eclipse.rse.remotecdt"; //$NON-NLS-1$
public static final String REMOTE_WS_ROOT = "remoteWsRoot"; //$NON-NLS-1$
public static final String DEFAULT_SKIP_DOWNLOAD = "defaultSkipDownload"; //$NON-NLS-1$
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2008 Wind River Systems, Inc. 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
@ -8,6 +8,7 @@
* Contributors:
* Martin Oberhuber (Wind River) - initial API and implementation
* Ewa Matejska (PalmSource) - [158783] browse button for cdt remote path
* Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
*******************************************************************************/
package org.eclipse.rse.internal.remotecdt;
@ -34,6 +35,10 @@ public class Messages extends NLS {
public static String RemoteCMainTab_ErrorNoConnection;
public static String RemoteCMainTab_Connection;
public static String RemoteCMainTab_New;
public static String RemoteCMainTab_Properties;
public static String RemoteCMainTab_Properties_title;
public static String RemoteCMainTab_Properties_Location;
public static String RemoteCMainTab_Properties_Skip_default;
public static String RemoteRunLaunchDelegate_RemoteShell;
public static String RemoteRunLaunchDelegate_1;

View file

@ -11,6 +11,7 @@
* Martin Oberhuber (Wind River) - [196934] hide disabled system types in remotecdt combo
* Yu-Fen Kuo (MontaVista) - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded
* Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
* Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
*******************************************************************************/
package org.eclipse.rse.internal.remotecdt;
@ -26,10 +27,13 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.window.Window;
import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
import org.eclipse.rse.ui.actions.SystemNewConnectionAction;
@ -43,8 +47,10 @@ 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.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
@ -62,6 +68,7 @@ public class RemoteCMainTab extends CMainTab {
private static final boolean SKIP_DOWNLOAD_TO_REMOTE_DEFAULT = false;
protected Button newRemoteConnectionButton;
protected Button remoteConnectionPropertiesButton;
protected Button remoteBrowseButton;
protected Label connectionLabel;
protected Combo connectionCombo;
@ -90,7 +97,7 @@ public class RemoteCMainTab extends CMainTab {
/* The RSE Connection dropdown with New button. */
createVerticalSpacer(comp, 1);
createRemoteConnectionGroup(comp, 3);
createRemoteConnectionGroup(comp, 4);
/* The Project and local binary location */
createVerticalSpacer(comp, 1);
@ -145,7 +152,7 @@ public class RemoteCMainTab extends CMainTab {
protected void createRemoteConnectionGroup(Composite parent, int colSpan) {
Composite projComp = new Composite(parent, SWT.NONE);
GridLayout projLayout = new GridLayout();
projLayout.numColumns = 3;
projLayout.numColumns = 4;
projLayout.marginHeight = 0;
projLayout.marginWidth = 0;
projComp.setLayout(projLayout);
@ -168,6 +175,7 @@ public class RemoteCMainTab extends CMainTab {
public void modifyText(ModifyEvent e) {
setDirty(true);
updateLaunchConfigurationDialog();
useDefaultsFromConnection();
}
});
updateConnectionPulldown();
@ -182,6 +190,14 @@ public class RemoteCMainTab extends CMainTab {
}
});
remoteConnectionPropertiesButton = createPushButton(projComp, Messages.RemoteCMainTab_Properties, null);
remoteConnectionPropertiesButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
handleRemoteConnectionPropertiesSelected();
}
});
}
/*
@ -335,6 +351,77 @@ public class RemoteCMainTab extends CMainTab {
}
}
protected void handleRemoteConnectionPropertiesSelected() {
class RemoteConnectionPropertyDialog extends Dialog {
private IHost fHost;
boolean fbLocalHost;
private Button fSkipDownloadBtn;
private Text fWSRoot;
public RemoteConnectionPropertyDialog(Shell parentShell, String dialogTitle, IHost host) {
super(parentShell);
parentShell.setText(dialogTitle);
fHost = host;
fbLocalHost = fHost.getSystemType().isLocal();
}
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;
}
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();
}
private void waitForRSEInit(final Runnable callback) {
Job initRSEJob = null;
Job[] jobs = Job.getJobManager().find(null);
@ -428,15 +515,80 @@ public class RemoteCMainTab extends CMainTab {
*/
private void setLocalPathForRemotePath() {
String programName = fProgText.getText().trim();
boolean bUpdateRemote = false;
String remoteName = remoteProgText.getText().trim();
if (programName.length() != 0 && remoteName.length() == 0) {
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() {
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());
}
}
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) {
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;
}
}

View file

@ -1,5 +1,5 @@
################################################################################
# Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
# Copyright (c) 2006, 2008 Wind River Systems, Inc. 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
@ -8,6 +8,7 @@
# Contributors:
# Martin Oberhuber (Wind River) - externalized strings
# Ewa Matejska (PalmSource) - [158783] browse button for cdt remote path
# Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
################################################################################
# NLS_MESSAGEFORMAT_VAR
@ -32,3 +33,7 @@ Gdbserver_Settings_Tab_Name=Gdbserver Settings
Gdbserver_name_textfield_label=Gdbserver name:
Port_number_textfield_label=Port number:
RemoteCMainTab_Remote_Path_Browse_Button_Title=Select Remote C/C++ Application File
RemoteCMainTab_Properties=Properties...
RemoteCMainTab_Properties_title=Properties
RemoteCMainTab_Properties_Location=Remote workspace location:
RemoteCMainTab_Properties_Skip_default=Skip download to target path by default

View file

@ -2,7 +2,7 @@
<feature
id="org.eclipse.rse.remotecdt"
label="%featureName"
version="3.0.0.qualifier"
version="2.1.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.rse.remotecdt"
image="eclipse_update_120.jpg">