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

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

Introduction

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

Prototype

public static boolean openQuestion(Shell parent, String title, String message) 

Source Link

Document

Convenience method to open a simple Yes/No question dialog.

Usage

From source file:de.topicmapslab.tmcledit.export.wizards.TMCLExportWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    if (schema == null) {
        File onotoaFile = Activator.getDefault().getSelectionService().getOnotoaFile();
        if (onotoaFile != null)
            schema = onotoaFile.getTopicMapSchema();
        else {/*from w  w w . j av a 2 s. c  o m*/
            MessageDialog.openError(getShell(), "Error!", "No onotoa file opened!");
            return true;
        }
    }
    java.io.File file = new java.io.File(page.getFileName());

    if (file.exists()) {
        if (!MessageDialog.openQuestion(getShell(), "File already exists",
                "File already exists. Do you want to overwrite it?"))
            return false;

        file.delete();

    }
    try {
        TMCLTopicMapBuilder builder = new TMCLTopicMapBuilder(schema, page.isExportSchemaInfos(),
                page.isExportDiagramInfos());
        builder.setExportTopicTypesOnly(page.isExportTopicTypes());
        builder.setExportAnnotations(page.isExportAnnotations());
        builder.setExportSchema(page.isExportSchemaInfos());
        TopicMap tm = builder.createTopicMap();
        FileOutputStream stream = new FileOutputStream(file);

        TopicMapWriter writer = getTopicMapWriter(stream, schema.getBaseLocator(), tm);
        writer.write(tm);
        stream.flush();
        stream.close();

        Activator.getDefault().getPreferenceStore().putValue("exported_file", page.getFileName());
    } catch (Exception e) {
        MessageDialog.openError(getShell(), "Export Error!",
                "An error occurred while exporting: " + e.getMessage());
        throw new RuntimeException(e);
    }

    return true;
}

From source file:de.topicmapslab.tmcledit.model.actions.DeleteDiagramAction.java

License:Open Source License

/**
 * {@inheritDoc}//  w  w w  .j a va2s.  com
 */
@Override
public void run() {
    Shell shell = modelView.getSite().getShell();
    if (MessageDialog.openQuestion(shell, "Are you sure?",
            "Do you really want to delete the selected diagram?")) {

        CompoundCommand ccmd = new CompoundCommand();

        List<DeleteDiagramCommand> cmdList = new ArrayList<DeleteDiagramCommand>();
        for (Diagram d : diagrams) {
            DeleteDiagramCommand cmd = new DeleteDiagramCommand(d);
            cmdList.add(cmd);
        }

        // sorting commands, so the diagram deletion can be undone (command uses position in
        // diagram list therefor the diagrams with the lower indices need to be deleted last)
        Collections.sort(cmdList, new Comparator<DeleteDiagramCommand>() {

            public int compare(DeleteDiagramCommand o1, DeleteDiagramCommand o2) {
                if (o1.getIndex() == o2.getIndex())
                    return 0;
                if (o1.getIndex() < o2.getIndex())
                    return 1;
                else
                    return -1;
            }

        });
        for (DeleteDiagramCommand cmd : cmdList)
            ccmd.append(cmd);

        modelView.getEditingDomain().getCommandStack().execute(ccmd);
    }

}

From source file:de.topicmapslab.tmcledit.model.actions.DeleteTMCLConstruct.java

License:Open Source License

/**
 * {@inheritDoc}//from  ww w  .j a v  a  2 s  .  com
 */
@Override
public void run() {
    Shell shell = modelView.getSite().getShell();
    if (MessageDialog.openQuestion(shell, "Are you sure?",
            "Do you really want to delete the selected construct?")) {

        CompoundCommand cmd = new CompoundCommand();

        for (TMCLConstruct construct : getConstructList()) {
            if (construct instanceof TopicType)
                cmd.append(new DeleteTopicTypeCommand((TopicType) construct));

            if (construct instanceof NameTypeConstraint)
                cmd.append(new DeleteTopicTypeConstraintItemCommand((TopicType) construct.eContainer(),
                        (AbstractConstraint) construct, ModelPackage.TOPIC_TYPE__NAME_CONSTRAINTS));

            if (construct instanceof OccurrenceTypeConstraint)
                cmd.append(new DeleteTopicTypeConstraintItemCommand((TopicType) construct.eContainer(),
                        (AbstractConstraint) construct, ModelPackage.TOPIC_TYPE__OCCURRENCE_CONSTRAINTS));

            if (construct instanceof ItemIdentifierConstraint)
                cmd.append(new DeleteTopicTypeConstraintItemCommand((TopicType) construct.eContainer(),
                        (AbstractConstraint) construct, ModelPackage.TOPIC_TYPE__ITEM_IDENTIFIER_CONSTRAINTS));

            if (construct instanceof SubjectIdentifierConstraint)
                cmd.append(new DeleteTopicTypeConstraintItemCommand((TopicType) construct.eContainer(),
                        (AbstractConstraint) construct,
                        ModelPackage.TOPIC_TYPE__SUBJECT_IDENTIFIER_CONSTRAINTS));

            if (construct instanceof SubjectLocatorConstraint)
                cmd.append(new DeleteTopicTypeConstraintItemCommand((TopicType) construct.eContainer(),
                        (AbstractConstraint) construct, ModelPackage.TOPIC_TYPE__SUBJECT_LOCATOR_CONSTRAINTS));

            if (construct instanceof AssociationTypeConstraint)
                cmd.append(new DeleteAssociationConstraintCommand((AssociationTypeConstraint) construct));

        }
        if (cmd != null)
            modelView.getEditingDomain().getCommandStack().execute(cmd);
    }

}

From source file:de.topicmapslab.tmcledit.model.views.ModelView.java

License:Open Source License

private void checkSavedState() {
    if (currFile != null) {
        currFile.eAdapters().remove(dirtyListener);
        WorkspaceCommandStackImpl cmdStack = (WorkspaceCommandStackImpl) getEditingDomain().getCommandStack();
        if (cmdStack.isSaveNeeded()) {
            if (MessageDialog.openQuestion(getViewSite().getShell(), "Unsaved model",
                    "Your model is not saved. Do you want to save now?")) {
                doSave(null);/*w  w w . j  ava2s. c o  m*/
            }
        }
    }
}

From source file:de.tub.tfs.henshin.tggeditor.actions.imports.LoadReconstructXMLForSource.java

License:Open Source License

public HashSet<EStructuralFeature> improveModel(BasicExtendedMetaData data) {
    HashSet<EStructuralFeature> criticalFeatures = new HashSet<EStructuralFeature>();
    HashSet<EStructuralFeature> invalidFeat = new HashSet<EStructuralFeature>();
    HashSet<EStructuralFeature> wrongRefs = new HashSet<EStructuralFeature>();

    EPackage reconstructedPackage = ((ReconstructingMetaData) data).getReconstructedPackage();

    for (EClassifier clazz : reconstructedPackage.getEClassifiers()) {
        if (clazz instanceof EClass) {
            EClass eclass = (EClass) clazz;
            for (EStructuralFeature feat : eclass.getEStructuralFeatures()) {
                if (feat instanceof EReference)
                    if (feat.getEType() instanceof EDataType)
                        wrongRefs.add(feat);
                    else if (((EClass) feat.getEType()).getEStructuralFeatures().isEmpty())
                        criticalFeatures.add(feat);
                    else if (((EClass) feat.getEType()).getEStructuralFeatures().size() == 2
                            && ((EClass) feat.getEType()).getEStructuralFeatures().get(0).getName()
                                    .equals(MIXEDELEMENTFEATURE)
                            && ((EClass) feat.getEType()).getEStructuralFeatures().get(1).getName()
                                    .equals(XML_ELEMENT_TEXT))
                        criticalFeatures.add(feat);
                if (feat instanceof EAttribute) {
                    if (feat.getName() == null || feat.getName().isEmpty()) {
                        invalidFeat.add(feat);
                    } else if (!(((EAttribute) feat).getEType() instanceof EDataType)) {
                        criticalFeatures.add(feat);
                    }//from   ww w.  j a  v  a 2  s  . c  o  m
                }
            }
        }
    }
    Shell shell = new Shell();
    for (EStructuralFeature eStructuralFeature : criticalFeatures) {
        if (!MessageDialog.openQuestion(shell, "Process " + eStructuralFeature.getName(),
                "Dou you want to change the EReference " + ((EClass) eStructuralFeature.eContainer()).getName()
                        + "." + eStructuralFeature.getName() + " into an EAttribute with the Type EString?")) {
            continue;
        }
        EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute();
        eAttribute.setName(eStructuralFeature.getName());
        eAttribute.setEType(EcorePackage.Literals.ESTRING);
        eAttribute.setDerived(false);
        eAttribute.setTransient(false);
        eAttribute.setVolatile(false);
        eAttribute.setUpperBound(1);

        EAnnotation eAnnotation = eAttribute
                .getEAnnotation("http:///org/eclipse/emf/ecore/util/ExtendedMetaData");
        if (eAnnotation == null) {
            eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
            eAnnotation.setSource("http:///org/eclipse/emf/ecore/util/ExtendedMetaData");
            eAttribute.getEAnnotations().add(eAnnotation);

        }

        eAnnotation.getDetails().put("name",
                eStructuralFeature.getEAnnotation("http:///org/eclipse/emf/ecore/util/ExtendedMetaData")
                        .getDetails().get("name"));
        eAnnotation.getDetails().put("kind", "element");
        eAnnotation.getDetails().put("namespace", "##targetNamespace");

        reconstructedPackage.getEClassifiers().remove(eStructuralFeature.getEType());

        EClass cont = (EClass) eStructuralFeature.eContainer();
        cont.getEStructuralFeatures().add(eAttribute);
        cont.getEStructuralFeatures().remove(eStructuralFeature);

    }
    shell.close();
    for (EStructuralFeature eStructuralFeature : invalidFeat) {
        ((List) eStructuralFeature.eContainer().eGet(eStructuralFeature.eContainingFeature()))
                .remove(eStructuralFeature);
    }
    return wrongRefs;
}

From source file:de.tub.tfs.henshin.tggeditor.actions.imports.LoadReconstructXMLForSource.java

License:Open Source License

@Override
public void run() {
    manual = null;/*from   w  ww  .j av  a  2s.  c o m*/
    Shell shell = new Shell();
    try {
        FileDialog dialog = new FileDialog(shell, SWT.MULTI);

        BasicExtendedMetaData data = null;
        dialog.setText("Please select the xml file you want to import.");
        String str = dialog.open();
        str = str.substring(0, str.lastIndexOf(File.separator + "") + 1);
        for (String xmlURI : dialog.getFileNames()) {
            xmlURI = str + xmlURI;
            Stack<String> stack = new Stack<String>();

            data = loadModelInformations(xmlURI);
            try {
                data = extractModelInformation(xmlURI, stack, data);
            } catch (Exception ex) {
                ex.printStackTrace();
            }

            if (data instanceof ReconstructingMetaData) {

                p = ((ReconstructingMetaData) data).getReconstructedPackage();

            } else {

            }

            cleanUp();
        }
        if (MessageDialog.openQuestion(shell, "PostProcessing",
                "Do you want to run the post processor for the generated ecore model?")) {
            improveModel(data);
        }

        exportGeneratedEcoreModel(p, null);

        boolean r = MessageDialog.openQuestion(shell, "XSD Replacement",
                "Do you want to create compatibility entries with an existing XSD Model?");
        if (r) {
            FileDialog d = new FileDialog(shell);
            d.setText("Please select the ecore model corresponding to the XSD.");

            String ecoreModel = d.open();
            ResourceSet set = new ResourceSetImpl();

            EObject resPkg = null;
            if (ecoreModel.endsWith("ecore")) {
                Resource resource = set.getResource(URI.createFileURI(ecoreModel), true);
                resPkg = resource.getContents().get(0);
            } else {
                XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder();
                Collection<EObject> generatedPackages = xsdEcoreBuilder.generate(URI.createFileURI(ecoreModel));

                // register the packages loaded from XSD
                for (EObject generatedEObject : generatedPackages) {
                    if (generatedEObject instanceof EPackage) {
                        if (resPkg == null) {
                            resPkg = generatedEObject;
                            break;
                        }
                    }
                }

            }

            if (resPkg instanceof EPackage) {
                EPackage pkg = (EPackage) resPkg;
                p.setName(pkg.getName());
                p.setNsPrefix(pkg.getNsPrefix());
                p.setNsURI(pkg.getNsURI());
                EPackageRegistryImpl.INSTANCE.put(pkg.getNsURI(), p);
                EAnnotation annotation = p.getEAnnotation("EMFModelManager");
                if (annotation == null) {
                    annotation = EcoreFactory.eINSTANCE.createEAnnotation();
                    annotation.setSource("EMFModelManager");
                    p.getEAnnotations().add(annotation);
                }
                LinkedList<EClass> copiedClasses = new LinkedList<EClass>();
                for (final EClassifier cl : pkg.getEClassifiers()) {
                    newCl = p.getEClassifier(cl.getName());
                    if (newCl == null)
                        newCl = p.getEClassifier(cl.getName().replaceAll("(\\w+)[Tt][Yy][Pp][Ee]\\d*", "$1"));

                    String guessedNewName = "";
                    if (newCl != null) {
                        guessedNewName = newCl.getName();
                    } else {
                        guessedNewName = annotation.getDetails().get("/" + cl.getName());
                        ;
                        if (guessedNewName != null && !guessedNewName.isEmpty()) {
                            guessedNewName = guessedNewName.substring(1);
                            newCl = p.getEClassifier(guessedNewName);
                        }
                    }
                    if (newCl == null) {
                        if (manual == null) {
                            boolean b = MessageDialog.openQuestion(shell, "",
                                    "At least one class could not be mapped. Do you want to select the mapped classes by hand?");
                            manual = b;
                        }
                        if (manual && !(cl instanceof EDataType)) {
                            EList<EClassifier> eClassifiers = p.getEClassifiers();
                            copied = false;
                            newCl = DialogUtil.runClassSelectionDialog(shell, eClassifiers, cl,
                                    new SingleElementListSelectionDialog.ListEntry() {

                                        @Override
                                        public String getText() {
                                            return "Copy EClass to new model.";
                                        }

                                        @Override
                                        public Object execute() {
                                            copied = true;
                                            newCl = EcoreUtil.copy(cl);
                                            p.getEClassifiers().add(newCl);
                                            return newCl;
                                        }

                                    });
                            if (newCl != null)
                                guessedNewName = newCl.getName();
                            else {
                                annotation.getDetails().put("/" + cl.getName(), "");
                                continue;
                            }
                            if (copied) {
                                if (newCl instanceof EClass) {
                                    copiedClasses.add((EClass) newCl);
                                }
                            }
                        } else {
                            annotation.getDetails().put("/" + cl.getName(), "");
                            continue;
                        }

                    }

                    annotation.getDetails().put("/" + cl.getName(), "/" + guessedNewName);

                    mappedClasses.put(cl, newCl);
                    mappedClasses.put(newCl, cl);
                    outer: for (EObject attr : cl.eContents()) {
                        if (attr instanceof EStructuralFeature) {
                            if (!annotation.getDetails()
                                    .contains("/" + cl.getName() + "/" + ((EStructuralFeature) attr).getName()))
                                annotation.getDetails().put(
                                        "/" + cl.getName() + "/" + ((EStructuralFeature) attr).getName(), "");
                        }
                        if (attr instanceof EReference) {
                            EReference newAttr = null;
                            String attrName = annotation.getDetails()
                                    .get("/" + cl.getName() + "/" + ((EStructuralFeature) attr).getName());
                            if (attrName != null && !attrName.isEmpty()) {
                                attrName = attrName.substring(attrName.lastIndexOf("/") + 1);
                                for (EObject obj : newCl.eContents()) {
                                    if (obj instanceof EReference) {
                                        if (attrName.equals(((EReference) attr).getName())) {
                                            newAttr = (EReference) obj;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (newAttr == null)
                                for (EObject obj : newCl.eContents()) {
                                    if (obj instanceof EReference) {
                                        if (((EReference) obj).getName().toLowerCase()
                                                .equals(((EReference) attr).getName().toLowerCase())) {
                                            newAttr = (EReference) obj;
                                            break;
                                        }
                                    }
                                    if (obj instanceof EAttribute) {
                                        if (((EAttribute) obj).getName().toLowerCase()
                                                .equals(((EReference) attr).getName().toLowerCase())) {
                                            continue outer;
                                        }
                                    }
                                }

                            if (newAttr != null) {
                                mappedClasses.put(attr, newAttr);
                                mappedClasses.put(newAttr, attr);

                                annotation.getDetails().put(
                                        "/" + cl.getName() + "/" + ((EStructuralFeature) attr).getName(),
                                        "/" + newCl.getName() + "/" + ((EStructuralFeature) newAttr).getName());
                            } else {
                                annotation.getDetails().put(
                                        "/" + cl.getName() + "/" + ((EStructuralFeature) attr).getName(), "");
                            }
                        }
                        if (attr instanceof EAttribute) {
                            EAttribute newAttr = null;

                            String attrName = annotation.getDetails()
                                    .get("/" + cl.getName() + "/" + ((EStructuralFeature) attr).getName());
                            if (attrName != null && !attrName.isEmpty()) {
                                attrName = attrName.substring(attrName.lastIndexOf("/") + 1);
                                for (EObject obj : newCl.eContents()) {
                                    if (obj instanceof EAttribute) {
                                        if (attrName.equals(((EAttribute) attr).getName())) {
                                            newAttr = (EAttribute) obj;
                                            break;
                                        }
                                    }
                                }
                            }
                            if (newAttr == null)
                                for (EObject obj : newCl.eContents()) {
                                    if (obj instanceof EAttribute) {
                                        if (((EAttribute) obj).getName().toLowerCase()
                                                .equals(((EAttribute) attr).getName().toLowerCase())) {
                                            newAttr = (EAttribute) obj;
                                            break;
                                        }
                                    }
                                    if (obj instanceof EReference) {
                                        if (((EReference) obj).getName().toLowerCase()
                                                .equals(((EAttribute) attr).getName().toLowerCase())) {
                                            continue outer;
                                        }
                                    }
                                }
                            if (newAttr == null) {
                                EObject copy = EcoreUtil.copy(attr);
                                ((EClass) newCl).getEStructuralFeatures().add((EStructuralFeature) copy);
                                newAttr = (EAttribute) copy;
                            }
                            mappedClasses.put(attr, newAttr);
                            mappedClasses.put(newAttr, attr);

                            annotation.getDetails().put(
                                    "/" + cl.getName() + "/" + ((EStructuralFeature) attr).getName(),
                                    "/" + newCl.getName() + "/" + newAttr.getName());

                            if (((EAttribute) attr).getEAttributeType().eContainer().equals(cl.eContainer())) {
                                EDataType dataType = (EDataType) p
                                        .getEClassifier(((EAttribute) attr).getEType().getName());
                                if (dataType == null) {
                                    dataType = EcoreUtil.copy(((EAttribute) attr).getEAttributeType());
                                    p.getEClassifiers().add(dataType);
                                }
                                newAttr.setEType(dataType);
                            } else {
                                newAttr.setEType(((EAttribute) attr).getEAttributeType());
                            }
                            EAnnotation meta = ((EModelElement) attr)
                                    .getEAnnotation("http:///org/eclipse/emf/ecore/util/ExtendedMetaData");
                            if (meta != null) {
                                String ns = meta.getDetails().get("namespace");
                                if (ns == null && newCl != null) {
                                    meta = newAttr.getEAnnotation(
                                            "http:///org/eclipse/emf/ecore/util/ExtendedMetaData");
                                    meta.getDetails().remove("namespace");
                                }
                            }

                        }
                    }

                }
                for (EClass eClass : copiedClasses) {
                    updateSuperTypes(eClass);
                }
                for (EClassifier classifier : pkg.getEClassifiers()) {
                    if (classifier instanceof EClass) {
                        for (EClass superType : ((EClass) classifier).getESuperTypes()) {
                            EClass newSuperType = (EClass) mappedClasses.get(superType);
                            if (newSuperType != null) {
                                EClass mappedClass = (EClass) mappedClasses.get(classifier);
                                if (mappedClass != null && !mappedClass.getESuperTypes().contains(newSuperType)
                                        && mappedClass != newSuperType) {
                                    if (mappedClass.getESuperTypes().contains(superType)) {
                                        mappedClass.getESuperTypes().remove(superType);
                                    }
                                    mappedClass.getESuperTypes().add(newSuperType);

                                }
                            }
                        }
                    }
                }
            }
            //(eClassifiers xsi:type="ecore:EClass" name="[^"]*")\s*>
            exportGeneratedEcoreModel(p, null);
        }
        cleanUp();
        EPackage.Registry.INSTANCE.put(p.getNsURI(), p);

        for (String xmlURI : dialog.getFileNames()) {
            xmlURI = str + xmlURI;

            ResourceImpl res = null;
            try {
                String fileType = xmlURI.substring(xmlURI.lastIndexOf(".") + 1);

                res = (ResourceImpl) new XMLResourceFactoryImpl().createResource(URI.createFileURI(xmlURI));

                res.unload();

                HashMap<String, Object> options = new HashMap<String, Object>();
                options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
                options.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

                options.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);

                options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);
                options.put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE);

                options.put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE);

                res.load(options);
            } catch (Exception ex) {
                res = (ResourceImpl) transSys.eResource().getResourceSet()
                        .getResource(URI.createFileURI(xmlURI), true);
                ex.printStackTrace();
            }

            postprocessModel(res.getContents());

            ImportInstanceModelAction action = new ImportInstanceModelAction(null);
            action.setModule(transSys);
            action.createAndAddGraph((ResourceImpl) res, URI.createFileURI(xmlURI));

            action.dispose();
        }

        cleanUp();
        MessageDialog.openInformation(shell, "Importing XML", "XML import finished.");
    } finally {
        shell.close();
    }

    System.out.println("import finished!");
}

From source file:de.tud.cs.st.vespucci.vespucci_model.diagram.part.VespucciDocumentProvider.java

License:Open Source License

/**
 * Checks the given sad file and starts the conversion dialog if an
 * old version is detected.//from ww w  . ja  v  a 2 s. co m
 * 
 * @generated NOT
 * @author Dominic Scheurer
 * @param file
 *            The sad file to check and to update if necessary.
 */
private static void checkConversionNeeded(final IFile file) {
    final String updateQuestionTitle = VESPUCCI_DIAGRAM_MSG_RES_BUNDLE
            .getString("VespucciAutoTransformationTitle");
    final String updateQuestionText = VESPUCCI_DIAGRAM_MSG_RES_BUNDLE
            .getString("VespucciAutoTransformationMessage");

    final VespucciVersionChain versionChain = VespucciVersionChain.getInstance();

    final VespucciVersionTemplate fileVersion = versionChain.getVersionOfFile(file);

    if (!fileVersion.isNewestVersion()
            && MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    updateQuestionTitle, updateQuestionText)) {
        final UpdateSadFileHandler sadUpdater = new UpdateSadFileHandler();
        sadUpdater.execute(file);
    }
}

From source file:de.uniluebeck.itm.spyglass.gui.configuration.PluginPreferencePage.java

License:Open Source License

/**
 * Delete the plugin/*from ww w.  j av a  2  s. c  om*/
 */
private final void performDelete() {
    log.info("Pressed button Delete");

    final boolean ok = MessageDialog.openQuestion(getShell(), "Remove plugin instance",
            "Are you sure you want to remove the plugin instance?");
    if (ok) {
        final boolean ret = spyglass.getPluginManager().removePlugin(this.plugin);
        if (!ret) {
            MessageDialog.openError(this.getShell(), "Cannot delete plugin", "Could not delete the plugin.");
        }
    }
}

From source file:de.uniluebeck.itm.spyglass.io.SpyglassPacketRecorder.java

License:Open Source License

@Override
public void reset() throws IOException {
    log.info("Reset requested");
    skipWaiting.set(true);/*from w w w  .  j  av  a 2 s .c  o m*/

    super.reset();
    synchronized (gatewayMutex) {
        if (isReadFromFile() && !isRecord()) {
            MessageDialog.openInformation(null, "Reset Playbak",
                    "The playback will be started from the beginning of the file.");
        }

        else if (isReadFromFile() && isRecord()) {
            if (MessageDialog.openQuestion(null, "Reset Recorder",
                    "The playback will be started from the beginning of the file.\r\n"
                            + "Do you want to disable recording?")) {
                setRecording(false);
            }
        }

        else if (isRecord()
                && MessageDialog.openQuestion(null, "Reset Recorder", "Do you want to disable recording?")) {
            setRecording(false);
        }

        recModule.reset();

        delayModule.reset();

        gatewayMutex.notifyAll();
        playbackModule.reset();
    }

    log.info("Reset done");
}

From source file:de.uni_hildesheim.sse.easy.ui.reasoner.ReasonerPreferencePage.java

License:Open Source License

/**
 * Performs the upgrade of the selected reasoner.
 *///from   w w w. j a  v a 2 s  .  co m
private void upgrade() {
    ReasonerDescriptor descriptor = getSelected();
    StringBuilder builder = new StringBuilder();
    if (null != descriptor) {
        try {
            ReasoningResult result = frontend.upgradeReasoner(descriptor, new URI(url.getText()),
                    ProgressObserver.NO_OBSERVER);
            if (result.getMessageCount() > 0) {
                for (int m = 0; m < result.getMessageCount(); m++) {
                    if (m > 0) {
                        builder.append("\n");
                    }
                    builder.append(result.getMessage(m).getDescription());
                }
            }
        } catch (URISyntaxException e) {
            builder.append(e.getMessage());
        }
    }

    if (builder.length() > 0) {
        MessageDialog.openError(getShell(), "Problems during upgrade", builder.toString());
    } else {
        if (MessageDialog.openQuestion(getShell(), "Successful",
                "Upgrade complete. Eclipse needs to be restarted. Restart eclipse now?")) {
            PlatformUI.getWorkbench().restart();
        }
    }
}