Example usage for org.eclipse.jface.dialogs MessageDialog openWarning

List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog openWarning.

Prototype

public static void openWarning(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a standard warning dialog.

Usage

From source file:com.tencent.wstt.apt.ui.views.DevicesView.java

License:Open Source License

/**
 * APT????//from w  w w .ja v a 2  s  .  c  o m
 */
private void initAPT() {
    // ?
    APTConsoleFactory.getInstance().openConsole();
    // ???
    StatusBar.getInstance().init();
    APTState.getInstance().setInitState();

    // ??APT??
    PCInfo.OSName = System.getProperty("os.name");

    if (!GetAdbPathUtil.getAdbPath()) {
        DeviceInfo.getInstance().state = PhoneState.STATE_NOT_ADB;
        // TODO ?????
        String info = "ADT?Eclipse PreferencesAndroid SDK Location???APT";
        APTConsoleFactory.getInstance().APTPrint(info);
        MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??", info);
    } else {
        //apt
    }
    DDMSUtil.init();
    APTConsoleFactory.getInstance().APTPrint("initAPT complete");
}

From source file:com.tencent.wstt.apt.util.TestSenceUtil.java

License:Open Source License

/**
* @Description ?? /*ww  w.j a  va  2 s.com*/
* @param @return   
* @return boolean 
* @throws
 */
public static boolean verifyTestSence() {
    //
    if (TestSence.getInstance().pkgInfos.size() == 0) {
        String info = "";
        APTConsoleFactory.getInstance().APTPrint(info);
        MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??", info);
        return false;
    }

    //?
    int testItemCount = 0;
    for (int i = 0; i < Constant.TEST_ITEM_COUNT; i++) {
        if (TestSence.getInstance().itemTestSwitch[i]) {
            testItemCount++;
        }
    }

    if (testItemCount == 0) {
        String info = "";
        APTConsoleFactory.getInstance().APTPrint(info);
        MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??", info);
        return false;
    }

    if (TestSence.getInstance().itemTestSwitch[Constant.MEM_INDEX] && testItemCount > 1) {
        String info = "?CPU?CPU";
        APTConsoleFactory.getInstance().APTPrint(info);
        if (!MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??",
                info)) {
            return false;
        }
    }

    if (TestSence.getInstance().itemTestPeriod[Constant.CPU_INDEX] < Constant.TOP_UPDATE_PERIOD * 1000) {
        String info = "CPU3";
        APTConsoleFactory.getInstance().APTPrint(info);
        MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "??", info);
        return false;
    }

    return true;
}

From source file:com.tida_okinawa.corona.ui.UIActivator.java

License:Open Source License

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;

    /* ??? *///from   ww w.  j  ava 2 s  . c om
    LicenseActivator.getDefault();

    CorrectionActivator.initAutoSchedules();

    /*
     * ??????
     * ????????????????
     * ???? DB ????????????????
     */
    ConnectionParameter cp = PreferenceUtils.getCurrentConnectionParameter();
    if (cp == null) {
        cp = new ConnectionParameter("", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }

    // testH25 20130806 ?
    //        /* DB?? */
    //        com.tida_okinawa.corona.io.IoActivator.getService().connect(cp.url, cp.user, cp.passwd);
    //
    boolean isConnect = false;
    try {
        isConnect = com.tida_okinawa.corona.io.IoActivator.getService().connect(cp.url, cp.user, cp.passwd);
    } catch (Exception e) {
        /* ???(/????) */
        e.getStackTrace();
    }

    // testH25 20130806 ?
    String name = cp.name;
    String dburl = cp.url;
    String dbname = cp.url;
    String lastSep = Messages.UIActivator_LastSep;
    int index = dbname.lastIndexOf(lastSep);
    if (index != -1) {
        dbname = dburl.substring(index + 1);
    }

    if (isConnect) {
        /* DB???? */
        int result[] = { 0 };
        String dbValue = com.tida_okinawa.corona.io.IoActivator.getService().getDbVersion(result).trim();
        LicenseActivator license = LicenseActivator.getDefault();
        String dbVersion = license.getDbVersion().trim();

        /* DB??? */
        if (dbValue.isEmpty()) {
            /*
             * SQL????????? DB?NOT
             * NULL??????????????
             */
            String title = Messages.UIActivator_VerErrTitle;
            String dialogMessage = Messages.UIActivator_VerErrMessage;
            Object args[] = { name, dbname };
            String dialogMessageSub0 = String.format(Messages.UIActivator_VerErrDbInfo, args);
            String dialogMessageSub1 = String.format(Messages.UIActivator_VerErrValue, dbVersion);
            String dialogMessageSub2 = String.format(Messages.UIActivator_VerErrDBValue, dbValue);
            if (result[0] == 2) {
                /* ?? */
                dialogMessage = Messages.UIActivator_VerErrMessageNonTable;
            }
            if (result[0] == 1) {
                /* ?? ? */
                dialogMessage = Messages.UIActivator_VerErrMessageSqlErr;
            }
            dialogMessage += dialogMessageSub0 + dialogMessageSub1 + dialogMessageSub2;
            // (Error)
            MessageDialog.openError(new Shell(), title, dialogMessage);
        }
        /* DB?????DBVer?DB?DBVer? */
        else if (dbVersion.compareTo(dbValue) != 0) {
            /* DB?????? */
            String title = Messages.UIActivator_VerWarTitle;
            String dialogMessage = Messages.UIActivator_VerWarMessage;
            Object args[] = { name, dbname };
            String dialogMessageSub0 = String.format(Messages.UIActivator_VerErrDbInfo, args);
            String dialogMessageSub1 = String.format(Messages.UIActivator_VerErrValue, dbVersion);
            String dialogMessageSub2 = String.format(Messages.UIActivator_VerErrDBValue, dbValue);
            dialogMessage += dialogMessageSub0 + dialogMessageSub1 + dialogMessageSub2;
            // (Warning)
            MessageDialog.openWarning(new Shell(), title, dialogMessage);
        }
    } else {
        /* DB??? */
        String title = Messages.UIActivator_connectErrTitle;
        String dialogMessage = Messages.UIActivator_connectErrMessage;
        Object args[] = { name, dbname, cp.user };
        String dialogMessageSub0 = String.format(Messages.UIActivator_connectErrDbInfo, args);
        dialogMessage += dialogMessageSub0;
        // (Error)
        MessageDialog.openError(new Shell(), title, dialogMessage);
    }

    /* ? */
    CoronaActivator.getDefault().setLogger(MessageConsoleLogger.getInstance());

    /* Log */
    /* ????????????? */
    // CoronaActivator.getDefault().getLog().addLogListener(logListener);

    /* ?(DB????)CoronaProject???? */
    CoronaModel.INSTANCE.openCoronaProject();
}

From source file:com.vectrace.MercurialEclipse.history.BisectAbstractAction.java

License:Open Source License

protected boolean checkDirty(final HgRoot root) {
    if (HgStatusClient.isDirty(root)) {
        MessageDialog.openWarning(mercurialHistoryPage.getControl().getShell(), "Uncommitted Changes", //$NON-NLS-1$
                "Your hg root has uncommited changes." + "\nPlease commit or revert to start Bisection."); //$NON-NLS-2$
        return true;
    }/*from  w  ww .  j a v  a  2  s . c o m*/
    return false;
}

From source file:com.vectrace.MercurialEclipse.wizards.MercurialParticipantSynchronizeWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    boolean performFinish = true;
    if (repoPage != null) {
        repoPage.finish(new NullProgressMonitor());
        performFinish = super.performFinish();
    } else {//from w w  w  .  j a va  2  s .c  o  m
        // UI was not created, so we just need to continue with synchronization
        try {
            List<Map<String, Object>> properties = prepareDefaultSettings();
            if (properties != null && properties.size() > 0) {
                createdParticipant = createParticipant(properties, projects);
            } else {
                performFinish = false;
                throw new HgException("No properties found for synchronizing");
            }
        } catch (final HgException e) {
            MercurialEclipsePlugin.logWarning(e.getLocalizedMessage(), e);
            MercurialEclipsePlugin.getStandardDisplay().asyncExec(new Runnable() {
                public void run() {
                    MessageDialog.openWarning(getShell(), "Could not synchronize", e.getMessage());

                }
            });
        }
    }
    if (performFinish && createdParticipant != null) {
        openSyncView(createdParticipant);
    }
    return performFinish;
}

From source file:com.xse.optstack.persconftool.ui.AbstractPersistablePart.java

License:Open Source License

@Persist
public void exportToFiles(final MWindow window, final Resource resource, final EPartService partService) {
    if (!partService.getDirtyParts().isEmpty()) {
        URI fileURI = null;//  w ww.ja va 2  s. c o  m
        if (resource.getURI() == null) {
            final DirectoryDialog dirDialog = new DirectoryDialog(Display.getDefault().getActiveShell(),
                    SWT.SAVE);
            dirDialog.setMessage("Select the folder to export the configuration to:");

            final String path = dirDialog.open();
            if ((path != null) && (path.length() > 2)) {
                fileURI = URI.createFileURI(path);
            }
        } else {
            fileURI = resource.getURI();
        }

        if (fileURI != null) {
            resource.setURI(fileURI);
            final PersConfExport persConfExport = new PersConfExport(fileURI.toFileString());
            if (!persConfExport.export(resource)) {
                MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Export",
                        "The current configuration could not be fully exported.");
            } else {
                // make sure to reset dirty state for all parts
                partService.getDirtyParts().forEach(p -> p.setDirty(false));
            }

            window.setLabel(fileURI.toFileString() + " - " + APPLICATION_TITLE);
        }
    }
}

From source file:com.yoursway.hello.debug.ui.internal.HelloDebugUIPlugin.java

License:Open Source License

public void showWarning(final String title, final String information) {
    Display.getDefault().asyncExec(new Runnable() {

        public void run() {
            MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title,
                    information);//w w  w.  j a  v  a2s.  com
        }

    });
}

From source file:crosswalk.diagram.part.CrosswalkDiagramEditor.java

License:Apache License

/**
 * @generated//from  w w  w . j  a va2 s  .  co  m
 */
protected void performSaveAs(IProgressMonitor progressMonitor) {
    Shell shell = getSite().getShell();
    IEditorInput input = getEditorInput();
    SaveAsDialog dialog = new SaveAsDialog(shell);
    IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input).getFile() : null;
    if (original != null) {
        dialog.setOriginalFile(original);
    }
    dialog.create();
    IDocumentProvider provider = getDocumentProvider();
    if (provider == null) {
        // editor has been programmatically closed while the dialog was open
        return;
    }
    if (provider.isDeleted(input) && original != null) {
        String message = NLS.bind(Messages.CrosswalkDiagramEditor_SavingDeletedFile, original.getName());
        dialog.setErrorMessage(null);
        dialog.setMessage(message, IMessageProvider.WARNING);
    }
    if (dialog.open() == Window.CANCEL) {
        if (progressMonitor != null) {
            progressMonitor.setCanceled(true);
        }
        return;
    }
    IPath filePath = dialog.getResult();
    if (filePath == null) {
        if (progressMonitor != null) {
            progressMonitor.setCanceled(true);
        }
        return;
    }
    IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    IFile file = workspaceRoot.getFile(filePath);
    final IEditorInput newInput = new FileEditorInput(file);
    // Check if the editor is already open
    IEditorMatchingStrategy matchingStrategy = getEditorDescriptor().getEditorMatchingStrategy();
    IEditorReference[] editorRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getEditorReferences();
    for (int i = 0; i < editorRefs.length; i++) {
        if (matchingStrategy.matches(editorRefs[i], newInput)) {
            MessageDialog.openWarning(shell, Messages.CrosswalkDiagramEditor_SaveAsErrorTitle,
                    Messages.CrosswalkDiagramEditor_SaveAsErrorMessage);
            return;
        }
    }
    boolean success = false;
    try {
        provider.aboutToChange(newInput);
        getDocumentProvider(newInput).saveDocument(progressMonitor, newInput,
                getDocumentProvider().getDocument(getEditorInput()), true);
        success = true;
    } catch (CoreException x) {
        IStatus status = x.getStatus();
        if (status == null || status.getSeverity() != IStatus.CANCEL) {
            ErrorDialog.openError(shell, Messages.CrosswalkDiagramEditor_SaveErrorTitle,
                    Messages.CrosswalkDiagramEditor_SaveErrorMessage, x.getStatus());
        }
    } finally {
        provider.changed(newInput);
        if (success) {
            setInput(newInput);
        }
    }
    if (progressMonitor != null) {
        progressMonitor.setCanceled(!success);
    }
}

From source file:de.akra.idocit.ui.components.DocumentationEditor.java

License:Apache License

/**
 * {@inheritDoc}/*from  w  ww  . ja v a 2s . c om*/
 */
@Override
public void doSave(IProgressMonitor monitor) {
    IFile interfaceFile = getMask().getSelection().getArtifactFile();
    InterfaceArtifact artifact = getMask().getSelection().getInterfaceArtifact();

    String type = interfaceFile.getFileExtension();

    if ((type != null)) {
        try {
            ValidationReport report = ServiceManager.getInstance().getPersistenceService()
                    .validateInterfaceArtifact(artifact, interfaceFile);

            switch (report.getReturnCode()) {
            case OK: {
                ServiceManager.getInstance().getPersistenceService().writeInterface(artifact, interfaceFile);

                initialInterfaceArtifact = (InterfaceArtifact) artifact
                        .copy(SignatureElement.EMPTY_SIGNATURE_ELEMENT);

                getMask().getSelection().resetOriginalDocumentations();
                firePropertyChange(PROP_DIRTY);
                break;
            }
            case ERROR: {
                MessageDialog.openError(getSite().getShell(), DialogConstants.DIALOG_TITLE,
                        report.getMessage());
                break;
            }
            case WARNING: {
                MessageDialog.openWarning(getSite().getShell(), DialogConstants.DIALOG_TITLE,
                        report.getMessage());
                break;
            }
            default:
                throw new RuntimeException("The validation code " + report.getReturnCode() + " is unknown.");
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            MessageDialog.openError(getSite().getShell(), DialogConstants.DIALOG_TITLE,
                    ERR_FILE_CAN_NOT_BE_SAVED + ":\n" + e.getMessage());
        }
    } else {
        logger.log(Level.SEVERE, ERR_FILE_NOT_SUPPORTED);
        MessageDialog.openError(getSite().getShell(), DialogConstants.DIALOG_TITLE, ERR_FILE_NOT_SUPPORTED);
    }
}

From source file:de.anbos.eclipse.logviewer.plugin.LogViewerPlugin.java

License:Apache License

public void showWarningMessage(String message) {
    IWorkbenchWindow window = getDefault().getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
        MessageDialog.openWarning(window.getShell().getShell(), getResourceString("error.warning.title"), //$NON-NLS-1$
                message);/*from w  w  w .j  a va  2  s .com*/
    }
}