Package javax.xml.transform.sax

Examples of javax.xml.transform.sax.TransformerHandler


        }

        public TransformerHandler createTasksPageHandler() {
            try {
                URL tasksUrl = new URL(getUrl(), "gantt-tasks.xsl");
                TransformerHandler result = createHandler(tasksUrl.toString());
                return result;
               
            } catch (MalformedURLException e) {
              if (!GPLogger.log(e)) {
                e.printStackTrace(System.err);
View Full Code Here


        }
       
        public TransformerHandler createGanttChartPageHandler() {
            try {
                URL tasksUrl = new URL(getUrl(), "gantt-chart.xsl");
                TransformerHandler result = createHandler(tasksUrl.toString());
                return result;
               
            } catch (MalformedURLException e) {
              if (!GPLogger.log(e)) {
                e.printStackTrace(System.err);
View Full Code Here

            }
        }
        public TransformerHandler createResourcesPageHandler() {
            try {
                URL tasksUrl = new URL(getUrl(), "gantt-resources.xsl");
                TransformerHandler result = createHandler(tasksUrl.toString());
                return result;
               
            } catch (MalformedURLException e) {
              if (!GPLogger.log(e)) {
                e.printStackTrace(System.err);
View Full Code Here

        try {
            AttributesImpl attrs = new AttributesImpl();
            StreamResult result = new StreamResult(stream);
            SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory
                    .newInstance();
            TransformerHandler handler = factory.newTransformerHandler();
            Transformer serializer = handler.getTransformer();
            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.setOutputProperty(OutputKeys.METHOD, "xml");
            serializer.setOutputProperty(
                    "{http://xml.apache.org/xslt}indent-amount", "4");
            handler.setResult(result);
            handler.startDocument();
            addAttribute("name", getProject().getProjectName(), attrs);
            addAttribute("company", getProject().getOrganization(), attrs);
            addAttribute("webLink", getProject().getWebLink(), attrs);
            addAttribute("view-date", new GanttCalendar(area.getViewState()
                    .getStartDate()).toXMLString(), attrs);
            addAttribute("view-index", "" + myUIFacade.getViewIndex(), attrs);
            //TODO for GP 2.0: move view configurations into <view> tag (see ViewSaver)
            addAttribute("gantt-divider-location", ""
                    + myUIFacade.getGanttDividerLocation(), attrs);
            addAttribute("resource-divider-location", ""
                    + myUIFacade.getResourceDividerLocation(), attrs);
            addAttribute("version", VERSION, attrs);
            startElement("project", attrs, handler);
            //
            cdataElement("description", getProject().getDescription(), attrs, handler);
           
            saveViews(handler);
            emptyComment(handler);
            saveCalendar(handler);
            saveTasks(handler);
            saveResources(handler);
            saveAssignments(handler);
            saveVacations(handler);
            saveGanttChartView(handler);
            saveHistory(handler);
            saveRoles(handler);
            endElement("project", handler);
            handler.endDocument();

            stream.close();
        } catch (Throwable e) {
          if (!GPLogger.log(e)) {
            e.printStackTrace(System.err);
View Full Code Here

        return myFactory;
    }

    protected TransformerHandler createHandler(String xsltPath) {
        try {
            TransformerHandler result = getTransformerFactory().newTransformerHandler(new StreamSource(xsltPath));
            Transformer transformer = result.getTransformer();
            transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty(
                    "{http://xml.apache.org/xslt}indent-amount", "4");
            return result;
View Full Code Here

                    Platform.getJobManager().cancel(ExporterBase.EXPORT_JOB_FAMILY);
                    return Status.CANCEL_STATUS;
                }
                try {
                    {
                        TransformerHandler handler = mySelectedStylesheet.createTitlePageHandler();
                        handler.setResult(new StreamResult(outputFile));
                        serialize(handler, outputFile);
                        resultFiles.add(outputFile);
                    }
                    //
                    {
                        TransformerHandler handler = mySelectedStylesheet.createTasksPageHandler();
                        File tasksPageFile = appendSuffixBeforeExtension(outputFile, "-tasks");
                        handler.setResult(new StreamResult(tasksPageFile));
                        serialize(handler, outputFile);
                        resultFiles.add(tasksPageFile);
                    }
                    {
                        TransformerHandler handler = mySelectedStylesheet.createGanttChartPageHandler();
                        File chartPageFile = appendSuffixBeforeExtension(outputFile, "-chart");
                        handler.setResult(new StreamResult(chartPageFile));
                        serialize(handler, outputFile);
                        resultFiles.add(chartPageFile);      
                    }
                    {
                        TransformerHandler handler = mySelectedStylesheet.createResourcesPageHandler();
                        File resourcesPageFile = appendSuffixBeforeExtension(outputFile, "-resources");
                        handler.setResult(new StreamResult(resourcesPageFile));
                        serialize(handler, outputFile);
                        resultFiles.add(resourcesPageFile);           
                       
                    }
                    monitor.worked(1);
View Full Code Here

            this.outputHandler = outputHandler;
        }

        public final ContentHandler createContentHandler() {
            try {
                TransformerHandler handler = saxtf.newTransformerHandler(templates);
                handler.setResult(new SAXResult(outputHandler));
                return handler;
            } catch (TransformerConfigurationException ex) {
                throw new RuntimeException(ex.toString());
            }
        }
View Full Code Here

        try {
            AttributesImpl attrs = new AttributesImpl();
            StreamResult result = new StreamResult(os);
            SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory
                    .newInstance();
            TransformerHandler handler = factory.newTransformerHandler();
            Transformer serializer = handler.getTransformer();
            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.setOutputProperty(
                    "{http://xml.apache.org/xslt}indent-amount", "4");
            handler.setResult(result);
            handler.startDocument();

            handler.endDocument();
            writeTasks();
            os.close();
        } catch (Throwable e) {
          if (!GPLogger.log(e)) {
            e.printStackTrace(System.err);
View Full Code Here

        try {
            AttributesImpl attrs = new AttributesImpl();
            StreamResult result = new StreamResult(os);
            SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory
                    .newInstance();
            TransformerHandler handler = factory.newTransformerHandler();
            Transformer serializer = handler.getTransformer();
            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.setOutputProperty(
                    "{http://xml.apache.org/xslt}indent-amount", "4");
            handler.setResult(result);
            handler.startDocument();

            handler.endDocument();
            writeTasksFromLoaded(tasks);
            os.close();
        } catch (Throwable e) {
          if (!GPLogger.log(e)) {
            e.printStackTrace(System.err);
View Full Code Here

            File file = new File(System.getProperty("user.home")
                    + System.getProperty("file.separator") + sFileName);
            // DataOutputStream fout = new DataOutputStream(new
            // FileOutputStream(file));
            TransformerHandler handler = ((SAXTransformerFactory) SAXTransformerFactory
                    .newInstance()).newTransformerHandler();
            Transformer serializer = handler.getTransformer();
            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.setOutputProperty(
                    "{http://xml.apache.org/xslt}indent-amount", "4");
            handler.setResult(new StreamResult(file));
            handler.startDocument();
            // handler.startDTD("ganttproject.sourceforge.net",
            // "-//GanttProject.org//DTD GanttProject-1.x//EN",
            // "http://ganttproject.sourceforge.net/dtd/ganttproject.dtd");
            // handler.endDTD();
            //
            AttributesImpl attrs = new AttributesImpl();
            handler.startElement("", "ganttproject-options",
                    "ganttproject-options", attrs);
            //
            attrs.addAttribute("", "selection", "selection", "CDATA", language
                    .getText("shortLanguage"));
            handler.startElement("", "language", "language", attrs);
            handler.endElement("", "language", "language");
            attrs.clear();
            // write the task Color
            /*
             * Color color = getUIConfiguration().getTaskColor();
             * attrs.addAttribute("", "red", "red", "CDATA", ""+color.getRed());
             * attrs.addAttribute("", "green", "green", "CDATA",
             * ""+color.getGreen()); attrs.addAttribute("", "blue", "blue",
             * "CDATA", ""+color.getBlue()); handler.startElement("",
             * "task-color", "task-color", attrs); handler.endElement("",
             * "task-color", "task-color"); attrs.clear();
             */

            Color resourceColor = myUIConfig.getResourceColor();
            if (resourceColor != null)
                attrs.addAttribute("", "resources", "resources", "CDATA", ""
                        + ColorConvertion.getColor(resourceColor));
            Color resourceOverloadColor = myUIConfig.getResourceOverloadColor();
            if (resourceOverloadColor != null)
                attrs.addAttribute("", "resourcesOverload",
                        "resourcesOverload", "CDATA", ""
                                + ColorConvertion
                                        .getColor(resourceOverloadColor));
            Color resourceUnderloadColor = myUIConfig
                    .getResourceUnderloadColor();
            if (resourceUnderloadColor != null)
                attrs.addAttribute("", "resourcesUnderload",
                        "resourcesUnderload", "CDATA", ""
                                + ColorConvertion
                                        .getColor(resourceUnderloadColor));
            Color weekEndColor = myUIConfig.getWeekEndColor();
            if (weekEndColor != null)
                attrs.addAttribute("", "weekEnd", "weekEnd", "CDATA", ""
                        + ColorConvertion.getColor(weekEndColor));
            Color daysOffColor = myUIConfig.getDayOffColor();
            if (daysOffColor != null)
                attrs.addAttribute("", "daysOff", "daysOff", "CDATA", ""
                        + ColorConvertion.getColor(daysOffColor));
            handler.startElement("", "colors", "colors", attrs);
            handler.endElement("", "colors", "colors");
            attrs.clear();

            // Geometry of the window
            addAttribute("x", "" + x, attrs);
            addAttribute("y", "" + y, attrs);
            addAttribute("width", "" + width, attrs);
            addAttribute("height", "" + height, attrs);
            emptyElement("geometry", attrs, handler);
            // look'n'feel
            addAttribute("name", lookAndFeel.getName(), attrs);
            addAttribute("class", lookAndFeel.getClassName(), attrs);
            emptyElement("looknfeel", attrs, handler);

            // ToolBar position
            addAttribute("position", "" + toolBarPosition, attrs);
            addAttribute("icon-size", "" + iconSize, attrs);
            addAttribute("show", "" + buttonsshow, attrs);
            emptyElement("toolBar", attrs, handler);
            addAttribute("show", "" + bShowStatusBar, attrs);
            emptyElement("statusBar", attrs, handler);

            // Export options
            addAttribute("name", "" + bExportName, attrs);
            addAttribute("complete", "" + bExportComplete, attrs);
            addAttribute("border3d", "" + bExport3DBorders, attrs);
            addAttribute("relations", "" + bExportRelations, attrs);
            emptyElement("export", attrs, handler);

            // csv export options
            startElement("csv-export", attrs, handler);
            addAttribute("fixed", "" + csvOptions.bFixedSize, attrs);
            addAttribute("separatedChar", "" + csvOptions.sSeparatedChar, attrs);
            addAttribute("separatedTextChar", ""
                    + csvOptions.sSeparatedTextChar, attrs);
            emptyElement("csv-general", attrs, handler);

            addAttribute("id", "" + csvOptions.bExportTaskID, attrs);
            addAttribute("name", "" + csvOptions.bExportTaskName, attrs);
            addAttribute("start-date", "" + csvOptions.bExportTaskStartDate,
                    attrs);
            addAttribute("end-date", "" + csvOptions.bExportTaskEndDate, attrs);
            addAttribute("percent", "" + csvOptions.bExportTaskPercent, attrs);
            addAttribute("duration", "" + csvOptions.bExportTaskDuration, attrs);
            addAttribute("webLink", "" + csvOptions.bExportTaskWebLink, attrs);
            addAttribute("resources", "" + csvOptions.bExportTaskResources,
                    attrs);
            addAttribute("notes", "" + csvOptions.bExportTaskNotes, attrs);
            emptyElement("csv-tasks", attrs, handler);

            addAttribute("id", "" + csvOptions.bExportResourceID, attrs);
            addAttribute("name", "" + csvOptions.bExportResourceName, attrs);
            addAttribute("mail", "" + csvOptions.bExportResourceMail, attrs);
            addAttribute("phone", "" + csvOptions.bExportResourcePhone, attrs);
            addAttribute("role", "" + csvOptions.bExportResourceRole, attrs);
            emptyElement("csv-resources", attrs, handler);

            endElement("csv-export", handler);

            // automatic popup launch
            addAttribute("value", "" + automatic, attrs);
            emptyElement("automatic-launch", attrs, handler);
            // automaticdrag time on the chart
            // addAttribute("value", ""+dragTime, attrs);
            emptyElement("dragTime", attrs, handler);
            // automatic tips of the day launch
            addAttribute("value", "" + openTips, attrs);
            emptyElement("tips-on-startup", attrs, handler);
            // Should WebDAV resources be locked, when opening them?
            addAttribute("value", "" + lockDAVMinutes, attrs);
            emptyElement("lockdavminutes", attrs, handler);
            // write the xsl directory
            addAttribute("dir", xslDir, attrs);
            emptyElement("xsl-dir", attrs, handler);
            // write the xslfo directory
            addAttribute("file", xslFo, attrs);
            emptyElement("xsl-fo", attrs, handler);
            // write the working directory directory
            addAttribute("dir", workingDir, attrs);
            emptyElement("working-dir", attrs, handler);
            // write the task name prefix
            addAttribute("prefix", sTaskNamePrefix, attrs);
            emptyElement("task-name", attrs, handler);
            // The last opened files
            {
                startElement("files", attrs, handler);
                for (Iterator iterator = documentsMRU.iterator(); iterator
                        .hasNext();) {
                    Document document = (Document) iterator.next();
                    addAttribute("path", document.getPath(), attrs);
                    emptyElement("file", attrs, handler);
                }
                endElement("files", handler);
            }
            addAttribute("category", "menu", attrs);
            addAttribute("spec",
                    getFontSpec(getUIConfiguration().getMenuFont()), attrs);
            emptyElement("font", attrs, handler);
            //
            addAttribute("category", "chart-main", attrs);
            addAttribute("spec", getFontSpec(getUIConfiguration()
                    .getChartMainFont()), attrs);
            emptyElement("font", attrs, handler);
            //

            saveIconPositions(handler);
            saveRoleSets(handler);
            for (Iterator options = myGPOptions.entrySet().iterator(); options.hasNext();) {
                Map.Entry nextEntry = (Entry) options.next();
                GPOption nextOption = (GPOption)nextEntry.getValue();
                if (nextOption.getPersistentValue()!=null) {
                    addAttribute("id", nextEntry.getKey().toString(), attrs);
                    addAttribute("value", nextOption.getPersistentValue(), attrs);
                    emptyElement("option", attrs, handler);
                }
            }
            endElement("ganttproject-options", handler);
            //
            GPLogger.log("[GanttOptions] save(): finished!!");
            handler.endDocument();
        } catch (Exception e) {
          if (!GPLogger.log(e)) {
            e.printStackTrace(System.err);
          }
        }
View Full Code Here

TOP

Related Classes of javax.xml.transform.sax.TransformerHandler

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.