1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

Cleanup some Jsch files

Source->Cleanup for files changed by child commit.

Change-Id: I787b623fc0832df3bf98cc1b89edc69f461235e2
This commit is contained in:
Roland Schulz 2014-10-02 19:39:02 -04:00 committed by John Eblen
parent d83bd777dc
commit 5ee4fa818a
6 changed files with 115 additions and 105 deletions

View file

@ -817,7 +817,7 @@ public class JSchConnection implements IRemoteConnection {
if (subMon.isCanceled()) {
throw new RemoteConnectionException(Messages.JSchConnection_Connection_was_cancelled);
}
//getCwd checks the exec channel before checkConfiguration checks the sftp channel
// getCwd checks the exec channel before checkConfiguration checks the sftp channel
fWorkingDir = getCwd(subMon.newChild(10));
if (!checkConfiguration(session, subMon.newChild(20))) {
newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));

View file

@ -88,6 +88,21 @@ public class JSchConnectionAttributes {
return fAttributes;
}
public boolean getBoolean(String key, boolean def) {
if (fAttributes.containsKey(key)) {
return Boolean.parseBoolean(fAttributes.get(key));
}
return def;
}
public int getInt(String key, int def) {
try {
return Integer.parseInt(fAttributes.get(key));
} catch (NumberFormatException e) {
return def;
}
}
public String getName() {
if (fNewName == null) {
return fName;
@ -108,21 +123,6 @@ public class JSchConnectionAttributes {
return def;
}
public int getInt(String key, int def) {
try {
return Integer.parseInt(fAttributes.get(key));
} catch (NumberFormatException e) {
return def;
}
}
public boolean getBoolean(String key, boolean def) {
if (fAttributes.containsKey(key)) {
return Boolean.parseBoolean(fAttributes.get(key));
}
return def;
}
public Map<String, String> getSecureAttributes() {
return fSecureAttributes;
}
@ -166,6 +166,11 @@ public class JSchConnectionAttributes {
}
}
public void remove() {
clearPreferences();
flushPreferences();
}
public void save() {
clearPreferences();
if (fNewName != null) {
@ -176,11 +181,6 @@ public class JSchConnectionAttributes {
flushPreferences();
}
public void remove() {
clearPreferences();
flushPreferences();
}
private void savePreferences() {
Preferences node = getPreferences();
synchronized (fAttributes) {

View file

@ -72,6 +72,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#getOriginal()
*/
@Override
public IRemoteConnection getOriginal() {
return fOriginal;
}
@ -141,6 +142,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#isDirty()
*/
@Override
public boolean isDirty() {
return fIsDirty;
}
@ -160,6 +162,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#save()
*/
@Override
public IRemoteConnection save() {
JSchConnectionAttributes info = fOriginal.getInfo();
info.getAttributes().clear();
@ -182,6 +185,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAddress(java.lang.String)
*/
@Override
public void setAddress(String address) {
fIsDirty = true;
fWorkingAttributes.setAttribute(JSchConnectionAttributes.ADDRESS_ATTR, address);
@ -192,6 +196,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAttribute(java.lang.String, java.lang.String)
*/
@Override
public void setAttribute(String key, String value) {
fIsDirty = true;
fWorkingAttributes.setAttribute(key, value);
@ -217,6 +222,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
*/
@Override
public void setName(String name) {
fIsDirty = true;
fWorkingAttributes.setName(name);
@ -232,6 +238,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPassword(java.lang.String)
*/
@Override
public void setPassword(String password) {
fIsDirty = true;
fWorkingAttributes.setSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, password);
@ -242,6 +249,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPort(int)
*/
@Override
public void setPort(int port) {
fIsDirty = true;
fWorkingAttributes.setAttribute(JSchConnectionAttributes.PORT_ATTR, Integer.toString(port));
@ -262,6 +270,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setUsername(java.lang.String)
*/
@Override
public void setUsername(String userName) {
fIsDirty = true;
fWorkingAttributes.setAttribute(JSchConnectionAttributes.USERNAME_ATTR, userName);

View file

@ -21,10 +21,6 @@ public class Messages extends NLS {
NLS.initializeMessages(BUNDLE_ID, Messages.class);
}
private Messages() {
// cannot create new instance
}
public static String JSchConnectionPage_A_connection_with_that_name_already_exists;
public static String JSchConnectionPage_Edit_Connection;
public static String JSchConnectionPage_Edit_properties_of_an_existing_connection;
@ -55,4 +51,8 @@ public class Messages extends NLS {
public static String JSchNewConnectionPage_User_name_cannot_be_empty;
public static String JSchUIConnectionManager_Connection_Error;
public static String JSchUIConnectionManager_Could_not_open_connection;
private Messages() {
// cannot create new instance
}
}

View file

@ -38,13 +38,13 @@ 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.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.swt.widgets.Control;
public class JSchConnectionPage extends WizardPage {
private class DataModifyListener implements ModifyListener {
@ -198,7 +198,8 @@ public class JSchConnectionPage extends WizardPage {
fPasswordButton.setSelection(true);
fPublicKeyButton.setSelection(false);
controls.setTabList(new Control[]{fHostText, fUserText, fPasswordButton, fPasswordText, fPublicKeyButton, fFileWidget, fPassphraseText});
controls.setTabList(new Control[] { fHostText, fUserText, fPasswordButton, fPasswordText, fPublicKeyButton, fFileWidget,
fPassphraseText });
}
@Override
@ -364,6 +365,18 @@ public class JSchConnectionPage extends WizardPage {
fInitialAttributes.put(JSchConnectionAttributes.PORT_ATTR, Integer.toString(port));
}
private void setTextFieldWidthInChars(Text text, int chars) {
text.setTextLimit(chars);
Object data = text.getLayoutData();
if (data instanceof GridData) {
GC gc = new GC(text);
FontMetrics fm = gc.getFontMetrics();
int width = chars * fm.getAverageCharWidth();
gc.dispose();
((GridData) data).widthHint = width;
}
}
public void setUsername(String username) {
fInitialAttributes.put(JSchConnectionAttributes.USERNAME_ATTR, username);
}
@ -473,16 +486,4 @@ public class JSchConnectionPage extends WizardPage {
}
return null;
}
private void setTextFieldWidthInChars(Text text, int chars) {
text.setTextLimit(chars);
Object data = text.getLayoutData();
if (data instanceof GridData) {
GC gc = new GC(text);
FontMetrics fm = gc.getFontMetrics();
int width = chars * fm.getAverageCharWidth();
gc.dispose();
((GridData) data).widthHint = width;
}
}
}