Package com.lightcrafts.ui.export

Examples of com.lightcrafts.ui.export.SaveOptions


        doc.save(root);

        // Try/catch XML manipulation errors:
        try {
            // The next steps depend on the SaveOptions:
            SaveOptions options = doc.getSaveOptions();

            if (options.isLzn()) {
                // Just write the XML to a file, with a thumbnail and a preview:
                frame.pause();
                saveLzn(doc, xml);
                frame.resume();
            }
            else {
                // We're performing some kind of Engine export:
                Engine engine = doc.getEngine();
                ImageExportOptions export =
                    SaveOptions.getExportOptions(options);

                OtherApplication app = (OtherApplication)doc.getSource();

                // Mangle LZN and add it to the export options as appropriate:
                if (options.isSidecarJpeg() || options.isSidecarTiff()) {
                    if (app instanceof LightroomApplication) {
                        File file = LightroomApplication.getOriginalFile(
                            options.getFile()
                        );
                        mangleLznSidecarFile(xml,file);
                    }
                    addLznMetadata(export, xml);
                }
                else if (options.isMultilayerTiff()) {
                    mangleLznMultilayerTiff(xml);
                    addLznMetadata(export, xml);
                }
                String message = LOCALE.get("SavingMessage");
View Full Code Here


     */
    static void saveLzn(Document doc, XmlDocument xmlDoc) throws IOException {
        Engine engine = doc.getEngine();

        // Fill up the LZN file:
        SaveOptions options = doc.getSaveOptions();
        File file = options.getFile();
        OutputStream out = new FileOutputStream(file);
        xmlDoc.write(out);
        out.close();

        // Add thumbnail data for the browser:
View Full Code Here

                doc = new Document(meta, cancel);
            }
        }
        maybeAddRawAdjustments(doc);

        SaveOptions save = doc.getSaveOptions();

        // Make sure the save options point to the place the file was opened
        // from, in case it was moved since it was written:
        if (save != null) {
            save.setFile(file);
        }
        // Check for the legacy LZN saved document format, and mutate into the
        // current default format if the legacy format was used.
        ImageType type = ImageType.determineTypeByExtensionOf(file);
        boolean recentLzn = ((save != null) && save.isLzn());
        boolean oldLzn = (save == null) && type.equals(LZNImageType.INSTANCE);
        // (Basically, if save == null and it's not an original image.)
        if (recentLzn || oldLzn) {
            // A legacy file: clobber the save options with defaults.
            doc.setSaveOptions(null);
View Full Code Here

                doc = new Document(meta);
            }
        }
        maybeAddRawAdjustments(doc);

        SaveOptions save = doc.getSaveOptions();

        // Make sure the save options point to the place the file was opened
        // from, in case it was moved since it was written:
        if (save != null) {
            save.setFile(file);
        }
        // Check for the legacy LZN saved document format, and mutate into the
        // current default format if the legacy format was used.
        ImageType type = ImageType.determineTypeByExtensionOf(file);
        boolean recentLzn = ((save != null) && save.isLzn());
        boolean oldLzn = (save == null) && type.equals(LZNImageType.INSTANCE);
        // (Basically, if save == null and it's not an original image.)
        if (recentLzn || oldLzn) {
            // A legacy file: clobber the save options with defaults.
            doc.setSaveOptions(null);
View Full Code Here

        final Document doc = frame.getDocument();
        if ( doc == null ) {
            return false;
        }
        boolean saveDirectly = false;
        SaveOptions options = doc.getSaveOptions();
        if (options == null) {
            if (OtherApplicationShim.shouldSaveDirectly(doc)) {
                options = OtherApplicationShim.createExportOptions(doc);
                if (options == null) {
                    // Something went wrong in all the redundant I/O required
                    // by OtherApplication.
                    showError(LOCALE.get("DirectSaveError"), null, frame);
                    return false;
                }
                doc.setSaveOptions(options);
                saveDirectly = true;
            }
            else {
                options = getSaveOptions(doc);

                final FileChooser chooser =
                    Platform.getPlatform().getFileChooser();
                File file = options.getFile();
                file = chooser.saveFile(file, frame);

                if (file == null) {
                    return false;
                }
                options.setFile(file);

                // We've stopped exposing the multilayer TIFF option to users,
                // but the option can slip through via persisted options.
                if (options.isMultilayerTiff()) {
                    // Convert to a single-layer TIFF in this case.
                    final ImageExportOptions export =
                        SaveOptions.getExportOptions(options);
                    options = SaveOptions.createSidecarTiff(export);
                }
                LastSaveOptions = options;
                doc.setSaveOptions(options);
            }
        } else
            saveDirectly = options.shouldSaveDirectly();

        frame.showWait(LOCALE.get("SaveMessage"));

        final boolean isLzn = options.isLzn();
        final File saveFile = options.getFile();

        Throwable error = null;
//        Throwable error = BlockingExecutor.execute(
//            new BlockingExecutor.BlockingRunnable() {
//                public void run() throws IOException {
                    frame.pause();
                    try {
                        TemporaryEditorCommitState state = doc.saveStart();
                        DocumentWriter.save(doc, frame, saveDirectly, null);
                        doc.saveEnd(state);
                        if (!isLzn && OtherApplication.isIntegrationEnabled()) {
                            final OtherApplication app =
                                (OtherApplication)doc.getSource();
                            if (app != null) {
                                app.postSave(
                                    saveFile, saveDirectly, openPending
                                );
                            }
                        }
                    }
                    catch (Exception e) {
                        error = e;
                    }
                    finally {
                        frame.resume();
                    }
//                }
//            }
//        );
        frame.hideWait();

        if (error != null) {
            final File file = options.getFile();
            showError(
                LOCALE.get("SaveError", file.getPath()),
                error, frame
            );
            return false;
        }
        doc.markClean();

        // Don't let synthetic writeback options be persisted:
        if ( saveDirectly ) {
            doc.setSaveOptions(null);
        }
        final File file = options.getFile();
        DocumentDatabase.addDocumentFile(file);

        addToRecentFiles(file);
        savePrefs();
View Full Code Here

                if (template != null) {
                    XmlNode root = template.getRoot();

                    doc.applyTemplate(root);

                    SaveOptions save = doc.getSaveOptions();
                    if (save == null) {
                        save = createTemplateSaveOptions(doc, export, ignoreResize);
                    }
                    doc.setSaveOptions(save);

                    ComboFrame frame = (ComboFrame) Dialog.getOwner();
                    DocumentWriter.save(doc, frame, false, Progress);
                    outFile = save.getFile();
                    outName = outFile.getName();
                    DocumentDatabase.addDocumentFile(outFile);
                } else {
                    conformExportOptions(doc, conf, ignoreResize);
View Full Code Here

        ImageType type = export.getImageType();
        String ext = type.getExtensions()[0];
        file = ExportNameUtility.setFileExtension(file, ext);
        file = ExportNameUtility.ensureNotExists(file);
        if (type == LZNImageType.INSTANCE) {
            SaveOptions options = SaveOptions.createLzn(file);
            return options;
        }
        SaveOptions options;
        Engine engine = doc.getEngine();
        Dimension size = engine.getNaturalSize();

        if (type instanceof TIFFImageType) {
            options = SaveOptions.createSidecarTiff(export);
        }
        else if (type instanceof JPEGImageType) {
            options = SaveOptions.createSidecarJpeg(export);
        }
        else {
            throw new IllegalArgumentException(
                "Can't save to image type \"" + type.getName() + "\""
            );
        }
        if (ignoreResize) {
            export.resizeWidth.setValue(size.width);
            export.resizeHeight.setValue(size.height);
        }
        options.setFile(file);

        return options;
    }
View Full Code Here

    public static SaveResult saveAs(ComboFrame frame) {
        Document doc = frame.getDocument();
        if (doc == null) {
            return SaveResult.DontSave;
        }
        SaveOptions options = getSaveOptions(doc);

        FileChooser chooser = Platform.getPlatform().getFileChooser();
        File file = options.getFile();
        file = chooser.saveFile(file, frame);

        if (file == null) {
            return SaveResult.Cancelled;
        }
        options.setFile(file);

        // We've stopped exposing the multilayer TIFF option to users,
        // but the option can slip through via persisted options.
        if (options.isMultilayerTiff()) {
            // Convert to a single-layer TIFF in this case.
            ImageExportOptions export =
                SaveOptions.getExportOptions(options);
            options = SaveOptions.createSidecarTiff(export);
        }
View Full Code Here

            scales.setScale(s);
        }
    }

    static SaveOptions getSaveOptions(Document doc) {
        SaveOptions options = doc.getSaveOptions();
        if (options == null) {
            ImageMetadata meta = doc.getMetadata();

            Preferences prefs = getPreferences();
            boolean byOriginal = prefs.getBoolean("SaveByOriginal", true);
            File dir;
            if (byOriginal || LastSaveOptions == null) {
                dir = meta.getFile().getParentFile();
            }
            else {
                dir = LastSaveOptions.getFile().getParentFile();
            }
            options = SaveOptions.getDefaultSaveOptions();

            ImageFileExportOptions export =
                (ImageFileExportOptions) SaveOptions.getExportOptions(options);
            ImageType type = export.getImageType();

            File file = new File(dir, meta.getFile().getName());
            String name = ExportNameUtility.getBaseName(file);
            name = name + "_lzn." + type.getExtensions()[0];
            file = new File(name);
            file = ExportNameUtility.ensureNotExists(file);

            // Code for the "actual size" save preference:
            if (export.resizeWidth.getValue() == 0 &&
                export.resizeHeight.getValue() == 0
            ) {
                Engine engine = doc.getEngine();
                Dimension size = engine.getNaturalSize();
                options.updateSize(size);
            }
            options.setFile(file);
        }
        return options;
    }
View Full Code Here

    private SaveResult autoSave() {
        SaveResult result = SaveResult.Saved;
        if (doc != null) {
            if (doc.isDirty()) {
                SaveOptions options = doc.getSaveOptions();
                if (options == null) {
                    if (OtherApplicationShim.shouldSaveDirectly(doc)) {
                        options = OtherApplicationShim.createExportOptions(doc);
                    }
                    else {
                        options = Application.getSaveOptions(doc);
                    }
                }
                Preferences prefs = Preferences.userRoot().node(
                    "/com/lightcrafts/app"
                );
                boolean autoSave = prefs.getBoolean("AutoSave", true);
                if (autoSave) {
                    doc.setSaveOptions(options);
                    result = Application.save(this) ?
                        SaveResult.Saved : SaveResult.CouldntSave;
                }
                else {
                    JLabel prompt = new JLabel(
                        LOCALE.get(
                            "AutoSaveQuestion", options.getFile().getName()
                        )
                    );
                    boolean defaultAutoSave =
                        prefs.getBoolean("DefaultAutoSave", true);
                    JCheckBox check = new JCheckBox(
View Full Code Here

TOP

Related Classes of com.lightcrafts.ui.export.SaveOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.