1 11 package org.eclipse.update.internal.ui.security; 12 import org.eclipse.jface.dialogs.*; 13 import org.eclipse.jface.resource.*; 14 import org.eclipse.swt.*; 15 import org.eclipse.swt.graphics.*; 16 import org.eclipse.swt.layout.*; 17 import org.eclipse.swt.widgets.*; 18 import org.eclipse.update.core.*; 19 import org.eclipse.update.internal.ui.*; 20 21 24 public class JarVerificationDialog extends TitleAreaDialog { 25 public final static int INSTALL_ALL = CANCEL + OK + 1; 26 private IVerificationResult _VerificationResult = null; 27 private IDialogPage _DialogPage; 28 private Composite pageContainer; 29 private Image defaultImage = null; 30 private ImageDescriptor defaultImageDescriptor = 31 UpdateUIImages.DESC_UPDATE_WIZ; 32 33 37 public JarVerificationDialog(Shell parentShell,IDialogPage dialogPage, IVerificationResult verificationResult) { 38 super(parentShell); 39 setShellStyle(SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL | SWT.RESIZE); 40 _VerificationResult = verificationResult; 41 _DialogPage = dialogPage; 42 if (dialogPage instanceof JarVerificationPage){ 43 ((JarVerificationPage)_DialogPage).setTitleAreaDialog(this); 44 } 45 } 46 47 50 protected void createButtonsForButtonBar(Composite parent) { 51 if (_VerificationResult.getVerificationCode() 52 != IVerificationResult.TYPE_ENTRY_CORRUPTED) { 53 54 if (_VerificationResult.isFeatureVerification()) { 55 createButton( 56 parent, 57 IDialogConstants.OK_ID, 58 UpdateUIMessages.JarVerificationDialog_Install, 59 false); 60 } else { 61 createButton( 62 parent, 63 IDialogConstants.OK_ID, 64 UpdateUIMessages.JarVerificationDialog_Continue, 65 false); 66 } 67 createButton( 70 parent, 71 IDialogConstants.YES_TO_ALL_ID, 72 UpdateUIMessages.JarVerificationDialog_InstallAll, 73 false); 74 75 createButton( 78 parent, 79 IDialogConstants.CANCEL_ID, 80 UpdateUIMessages.JarVerificationDialog_Cancel, 81 true); 82 } else { 83 createButton( 84 parent, 85 IDialogConstants.CANCEL_ID, 86 UpdateUIMessages.JarVerificationDialog_Cancel, 87 true); 88 } 89 getButton(IDialogConstants.CANCEL_ID).setFocus(); 90 } 91 92 95 protected Control createDialogArea(Composite parent) { 96 Composite compositeParent = (Composite)super.createDialogArea(parent); 97 setTitleImage(this.getImage()); 98 setTitle(UpdateUIMessages.JarVerificationDialog_Title); 99 100 _DialogPage.createControl(compositeParent); 101 pageContainer=(Composite)_DialogPage.getControl(); 102 GridData gd = new GridData(GridData.FILL_BOTH); 103 pageContainer.setLayoutData(gd); 104 pageContainer.setFont(parent.getFont()); 105 106 Label separator= new Label(compositeParent, SWT.HORIZONTAL | SWT.SEPARATOR); 108 separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 109 110 return compositeParent; 111 } 112 113 116 public Image getImage() { 117 if (defaultImage == null) 118 defaultImage = defaultImageDescriptor.createImage(); 119 120 return defaultImage; 121 } 122 123 public boolean close() { 124 if (defaultImage != null) { 126 defaultImage.dispose(); 127 defaultImage = null; 128 } 129 return super.close(); 130 } 131 134 protected void buttonPressed(int buttonId) { 135 if (IDialogConstants.YES_TO_ALL_ID == buttonId) 136 installAllPressed(); 137 else 138 super.buttonPressed(buttonId); 139 } 140 141 private void installAllPressed() { 142 setReturnCode(JarVerificationDialog.INSTALL_ALL); 143 close(); 144 } 145 } 146 | Popular Tags |