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.nextep.designer.synch.ui.services.impl.SynchronizationUIService.java

License:Open Source License

@Override
public void synchronize(final IVersionContainer container, final IConnection connection,
        IProgressMonitor monitor) {/*from w  w  w  . j a  v  a 2  s  . c  o  m*/
    // Checking whether we are generating for current vendor
    final DBVendor currentVendor = workspaceService.getCurrentWorkspace().getDBVendor();
    if (connection.getDBVendor() != currentVendor) {
        final IUIComponent domainDialog = new DomainEditorComponent();

        // Initializing dialog
        ComponentWizard wiz = new ComponentWizard(SynchUIMessages.getString("wizard.synch.crossvendor"), //$NON-NLS-1$
                Arrays.asList(domainDialog));
        WizardDialog dlg = new WizardDialog(UIHelper.getShell(), wiz) {
            @Override
            protected Point getInitialSize() {
                return new Point(600, 540);
            }

        };
        dlg.setBlockOnOpen(true);
        dlg.open();
        // Checking cancel state
        if (wiz.isCanceled()) {
            return;
        }
    }
    Job j = new BlockingJob(SynchUIMessages.getString("synch.job.name")) { //$NON-NLS-1$

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                synchronizationService.synchronize(container, connection, monitor);
            } catch (final ErrorException e) {
                log.error(SynchUIMessages.getString("synch.job.error"), e); //$NON-NLS-1$
                this.addJobChangeListener(new JobChangeAdapter() {

                    @Override
                    public void done(IJobChangeEvent event) {
                        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                            @Override
                            public void run() {
                                MessageDialog.openWarning(null, SynchUIMessages.getString("synch.job.error"), e //$NON-NLS-1$
                                        .getMessage());
                            }
                        });

                    }

                });
            } catch (CancelException e) {
                return Status.CANCEL_STATUS;
            }
            return Status.OK_STATUS;
        }
    };
    j.setUser(true);
    j.setPriority(Job.BUILD);
    j.schedule();
}

From source file:com.nextep.designer.vcs.ui.handlers.CopyHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final ISelection s = HandlerUtil.getCurrentSelection(event);
    if (!s.isEmpty() && s instanceof IStructuredSelection) {
        final IStructuredSelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
        if (sel.size() == 1 && sel.getFirstElement() instanceof IVersionable<?>) {
            final IVersionable<?> o = (IVersionable<?>) sel.getFirstElement();
            // Prompting for new name
            final RenameConnector connector = new RenameConnector((IObservable) o);
            GUIWrapper wrapper = new GUIWrapper(connector, VCSUIMessages.getString("handler.copy.title"), //$NON-NLS-1$
                    300, 120);/*from ww w .  ja  v a2  s  .c  om*/
            wrapper.invoke();
            if (!wrapper.isCancelled()) {
                String newName = connector.getNewName();
                if (newName == null || "".equals(newName.trim())) { //$NON-NLS-1$
                    MessageDialog.openWarning(wrapper.getShell(),
                            VCSUIMessages.getString("handler.rename.invalidTitle"), //$NON-NLS-1$
                            VCSUIMessages.getString("handler.rename.invalidMsg")); //$NON-NLS-1$
                } else if (newName.equals(o.getName())) {
                    MessageDialog.openWarning(wrapper.getShell(),
                            VCSUIMessages.getString("handler.copy.invalidTitle"), //$NON-NLS-1$
                            VCSUIMessages.getString("handler.copy.invalidMsg")); //$NON-NLS-1$
                } else {
                    final IVersionable<?> copy = VersionableFactory.copy(o);
                    copy.setName(newName);
                    copy.setVersion(VersionFactory.getUnversionedInfo(
                            new Reference(copy.getType(), copy.getName(), copy),
                            Activity.getDefaultActivity()));
                    // Assigning fresh new references to contained elements
                    final Map<IReference, IReferenceable> refMap = copy.getReferenceMap();
                    for (IReference r : refMap.keySet()) {
                        final IReferenceable referenceable = refMap.get(r);
                        referenceable.setReference(new Reference(r.getType(),
                                ((INamedObject) referenceable).getName(), referenceable));
                    }
                    // Adding to container
                    o.getContainer().addVersionable(copy, new ImportPolicyAddOnly());
                    return newName;
                }
            }
        }
    }
    return null;
}

From source file:com.nextep.designer.vcs.ui.handlers.RenameHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection s = HandlerUtil.getCurrentSelection(event);
    if (s instanceof IStructuredSelection && !s.isEmpty()) {
        final IStructuredSelection sel = (IStructuredSelection) s;
        Object o = sel.getFirstElement();
        // Checking whether we can modify this element or not
        o = VCSPlugin.getService(IVersioningService.class).ensureModifiable(o);
        // Yes we can...
        if (o instanceof INamedObject && o instanceof IObservable) {
            // Invoking editor through our helper GUIWrapper class
            final RenameConnector connector = new RenameConnector((IObservable) o);
            GUIWrapper wrapper = new GUIWrapper(connector,
                    VCSUIMessages.getString("handler.rename.dialogTitle"), //$NON-NLS-1$
                    300, 120);//from   ww  w.  ja  v a2s.  c o m
            wrapper.invoke();
            if (!wrapper.isCancelled()) {
                String newName = connector.getNewName();
                if (newName == null || "".equals(newName.trim())) { //$NON-NLS-1$
                    MessageDialog.openWarning(wrapper.getShell(),
                            VCSUIMessages.getString("handler.rename.invalidTitle"), //$NON-NLS-1$
                            VCSUIMessages.getString("handler.rename.invalidMsg")); //$NON-NLS-1$
                } else {
                    final INamedObject named = (INamedObject) connector.getModel();
                    named.setName(newName);
                    return newName;
                }
            }
        }
    }
    return null;
}

From source file:com.nextep.designer.vcs.ui.impl.ExceptionHandler.java

License:Open Source License

/**
 * Handles exception within the neXtep designer environment. This method returns a boolean
 * indicating whether the exception handling should go on with Eclipse exception handling or if
 * it has been absorbed by neXtep./* w w  w . ja  va 2  s  .c  om*/
 * 
 * @param t the exception to handle
 * @return <code>true</code> when the exception has been completely handled and should not be
 *         raised, else <code>false</code>.
 */
public static boolean handle(Throwable t) {
    if (t instanceof OutOfDateObjectException) {
        VersionUIHelper.promptObjectSynched(((OutOfDateObjectException) t).getStaleObject());
    } else if (t instanceof CancelException) {
        log.info(t.getMessage());
    } else if (t instanceof ErrorException) {
        if (t.getCause() instanceof InvocationTargetException) {
            t = t.getCause().getCause();
            return handle(t);
        }
        log.error(t.getMessage(), t);
        MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                "Error when performing user action", t.getMessage());
        // if("true".equals(Designer.getInstance().getProperty("nextep.designer.debug"))) {
        // log.error(t);
        // }
    } else if (t instanceof ExitDesignerException) {
        log.info(t.getMessage());
    } else if (t instanceof JDBCConnectionException) {
        if (!Designer.getTerminationSignal()) {
            Designer.setTerminationSignal(true);
            try {
                // Ensuring a UI Thread
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        // We are in a situation where we've lost our connection to the
                        // repository
                        MessageDialog.openError(null,
                                UIMessages.getString("exceptionHandler.repositoryConnectionLost.title"), //$NON-NLS-1$
                                UIMessages.getString("exceptionHandler.repositoryConnectionLost.message")); //$NON-NLS-1$
                        // Closing perpective
                        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                                .getActivePage();
                        page.closeAllPerspectives(true, true);
                        // Closing and reopening session
                        HibernateUtil.getInstance().reconnectAll();
                        // Changing view
                        final IWorkspaceUIService viewUiService = VCSUIPlugin
                                .getService(IWorkspaceUIService.class);
                        final IWorkspaceService viewService = VCSPlugin.getService(IWorkspaceService.class);
                        viewUiService.changeWorkspace(viewService.getCurrentWorkspace().getUID());
                    }
                });
            } finally {
                Designer.setTerminationSignal(false);
            }
        } else {
            log.error("Error thrown while reinitializing repository connection: " + t.getMessage(), t);
        }
        return true;
    } else {
        log.error("An error has been raised: " + t.getMessage(), t); //$NON-NLS-1$
        if (t instanceof HibernateException && PlatformUI.getWorkbench() != null
                && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
            MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    UIMessages.getString("systemInstableTitle"), UIMessages //$NON-NLS-1$
                            .getString("systemInstable")); //$NON-NLS-1$
        }
    }
    if (Designer.isDebugging()) {
        t.printStackTrace();
    }
    // By default we consider that we haven't handled completely the problem
    return false;
}

From source file:com.nokia.carbide.cpp.internal.codescanner.ui.CSFileFiltersTabPage.java

License:Open Source License

/**
 * Check whether a file filter already exists.
 *//*from  ww w. j av a  2  s. c o m*/
private boolean fileFilterExist(String fileFilter) {
    if (filterList.contains(fileFilter)) {
        MessageDialog.openWarning(getShell(), Messages.getString("FileFiltersTabPage.FileFilterExistTitle"),
                Messages.getString("FileFiltersTabPage.FileFilterExistMessage"));
        return true;
    }
    return false;
}

From source file:com.nokia.carbide.cpp.internal.sdk.core.model.SDKManagerRaptorOnly.java

License:Open Source License

protected void reportError(final String string) {
    if (WorkbenchUtils.isJUnitRunning())
        return;//from  w  ww.ja  v a2 s. c  o  m
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            MessageDialog.openWarning(WorkbenchUtils.getActiveShell(), "SBSv2 Setup Failed", string);
        }
    });
}

From source file:com.nokia.carbide.internal.discovery.ui.wizard.ImportWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {//from  w w w . jav  a2 s  . co m
        getContainer().run(true, true, new FeatureInstallOperation(importPage.getURIs(),
                importPage.getFeatureInfos(), importPage.getWantsOriginalVersions()));
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        if (cause instanceof CoreException) {
            IStatus status = ((CoreException) cause).getStatus();
            if (allInstalledStatus(status)) {
                MessageDialog.openWarning(getShell(), Messages.ImportWizard_AllInstalledTitle,
                        Messages.ImportWizard_AllInstalledMessage);
            } else {
                ErrorDialog.openError(getShell(), Messages.ImportWizard_ErrorTitle, null, status);
            }
        } else {
            MessageDialog.openError(getShell(), Messages.ImportWizard_ErrorTitle,
                    MessageFormat.format(Messages.ImportWizard_InstallErrorSimple, cause.getMessage()));
        }
    } catch (InterruptedException e) {
    }
    return true;
}

From source file:com.nokia.carbide.internal.updater.ProjectUpdateJob.java

License:Open Source License

private void doInitialWorkspaceScan() {
    List<String> messages = new ArrayList();
    for (IUpdateProjectsScanner scanner : Startup.getScanners()) {
        Collection<IProject> excludedProjectsCollection = scanner.scanProjects(selectedProjects, monitor);
        for (IProject project : excludedProjectsCollection) {
            if (selectedProjects.contains(project)) {
                IStatus projectStatus = scanner.getProjectStatus(project);
                messages.add(projectStatus.getMessage());
                selectedProjects.remove(project);
            }//w w  w  .  j a v a 2s.  c  o  m
        }
    }

    if (messages.isEmpty())
        return;

    final String title = Messages.getString("UpdateProjectsJob.WarningTitle"); //$NON-NLS-1$
    final String message = MessageFormat.format(
            Messages.getString("UpdateProjectsJob.ProjectsNotUpdatedMessageFormat"), //$NON-NLS-1$
            new Object[] { TextUtils.formatTabbedList(messages) });
    Display.getDefault().syncExec(new Runnable() {
        public void run() {
            MessageDialog.openWarning(null, title, message);
        }
    });
}

From source file:com.nokia.cdt.debug.cw.symbian.SettingsData.java

License:Open Source License

private static void displayWarningDialog(final String msg) {
    //  Display warning dialog
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
        window = windows[0];/*from  ww w .  ja v a  2 s  . c o m*/
    }

    final Shell shell = window.getShell();
    //using syncExec could cause a dead-lock
    //that is why asyncExec is used
    shell.getDisplay().asyncExec(new Runnable() {
        public void run() {
            MessageDialog.openWarning(shell, Messages.getString("SettingsData.70"), msg); //$NON-NLS-1$
        }
    });
}

From source file:com.nokia.cdt.internal.debug.launch.NokiaAbstractLaunchDelegate.java

License:Open Source License

protected void showMessage(final String title, final String msg) {
    // Pop up a dialog telling user.
    Display display = Display.getCurrent();
    if (display == null) {
        display = Display.getDefault();//from  w  ww  .j  ava2  s  . c  o m
    }

    display.syncExec(new Runnable() {
        public void run() {
            MessageDialog.openWarning(CUIPlugin.getActiveWorkbenchShell(), title, msg);
        }
    });
}