本文整理匯總了Java中org.eclipse.jface.dialogs.MessageDialog.openConfirm方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageDialog.openConfirm方法的具體用法?Java MessageDialog.openConfirm怎麽用?Java MessageDialog.openConfirm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.dialogs.MessageDialog
的用法示例。
在下文中一共展示了MessageDialog.openConfirm方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: exportTextFile
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
protected void exportTextFile() {
boolean done = false;
while (!done)
if (!textEditor.isDisposed()) {
FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
fd.setFilterNames(new String[] { "Plain text file (*.txt)", "All Files (*.*)" });
fd.setFilterExtensions(new String[] { "*.txt", "*.*" });
String lastPath = Config.getInstance().getString(Config.LAST_EXPORT_TRANSCRIPTION_PATH);
if (lastPath != null && !lastPath.isEmpty())
fd.setFileName(lastPath);
String file = fd.open();
try {
if (file != null) {
Config.getInstance().putValue(Config.LAST_EXPORT_TRANSCRIPTION_PATH, file);
File destFile = new File(file);
boolean overwrite = true;
if (destFile.exists())
overwrite = MessageDialog.openConfirm(shell, "Overwrite current file?",
"Would you like to overwrite " + destFile.getName() + "?");
if (overwrite) {
textEditor.exportText(new File(file));
done = true;
}
} else
done = true;
} catch (Exception e) {
e.printStackTrace();
MessageBox diag = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
diag.setMessage("Unable to export to file " + transcriptionFile.getPath());
diag.open();
}
}
}
示例2: save
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
/**
* Stash using appropriate messages to the user.
* @param models
* @param shell
*/
@Override
public void save(Object object) {
try {
if (file.exists()) {
boolean ok = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "Confirm Overwrite", "Are you sure that you would like to overwrite '"+file.getName()+"'?");
if (!ok) return;
}
stash(object);
} catch (Exception e) {
ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Error Saving Information", "An exception occurred while writing the "+getStashName()+" to file.",
new Status(IStatus.ERROR, "org.eclipse.scanning.device.ui", e.getMessage()));
logger.error("Error Saving Information", e);
}
}
示例3: restart
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
private void restart() {
HeartbeatBean bean = getSelection();
if (bean==null) return;
boolean ok = MessageDialog.openConfirm(getSite().getShell(), "Confirm Retstart", "If you restart this consumer other people's running jobs may be lost.\n\n"
+ "Are you sure that you want to continue?");
if (!ok) return;
final KillBean kbean = new KillBean();
kbean.setExitProcess(false);
kbean.setMessage("Requesting a restart of "+bean.getConsumerName());
kbean.setConsumerId(bean.getConsumerId());
kbean.setRestart(true);
send(bean, kbean);
consumers.clear();
viewer.refresh();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
logger.error("Refreshing consumers that we can process", e);
}
viewer.refresh();
}
示例4: showDialog
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
private Boolean showDialog ( final ConfirmationCallback cb, final Display display, final Shell parentShell, final String dialogTitle )
{
switch ( cb.getConfirmationType () )
{
case CONFIRM:
return MessageDialog.openConfirm ( parentShell, dialogTitle, cb.getLabel () ) ? true : null;
case ERROR:
MessageDialog.openError ( parentShell, dialogTitle, cb.getLabel () );
return true;
case WARNING:
MessageDialog.openWarning ( parentShell, dialogTitle, cb.getLabel () );
return true;
case INFORMATION:
MessageDialog.openInformation ( parentShell, dialogTitle, cb.getLabel () );
return true;
case QUESTION:
return MessageDialog.openQuestion ( parentShell, dialogTitle, cb.getLabel () );
case QUESTION_WITH_CANCEL:
{
final MessageDialog dialog = new MessageDialog ( parentShell, dialogTitle, null, cb.getLabel (), MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0 );
final int result = dialog.open ();
if ( result == 2 /*CANCEL*/)
{
return null;
}
else
{
return result == Window.OK;
}
}
default:
throw new IllegalArgumentException ( String.format ( "Unable to process type: %s", cb.getConfirmationType () ) );
}
}
示例5: stop
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
private void stop() {
HeartbeatBean bean = getSelection();
if (bean==null) return;
boolean ok = MessageDialog.openConfirm(getSite().getShell(), "Confirm Stop", "If you stop this consumer it will have to be restarted by an administrator using a server hard restart.\n\n"
+ "Are you sure that you want to do this?\n\n"
+ "(NOTE: Long running jobs can be terminated without stopping the consumer!)");
if (!ok) return;
boolean notify = MessageDialog.openQuestion(getSite().getShell(), "Warn Users", "Would you like to warn users before stopping the consumer?\n\n"
+ "If you say yes, a popup will open on users clients to warn about the imminent stop.");
if (notify) {
final AdministratorMessage msg = new AdministratorMessage();
msg.setTitle("'"+bean.getConsumerName()+"' will shutdown.");
msg.setMessage("'"+bean.getConsumerName()+"' is about to shutdown.\n\n"+
"Any runs corrently running may loose progress notification,\n"+
"however they should complete.\n\n"+
"Runs yet to be started will be picked up when\n"+
"'"+bean.getConsumerName()+"' restarts.");
try {
final IPublisher<AdministratorMessage> send = service.createPublisher(new URI(Activator.getJmsUri()), IEventService.ADMIN_MESSAGE_TOPIC);
send.broadcast(msg);
} catch (Exception e) {
logger.error("Cannot notify of shutdown!", e);
}
}
final KillBean kbean = new KillBean();
kbean.setMessage("Requesting a termination of "+bean.getConsumerName());
kbean.setConsumerId(bean.getConsumerId());
send(bean, kbean);
}
示例6: editSelection
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
/**
* Edits a not run yet selection
*/
@SuppressWarnings({"squid:S3776", "squid:S135"})
protected void editSelection() {
for (StatusBean bean : getSelection()) {
if (bean.getStatus()!=org.eclipse.scanning.api.event.status.Status.SUBMITTED) {
MessageDialog.openConfirm(getSite().getShell(), "Cannot Edit '"+bean.getName()+"'", "The run '"+bean.getName()+"' cannot be edited because it is not waiting to run.");
continue;
}
try {
final IConfigurationElement[] c = Platform.getExtensionRegistry().getConfigurationElementsFor(MODIFY_HANDLER_EXTENSION_POINT_ID);
if (c!=null) {
for (IConfigurationElement i : c) {
final IModifyHandler handler = (IModifyHandler)i.createExecutableExtension("class");
handler.init(service, createConsumerConfiguration());
if (handler.isHandled(bean)) {
boolean ok = handler.modify(bean);
if (ok) continue;
}
}
}
} catch (Exception ne) {
final String err = "Cannot modify "+bean.getRunDirectory()+" normally.\n\nPlease contact your support representative.";
logger.error(err, ne);
ErrorDialog.openError(getSite().getShell(), "Internal Error", err, new Status(IStatus.ERROR, Activator.PLUGIN_ID, ne.getMessage()));
continue;
}
MessageDialog.openConfirm(getSite().getShell(), "Cannot Edit '"+bean.getName()+"'", "There are no editers registered for '"+bean.getName()+"'\n\nPlease contact your support representative.");
}
}
示例7: open
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
@Override
public boolean open(StatusBean bean) throws Exception {
try {
final IWorkbenchPage page = Util.getPage();
final File fdir = new File(Util.getSanitizedPath(bean.getRunDirectory()));
if (!fdir.exists()){
MessageDialog.openConfirm(getShell(), "Directory Not Found", "The directory '"+bean.getRunDirectory()+"' has been moved or deleted.\n\nPlease contact your support representative.");
return false;
}
if (Util.isWindowsOS()) { // Open inside DAWN
final String dir = fdir.getAbsolutePath();
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(dir+"/fred.html");
final IEditorInput edInput = Util.getExternalFileStoreEditorInput(dir);
page.openEditor(edInput, desc.getId());
} else { // Linux cannot be relied on to open the browser on a directory.
Util.browse(fdir);
}
return true;
} catch (Exception e1) {
ErrorDialog.openError(getShell(), "Internal Error", "Cannot open "+bean.getRunDirectory()+".\n\nPlease contact your support representative.",
new Status(IStatus.ERROR, Activator.PLUGIN_ID, e1.getMessage()));
return false;
}
}
示例8: execute
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
@Override
public void execute() {
flag = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "提示", "刪除外鍵約束時是否刪除對應的列字段?");
column = connection.getFkColumn();
index = connection.getTarget().getColumns().indexOf(column);
redo();
}
示例9: openViewDialog
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
static PandionJView openViewDialog() {
if(MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Open PandionJ view", PandionJConstants.Messages.RUN_DIALOG)) {
try {
return (PandionJView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PandionJConstants.VIEW_ID);
} catch (PartInitException e) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Open PandionJ view", "View could not be opened.");
}
}
return null;
}
示例10: toggleBlock
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
protected void toggleBlock ()
{
final DataItemValue value = getBlockItemValue ();
final Map<String, Variant> attributes = new HashMap<String, Variant> ();
if ( !isActive ( value ) )
{
final String reason = getBlockReason ( value );
if ( reason == null )
{
// user did not press "OK"
return;
}
if ( reason.isEmpty () )
{
attributes.put ( "org.eclipse.scada.da.master.common.block.note", Variant.valueOf ( Messages.BlockControllerImage_String_BlockNote_None ) );//$NON-NLS-1$
}
else
{
attributes.put ( "org.eclipse.scada.da.master.common.block.note", Variant.valueOf ( reason ) );//$NON-NLS-1$
}
}
else
{
String blockNote = getActiveBlockAttribute ( value, ATTR_BLOCK_NOTE );
if ( blockNote == null || blockNote.isEmpty () )
{
blockNote = Messages.BlockControllerImage_String_BlockNote_None;
}
if ( !MessageDialog.openConfirm ( getShell (), Messages.BlockControllerImage_ConfirmDialog_Title, String.format ( Messages.BlockControllerImage_ConfirmDialog_Message_Format, blockNote ) ) )
{
return;
}
}
attributes.put ( "org.eclipse.scada.da.master.common.block.active", Variant.valueOf ( !isActive ( value ) ) );//$NON-NLS-1$
try
{
final CallbackHandler handler = new DisplayCallbackHandler ( getShell (), "Confirmation", "Confirm block operation" );
this.registrationManager.startWriteAttributes ( this.item.getConnectionString (), this.item.getId (), attributes, handler );
}
catch ( final InterruptedException e )
{
logger.warn ( "Failed to write", e );
}
}
示例11: handleDelete
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
public void handleDelete ()
{
final ISelection sel = this.viewer.getSelection ();
if ( sel == null || sel.isEmpty () || ! ( sel instanceof IStructuredSelection ) )
{
return;
}
final IStructuredSelection selection = (IStructuredSelection)sel;
final Collection<String> items = new LinkedList<String> ();
final Iterator<?> i = selection.iterator ();
while ( i.hasNext () )
{
final ConfigurationDescriptor info = (ConfigurationDescriptor)i.next ();
items.add ( info.getConfigurationInformation ().getId () );
}
if ( items.isEmpty () )
{
return;
}
if ( !MessageDialog.openConfirm ( this.viewer.getControl ().getShell (), "Delete configurations", String.format ( "Delete %s configuration entries", items.size () ) ) )
{
return;
}
final org.eclipse.core.runtime.jobs.Job job = this.factoryInput.createDeleteJob ( items );
job.addJobChangeListener ( new JobChangeAdapter () {
@Override
public void done ( final IJobChangeEvent event )
{
refresh ();
}
} );
job.schedule ();
}
示例12: configure
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
@Override
public void configure() throws StreamConnectionException {
MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Matthew Taylor TODO", "Please write a form to set the three things for simulation: URI, sleep time, cache size");
// TODO Show a form setting URI, sleep time, cache size.
}
示例13: eltConfirmMessage
import org.eclipse.jface.dialogs.MessageDialog; //導入方法依賴的package包/類
/**
* Elt confirm message.
*
* @param message
* the message
* @return true, if successful
*/
public static boolean eltConfirmMessage(String message){
return MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), Messages.WARNING, message);
}