Search in sources :

Example 6 with YesNoDialog

use of ini.trakem2.display.YesNoDialog in project TrakEM2 by trakem2.

the class Project method saveTask.

public Bureaucrat saveTask(final String command) {
    return Bureaucrat.createAndStart(new Worker.Task("Saving") {

        public void exec() {
            if (command.equals("Save")) {
                save();
            } else if (command.equals("Save as...")) {
                XMLOptions options = new XMLOptions();
                options.overwriteXMLFile = false;
                options.export_images = false;
                options.include_coordinate_transform = true;
                options.patches_dir = null;
                // Will open a file dialog
                loader.saveAs(project, options);
                restartAutosaving();
            // 
            } else if (command.equals("Save as... without coordinate transforms")) {
                YesNoDialog yn = new YesNoDialog("WARNING", "You are about to save an XML file that lacks the information for the coordinate transforms of each image.\n" + "These transforms are referred to with the attribute 'ct_id' of each 't2_patch' entry in the XML document,\n" + "and the data for the transform is stored in an individual file under the folder 'trakem2.cts/'.\n" + " \n" + "It is advised to keep a complete XML file with all coordinate transforms included along with this new copy.\n" + "Please check NOW that you have such a complete XML copy.\n" + " \n" + "Proceed?");
                if (!yn.yesPressed())
                    return;
                saveWithoutCoordinateTransforms();
            // 
            } else if (command.equals("Delete stale files...")) {
                setTaskName("Deleting stale files");
                GenericDialog gd = new GenericDialog("Delete stale files");
                gd.addMessage("You are about to remove all files under the folder 'trakem2.cts/' which are not referred to from the\n" + "currently loaded project. If you have sibling XML files whose 't2_patch' entries (the images) refer,\n" + "via 'ct_id' attributes, to coordinate transforms in 'trakem2.cts/' that this current XML doesn't,\n" + "they may be LOST FOREVER. Unless you have a version of the XML file with the coordinate transforms\n" + "written in it, as can be obtained by using the 'Project - Save' command.\n" + " \n" + "The same is true for the .zip files that store alpha masks, under folder 'trakem2.masks/'\n" + "and which are referred to from the 'alpha_mask_id' attribute of 't2_patch' entries.\n" + " \n" + "Do you have such complete XML file? Check *NOW*.\n" + " \n" + "Proceed with deleting:");
                gd.addCheckbox("Delete stale coordinate transform files", true);
                gd.addCheckbox("Delete stale alpha mask files", true);
                gd.showDialog();
                if (gd.wasCanceled())
                    return;
                project.getLoader().deleteStaleFiles(gd.getNextBoolean(), gd.getNextBoolean());
            }
        }
    }, project);
}
Also used : YesNoDialog(ini.trakem2.display.YesNoDialog) GenericDialog(ij.gui.GenericDialog) Worker(ini.trakem2.utils.Worker) XMLOptions(ini.trakem2.persistence.XMLOptions)

Example 7 with YesNoDialog

use of ini.trakem2.display.YesNoDialog in project TrakEM2 by trakem2.

the class Project method destroy.

public boolean destroy() {
    if (null == loader) {
        return true;
    }
    if (loader.hasChanges() && !getBooleanProperty("no_shutdown_hook")) {
        // DBLoader always returns false
        if (ControlWindow.isGUIEnabled()) {
            final YesNoDialog yn = ControlWindow.makeYesNoDialog("TrakEM2", "There are unsaved changes in project " + title + ". Save them?");
            if (yn.yesPressed()) {
                save();
            }
        } else {
            Utils.log2("WARNING: closing project '" + title + "' with unsaved changes.");
        }
    }
    try {
        if (null != autosaving)
            autosaving.cancel(true);
    } catch (Throwable t) {
    }
    al_open_projects.remove(this);
    // flush all memory
    if (null != loader) {
        // the last project is destroyed twice for some reason, if several are open. This is a PATCH
        // and disconnect
        loader.destroy();
        loader = null;
    }
    if (null != layer_set)
        layer_set.destroy();
    // AFTER loader.destroy() call.
    ControlWindow.remove(this);
    if (null != template_tree)
        template_tree.destroy();
    if (null != project_tree)
        project_tree.destroy();
    if (null != layer_tree)
        layer_tree.destroy();
    Polyline.flushTraceCache(this);
    // flag to mean: we're closing
    this.template_tree = null;
    // close all open Displays
    Display.close(this);
    Search.removeTabs(this);
    synchronized (ptcache) {
        ptcache.clear();
    }
    return true;
}
Also used : YesNoDialog(ini.trakem2.display.YesNoDialog)

Aggregations

YesNoDialog (ini.trakem2.display.YesNoDialog)6 GenericDialog (ij.gui.GenericDialog)4 ImagePlus (ij.ImagePlus)3 Worker (ini.trakem2.utils.Worker)3 File (java.io.File)3 YesNoCancelDialog (ij.gui.YesNoCancelDialog)2 FileInfo (ij.io.FileInfo)2 OpenDialog (ij.io.OpenDialog)2 Patch (ini.trakem2.display.Patch)2 HashSet (java.util.HashSet)2 AmiraMeshDecoder (amira.AmiraMeshDecoder)1 ImageStack (ij.ImageStack)1 VirtualStack (ij.VirtualStack)1 PolygonRoi (ij.gui.PolygonRoi)1 Roi (ij.gui.Roi)1 ShapeRoi (ij.gui.ShapeRoi)1 DirectoryChooser (ij.io.DirectoryChooser)1 SaveDialog (ij.io.SaveDialog)1 Project (ini.trakem2.Project)1 AreaList (ini.trakem2.display.AreaList)1