当前位置: 首页>>代码示例>>Java>>正文


Java MessageDialog.openConfirm方法代码示例

本文整理汇总了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();
            }
        }
}
 
开发者ID:juanerasmoe,项目名称:pmTrans,代码行数:34,代码来源:PmTrans.java

示例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);
    }
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:23,代码来源:Stashing.java

示例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();
    }
 
开发者ID:eclipse,项目名称:scanning,代码行数:26,代码来源:ConsumerView.java

示例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 () ) );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:35,代码来源:ConfirmationDialogFuture.java

示例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);

    }
 
开发者ID:eclipse,项目名称:scanning,代码行数:37,代码来源:ConsumerView.java

示例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.");
    }
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:34,代码来源:StatusQueueView.java

示例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;
    }
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:28,代码来源:DefaultResultsHandler.java

示例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();
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:8,代码来源:ConnectionDeleteCommand.java

示例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;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:11,代码来源:PandionJUI.java

示例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 );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:51,代码来源:BlockControlImage.java

示例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 ();
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:42,代码来源:FactoryEditor.java

示例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.
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:6,代码来源:SimulationConnection.java

示例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);
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:11,代码来源:WidgetUtility.java


注:本文中的org.eclipse.jface.dialogs.MessageDialog.openConfirm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。