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

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

Introduction

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

Prototype

public MessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
        int dialogImageType, int defaultIndex, String... dialogButtonLabels) 

Source Link

Document

Create a message dialog.

Usage

From source file:ch.elexis.agenda.data.Termin.java

License:Open Source License

public boolean delete(boolean askForConfirmation) {
    boolean confirmed = !askForConfirmation;
    if (checkLock()) {
        return false;
    }//  w  w w .  j a  v a  2s.  c  om
    String linkgroup = get(FLD_LINKGROUP); //$NON-NLS-1$
    boolean isLinked = linkgroup != null && !linkgroup.isEmpty();

    if (isLinked && askForConfirmation) {
        MessageDialog msd = new MessageDialog(UiDesk.getTopShell(), Messages.Termin_deleteSeries, null,
                Messages.Termin_thisAppIsPartOfSerie, MessageDialog.QUESTION,
                new String[] { Messages.Termin_yes, Messages.Termin_no }, 1);
        int retval = msd.open();
        if (retval == SWT.DEFAULT) {
            return false;
        }
        confirmed = (retval == Dialog.OK);
    }
    if (isLinked) {
        List<Termin> linked = getLinked(this);
        if (confirmed) {
            // delete whole series
            for (Termin ae : (List<Termin>) linked) {
                ae.set(new String[] { FLD_LASTEDIT, FLD_DELETED },
                        new String[] { createTimeStamp(), StringConstants.ONE });
            }
        } else {
            if (getId().equals(linkgroup)) {
                // move root information
                if (linked.size() > 1) {
                    int index = 0;
                    Termin moveto = linked.get(index);
                    while (moveto.getId().equals(linkgroup)) {
                        moveto = linked.get(++index);
                    }
                    moveto.set(Termin.FLD_PATIENT, get(Termin.FLD_PATIENT));
                    moveto.set(Termin.FLD_GRUND, get(Termin.FLD_GRUND));
                    moveto.set(Termin.FLD_CREATOR, get(Termin.FLD_CREATOR));
                    moveto.set(Termin.FLD_EXTENSION, get(Termin.FLD_EXTENSION));
                    for (Termin termin : linked) {
                        termin.set(Termin.FLD_LINKGROUP, moveto.getId());
                    }
                }
            }
            // delete this
            set(new String[] { FLD_DELETED, FLD_LASTEDIT }, StringConstants.ONE, createTimeStamp());
        }
    } else {
        // delete this
        set(new String[] { FLD_DELETED, FLD_LASTEDIT }, StringConstants.ONE, createTimeStamp());
    }
    return true;
}

From source file:ch.elexis.core.ui.Hub.java

License:Open Source License

/**
 * Programmende/*from  ww  w  .  j a  va 2s  .  c  o  m*/
 */
public static void postShutdown() {
    // shutdownjobs are executed after the workbench has been shut down.
    // So those jobs must not use any of the workbench's resources.
    if ((shutdownJobs != null) && (shutdownJobs.size() > 0)) {
        Shell shell = new Shell(Display.getDefault());
        MessageDialog dlg = new MessageDialog(shell, Messages.Hub_title_configuration, Dialog.getDefaultImage(),
                Messages.Hub_message_configuration, SWT.ICON_INFORMATION, new String[] {}, 0);
        dlg.setBlockOnOpen(false);
        dlg.open();
        for (ShutdownJob job : shutdownJobs) {
            try {
                job.doit();
            } catch (Exception e) {
                log.error("Error starting job: " + e.getMessage());
            }
        }
        dlg.close();
    }
}

From source file:ch.elexis.core.ui.views.RezepteView.java

License:Open Source License

private void makeActions() {
    newRpAction = new Action(Messages.RezepteView_newPrescriptionAction) { //$NON-NLS-1$
        {/*from   w  w w  .  j  ava 2s  . co  m*/
            setImageDescriptor(Images.IMG_NEW.getImageDescriptor());
            setToolTipText(Messages.RezepteView_newPrescriptonTooltip); //$NON-NLS-1$
        }

        @Override
        public void run() {
            Patient act = (Patient) ElexisEventDispatcher.getSelected(Patient.class);
            if (act == null) {
                MessageBox mb = new MessageBox(getViewSite().getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mb.setText(Messages.RezepteView_newPrescriptionError); //$NON-NLS-1$
                mb.setMessage(Messages.RezepteView_noPatientSelected); //$NON-NLS-1$
                mb.open();
                return;
            }
            Fall fall = (Fall) ElexisEventDispatcher.getSelected(Fall.class);
            if (fall == null) {
                Konsultation k = act.getLetzteKons(false);
                if (k == null) {
                    SWTHelper.alert(Messages.RezepteView_noCaseSelected, //$NON-NLS-1$
                            Messages.RezepteView_pleaseCreateOrChooseCase); //$NON-NLS-1$                     
                    return;
                }
            }
            Rezept rezept = new Rezept(act);
            tv.refresh();
            doSelectNewRezept(rezept);
            doAddLine();
        }
    };
    deleteRpAction = new Action(Messages.RezepteView_deletePrescriptionActiom) { //$NON-NLS-1$
        @Override
        public void run() {
            Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class);
            if (MessageDialog.openConfirm(getViewSite().getShell(),
                    Messages.RezepteView_deletePrescriptionActiom, //$NON-NLS-1$
                    MessageFormat.format(Messages.RezepteView_deletePrescriptionConfirm, rp //$NON-NLS-1$
                            .getDate()))) {
                rp.delete();
                tv.refresh();
            }
        }
    };
    removeLineAction = new Action(Messages.RezepteView_deleteLineAction) { //$NON-NLS-1$
        @Override
        public void run() {
            Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class);
            IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection();
            Prescription p = (Prescription) sel.getFirstElement();
            if ((rp != null) && (p != null)) {
                rp.removePrescription(p);
                lvRpLines.refresh();
            }
            /*
             * RpZeile z=(RpZeile)sel.getFirstElement(); if((rp!=null) && (z!=null)){
             * rp.removeLine(z); lvRpLines.refresh(); }
             */
        }
    };
    addLineAction = new Action(Messages.RezepteView_newLineAction) { //$NON-NLS-1$
        @Override
        public void run() {
            doAddLine();
        }
    };
    printAction = new Action(Messages.RezepteView_printAction) { //$NON-NLS-1$
        @Override
        public void run() {
            try {
                RezeptBlatt rp = (RezeptBlatt) getViewSite().getPage().showView(RezeptBlatt.ID);
                Rezept actR = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class);
                Brief rpBrief = actR.getBrief();
                if (rpBrief == null)
                    // not yet created - just create a new Rezept
                    rp.createRezept(actR);
                else {
                    // Brief for Rezept already exists:
                    // ask if it should be recreated or just shown
                    String[] dialogButtonLabels = { Messages.RezepteView_RecreatePrescription,
                            Messages.RezepteView_ShowPrescription, Messages.RezepteView_PrescriptionCancel };
                    MessageDialog msg = new MessageDialog(null, Messages.RezepteView_CreatePrescription, //$NON-NLS-1$
                            null, Messages.RezepteView_ReallyWantToRecreatePrescription, //$NON-NLS-1$
                            MessageDialog.WARNING, dialogButtonLabels, 2);
                    int result = msg.open();
                    switch (result) {
                    case 0: // recreate rezept
                        rp.createRezept(actR);
                        break;
                    case 1: // open rezept
                        rp.loadRezeptFromDatabase(actR, rpBrief);
                        break;
                    case 2: // cancel or closebox - do nothing
                        break;
                    }
                }
            } catch (Exception ex) {
                ExHandler.handle(ex);
            }
        }
    };
    changeMedicationAction = new RestrictedAction(AccessControlDefaults.MEDICATION_MODIFY,
            Messages.RezepteView_ChangeLink) { //$NON-NLS-1$
        {
            setImageDescriptor(Images.IMG_EDIT.getImageDescriptor());
            setToolTipText(Messages.RezepteView_ChangeTooltip); //$NON-NLS-1$
        }

        public void doRun() {
            Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class);
            IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection();
            Prescription pr = (Prescription) sel.getFirstElement();
            if (pr != null) {
                new MediDetailDialog(getViewSite().getShell(), pr).open();
                lvRpLines.refresh();
            }
        }
    };
    addLineAction.setImageDescriptor(Images.IMG_ADDITEM.getImageDescriptor());
    printAction.setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor());
    deleteRpAction.setImageDescriptor(Images.IMG_DELETE.getImageDescriptor());
}

From source file:ch.elexis.Hub.java

License:Open Source License

/**
 * Programmende//w  w w. ja  va  2 s .c  o  m
 */
public static void postShutdown() {
    // heart.stop();
    // JobPool.getJobPool().dispose();
    if (Hub.actUser != null) {
        Anwender.logoff();
    }
    if (globalCfg != null) {
        // We should not flush at this point, since this might
        // overwrite other client's
        // settings
        // acl.flush();
        // globalCfg.flush();
    }

    // shutdownjobs are executed after the workbench has been shut down.
    // So those jobs must not use any of the workbench's resources.
    if ((shutdownJobs != null) && (shutdownJobs.size() > 0)) {
        Shell shell = new Shell(Display.getDefault());
        MessageDialog dlg = new MessageDialog(shell, Messages.Hub_title_configuration, Dialog.getDefaultImage(),
                Messages.Hub_message_configuration, SWT.ICON_INFORMATION, new String[] {}, 0);
        dlg.setBlockOnOpen(false);
        dlg.open();
        for (ShutdownJob job : shutdownJobs) {
            try {
                job.doit();
            } catch (Exception e) {
                log.log("Error starting job: " + e.getMessage(), Log.ERRORS);
            }
        }
        dlg.close();
    }
}

From source file:ch.elexis.views.KonsDetailView.java

License:Open Source License

@Override
public void createPartControl(final Composite p) {
    org.eclipse.swt.graphics.Image icon = Desk.getImage(ICON);
    if (icon != null) {
        setTitleImage(icon);/*from w w  w .ja va2  s . c  o m*/
    }
    sash = new SashForm(p, SWT.VERTICAL);

    tk = Desk.getToolkit();
    form = tk.createForm(sash);
    form.getBody().setLayout(new GridLayout(1, true));
    form.setText(NO_CONS_SELECTED);
    cEtiketten = new Composite(form.getBody(), SWT.NONE);
    cEtiketten.setLayout(new RowLayout(SWT.HORIZONTAL));
    cEtiketten.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
    cDesc = new Composite(form.getBody(), SWT.NONE);
    cDesc.setLayout(new RowLayout(SWT.HORIZONTAL));
    cDesc.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
    lBeh = tk.createLabel(cDesc, NO_CONS_SELECTED);
    emFont = Desk.getFont("Helvetica", 11, SWT.BOLD); //$NON-NLS-1$
    lBeh.setFont(emFont);
    defaultBackground = p.getBackground();
    // lBeh.setBackground();
    hlMandant = tk.createHyperlink(cDesc, "--", SWT.NONE); //$NON-NLS-1$
    hlMandant.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            KontaktSelektor ksl = new KontaktSelektor(getSite().getShell(), Mandant.class,
                    Messages.getString("KonsDetailView.SelectMandatorCaption"), //$NON-NLS-1$
                    Messages.getString("KonsDetailView.SelectMandatorBody"),
                    new String[] { Mandant.FLD_SHORT_LABEL, Mandant.FLD_NAME1, Mandant.FLD_NAME2 }); //$NON-NLS-1$
            if (ksl.open() == Dialog.OK) {
                actKons.setMandant((Mandant) ksl.getSelection());
                setKons(actKons);
            }
        }

    });
    hlMandant.setBackground(p.getBackground());

    cbFall = new Combo(form.getBody(), SWT.SINGLE);
    cbFall.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            Fall[] faelle = (Fall[]) cbFall.getData();
            int i = cbFall.getSelectionIndex();
            if (i > -1 && i < faelle.length) {
                Fall nFall = faelle[i];

                Fall actFall = null;
                String fallId = "";
                if (actKons != null) {
                    actFall = actKons.getFall();
                    fallId = actFall.getId();
                }

                if (!nFall.getId().equals(fallId)) {
                    if (!nFall.isOpen()) {
                        SWTHelper.alert(Messages.getString("KonsDetailView.CaseClosedCaption"), //$NON-NLS-1$
                                Messages.getString("KonsDetailView.CaseClosedBody")); //$NON-NLS-1$
                    } else {
                        MessageDialog msd = new MessageDialog(getViewSite().getShell(),
                                Messages.getString("KonsDetailView.ChangeCaseCaption"), //$NON-NLS-1$
                                Images.IMG_LOGO48.getImage(),
                                MessageFormat.format(
                                        Messages.getString("KonsDetailView.ConfirmChangeConsToCase"),
                                        new Object[] { actFall.getLabel(), nFall.getLabel() }),
                                MessageDialog.QUESTION, new String[] { Messages.getString("KonsDetailView.Yes"), //$NON-NLS-1$
                                        Messages.getString("KonsDetailView.No") }, //$NON-NLS-1$
                                0);
                        if (msd.open() == 0) {
                            actKons.setFall(nFall);
                            setKons(actKons);
                        }
                    }
                }
            }
        }

    });
    GridData gdFall = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    cbFall.setLayoutData(gdFall);

    lVersion = tk.createLabel(form.getBody(), Messages.getString("KonsDetailView.actual")); //$NON-NLS-1$
    GridData gdVer = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
    lVersion.setLayoutData(gdVer);

    text = new EnhancedTextField(form.getBody());
    hXrefs = new Hashtable<String, IKonsExtension>();
    @SuppressWarnings("unchecked")
    List<IKonsExtension> xrefs = Extensions.getClasses("ch.elexis.KonsExtension", "KonsExtension"); //$NON-NLS-1$ //$NON-NLS-2$
    for (IKonsExtension x : xrefs) {
        String provider = x.connect(text);
        hXrefs.put(provider, x);
    }
    text.setXrefHandlers(hXrefs);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL | GridData.GRAB_VERTICAL
            | GridData.GRAB_HORIZONTAL);
    text.setLayoutData(gd);
    tk.adapt(text);
    SashForm bf = new SashForm(sash, SWT.HORIZONTAL);

    Composite botleft = tk.createComposite(bf);
    botleft.setLayout(new GridLayout(1, false));
    Composite botright = tk.createComposite(bf);
    botright.setLayout(new GridLayout(1, false));

    dd = new DiagnosenDisplay(getSite().getPage(), botleft, SWT.NONE);
    dd.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    vd = new VerrechnungsDisplay(getSite().getPage(), botright, SWT.NONE);
    vd.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    getSite().registerContextMenu(ID + ".VerrechnungsDisplay", vd.contextMenuManager, vd.viewer);
    getSite().setSelectionProvider(vd.viewer);

    makeActions();
    ViewMenus menu = new ViewMenus(getViewSite());
    if (Hub.acl.request(AccessControlDefaults.AC_PURGE)) {
        menu.createMenu(versionFwdAction, versionBackAction, GlobalActions.neueKonsAction,
                GlobalActions.delKonsAction, GlobalActions.redateAction, assignStickerAction, purgeAction);
    } else {
        menu.createMenu(versionFwdAction, versionBackAction, GlobalActions.neueKonsAction,
                GlobalActions.delKonsAction, GlobalActions.redateAction, assignStickerAction);
    }
    sash.setWeights(sashWeights == null ? new int[] { 80, 20 } : sashWeights);

    menu.createToolbar(GlobalActions.neueKonsAction, saveAction);
    GlobalEventDispatcher.addActivationListener(this, this);
    text.connectGlobalActions(getViewSite());
    adaptMenus();
    setKons((Konsultation) ElexisEventDispatcher.getSelected(Konsultation.class));
}

From source file:ch.elexis.views.RezepteView.java

License:Open Source License

private void makeActions() {
    newRpAction = new Action(Messages.getString("RezepteView.newPrescriptionAction")) { //$NON-NLS-1$
        {//  w ww .j a v  a  2  s. c om
            setImageDescriptor(Images.IMG_NEW.getImageDescriptor());
            setToolTipText(Messages.getString("RezepteView.newPrescriptonTooltip")); //$NON-NLS-1$
        }

        @Override
        public void run() {
            Patient act = (Patient) ElexisEventDispatcher.getSelected(Patient.class);
            if (act == null) {
                MessageBox mb = new MessageBox(getViewSite().getShell(), SWT.ICON_INFORMATION | SWT.OK);
                mb.setText(Messages.getString("RezepteView.newPrescriptionError")); //$NON-NLS-1$
                mb.setMessage(Messages.getString("RezepteView.noPatientSelected")); //$NON-NLS-1$
                mb.open();
                return;
            }
            Fall fall = (Fall) ElexisEventDispatcher.getSelected(Fall.class);
            if (fall == null) {
                Konsultation k = act.getLetzteKons(false);
                if (k == null) {
                    SWTHelper.alert(Messages.getString("RezepteView.noCaseSelected"), //$NON-NLS-1$
                            Messages.getString("RezepteView.pleaseCreateOrChooseCase")); //$NON-NLS-1$
                    return;
                } else {
                    fall = k.getFall();
                }
            }
            new Rezept(act);
            tv.refresh();
        }
    };
    deleteRpAction = new Action(Messages.getString("RezepteView.deletePrescriptionActiom")) { //$NON-NLS-1$
        @Override
        public void run() {
            Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class);
            if (MessageDialog.openConfirm(getViewSite().getShell(),
                    Messages.getString("RezepteView.deletePrescriptionActiom"), //$NON-NLS-1$
                    MessageFormat.format(Messages.getString("RezepteView.deletePrescriptionConfirm"), rp //$NON-NLS-1$
                            .getDate()))) {
                rp.delete();
                tv.refresh();
            }
        }
    };
    removeLineAction = new Action(Messages.getString("RezepteView.deleteLineAction")) { //$NON-NLS-1$
        @Override
        public void run() {
            Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class);
            IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection();
            Prescription p = (Prescription) sel.getFirstElement();
            if ((rp != null) && (p != null)) {
                rp.removePrescription(p);
                lvRpLines.refresh();
            }
            /*
             * RpZeile z=(RpZeile)sel.getFirstElement(); if((rp!=null) && (z!=null)){
             * rp.removeLine(z); lvRpLines.refresh(); }
             */
        }
    };
    addLineAction = new Action(Messages.getString("RezepteView.newLineAction")) { //$NON-NLS-1$
        @Override
        public void run() {
            try {
                LeistungenView lv1 = (LeistungenView) getViewSite().getPage().showView(LeistungenView.ID);
                CodeSelectorHandler.getInstance().setCodeSelectorTarget(dropTarget);
                CTabItem[] tabItems = lv1.ctab.getItems();
                for (CTabItem tab : tabItems) {
                    ICodeElement ics = (ICodeElement) tab.getData();
                    if (ics instanceof Artikel) {
                        lv1.ctab.setSelection(tab);
                        break;
                    }
                }
            } catch (PartInitException ex) {
                ExHandler.handle(ex);
            }
        }
    };
    printAction = new Action(Messages.getString("RezepteView.printAction")) { //$NON-NLS-1$
        @Override
        public void run() {
            try {
                RezeptBlatt rp = (RezeptBlatt) getViewSite().getPage().showView(RezeptBlatt.ID);
                Rezept actR = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class);
                Brief rpBrief = actR.getBrief();
                if (rpBrief == null)
                    // not yet created - just create a new Rezept
                    rp.createRezept(actR);
                else {
                    // Brief for Rezept already exists:
                    // ask if it should be recreated or just shown
                    String[] dialogButtonLabels = { Messages.getString("RezepteView.RecreatePrescription"), //$NON-NLS-1$
                            Messages.getString("RezepteView.ShowPrescription"), //$NON-NLS-1$
                            Messages.getString("RezepteView.PrescriptionCancel") //$NON-NLS-1$
                    };
                    MessageDialog msg = new MessageDialog(null,
                            Messages.getString("RezepteView.CreatePrescription"), //$NON-NLS-1$
                            null, Messages.getString("RezepteView.ReallyWantToRecreatePrescription"), //$NON-NLS-1$
                            MessageDialog.WARNING, dialogButtonLabels, 2);
                    int result = msg.open();
                    switch (result) {
                    case 0: // recreate rezept
                        rp.createRezept(actR);
                        break;
                    case 1: // open rezept
                        rp.loadRezeptFromDatabase(actR, rpBrief);
                        break;
                    case 2: // cancel or closebox - do nothing
                        break;
                    }
                }
            } catch (Exception ex) {
                ExHandler.handle(ex);
            }
        }
    };
    changeMedicationAction = new RestrictedAction(AccessControlDefaults.MEDICATION_MODIFY,
            Messages.getString("RezepteView.ChangeLink")) { //$NON-NLS-1$
        {
            setImageDescriptor(Images.IMG_EDIT.getImageDescriptor());
            setToolTipText(Messages.getString("RezepteView.ChangeTooltip")); //$NON-NLS-1$
        }

        public void doRun() {
            Rezept rp = (Rezept) ElexisEventDispatcher.getSelected(Rezept.class);
            IStructuredSelection sel = (IStructuredSelection) lvRpLines.getSelection();
            Prescription pr = (Prescription) sel.getFirstElement();
            if (pr != null) {
                new MediDetailDialog(getViewSite().getShell(), pr).open();
                lvRpLines.refresh();
            }
        }
    };
    addLineAction.setImageDescriptor(Images.IMG_ADDITEM.getImageDescriptor());
    printAction.setImageDescriptor(Images.IMG_PRINTER.getImageDescriptor());
    deleteRpAction.setImageDescriptor(Images.IMG_DELETE.getImageDescriptor());
}

From source file:ch.netcetera.eclipse.workspaceconfig.ui.handler.WorkspaceStartupHandler.java

License:Open Source License

/** {@inheritDoc} */
@Override/*from  w w w  . j av a2s . co  m*/
public void earlyStartup() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    final String bundleId = FrameworkUtil.getBundle(getClass()).getSymbolicName();
    boolean isNewWorkspace = WorkspaceConfigurationStatusUtil.isNewWorkspace();
    boolean checkEnabled = Platform.getPreferencesService().getBoolean(bundleId,
            WorkspaceConfigurationConstants.CONFIG_STARTUP_CHECK, true, null);
    boolean urlConfigured = ConfigurationUtil.isEpfUrlConfigured();

    if (checkEnabled && isNewWorkspace && urlConfigured) {

        workbench.getDisplay().asyncExec(new Runnable() {

            @Override
            public void run() {
                IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
                if (window != null) {
                    String[] buttonLabels = new String[] {
                            WorkspaceConfigurationUIPlugin.getDefault()
                                    .getText("startup.handler.dialog.button.yes"),
                            WorkspaceConfigurationUIPlugin.getDefault()
                                    .getText("startup.handler.dialog.button.no"),
                            WorkspaceConfigurationUIPlugin.getDefault()
                                    .getText("startup.handler.dialog.button.ask.again") };
                    String message = WorkspaceConfigurationUIPlugin.getDefault()
                            .getText("startup.handler.dialog.text");
                    Image titleImage = WorkspaceConfigurationUIPlugin
                            .getImageDescriptor(PluginImages.IMG_DIALOG_TITLE).createImage();
                    String title = WorkspaceConfigurationUIPlugin.getDefault()
                            .getText("startup.handler.dialog.title");
                    MessageDialog dialog = new MessageDialog(window.getShell(), title, titleImage, message,
                            MessageDialog.QUESTION, buttonLabels, 0);
                    int result = dialog.open();

                    if (result == IMPORT_CONFIG) {
                        applySettings();
                        WorkspaceConfigurationStatusUtil.writeConfiguredFlag();
                    } else if (result == DO_NOT_IMPORT_CONFIG) {
                        WorkspaceConfigurationStatusUtil.writeNoConfigFlag();
                    }
                    // else: do nothing
                }
            }

            private void applySettings() {
                IHandlerService service = (IHandlerService) workbench.getService(IHandlerService.class);
                try {
                    service.executeCommand(ImportWorkspaceConfigurationHandler.COMMAND_ID, null);
                } catch (CommandException e) {
                    ILog log = WorkspaceConfigurationUIPlugin.getDefault().getLog();
                    log.log(new Status(IStatus.ERROR, bundleId, "applying settings failed", e));
                    displayErrorDialog();
                }
            }
        });
    }
}

From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.DockerFoundryUiCallback.java

License:Open Source License

@Override
public void handleError(final IStatus status) {

    if (status != null && status.getSeverity() == IStatus.ERROR) {

        UIJob job = new UIJob(Messages.DockerFoundryUiCallback_JOB_CF_ERROR) {
            public IStatus runInUIThread(IProgressMonitor monitor) {
                Shell shell = CloudUiUtil.getShell();
                if (shell != null) {
                    new MessageDialog(shell, Messages.DockerFoundryUiCallback_ERROR_CALLBACK_TITLE, null,
                            status.getMessage(), MessageDialog.ERROR, new String[] { Messages.COMMONTXT_OK }, 0)
                                    .open();
                }//from   w  w  w .  j a  va  2 s .com
                return Status.OK_STATUS;
            }
        };
        job.setSystem(true);
        job.schedule();

    }
}

From source file:codeOrchestra.lcs.license.AbstractExpirationWithSerialNumberStrategy.java

@Override
public void showLicenseExpirationInProgressDialog() {
    String expireMessage = String.format(
            "You have %d days of %d evaluation period days left. You may continue evaluation or enter a serial number",
            getDaysLeft(), getExpirationPeriod());

    MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "Evaluation License", null,
            expireMessage, MessageDialog.INFORMATION,
            new String[] { "Continue Evaluation", "Enter Serial Number" }, 0);
    int result = dialog.open();
    if (result == 1) {
        showSerialNumberDialog();//from   w  ww.  ja v  a 2s .  c om
    }
}

From source file:codeOrchestra.lcs.license.CalendarUsageDayExpirationStrategy.java

@Override
public boolean showLicenseExpiredDialog() {
    String expireMessage = String.format(
            "%d day(s) evaluation license has expired. The programm will quit unless you enter a serial number",
            getExpirationPeriod());//from   w w w .  j  av  a2 s.com

    MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "Evaluation License", null,
            expireMessage, MessageDialog.QUESTION, new String[] { "Exit", "Enter Serial Number" }, 0);

    int result = dialog.open();
    if (result == 1) {
        return showSerialNumberDialog();
    }

    return false;
}