1 11 package org.eclipse.update.internal.ui; 12 13 import org.eclipse.core.runtime.IProduct; 14 import org.eclipse.core.runtime.Platform; 15 import org.eclipse.jface.dialogs.IDialogConstants; 16 import org.eclipse.jface.dialogs.MessageDialog; 17 import org.eclipse.osgi.util.NLS; 18 import org.eclipse.swt.widgets.Shell; 19 import org.eclipse.update.operations.*; 20 21 25 public class RestartDialog extends MessageDialog { 26 private static final int CONTINUE = 2; 27 private final static String [] yesNo = new String [] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}; 28 private final static String [] yesNoApply = new String [] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, UpdateUIMessages.ApplyChanges}; 29 30 private int buttonId = 0; 31 32 36 public RestartDialog(Shell parent, String title, String message, boolean restartNeeded) { 37 super(parent, 38 title, 39 null, message, 41 QUESTION, 42 restartNeeded ? yesNo : yesNoApply, 43 0); } 45 46 54 public static boolean openQuestion(Shell parent, boolean restartIsReallyNeeded) { 55 String title = UpdateUIMessages.RestartTitle; 56 IProduct product = Platform.getProduct(); 57 String productName = product != null && product.getName() != null ? product.getName() : UpdateUIMessages.ApplicationInRestartDialog; 58 String message = NLS.bind(restartIsReallyNeeded ? UpdateUIMessages.RestartMessage: UpdateUIMessages.OptionalRestartMessage, productName); 59 RestartDialog dialog = new RestartDialog(parent, title, message, restartIsReallyNeeded); 60 int button= dialog.open(); 61 if (button == 2) 62 OperationsManager.applyChangesNow(); 63 return button == 0; } 65 66 71 protected void buttonPressed(int id) { 72 if (id == 2) { 73 buttonId= CONTINUE; 74 } 75 76 super.buttonPressed(id); 77 } 78 79 85 public int getResult() { 86 return buttonId; 87 } 88 } 89 | Popular Tags |