Package com.lightcrafts.utils.xml

Examples of com.lightcrafts.utils.xml.XmlDocument


        }
        // Loop until a unique name is selected or the dialog is cancelled:
        boolean done = false;
        TemplateKey key;
        do {
            XmlDocument xml = new XmlDocument("Template")// See Document()
            XmlNode root = xml.getRoot();
            doc.saveTemplate(root);

            SaveTemplateDialog dialog = new SaveTemplateDialog();
            ImageMetadata meta = doc.getMetadata();
            key = dialog.showDialog(meta, xml, namespace, frame);
            if (key == null) {
                // Dialog was disposed, or the user cancelled.
                return null;
            }
            // First check if a template with this name already exists:
            XmlDocument conflict = null;
            try {
                conflict = TemplateDatabase.getTemplateDocument(key);
            }
            catch (TemplateDatabase.TemplateException e) {
                // Interpret as no preexisting template with this name.
View Full Code Here


        Document doc = frame.getDocument();
        if (doc == null) {
            return;
        }
        try {
            XmlDocument template = TemplateDatabase.getTemplateDocument(key);
            if (template != null) {
                XmlNode root = template.getRoot();
                doc.applyTemplate(root);
            }
            else {
                showError(
                    LOCALE.get("TemplateNameError", key.toString()), null, frame
View Full Code Here

     * Apply the named template from TemplateDocuments to the File[].
     */
    public static void applyTemplate(
        ComboFrame frame, File[] files, TemplateKey key
    ) {
        XmlDocument template;
        try {
            template = TemplateDatabase.getTemplateDocument(key);
        }
        catch (TemplateDatabase.TemplateException e) {
            showError(
View Full Code Here

        conf.name = "";
        conf.export = (ImageFileExportOptions)
            SaveOptions.getExportOptions(SaveOptions.getDefaultSaveOptions());

        try {
            XmlDocument template = interp.xml;
            BatchProcessor.process(frame, files, template, conf);
        }
        catch (RuntimeException e) {
            showError(
                "An error occurred during batch processing.", e, frame
View Full Code Here

        if (LastSaveOptions != null) {
            // We're remembering the whole SaveOptions object, but
            // SaveOptions.getDefaultSaveOptions() is the authoritative
            // reposity for sticky options.  The LastSaveOptions is only
            // used to remember the recent folder.
            XmlDocument doc = new XmlDocument(SaveTag);
            LastSaveOptions.save(doc.getRoot());
            saveXmlPrefs(SaveTag, doc);
        }
        if (LastPrintLayout != null) {
            XmlDocument doc = new XmlDocument(PrintTag);
            LastPrintLayout.save(doc.getRoot());
            saveXmlPrefs(PrintTag, doc);
        }
        if (LastExportOptions != null) {
            XmlDocument doc = new XmlDocument(ExportTag);
            LastExportOptions.write(doc.getRoot());
            saveXmlPrefs(ExportTag, doc);
        }
        try {
            prefs.sync();
        }
View Full Code Here

            path = prefs.get(OpenTag, null);
            if (path != null) {
                LastOpenPath = new File(path);
            }
            // Restore default save options:
            XmlDocument doc;
            doc = restoreXmlPrefs(SaveTag);
            if (doc != null) {
                try {
                    LastSaveOptions = SaveOptions.restore(doc.getRoot());
                }
                catch (XMLException e) {
                    System.err.println(
                        "Malformed save preferences: " + e.getMessage()
                    );
                    LastSaveOptions = null;
                }
            }
            // Restore default print settings:
            doc = restoreXmlPrefs(PrintTag);
            if (doc != null) {
                try {
                    LastPrintLayout = new PrintLayoutModel(0, 0);
                    LastPrintLayout.restore(doc.getRoot());
                }
                catch (XMLException e) {
                    System.err.println(
                        "Malformed print preferences: " + e.getMessage()
                    );
                    LastPrintLayout = null;
                }
            }
            // Restore default export options:
            doc = restoreXmlPrefs(ExportTag);
            if (doc != null) {
                try {
                    LastExportOptions = ImageExportOptions.read(doc.getRoot());
                }
                catch (XMLException e) {
                    System.err.println(
                        "Malformed export preferences: " + e.getMessage()
                    );
View Full Code Here

        if (text != null) {
            try {
                InputStream in = new ByteArrayInputStream(
                    text.getBytes("UTF-8")
                );
                XmlDocument doc = new XmlDocument(in);
                return doc;
            }
            catch (Exception e) {   // IOException, XMLException
                System.err.print("Error reading preferences: ");
                System.err.print(e.getClass().getName() + " ");
View Full Code Here

        }

        try {
            final Document lznDoc = getLZNDocumentImpl( imageInfo );
            if ( lznDoc != null ) {
                final XmlDocument xmlDoc =
                    new XmlDocument( lznDoc.getDocumentElement() );
                // The original image may be in the same file,
                // or referenced through a path pointer:
                final XmlNode root = xmlDoc.getRoot();
                // (tag copied from ui.editor.Document)
                final XmlNode imageNode = root.getChild( "Image" );
                // (tag written in export())
                if ( imageNode.hasAttribute( "self" ) )
                    return MultipageTIFFImageType.INSTANCE;
View Full Code Here

    public static boolean save(
        Document doc, ComboFrame frame, boolean saveDirectly,
        ProgressThread progress
    ) throws IOException {
        // Construct the LZN data that encode the Document's state:
        XmlDocument xml = new XmlDocument(
            Application.LznNamespace, "LightZoneTransform"
        );
        XmlNode root = xml.getRoot();
        doc.save(root);

        // Try/catch XML manipulation errors:
        try {
            // The next steps depend on the SaveOptions:
View Full Code Here

            LOCALE.get("RememberPresetMenuItem")
        );
        savePreset.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    XmlDocument preset = new XmlDocument("Preset");
                    control.save(preset.getRoot());
                    writePreset(preset);
                }
            }
        );
        menu.add(savePreset, 4);

        JMenuItem applyPreset = new JMenuItem(
            LOCALE.get("ApplyPresetMenuItem")
        );
        final XmlDocument preset = readPreset();
        applyPreset.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    try {
                        // Like control.restore(), but with undo:
                        control.restorePresets(preset.getRoot());
                    }
                    catch (XMLException e) {
                        // No way to back out of this, so leave things as
                        // they are and hope the user can recover.
                        System.err.println(
View Full Code Here

TOP

Related Classes of com.lightcrafts.utils.xml.XmlDocument

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.