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:ca.mcgill.cs.swevo.qualyzer.handlers.DeleteTranscriptHandler.java

License:Open Source License

/**
 * @param transcript/*from  w  w w. j  av  a  2 s.  c  o  m*/
 * @param deleteAudio
 * @param deleteCodes
 * @param deleteParticipants
 */
private void delete(Transcript transcript, boolean deleteCodes, boolean deleteParticipants, Shell shell) {
    Project project = transcript.getProject();
    IProject wProject = ResourcesPlugin.getWorkspace().getRoot().getProject(project.getFolderName());
    ArrayList<Participant> participants = null;
    ArrayList<Code> codes = null;

    if (deleteParticipants) {
        participants = deleteParticipants(transcript);
    }

    if (deleteCodes) {
        codes = deleteCodes(transcript);
    }

    File audioFile = null;
    if (transcript.getAudioFile() != null) {
        audioFile = new File(wProject.getLocation() + transcript.getAudioFile().getRelativePath());
    }

    File file = new File(wProject.getLocation() + TRANSCRIPT + transcript.getFileName());
    if (!file.delete()) {
        String warningMessage = Messages.getString("handlers.DeleteTranscriptHandler.transcriptDeleteFailed"); //$NON-NLS-1$
        fLogger.warn(warningMessage);
        MessageDialog.openWarning(shell, Messages.getString("handlers.DeleteTranscriptHandler.fileAccess"), //$NON-NLS-1$
                warningMessage);
    }

    Facade.getInstance().deleteTranscript(transcript);
    deleteCodesAndParticipants(codes, participants);

    if (audioFile != null && !audioFile.delete()) {
        String warningMessage = Messages.getString("handlers.DeleteTranscriptHandler.audioDeleteFailed"); //$NON-NLS-1$
        fLogger.warn(warningMessage);
        MessageDialog.openWarning(shell, Messages.getString("handlers.DeleteTranscriptHandler.fileAccess"), //$NON-NLS-1$
                warningMessage);
    }
}

From source file:cc.warlock.rcp.application.WarlockUpdates.java

License:Open Source License

public static void checkForUpdates(final Shell parent) {
    try {/*from   w ww.  j a  va2 s  . c  o  m*/
        System.out.println("Checking for updates...");

        String repository_loc = updateProperties.getProperty(UPDATE_SITE);
        System.out.println("Using repository: " + repository_loc);

        BundleContext context = FrameworkUtil.getBundle(WarlockUpdates.class).getBundleContext();
        ServiceReference<?> reference = context.getServiceReference(IProvisioningAgent.SERVICE_NAME);
        if (reference == null) {
            System.out.println("No service reference");
            return;
        }
        IProvisioningAgent agent = (IProvisioningAgent) context.getService(reference);
        ProvisioningSession session = new ProvisioningSession(agent);
        UpdateOperation operation = new UpdateOperation(session);

        // Create uri
        URI uri = null;
        try {
            uri = new URI(repository_loc);
        } catch (URISyntaxException e) {
            System.out.println("URI invalid: " + e.getMessage());
            return;
        }

        operation.getProvisioningContext().setArtifactRepositories(new URI[] { uri });
        operation.getProvisioningContext().setMetadataRepositories(new URI[] { uri });

        //Update[] updates = operation.getPossibleUpdates();
        IProgressMonitor monitor = new NullProgressMonitor();
        IStatus status = operation.resolveModal(monitor);

        // Failed to find updates (inform user and exit)
        if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
            System.out.println("No update");
            MessageDialog.openWarning(parent, "No update",
                    "No updates for the current installation have been found");
            return /*Status.CANCEL_STATUS*/;
        }

        // found updates, ask user if to install?
        if (status.isOK() && status.getSeverity() != IStatus.ERROR) {
            ProvisioningJob job = operation.getProvisioningJob(monitor);
            if (job == null) {
                System.out.println("Error with update (running in eclipse?)");
                MessageDialog.openInformation(parent, "Resolution",
                        operation.getResolutionDetails() + "\nLikely cause is from running inside Eclipse.");
            } else {
                System.out.println("Scheduling update");
                job.schedule();
            }
        } else {
            System.out.println("Error with update");
            MessageDialog.openError(parent, "Error updating", operation.getResolutionDetails());
        }
        context.ungetService(reference);
    } catch (Exception e) {
        System.out.println("Unexpected exception in updater: " + e.getMessage());
        e.printStackTrace();
    }
}

From source file:ch.elexis.base.befunde.EditFindingDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    Composite ret = new Composite(parent, SWT.NONE);
    Patient pat = ElexisEventDispatcher.getSelectedPatient();
    if (pat != null) {
        ret.setLayout(new GridLayout());
        ret.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
        dp = new DatePickerCombo(ret, SWT.NONE);
        if (mw == null) {
            dp.setDate(new Date());
        }/*from   w  w w.  j  ava  2  s. co  m*/
        if (mw != null) {
            dp.setDate(new TimeTool(mw.get(Messwert.FLD_DATE)).getTime());
            Map vals = mw.getMap(Messwert.FLD_BEFUNDE);
            for (int i = 0; i < flds.length; i++) {
                values[i] = (String) vals.get(flds[i]);
            }
        }
        if (flds != null) {
            for (int i = 0; i < flds.length; i++) {
                final String[] heading = flds[i].split("=", 2); //$NON-NLS-1$
                if (heading.length == 1) {
                    new Label(ret, SWT.NONE).setText(flds[i]);
                } else {
                    Label hl = SWTHelper.createHyperlink(ret, heading[0], new ScriptListener(heading[1], i));
                    hl.setForeground(UiDesk.getColor(UiDesk.COL_BLUE));
                }
                inputs[i] = SWTHelper.createText(ret, multiline[i] ? 4 : 1, SWT.NONE);
                inputs[i].setText(values[i] == null ? "" : values[i]); //$NON-NLS-1$
                if (heading.length > 1) {
                    inputs[i].setEditable(false);
                }
            }
        } else {
            MessageDialog.openWarning(getParentShell(), "Warnung",
                    "Es sind keine Metriken fr die Messung " + name + " vorhanden.");
            close();
        }
    }
    return ret;
}

From source file:ch.elexis.core.application.Desk.java

License:Open Source License

/**
 * @since 3.0.0 log-in has been moved from ApplicationWorkbenchAdvisor to this method
 *//*  w  ww.java2  s  . c  om*/
@Override
public Object start(IApplicationContext context) throws Exception {
    // register ElexisEvent and MessageEvent listeners
    log.debug("Registering " + CoreEventListenerRegistrar.class.getName());
    new CoreEventListenerRegistrar();

    // Check if we "are complete" - throws Error if not
    cod = CoreOperationExtensionPoint.getCoreOperationAdvisor();

    if (System.getProperty(ElexisSystemPropertyConstants.OPEN_DB_WIZARD) != null) {
        cod.requestDatabaseConnectionConfiguration();
    }

    // connect to the database
    try {
        if (PersistentObject.connect(CoreHub.localCfg) == false)
            log.error(PersistentObject.class.getName() + " initialization failed.");
    } catch (Throwable pe) {
        // error in database connection, we have to exit
        log.error("Database connection error", pe);
        pe.printStackTrace();

        Shell shell = PlatformUI.createDisplay().getActiveShell();
        StringBuilder sb = new StringBuilder();
        sb.append("Could not open database connection. Quitting Elexis.\n\n");
        sb.append("Message: " + pe.getMessage() + "\n\n");
        while (pe.getCause() != null) {
            pe = pe.getCause();
            sb.append("Reason: " + pe.getMessage() + "\n");
        }
        sb.append("\n\nWould you like to re-configure the database connection?");
        boolean retVal = MessageDialog.openQuestion(shell, "Error in database connection", sb.toString());

        if (retVal) {
            cod.requestDatabaseConnectionConfiguration();
        }

        return IApplication.EXIT_OK;
    }

    // check for initialization parameters
    args = context.getArguments();
    if (args.containsKey("--clean-all")) { //$NON-NLS-1$
        String p = CorePreferenceInitializer.getDefaultDBPath();
        FileTool.deltree(p);
        CoreHub.localCfg.clear();
        CoreHub.localCfg.flush();
    }

    // check if we should warn of too many instances
    if (CoreHub.isTooManyInstances()) {
        MessageDialog.openWarning(UiDesk.getDisplay().getActiveShell(), Messages.Warning_tooManyTitle,
                Messages.Warning_tooManyMessage + CoreHub.getWritableUserDir().getAbsolutePath());
    }

    // care for log-in
    WorkbenchPlugin.unsetSplashShell(UiDesk.getDisplay());
    cod.performLogin(UiDesk.getDisplay().getActiveShell());
    if ((CoreHub.actUser == null) || !CoreHub.actUser.isValid()) {
        // no valid user, exit (don't consider this as an error)
        log.warn("Exit because no valid user logged-in"); //$NON-NLS-1$
        PersistentObject.disconnect();
        System.exit(0);
    }
    // make sure identifiers are initialized
    initIdentifiers();

    // start the workbench
    try {
        int returnCode = PlatformUI.createAndRunWorkbench(UiDesk.getDisplay(),
                new ApplicationWorkbenchAdvisor());
        // Die Funktion kehrt erst beim Programmende zurck.
        CoreHub.heart.suspend();
        CoreHub.localCfg.flush();
        if (CoreHub.globalCfg != null) {
            CoreHub.globalCfg.flush();
        }
        if (returnCode == PlatformUI.RETURN_RESTART) {
            return IApplication.EXIT_RESTART;
        }
        return IApplication.EXIT_OK;
    } catch (Exception ex) {
        log.error("Exception caught", ex);
        ex.printStackTrace();
        return -1;
    }
}

From source file:ch.elexis.core.application.listeners.MessageEventListener.java

License:Open Source License

@Override
public void run(final ElexisEvent ev) {
    Display.getDefault().syncExec(new Runnable() {
        @Override/*from  w ww  .ja va2 s.  co m*/
        public void run() {
            MessageEvent me = (MessageEvent) ev.getGenericObject();
            log.debug("MessageEvent [TITLE] " + me.title);
            switch (me.mt) {
            case ERROR:
                MessageDialog.openError(UiDesk.getTopShell(), me.title, me.message);
                break;
            case WARN:
                MessageDialog.openWarning(UiDesk.getTopShell(), me.title, me.message);
                break;
            default:
                MessageDialog.openInformation(UiDesk.getTopShell(), me.title, me.message);
                break;
            }
        }
    });
}

From source file:ch.elexis.core.ui.laboratory.dialogs.ImportLabMapping.java

License:Open Source License

@Override
protected void okPressed() {
    FileInputStream fis = null;/*from   w ww .  j  a v a  2 s  . co  m*/
    try {
        fis = new FileInputStream(filePath.getText());
    } catch (FileNotFoundException fe) {
        setErrorMessage(String.format(Messages.ImportLabMapping_errorNotFound, filePath.getText()));
        return;
    }
    try {
        LabMapping.importMappingFromCsv(fis);
    } catch (IOException ioe) {
        setErrorMessage(String.format(Messages.ImportLabMapping_errorProblems, filePath.getText()));
        MessageDialog.openWarning(getShell(), Messages.ImportLabMapping_titleProblemDialog, ioe.getMessage());
    }

    super.okPressed();
}

From source file:ch.elexis.core.ui.laboratory.preferences.LaborPrefs.java

License:Open Source License

@Override
protected void contributeButtons(Composite parent) {
    ((GridLayout) parent.getLayout()).numColumns++;
    Button bMappingFrom2_1_7 = new Button(parent, SWT.PUSH);
    bMappingFrom2_1_7.setText(Messages.LaborPrefs_mappingFrom2_1_7);
    bMappingFrom2_1_7.addSelectionListener(new SelectionAdapter() {
        @Override// ww  w  .  ja va2s  .c  o  m
        public void widgetSelected(SelectionEvent e) {
            try {
                // execute the command
                IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow().getService(IHandlerService.class);

                handlerService.executeCommand(CreateMappingFrom2_1_7.COMMANDID, null);
            } catch (Exception ex) {
                throw new RuntimeException(CreateMappingFrom2_1_7.COMMANDID, ex);
            }
            tableViewer.refresh();
        }
    });

    if (CoreHub.acl.request(AccessControlDefaults.LABITEM_MERGE) == true) {
        ((GridLayout) parent.getLayout()).numColumns++;
        Button bImportMapping = new Button(parent, SWT.PUSH);
        bImportMapping.setText(Messages.LaborPrefs_mergeLabItems);
        bImportMapping.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                try {
                    // execute the command
                    IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                            .getActiveWorkbenchWindow().getService(IHandlerService.class);

                    handlerService.executeCommand(CreateMergeLabItemUi.COMMANDID, null);
                } catch (Exception ex) {
                    throw new RuntimeException(CreateMergeLabItemUi.COMMANDID, ex);
                }
                tableViewer.refresh();
            }
        });
    }

    ((GridLayout) parent.getLayout()).numColumns++;
    Button bImportMapping = new Button(parent, SWT.PUSH);
    bImportMapping.setText(Messages.LaborPrefs_importLabMapping);
    bImportMapping.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                // execute the command
                IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow().getService(IHandlerService.class);

                handlerService.executeCommand(CreateImportMappingUi.COMMANDID, null);
            } catch (Exception ex) {
                throw new RuntimeException(CreateImportMappingUi.COMMANDID, ex);
            }
            tableViewer.refresh();
        }
    });
    ((GridLayout) parent.getLayout()).numColumns++;
    Button bNewItem = new Button(parent, SWT.PUSH);
    bNewItem.setText(Messages.LaborPrefs_labValue);
    bNewItem.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            try {
                // execute the command
                IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench()
                        .getActiveWorkbenchWindow().getService(IHandlerService.class);

                handlerService.executeCommand(CreateLabItemUi.COMMANDID, null);
            } catch (Exception ex) {
                throw new RuntimeException(CreateLabItemUi.COMMANDID, ex);
            }
            tableViewer.refresh();
        }
    });
    ((GridLayout) parent.getLayout()).numColumns++;
    Button bDelItem = new Button(parent, SWT.PUSH);
    bDelItem.setText(Messages.LaborPrefs_deleteItem);
    bDelItem.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection sel = (IStructuredSelection) tableViewer.getSelection();
            Object o = sel.getFirstElement();
            if (o instanceof LabItem) {
                LabItem li = (LabItem) o;
                if (MessageDialog.openQuestion(getShell(), Messages.LaborPrefs_deleteItem,
                        MessageFormat.format(Messages.LaborPrefs_deleteReallyItem, li.getLabel()))) {
                    if (deleteResults(li)) {
                        deleteMappings(li);
                        li.delete();
                        tableViewer.remove(li);
                    } else {
                        MessageDialog.openWarning(getShell(), Messages.LaborPrefs_deleteItem,
                                Messages.LaborPrefs_deleteFail);
                    }
                }
            }
        }
    });
    ((GridLayout) parent.getLayout()).numColumns++;
    Button bDelAllItems = new Button(parent, SWT.PUSH);
    bDelAllItems.setText(Messages.LaborPrefs_deleteAllItems);
    bDelAllItems.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (SWTHelper.askYesNo(Messages.LaborPrefs_deleteReallyAllItems,
                    Messages.LaborPrefs_deleteAllExplain)) {
                Query<LabItem> qbli = new Query<LabItem>(LabItem.class);
                List<LabItem> items = qbli.execute();
                boolean success = true;
                for (LabItem li : items) {
                    if (deleteResults(li)) {
                        deleteMappings(li);
                        li.delete();
                    } else {
                        success = false;
                    }
                }
                if (!success) {
                    MessageDialog.openWarning(getShell(), Messages.LaborPrefs_deleteAllItems,
                            Messages.LaborPrefs_deleteFail);
                }
                tableViewer.refresh();
            }
        }
    });
    if (CoreHub.acl.request(AccessControlDefaults.DELETE_LABITEMS) == false) {
        bDelAllItems.setEnabled(false);
    }
}

From source file:ch.elexis.core.ui.stock.dialogs.ImportArticleDialog.java

License:Open Source License

private void doImport() {

    StringBuffer buf = new StringBuffer();

    // check for store availability
    final List<String> storeIds = ArticleServiceHolder.getStoreIds();
    if (storeIds.isEmpty()) {
        buf.append(/*from ww w.  j ava2  s .c  o  m*/
                "Es ist kein Artikelservice registriert. Vergewissern Sie sich, dass zumindest ein Artikel Plugin installiert ist.");
    } else {
        // check for stock availability
        StructuredSelection iSelection = (StructuredSelection) comboStockType.getSelection();
        if (iSelection.isEmpty()) {
            buf.append("Bitte whlen Sie ein Lager aus.");
        } else {
            final Stock stock = (Stock) iSelection.getFirstElement();

            // check src file
            String path = tFilePath.getText();
            if (path != null && !path.isEmpty() && path.toLowerCase().endsWith("xls")) {

                try (FileInputStream is = new FileInputStream(tFilePath.getText())) {
                    ExcelWrapper xl = new ExcelWrapper();
                    if (xl.load(is, 0)) {
                        xl.setFieldTypes(new Class[] { Integer.class, String.class, String.class, String.class,
                                String.class, String.class, Integer.class, String.class, String.class });
                        MessageDialog dialog = new MessageDialog(getShell(), "Datenimport", null,
                                "Wie sollen die Datenbestnde importiert werden ?", MessageDialog.QUESTION, 0,
                                "Datenbestand 'exakt' importieren", "Datenbestand 'aufaddieren'");
                        int ret = dialog.open();
                        if (ret >= 0) {
                            runImport(buf, storeIds, stock, xl, ret == 0);
                        }
                        return;
                    }
                } catch (IOException e) {
                    MessageDialog.openError(getShell(), "Import error",
                            "Import fehlgeschlagen.\nDatei nicht importierbar: " + path);
                    LoggerFactory.getLogger(ImportArticleDialog.class).error("cannot import file at " + path,
                            e);
                }
            } else {
                buf.append("Die Quelldatei ist ungltig. Bitte berprfen Sie diese Datei.\n" + path);
            }
        }
    }
    if (buf.length() > 0) {
        MessageDialog.openInformation(getShell(), "Import Ergebnis", buf.toString());
    } else {
        MessageDialog.openWarning(getShell(), "Import Ergebnis",
                "Import nicht mglich.\nberprfen Sie das Log-File.");
    }
}

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

License:Open Source License

/**
 * Find the default supplier. Shows a warning if supplier is null or inexisting
 * //from www .j  a v a2 s .c o m
 * @param cfgSupplier
 *            value delivered from the plugins configured supplier field
 * @param selDialogTitle
 *            title of the dialog
 * @return the supplier or null if none could be resolved.
 */
public static Kontakt resolveDefaultSupplier(String cfgSupplier, String selDialogTitle) {
    Kontakt supplier = null;
    if (cfgSupplier != null && !cfgSupplier.isEmpty()) {
        supplier = Kontakt.load(cfgSupplier);
    }

    //warn that there is no supplier
    if (supplier == null || !supplier.exists()) {
        MessageDialog.openWarning(UiDesk.getTopShell(), selDialogTitle,
                Messages.BestellView_CantOrderNoSupplier);
    }
    return supplier;
}

From source file:ch.elexis.core.ui.views.codesystems.CodeSelectorFactory.java

License:Open Source License

/**
 * Returns the {@link DoubleClickListener} used on the Viewer of this
 * {@link CodeSelectorFactory}. Default implementation passes the selected
 * {@link PersistentObject} directly to the code selector target (manage via
 * {@link CodeSelectorHandler}). If a {@link Leistungsblock} is selected it will pass its
 * contained elements to the code selector target. </br>
 * </br>//from  w  ww .ja v a2 s.  c o  m
 * Should be overridden by subclasses for special behaviour.
 * 
 * @return
 */
protected DoubleClickListener getDoubleClickListener() {
    return new DoubleClickListener() {
        public void doubleClicked(PersistentObject obj, CommonViewer cv) {
            ICodeSelectorTarget target = CodeSelectorHandler.getInstance().getCodeSelectorTarget();
            if (target != null) {
                if (obj instanceof Leistungsblock) {
                    Leistungsblock block = (Leistungsblock) obj;
                    java.util.List<ICodeElement> elements = block.getElements();
                    for (ICodeElement codeElement : elements) {
                        if (codeElement instanceof PersistentObject) {
                            PersistentObject po = (PersistentObject) codeElement;
                            target.codeSelected(po);
                        }
                    }
                    java.util.List<ICodeElement> diff = block.getDiffToReferences(elements);
                    if (!diff.isEmpty()) {
                        StringBuilder sb = new StringBuilder();
                        diff.forEach(r -> {
                            if (sb.length() > 0) {
                                sb.append("\n");
                            }
                            sb.append(r);
                        });
                        MessageDialog.openWarning(Display.getDefault().getActiveShell(), "Warnung",
                                "Warnung folgende Leistungen konnten im aktuellen Kontext (Fall, Konsultation, Gesetz) nicht verrechnet werden.\n"
                                        + sb.toString());
                    }
                } else {
                    target.codeSelected(obj);
                }
            }
        }
    };
}