diff options
author | yamanaka | 2004-02-07 15:28:45 +0000 |
---|---|---|
committer | yamanaka | 2004-02-07 15:28:45 +0000 |
commit | 7388d433849bd363f3115b7e7a85e0ad94870c91 (patch) | |
tree | 463e079952bf46c7ab67843e50af950dd7b22123 /bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse | |
parent | 2f2e4b517065d27e467eb5aae63d9a484f32b9f1 (diff) | |
download | eclipse.platform.team-7388d433849bd363f3115b7e7a85e0ad94870c91.tar.gz eclipse.platform.team-7388d433849bd363f3115b7e7a85e0ad94870c91.tar.xz eclipse.platform.team-7388d433849bd363f3115b7e7a85e0ad94870c91.zip |
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse')
-rw-r--r-- | bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/CVSSSH2PreferencePage.java | 409 |
1 files changed, 45 insertions, 364 deletions
diff --git a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/CVSSSH2PreferencePage.java b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/CVSSSH2PreferencePage.java index 826a5122a..4581d1d1a 100644 --- a/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/CVSSSH2PreferencePage.java +++ b/bundles/org.eclipse.team.cvs.ssh2/src/org/eclipse/team/ccvs/ssh2/CVSSSH2PreferencePage.java @@ -13,6 +13,7 @@ package org.eclipse.team.ccvs.ssh2; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.*; import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; @@ -355,7 +356,6 @@ public class CVSSSH2PreferencePage extends PreferencePage }); return group; } - private Control createKeyManagementPage(Composite parent) { int columnSpan=3; Composite group=new Composite(parent, SWT.NULL); @@ -599,10 +599,9 @@ public class CVSSSH2PreferencePage extends PreferencePage ok=false; } if(!ok){ - MessageBox mb=new MessageBox(getShell(),SWT.OK|SWT.ICON_ERROR); - mb.setText(Policy.bind("CVSSSH2PreferencePage.error")); //$NON-NLS-1$ - mb.setMessage(Policy.bind("CVSSSH2PreferencePage.47")); //$NON-NLS-1$ - mb.open(); + MessageDialog.openError(getShell(), + Policy.bind("CVSSSH2PreferencePage.error"), //$NON-NLS-1$ + Policy.bind("CVSSSH2PreferencePage.47")); //$NON-NLS-1$ } } }); @@ -675,7 +674,6 @@ public class CVSSSH2PreferencePage extends PreferencePage public void widgetSelected(SelectionEvent e){ if(kpair==null)return; - MessageBox mb; String pass=keyPassphrase1Text.getText(); /* if(!pass.equals(keyPassphrase2Text.getText())){ @@ -684,11 +682,11 @@ public class CVSSSH2PreferencePage extends PreferencePage } */ if(pass.length()==0){ - mb=new MessageBox(getShell(),SWT.YES|SWT.NO|SWT.ICON_WARNING); - mb.setText(Policy.bind("CVSSSH2PreferencePage.warning")); //$NON-NLS-1$ - mb.setMessage(Policy.bind("CVSSSH2PreferencePage.49")); //$NON-NLS-1$ - if(mb.open()==SWT.NO){ - return; + if(!MessageDialog.openConfirm(getShell(), + Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$ + Policy.bind("CVSSSH2PreferencePage.49") //$NON-NLS-1$ + )){ + return ; } } @@ -700,13 +698,14 @@ public class CVSSSH2PreferencePage extends PreferencePage File _home=new File(home); if(!_home.exists()){ - mb=new MessageBox(getShell(),SWT.YES|SWT.NO|SWT.ICON_QUESTION); - mb.setText(Policy.bind("CVSSSH2PreferencePage.question")); //$NON-NLS-1$ - mb.setMessage(home+Policy.bind("CVSSSH2PreferencePage.50")); //$NON-NLS-1$ - if(mb.open()==SWT.NO){ - return; + if(!MessageDialog.openConfirm(getShell(), + Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$ + home+Policy.bind("CVSSSH2PreferencePage.50") //$NON-NLS-1$ + )){ + return ; } if(!_home.mkdirs()){ + setErrorMessage(Policy.bind("CVSSSH2PreferencePage.100")+home); //$NON-NLS-1$ return; } } @@ -721,10 +720,10 @@ public class CVSSSH2PreferencePage extends PreferencePage } if(new File(file).exists()){ - mb=new MessageBox(getShell(),SWT.YES|SWT.NO|SWT.ICON_WARNING); - mb.setText(Policy.bind("CVSSSH2PreferencePage.warning")); //$NON-NLS-1$ - mb.setMessage(file+Policy.bind("CVSSSH2PreferencePage.53")); //$NON-NLS-1$ - if(mb.open()==SWT.NO){ + if(!MessageDialog.openConfirm(getShell(), + Policy.bind("CVSSSH2PreferencePage.confirmation"), //$NON-NLS-1$ + file+Policy.bind("CVSSSH2PreferencePage.53") //$NON-NLS-1$ + )){ return; } } @@ -739,12 +738,15 @@ public class CVSSSH2PreferencePage extends PreferencePage } if(ok){ - mb=new MessageBox(getShell(),SWT.OK|SWT.ICON_INFORMATION); - mb.setText(Policy.bind("CVSSSH2PreferencePage.information")); //$NON-NLS-1$ - mb.setMessage(Policy.bind("CVSSSH2PreferencePage.55")+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ - Policy.bind("CVSSSH2PreferencePage.57")+file+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ - Policy.bind("CVSSSH2PreferencePage.59")+file+".pub"); //$NON-NLS-1$ //$NON-NLS-2$ - mb.open(); + MessageDialog.openInformation(getShell(), + Policy.bind("CVSSSH2PreferencePage.information"), //$NON-NLS-2$ + Policy.bind("CVSSSH2PreferencePage.55")+ //$NON-NLS-1$ + "\n"+ //$NON-NLS-1$ + Policy.bind("CVSSSH2PreferencePage.57")+file+ //$NON-NLS-1$ + "\n"+ //$NON-NLS-1$ + Policy.bind("CVSSSH2PreferencePage.59")+ //$NON-NLS-1$ + file+ + ".pub"); } } }); @@ -816,10 +818,10 @@ public class CVSSSH2PreferencePage extends PreferencePage //setErrorMessage(debug+ee.message); } - MessageBox mb=new MessageBox(getShell(),SWT.OK|SWT.ICON_INFORMATION); - mb.setText(Policy.bind("CVSSSH2PreferencePage.information")); //$NON-NLS-1$ - mb.setMessage(Policy.bind("CVSSSH2PreferencePage.109")+(user+"@"+host+(port==22 ? "" : ":"+port)+":~/.ssh/authorized_keys")); //$NON-NLS-1$ - mb.open(); + MessageDialog.openInformation(getShell(), + Policy.bind("CVSSSH2PreferencePage.information"), //$NON-NLS-1$ + Policy.bind("CVSSSH2PreferencePage.109")+ + (user+"@"+host+(port==22 ? "" : ":"+port)+":~/.ssh/authorized_keys")); //$NON-NLS-1$ c.disconnect(); //session.disconnect(); @@ -913,338 +915,20 @@ public class CVSSSH2PreferencePage extends PreferencePage proxyPassText.setEchoChar('*'); updateControls(); } - protected void createProxy(Composite composite, int columnSpan) { - Group group=new Group(composite, SWT.NONE); - group.setText(Policy.bind("CVSSSH2PreferencePage.66")); //$NON-NLS-1$ - GridLayout layout=new GridLayout(); - layout.numColumns=2; - group.setLayout(layout); - GridData gd=new GridData(); - gd.horizontalSpan=columnSpan; - gd.horizontalAlignment=GridData.FILL; - group.setLayoutData(gd); - group.setFont(composite.getFont()); - - enableProxy=new Button(group, SWT.CHECK); - enableProxy.setText(Policy.bind("CVSSSH2PreferencePage.67")); //$NON-NLS-1$ - gd=new GridData(); - gd.horizontalSpan=2; - enableProxy.setLayoutData(gd); - - proxyTypeLabel=new Label(group, SWT.NONE); - proxyTypeLabel.setText(Policy.bind("CVSSSH2PreferencePage.68")); //$NON-NLS-1$ - proxyTypeCombo=new Combo(group, SWT.READ_ONLY); - proxyTypeCombo.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - proxyTypeCombo.setLayoutData(gd); - proxyTypeCombo.addModifyListener(new ModifyListener () { - public void modifyText(ModifyEvent e){ - if(proxyPortText==null) return; - Combo combo=(Combo)(e.getSource()); - String foo=combo.getText(); - if(foo.equals(HTTP)){ - proxyPortText.setText(HTTP_DEFAULT_PORT); - } - else if(foo.equals(SOCKS5)){ - proxyPortText.setText(SOCKS5_DEFAULT_PORT); - } - } - }); - proxyTypeCombo.add(HTTP); - proxyTypeCombo.add(SOCKS5); - proxyTypeCombo.select(0); - - proxyHostLabel=new Label(group, SWT.NONE); - proxyHostLabel.setText(Policy.bind("CVSSSH2PreferencePage.69")); //$NON-NLS-1$ - - proxyHostText=new Text(group, SWT.SINGLE | SWT.BORDER); - proxyHostText.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - proxyHostText.setLayoutData(gd); - - proxyPortLabel=new Label(group, SWT.NONE); - proxyPortLabel.setText(Policy.bind("CVSSSH2PreferencePage.70")); //$NON-NLS-1$ - - proxyPortText=new Text(group, SWT.SINGLE | SWT.BORDER); - proxyPortText.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - proxyPortText.setLayoutData(gd); - - createSpacer(group, 3); - - enableAuth=new Button(group, SWT.CHECK); - enableAuth.setText(Policy.bind("CVSSSH2PreferencePage.71")); //$NON-NLS-1$ - gd=new GridData(); - gd.horizontalSpan=2; - enableAuth.setLayoutData(gd); - - proxyUserLabel=new Label(group, SWT.NONE); - proxyUserLabel.setText(Policy.bind("CVSSSH2PreferencePage.72")); //$NON-NLS-1$ - - proxyUserText=new Text(group, SWT.SINGLE | SWT.BORDER); - proxyUserText.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=2; - proxyUserText.setLayoutData(gd); - - proxyPassLabel=new Label(group, SWT.NONE); - proxyPassLabel.setText(Policy.bind("CVSSSH2PreferencePage.73")); //$NON-NLS-1$ - - proxyPassText=new Text(group, SWT.SINGLE | SWT.BORDER); - proxyPassText.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=2; - proxyPassText.setLayoutData(gd); - - - // performDefaults(); - - enableProxy.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - updateControls(); - } - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - - enableAuth.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - updateControls(); - } - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - } - - protected void createKeyGeneration(Composite composite, int columnSpan) { - Group group=new Group(composite, SWT.NONE); - group.setText(Policy.bind("CVSSSH2PreferencePage.74")); //$NON-NLS-1$ - GridLayout layout=new GridLayout(); - layout.numColumns=2; - group.setLayout(layout); - GridData gd=new GridData(); - gd.horizontalSpan=columnSpan; - gd.horizontalAlignment=GridData.FILL; - group.setLayoutData(gd); - group.setFont(composite.getFont()); - - keyTypeLabel=new Label(group, SWT.NONE); - keyTypeLabel.setText(Policy.bind("CVSSSH2PreferencePage.75")); //$NON-NLS-1$ - keyTypeCombo=new Combo(group, SWT.READ_ONLY); - keyTypeCombo.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - keyTypeCombo.setLayoutData(gd); - - keyGenerate=new Button(group, SWT.NULL); - keyGenerate.setText(Policy.bind("CVSSSH2PreferencePage.76")); //$NON-NLS-1$ - gd=new GridData(GridData.HORIZONTAL_ALIGN_END); - gd.horizontalSpan=columnSpan; - keyGenerate.setLayoutData(gd); - - /* - keyLoad=new Button(group, SWT.NULL); - keyLoad.setText("Load(not implemented)"); - gd=new GridData(GridData.HORIZONTAL_ALIGN_END); - gd.horizontalSpan=columnSpan; - keyLoad.setLayoutData(gd); - */ - - publicKeylabel=new Label(group, SWT.NONE); - publicKeylabel.setText(Policy.bind("CVSSSH2PreferencePage.77")); //$NON-NLS-1$ - gd=new GridData(); - gd.horizontalSpan=columnSpan; - publicKeylabel.setLayoutData(gd); - - publicKeyText=new Text(group,SWT.MULTI|SWT.BORDER|SWT.V_SCROLL); - publicKeyText.setText(""); //$NON-NLS-1$ - publicKeyText.setEditable(false); - gd=new GridData(); - gd.horizontalSpan=columnSpan; - gd.horizontalAlignment = GridData.FILL; - gd.verticalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - gd.grabExcessVerticalSpace = true; - publicKeyText.setLayoutData(gd); - - keyFingerPrintLabel=new Label(group, SWT.NONE); - keyFingerPrintLabel.setText(Policy.bind("CVSSSH2PreferencePage.79")); //$NON-NLS-1$ - keyFingerPrintText=new Text(group, SWT.SINGLE | SWT.BORDER); - keyFingerPrintText.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=2; - keyFingerPrintText.setLayoutData(gd); - - keyCommentLabel=new Label(group, SWT.NONE); - keyCommentLabel.setText(Policy.bind("CVSSSH2PreferencePage.80")); //$NON-NLS-1$ - keyCommentText=new Text(group, SWT.SINGLE | SWT.BORDER); - keyCommentText.setFont(group.getFont()); - gd=new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=2; - keyCommentText.setLayoutData(gd); - - keyPassphrase1Label=new Label(group, SWT.NONE); - keyPassphrase1Label.setText(Policy.bind("CVSSSH2PreferencePage.81")); //$NON-NLS-1$ - keyPassphrase1Text=new Text(group, SWT.SINGLE | SWT.BORDER); - keyPassphrase1Text.setFont(group.getFont()); - keyPassphrase1Text.setEchoChar('*'); - gd=new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=2; - keyPassphrase1Text.setLayoutData(gd); - - keyPassphrase2Label=new Label(group, SWT.NONE); - keyPassphrase2Label.setText(Policy.bind("CVSSSH2PreferencePage.82")); //$NON-NLS-1$ - keyPassphrase2Text=new Text(group, SWT.SINGLE | SWT.BORDER); - keyPassphrase2Text.setFont(group.getFont()); - keyPassphrase2Text.setEchoChar('*'); - gd=new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan=2; - keyPassphrase2Text.setLayoutData(gd); - - saveKeyPair=new Button(group, SWT.NULL); - saveKeyPair.setText(Policy.bind("CVSSSH2PreferencePage.83")); //$NON-NLS-1$ - gd=new GridData(GridData.HORIZONTAL_ALIGN_END); - gd.horizontalSpan=columnSpan; - saveKeyPair.setLayoutData(gd); - - keyGenerate.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e){ - JSch jsch=JSchSession.getJSch(); - boolean ok=true; - String _type=keyTypeCombo.getText(); - - try{ - int type=0; - if(_type.equals(DSA)){ - type=KeyPair.DSA; - } - else if(_type.equals(RSA)){ - type=KeyPair.RSA; - } - else{ - return; - } - - kpair=KeyPair.genKeyPair(jsch, type); - ByteArrayOutputStream out=new ByteArrayOutputStream(); - kpairComment=_type+"-1024"; //$NON-NLS-1$ - kpair.writePublicKey(out, kpairComment); - out.close(); - publicKeyText.setText(out.toString()); - keyFingerPrintText.setText(kpair.getFingerPrint()); - keyCommentText.setText(kpairComment); - updateControls(); - } - catch(IOException ee){ - ok=false; - } - catch(JSchException ee){ - ok=false; - } - MessageBox mb=new MessageBox(getShell(),SWT.OK|SWT.ICON_INFORMATION); - mb.setText(Policy.bind("CVSSSH2PreferencePage.information")); //$NON-NLS-1$ - mb.setMessage(_type+Policy.bind("CVSSSH2PreferencePage.85")); //$NON-NLS-1$ - mb.open(); - } - }); - - saveKeyPair.addSelectionListener(new SelectionAdapter(){ - public void widgetSelected(SelectionEvent e){ - if(kpair==null)return; - - MessageBox mb; - String pass=keyPassphrase1Text.getText(); - if(!pass.equals(keyPassphrase2Text.getText())){ - mb=new MessageBox(getShell(),SWT.OK|SWT.ICON_ERROR); - mb.setText(Policy.bind("CVSSSH2PreferencePage.error")); //$NON-NLS-1$ - mb.setMessage(Policy.bind("CVSSSH2PreferencePage.86")); //$NON-NLS-1$ - mb.open(); - return; - } - if(pass.length()==0){ - mb=new MessageBox(getShell(),SWT.YES|SWT.NO|SWT.ICON_WARNING); - mb.setText(Policy.bind("CVSSSH2PreferencePage.awrning")); //$NON-NLS-1$ - mb.setMessage(Policy.bind("CVSSSH2PreferencePage.87")); //$NON-NLS-1$ - if(mb.open()==SWT.NO){ - return; - } - } - - kpair.setPassphrase(pass); - - IPreferenceStore store=CVSSSH2Plugin.getDefault().getPreferenceStore(); - String home=ssh2HomeText.getText(); - - File _home=new File(home); - - if(!_home.exists()){ - mb=new MessageBox(getShell(),SWT.YES|SWT.NO|SWT.ICON_QUESTION); - mb.setText(Policy.bind("CVSSSH2PreferencePage.question")); //$NON-NLS-1$ - mb.setMessage(home+Policy.bind("CVSSSH2PreferencePage.88")); //$NON-NLS-1$ - if(mb.open()==SWT.NO){ - return; - } - if(!_home.mkdirs()){ - return; - } - } - - FileDialog fd=new FileDialog(getShell(), SWT.SAVE); - fd.setFilterPath(home); - String file=(kpair.getKeyType()==KeyPair.RSA) ? "id_rsa" : "id_dsa"; //$NON-NLS-1$ //$NON-NLS-2$ - fd.setFileName(file); - file=fd.open(); - if(file==null){ // cancel - return; - } - - if(new File(file).exists()){ - mb=new MessageBox(getShell(),SWT.YES|SWT.NO|SWT.ICON_WARNING); - mb.setText(Policy.bind("CVSSSH2PreferencePage.warning")); //$NON-NLS-1$ - mb.setMessage(file+Policy.bind("CVSSSH2PreferencePage.91")); //$NON-NLS-1$ - if(mb.open()==SWT.NO){ - return; - } - } - - boolean ok=true; - try{ - kpair.writePrivateKey(file); - kpair.writePublicKey(file+".pub", kpairComment); //$NON-NLS-1$ - } - catch(Exception ee){ - ok=false; - } - - if(ok){ - mb=new MessageBox(getShell(),SWT.OK|SWT.ICON_INFORMATION); - mb.setText(Policy.bind("CVSSSH2PreferencePage.information")); //$NON-NLS-1$ - mb.setMessage(Policy.bind("CVSSSH2PreferencePage.93")+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ - Policy.bind("CVSSSH2PreferencePage.95")+file+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$ - Policy.bind("CVSSSH2PreferencePage.97")+file+".pub"); //$NON-NLS-1$ //$NON-NLS-2$ - mb.open(); - } - } - }); - - keyTypeCombo.add(DSA); - keyTypeCombo.add(RSA); - keyTypeCombo.select(0); - } - public boolean performOk() { boolean result=super.performOk(); if(result){ - setErrorMessage(null); + setErrorMessage(null); String home=ssh2HomeText.getText(); File _home=new File(home); if(!_home.exists()){ - MessageBox mb=new MessageBox(getShell(),SWT.YES|SWT.NO|SWT.ICON_QUESTION); - mb.setText(Policy.bind("CVSSSH2PreferencePage.question")); //$NON-NLS-1$ - mb.setMessage(home+Policy.bind("CVSSSH2PreferencePage.99")); //$NON-NLS-1$ - if(mb.open()==SWT.YES){ + if(MessageDialog.openQuestion(getShell(), + Policy.bind("CVSSSH2PreferencePage.question"), //$NON-NLS-1$ + home+Policy.bind("CVSSSH2PreferencePage.99") //$NON-NLS-1$ + )){ if(!(_home.mkdirs())){ - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.100")+home); //$NON-NLS-1$ - return false; + setErrorMessage(Policy.bind("CVSSSH2PreferencePage.100")+home); //$NON-NLS-1$ + return false; } } } @@ -1287,20 +971,17 @@ public class CVSSSH2PreferencePage extends PreferencePage return true; } public void performApply() { - super.performApply(); - setErrorMessage(null); - String home=ssh2HomeText.getText(); File _home=new File(home); if(!_home.exists()){ - MessageBox mb=new MessageBox(getShell(),SWT.YES|SWT.NO|SWT.ICON_QUESTION); - mb.setText(Policy.bind("CVSSSH2PreferencePage.question")); //$NON-NLS-1$ - mb.setMessage(home+Policy.bind("CVSSSH2PreferencePage.101")); //$NON-NLS-1$ - if(mb.open()==SWT.YES){ + if(MessageDialog.openQuestion(getShell(), + Policy.bind("CVSSSH2PreferencePage.question"), //$NON-NLS-1$ + home+Policy.bind("CVSSSH2PreferencePage.101") //$NON-NLS-1$ + )){ if(!(_home.mkdirs())){ - setErrorMessage(Policy.bind("CVSSSH2PreferencePage.102")+home); //$NON-NLS-1$ - return; + setErrorMessage(Policy.bind("CVSSSH2PreferencePage.102")+home); //$NON-NLS-1$ + return; } } } |