1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.jface.dialogs.ErrorDialog; 16 import org.eclipse.jface.viewers.Viewer; 17 import org.eclipse.swt.custom.BusyIndicator; 18 import org.eclipse.swt.widgets.Shell; 19 import org.eclipse.ui.actions.SelectionListenerAction; 20 21 24 public abstract class AbstractLaunchConfigurationAction extends SelectionListenerAction { 25 26 29 private String fMode; 30 31 34 public interface IConfirmationRequestor { 35 41 public boolean getConfirmation(); 42 } 43 44 47 private IConfirmationRequestor fConfirmationRequestor; 48 49 52 private Viewer fViewer; 53 54 58 public AbstractLaunchConfigurationAction(String text, Viewer viewer, String mode) { 59 super(text); 60 fViewer = viewer; 61 fViewer.addSelectionChangedListener(this); 62 fMode = mode; 63 } 64 65 70 protected Shell getShell() { 71 return getViewer().getControl().getShell(); 72 } 73 74 79 protected Viewer getViewer() { 80 return fViewer; 81 } 82 83 87 protected abstract void performAction(); 88 89 92 public final void run() { 93 if (fConfirmationRequestor != null) { 94 if (!fConfirmationRequestor.getConfirmation()) { 95 return; 96 } 97 } 98 Runnable r = new Runnable () { 99 102 public void run() { 103 performAction(); 104 } 105 }; 106 BusyIndicator.showWhile(getShell().getDisplay(), r); 107 } 108 109 114 public void setConfirmationRequestor(IConfirmationRequestor confirmationRequestor) { 115 fConfirmationRequestor = confirmationRequestor; 116 } 117 118 121 public void dispose() { 122 fViewer.removeSelectionChangedListener(this); 123 } 124 125 130 protected void errorDialog(CoreException exception) { 131 ErrorDialog.openError(getShell(), null, null, exception.getStatus()); 132 } 133 134 139 protected String getMode() { 140 return fMode; 141 } 142 } 143 | Popular Tags |