--- /dev/null
+<?xml version="1.0"?>
+<!-- ======================================================================
+ 05/2007
+
+ FO parameter editor
+ version 1.0
+
+ ====================================================================== -->
+<project name="editor" default="dist">
+ <description>
+ Create distribution for FO parameter editor.
+ </description>
+
+ <!-- set global properties for this build -->
+ <property name="src" location="src"/>
+ <property name="build" location="build"/>
+ <property name="dist" location="dist"/>
+ <property name="dist-pack" location="dist-pack"/>
+ <property name="resources" value="resources"/>
+ <property name="lib" value="lib"/>
+
+ <property name="params" value="docbook-params"/>
+ <property name="config" value="configuration"/>
+ <property name="schemas" value="schemas"/>
+ <property name="script" value="scripts"/>
+ <property name="template" value="templates"/>
+ <property name="doc" value="doc"/>
+
+ <!-- name of the application -->
+ <property name="name" value="FOeditor"/>
+ <!-- version of the application -->
+ <property name="version" value="1_0"/>
+
+ <property name="main" value="cz.zcu.fav.kiv.editor.controller.MainController"/>
+
+ <target name="init_dist" description="Initialize distribution">
+ <delete dir="${dist}"/>
+ <mkdir dir="${dist}"/>
+ </target>
+
+ <target name="init_compile" description="Initialize compilation">
+ <delete dir="${build}"/>
+ <mkdir dir="${build}"/>
+ </target>
+
+ <target name="copy_resources" description="Copy resources">
+ <copy todir="${build}">
+ <fileset dir="${src}">
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="compile" depends="init_compile, copy_resources"
+ description="Compile the source" >
+ <!-- Compile the java code from ${src} into ${build} -->
+ <javac srcdir="${src}" destdir="${build}" debug="on">
+ <classpath>
+ <fileset dir="${lib}">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="copy_config" depends="init_dist" description="Copy configuration files">
+ <mkdir dir="${dist}/${config}"/>
+ <copy todir="${dist}/${config}">
+ <fileset dir="${config}"/>
+ </copy>
+ <copy todir="${dist}/${template}">
+ <fileset dir="${template}"/>
+ </copy>
+ <mkdir dir="${params}"/>
+ <copy todir="${dist}/${params}">
+ <fileset dir="${params}"/>
+ </copy>
+ </target>
+
+ <target name="dist" depends="compile, copy_config"
+ description="Generate the distribution" >
+ <copy todir="${dist}">
+ <fileset dir="${script}"/>
+ </copy>
+ <jar jarfile="${dist}/${name}.jar" basedir="${build}">
+ <manifest>
+ <attribute name="Main-Class" value="${main}"/>
+ <attribute name="Class-Path" value="log4j-1.2.14.jar" />
+ </manifest>
+ <zipfileset src="${lib}/log4j-1.2.14.jar"/>
+ <zipfileset src="${lib}/jh.jar"/>
+ <zipfileset src="${lib}/help.jar"/>
+ </jar>
+ </target>
+
+ <target name="dist_zip" depends="dist"
+ description="Generate and pack the distribution" >
+ <delete dir="${dist-pack}"/>
+ <mkdir dir="${dist-pack}"/>
+ <zip destfile="${dist-pack}/${name}-${version}.zip"
+ basedir="${dist}"
+ update="true"
+ />
+ </target>
+
+ <target name="javadoc" description="Generate javadoc" >
+ <delete dir="${doc}"/>
+ <mkdir dir="${doc}"/>
+ <javadoc
+ destdir="doc"
+ author="true"
+ version="true"
+ use="true"
+ windowtitle="FO Parameter Editor API">
+ <packageset dir="src"/>
+ <classpath>
+ <fileset dir="${lib}">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </javadoc>
+ </target>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="windows-1250"?>\r
+<attributes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> \r
+ <group name="Space-before">\r
+ <attribute type="length" default="0pt">space-before</attribute> \r
+ <attribute type="length" default="0pt">space-before.optimum</attribute> \r
+ <attribute type="length" default="0pt">space-before.minimum</attribute>\r
+ <attribute type="length" default="0pt">space-before.maximum</attribute> \r
+ </group>\r
+\r
+ <group name="Space-after"> \r
+ <attribute type="length" default="0pt">space-after</attribute> \r
+ <attribute type="length" default="0pt">space-after.optimum</attribute> \r
+ <attribute type="length" default="0pt">space-after.minimum</attribute>\r
+ <attribute type="length" default="0pt">space-after.maximum</attribute> \r
+ </group>\r
+\r
+ <group name="Paragraph"> \r
+ <attribute type="length" default="0pt">start-indent</attribute> \r
+ <attribute type="length" default="0pt">end-indent</attribute> \r
+ <attribute type="length" default="0pt">line-height</attribute>\r
+ <attribute type="list" default="true" values="false,true">hyphenate</attribute> \r
+ <attribute type="list" default="left" values="justify,center,left,right,start,end">text-align</attribute> \r
+ </group>\r
+ \r
+ <group name="Font"> \r
+ <attribute type="font" default="serif">font-family</attribute> \r
+ <attribute type="list" default="normal" values="normal,bold,bolder,lighter,100,200,300,400,500,600,700,800,900">font-weight</attribute>\r
+ <attribute type="length" default="10pt">font-size</attribute> \r
+ <attribute type="list" default="normal" values="normal,italic,oblique">font-style</attribute> \r
+ </group> \r
+ \r
+ \r
+ <group name="Margin">\r
+ <attribute type="length" default="0pt">margin</attribute>\r
+ <attribute type="length" default="0pt">margin-left</attribute>\r
+ <attribute type="length" default="0pt">margin-right</attribute>\r
+ <attribute type="length" default="0pt">margin-bottom</attribute>\r
+ <attribute type="length" default="0pt">margin-top</attribute> \r
+ </group>\r
+\r
+ <group name="Padding"> \r
+ <attribute type="length" default="0pt">padding</attribute>\r
+ <attribute type="length" default="0pt">padding-left</attribute>\r
+ <attribute type="length" default="0pt">padding-right</attribute>\r
+ <attribute type="length" default="0pt">padding-bottom</attribute>\r
+ <attribute type="length" default="0pt">padding-top</attribute> \r
+ </group> \r
+ \r
+ <group name="Tables"> \r
+ <attribute type="length" default="0pt">width</attribute>\r
+ <attribute type="length" default="0pt">border-width</attribute>\r
+ <attribute type="color" default="black">border-color</attribute>\r
+ <attribute type="list" default="solid" values="none,solid,dotted,dashed,double,groove,ridge,inset,outset">border-style</attribute> \r
+ <attribute type="list" default="collapse" values="collapse,collapse-with-precedence,separate">border-collapse</attribute>\r
+ <attribute type="list" default="auto" values="auto,fixed">table-layout</attribute> \r
+ </group>\r
+ \r
+ <group name="Keep-with-next">\r
+ <attribute type="list" default="always" values="auto, always">keep-with-next.within-column</attribute> \r
+ <attribute type="list" default="always" values="auto, always">keep-with-next.within-line</attribute> \r
+ <attribute type="list" default="always" values="auto, always">keep-with-next.within-page</attribute>\r
+ <attribute type="list" default="no-wrap" values="no-wrap,wrap">wrap-option</attribute> \r
+ </group>\r
+\r
+ <group name="Colors">\r
+ <attribute type="color" default="black">color</attribute>\r
+ <attribute type="color" default="black">background-color</attribute> \r
+ </group>\r
+ \r
+</attributes>\r
+\r
--- /dev/null
+<?xml version='1.0' encoding='utf-8'?>\r
+<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <section name="Page Layout">\r
+ <subsection name="Paper Format">\r
+ <group> \r
+ <parameter>paper.type</parameter>\r
+ <parameter>page.orientation</parameter>\r
+ <parameter>double.sided</parameter>\r
+ <parameter>toc.html</parameter>\r
+ </group>\r
+ <group name="Paper size" graphics="page-format">\r
+ <parameter>page.width</parameter>\r
+ <parameter>page.height</parameter>\r
+ <parameter>page.width.portrait</parameter>\r
+ <parameter>page.height.portrait</parameter>\r
+ </group>\r
+ <group name="Margins">\r
+ <parameter>page.margin.inner</parameter>\r
+ <parameter>page.margin.outer</parameter> \r
+ <parameter>page.margin.top</parameter> \r
+ <parameter>page.margin.bottom</parameter> \r
+ <parameter>body.margin.top</parameter> \r
+ <parameter>body.margin.bottom</parameter> \r
+ <parameter>region.before.extent</parameter> \r
+ <parameter>region.after.extent</parameter> \r
+ </group> \r
+ </subsection>\r
+ <subsection name="Page Body">\r
+ <group name="Body indent">\r
+ <parameter>body.start.indent</parameter>\r
+ <parameter>body.end.indent</parameter>\r
+ </group> \r
+ <group name ="Paragraph">\r
+ <parameter>line-height</parameter>\r
+ <parameter>alignment</parameter>\r
+ <parameter>hyphenate</parameter>\r
+ <attribute-set>normal.para.spacing</attribute-set>\r
+ </group> \r
+ <group name ="Characters">\r
+ <attribute-set>superscript.properties</attribute-set>\r
+ <attribute-set>subscript.properties</attribute-set> \r
+ </group> \r
+ </subsection>\r
+ <subsection name="Header/Footer">\r
+ <group>\r
+ <parameter>marker.section.level</parameter>\r
+ </group> \r
+ <group name ="Header">\r
+ <parameter>headers.on.blank.pages</parameter>\r
+ <parameter>header.rule</parameter>\r
+ <parameter>header.column.widths</parameter>\r
+ <parameter>header.table.height</parameter> \r
+ <attribute-set>header.content.properties</attribute-set>\r
+ </group>\r
+ <group name ="Footer"> \r
+ <parameter>footers.on.blank.pages</parameter> \r
+ <parameter>footer.rule</parameter> \r
+ <parameter>footer.column.widths</parameter> \r
+ <parameter>footer.table.height</parameter> \r
+ <attribute-set>footer.content.properties</attribute-set>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Fonts">\r
+ <group name ="Font family">\r
+ <parameter>body.font.family</parameter>\r
+ <parameter>title.font.family</parameter>\r
+ <parameter>monospace.font.family</parameter>\r
+ <parameter>dingbat.font.family</parameter>\r
+ <parameter>sans.font.family</parameter>\r
+ <parameter>symbol.font.family</parameter>\r
+ </group>\r
+ <group name ="Font size"> \r
+ <parameter>body.font.master</parameter>\r
+ <parameter>body.font.size</parameter>\r
+ <parameter>footnote.font.size</parameter> \r
+ </group>\r
+ <group name ="Font properties"> \r
+ <attribute-set>monospace.properties</attribute-set>\r
+ <attribute-set>verbatim.properties</attribute-set> \r
+ </group> \r
+ </subsection> \r
+ <subsection name="Lists">\r
+ <group>\r
+ <attribute-set>list.block.properties</attribute-set> \r
+ </group> \r
+ <group name ="List spacing">\r
+ <attribute-set>list.block.spacing</attribute-set> \r
+ <attribute-set>list.item.spacing</attribute-set>\r
+ <attribute-set>compact.list.item.spacing</attribute-set> \r
+ </group> \r
+ <group name ="Variablelist">\r
+ <parameter>variablelist.max.termlength</parameter>\r
+ <parameter>variablelist.as.blocks</parameter>\r
+ <parameter>variablelist.term.separator</parameter>\r
+ <parameter>variablelist.term.break.after</parameter>\r
+ </group> \r
+ <group name ="Itemizedlist">\r
+ <parameter>itemizedlist.label.width</parameter>\r
+ <attribute-set>itemizedlist.properties</attribute-set> \r
+ <attribute-set>itemizedlist.label.properties</attribute-set> \r
+ </group> \r
+ <group name ="Orderedlist">\r
+ <parameter>orderedlist.label.width</parameter>\r
+ <attribute-set>orderedlist.properties</attribute-set> \r
+ <attribute-set>orderedlist.label.properties</attribute-set> \r
+ </group> \r
+ <group name ="Segmentedlist">\r
+ <parameter>segmentedlist.as.table</parameter>\r
+ </group>\r
+ </subsection> \r
+ <subsection name="Columns">\r
+ <group name ="Column count">\r
+ <parameter>column.count.back</parameter>\r
+ <parameter>column.count.body</parameter>\r
+ <parameter>column.count.front</parameter>\r
+ <parameter>column.count.index</parameter>\r
+ <parameter>column.count.lot</parameter>\r
+ <parameter>column.count.titlepage</parameter>\r
+ </group>\r
+ <group name ="Column gap">\r
+ <parameter>column.gap.back</parameter>\r
+ <parameter>column.gap.body</parameter>\r
+ <parameter>column.gap.front</parameter>\r
+ <parameter>column.gap.index</parameter>\r
+ <parameter>column.gap.lot</parameter>\r
+ <parameter>column.gap.titlepage</parameter>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Chapter and Section Numbering">\r
+ <group>\r
+ <parameter>chapter.autolabel</parameter>\r
+ <parameter>appendix.autolabel</parameter>\r
+ <parameter>preface.autolabel</parameter>\r
+ <parameter>reference.autolabel</parameter>\r
+ </group>\r
+ <group name ="Part numbering"> \r
+ <parameter>part.autolabel</parameter>\r
+ <parameter>label.from.part</parameter>\r
+ <parameter>component.label.includes.part.label</parameter> \r
+ </group>\r
+ <group name ="Section numbering">\r
+ <parameter>section.autolabel</parameter>\r
+ <parameter>section.label.includes.component.label</parameter> \r
+ <parameter>section.autolabel.max.depth</parameter> \r
+ </group> \r
+ </subsection>\r
+ <subsection name="Titles"> \r
+ <group>\r
+ <parameter>title.margin.left</parameter>\r
+ </group> \r
+ <group name ="Title placement"> \r
+ <parameter>formal.title.placement</parameter> \r
+ </group> \r
+ <group name ="Title properties"> \r
+ <attribute-set>component.title.properties</attribute-set>\r
+ <attribute-set>formal.title.properties</attribute-set>\r
+ <attribute-set>article.appendix.title.properties</attribute-set>\r
+ </group> \r
+ </subsection> \r
+ </section>\r
+ \r
+ <section name="Document Segments">\r
+ <subsection name="Page Objects">\r
+ <group>\r
+ <attribute-set>pgwide.properties</attribute-set> \r
+ </group> \r
+ <group name ="Object">\r
+ <attribute-set>formal.object.properties</attribute-set>\r
+ <attribute-set>informal.object.properties</attribute-set> \r
+ </group> \r
+ <group name ="Figure">\r
+ <attribute-set>figure.properties</attribute-set> \r
+ <attribute-set>informalfigure.properties</attribute-set>\r
+ </group>\r
+ <group name ="Example"> \r
+ <attribute-set>example.properties</attribute-set> \r
+ <attribute-set>informalexample.properties</attribute-set>\r
+ </group>\r
+ <group name ="Abstract">\r
+ <attribute-set>abstract.properties</attribute-set>\r
+ <attribute-set>abstract.title.properties</attribute-set>\r
+ </group>\r
+ <group name ="Block quotations">\r
+ <attribute-set>blockquote.properties</attribute-set> \r
+ </group> \r
+ <group name ="Revhistory">\r
+ <attribute-set>revhistory.table.properties</attribute-set>\r
+ <attribute-set>revhistory.table.cell.properties</attribute-set> \r
+ <attribute-set>revhistory.title.properties</attribute-set> \r
+ </group> \r
+ </subsection> \r
+ <subsection name ="Admonition">\r
+ <group name ="Text admonition">\r
+ <parameter>admon.textlabel</parameter>\r
+ <attribute-set>admonition.title.properties</attribute-set>\r
+ <attribute-set>admonition.properties</attribute-set>\r
+ <attribute-set>nongraphical.admonition.properties</attribute-set>\r
+ </group>\r
+ <group name ="Graphics admonition">\r
+ <parameter>admon.graphics</parameter>\r
+ <parameter>admon.graphics.path</parameter>\r
+ <parameter>admon.graphics.extension</parameter>\r
+ <attribute-set>graphical.admonition.properties</attribute-set>\r
+ </group> \r
+ </subsection> \r
+ <subsection name ="Callouts">\r
+ <group>\r
+ <parameter>callout.defaultcolumn</parameter>\r
+ <parameter>callouts.extension</parameter>\r
+ </group> \r
+ <group name ="Callout icons">\r
+ <parameter>callout.graphics</parameter> \r
+ <parameter>callout.graphics.path</parameter>\r
+ <parameter>callout.graphics.extension</parameter>\r
+ <parameter>callout.graphics.number.limit</parameter>\r
+ </group>\r
+ <group name ="Unicode characters">\r
+ <parameter>callout.unicode</parameter> \r
+ <parameter>callout.unicode.font</parameter>\r
+ <parameter>callout.unicode.number.limit</parameter>\r
+ <parameter>callout.unicode.start.character</parameter>\r
+ </group> \r
+ </subsection>\r
+ <subsection name ="Side Floats">\r
+ <group name ="Sidebars">\r
+ <attribute-set>sidebar.properties</attribute-set>\r
+ <attribute-set>sidebar.title.properties</attribute-set> \r
+ <parameter>sidebar.float.type</parameter>\r
+ <parameter>sidebar.float.width</parameter> \r
+ </group> \r
+ <group name ="Margin notes">\r
+ <attribute-set>margin.note.properties</attribute-set>\r
+ <attribute-set>margin.note.title.properties</attribute-set> \r
+ <parameter>margin.note.float.type</parameter>\r
+ <parameter>margin.note.width</parameter> \r
+ </group> \r
+ </subsection> \r
+ <subsection name ="Sections"> \r
+ <group name ="Section title">\r
+ <attribute-set>section.title.properties</attribute-set>\r
+ <attribute-set>section.title.level1.properties</attribute-set> \r
+ <attribute-set>section.title.level2.properties</attribute-set>\r
+ <attribute-set>section.title.level3.properties</attribute-set> \r
+ <attribute-set>section.title.level4.properties</attribute-set>\r
+ <attribute-set>section.title.level5.properties</attribute-set>\r
+ <attribute-set>section.title.level6.properties</attribute-set>\r
+ </group>\r
+ <group name ="Section"> \r
+ <attribute-set>section.properties</attribute-set>\r
+ <attribute-set>section.level1.properties</attribute-set>\r
+ <attribute-set>section.level2.properties</attribute-set>\r
+ <attribute-set>section.level3.properties</attribute-set>\r
+ <attribute-set>section.level4.properties</attribute-set>\r
+ <attribute-set>section.level5.properties</attribute-set>\r
+ <attribute-set>section.level6.properties</attribute-set>\r
+ </group>\r
+ </subsection>\r
+ <subsection name="Tables">\r
+ <group> \r
+ <attribute-set>table.table.properties</attribute-set> \r
+ <attribute-set>table.properties</attribute-set>\r
+ <attribute-set>informaltable.properties</attribute-set> \r
+ </group> \r
+ <group name ="Table width">\r
+ <parameter>default.table.width</parameter>\r
+ <parameter>nominal.table.width</parameter>\r
+ </group>\r
+ <group name ="Table frame borders">\r
+ <parameter>table.frame.border.thickness</parameter>\r
+ <parameter>table.frame.border.style</parameter>\r
+ <parameter>table.frame.border.color</parameter>\r
+ </group>\r
+ <group name ="Table cells">\r
+ <parameter>table.cell.border.thickness</parameter>\r
+ <parameter>table.cell.border.style</parameter> \r
+ <parameter>table.cell.border.color</parameter> \r
+ <attribute-set>table.cell.padding</attribute-set> \r
+ </group> \r
+ </subsection> \r
+ <subsection name ="Tables of Contents">\r
+ <group>\r
+ <parameter>generate.toc</parameter>\r
+ <parameter>autotoc.label.separator</parameter>\r
+ <attribute-set>toc.line.properties</attribute-set>\r
+ </group>\r
+ <group name ="Depth of ToC"> \r
+ <parameter>toc.max.depth</parameter>\r
+ <parameter>toc.section.depth</parameter>\r
+ <parameter>generate.section.toc.level</parameter>\r
+ </group>\r
+ <group name ="Process ToC">\r
+ <parameter>process.empty.source.toc</parameter>\r
+ <parameter>process.source.toc</parameter>\r
+ </group>\r
+ <group name ="Include in ToC">\r
+ <parameter>bridgehead.in.toc</parameter>\r
+ <parameter>simplesect.in.toc</parameter> \r
+ </group> \r
+ <group name ="ToC surrounding"> \r
+ <parameter>toc.indent.width</parameter>\r
+ <attribute-set>toc.margin.properties</attribute-set> \r
+ </group> \r
+ </subsection> \r
+ <subsection name="Q and A Sets">\r
+ <group name ="Q and A labeling">\r
+ <parameter>qandadiv.autolabel</parameter>\r
+ <parameter>qanda.inherit.numeration</parameter>\r
+ <parameter>qanda.defaultlabel</parameter>\r
+ </group> \r
+ <group name ="Q and A title">\r
+ <attribute-set>qanda.title.properties</attribute-set>\r
+ <attribute-set>qanda.title.level1.properties</attribute-set>\r
+ <attribute-set>qanda.title.level2.properties</attribute-set>\r
+ <attribute-set>qanda.title.level3.properties</attribute-set>\r
+ <attribute-set>qanda.title.level4.properties</attribute-set>\r
+ <attribute-set>qanda.title.level5.properties</attribute-set>\r
+ <attribute-set>qanda.title.level6.properties</attribute-set>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Bibliography">\r
+ <group>\r
+ <parameter>bibliography.numbered</parameter> \r
+ <parameter>bibliography.collection</parameter> \r
+ </group>\r
+ <group name="Bibliography entries">\r
+ <parameter>biblioentry.item.separator</parameter>\r
+ <attribute-set>biblioentry.properties</attribute-set>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Glossary">\r
+ <group name="Glossary formatting"> \r
+ <parameter>glossentry.show.acronym</parameter> \r
+ <parameter>glossary.as.blocks</parameter>\r
+ <parameter>glosslist.as.blocks</parameter>\r
+ <parameter>glossterm.separation</parameter>\r
+ <parameter>glossterm.width</parameter>\r
+ </group> \r
+ <group name="Glossary database">\r
+ <parameter>glossary.collection</parameter> \r
+ <parameter>glossterm.auto.link</parameter>\r
+ <parameter>firstterm.only.link</parameter> \r
+ </group>\r
+ </subsection> \r
+ <subsection name="Footnotes">\r
+ <group>\r
+ <attribute-set>footnote.properties</attribute-set>\r
+ <attribute-set>footnote.mark.properties</attribute-set>\r
+ <attribute-set>footnote.sep.leader.properties</attribute-set>\r
+ </group>\r
+ <group name ="Footnote numbers">\r
+ <parameter>footnote.number.format</parameter> \r
+ <parameter>footnote.number.symbols</parameter>\r
+ </group>\r
+ <group name ="Table footnote">\r
+ <parameter>table.footnote.number.format</parameter> \r
+ <parameter>table.footnote.number.symbols</parameter>\r
+ <attribute-set>table.footnote.properties</attribute-set>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Reference Pages">\r
+ <group name ="Refentry">\r
+ <parameter>refentry.generate.name</parameter>\r
+ <parameter>refentry.generate.title</parameter>\r
+ <attribute-set>refentry.title.properties</attribute-set>\r
+ <parameter>refentry.pagebreak</parameter>\r
+ <parameter>refentry.xref.manvolnum</parameter>\r
+ <parameter>refclass.suppress</parameter>\r
+ </group> \r
+ <group name ="Function">\r
+ <parameter>function.parens</parameter>\r
+ </group>\r
+ <group name ="Funcsynopsis">\r
+ <parameter>funcsynopsis.decoration</parameter>\r
+ <parameter>funcsynopsis.style</parameter>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Program Listings">\r
+ <group>\r
+ <parameter>default.float.class</parameter>\r
+ <parameter>formal.procedures</parameter>\r
+ <attribute-set>procedure.properties</attribute-set>\r
+ </group>\r
+ <group name ="Highlight">\r
+ <parameter>highlight.default.language</parameter>\r
+ <parameter>highlight.source</parameter>\r
+ </group> \r
+ <group name ="Menuchoice">\r
+ <parameter>menuchoice.separator</parameter>\r
+ <parameter>menuchoice.menu.separator</parameter>\r
+ </group>\r
+ <group name ="Verbatim text"> \r
+ <parameter>shade.verbatim</parameter> \r
+ <parameter>hyphenate.verbatim</parameter>\r
+ <parameter>hyphenate.verbatim.characters</parameter>\r
+ <attribute-set>shade.verbatim.style</attribute-set>\r
+ <attribute-set>monospace.verbatim.properties</attribute-set> \r
+ </group>\r
+ <group name ="Linenumbering"> \r
+ <parameter>linenumbering.everyNth</parameter>\r
+ <parameter>linenumbering.extension</parameter>\r
+ <parameter>linenumbering.separator</parameter>\r
+ <parameter>linenumbering.width</parameter>\r
+ </group> \r
+ </subsection> \r
+ </section>\r
+ \r
+ <section name="Document Properties"> \r
+ <subsection name ="General">\r
+ <group>\r
+ <parameter>show.comments</parameter> \r
+ </group> \r
+ <group name ="Root">\r
+ <parameter>rootid</parameter>\r
+ <attribute-set>root.properties</attribute-set> \r
+ </group>\r
+ <group name ="Draft">\r
+ <parameter>draft.watermark.image</parameter> \r
+ <parameter>draft.mode</parameter> \r
+ </group> \r
+ <group name ="EBNF">\r
+ <parameter>ebnf.assignment</parameter> \r
+ <parameter>ebnf.statement.terminator</parameter> \r
+ </group> \r
+ <group name ="Crops">\r
+ <parameter>crop.marks</parameter> \r
+ <parameter>crop.mark.width</parameter>\r
+ <parameter>crop.mark.offset</parameter>\r
+ <parameter>crop.mark.bleed</parameter> \r
+ </group> \r
+ <group name ="Others">\r
+ <parameter>runinhead.default.title.end.punct</parameter>\r
+ <parameter>runinhead.title.end.punct</parameter>\r
+ <parameter>email.delimiters.enabled</parameter> \r
+ </group> \r
+ </subsection> \r
+ <subsection name ="Localization">\r
+ <group>\r
+ <parameter>l10n.gentext.default.language</parameter> \r
+ <parameter>l10n.gentext.language</parameter>\r
+ <parameter>l10n.gentext.use.xref.language</parameter>\r
+ <parameter>l10n.lang.value.rfc.compliant</parameter> \r
+ </group> \r
+ </subsection> \r
+ <subsection name ="Meta / Info">\r
+ <group>\r
+ <parameter>make.single.year.ranges</parameter>\r
+ <parameter>make.year.ranges</parameter>\r
+ <parameter>author.othername.in.middle</parameter> \r
+ <parameter>punct.honorific</parameter>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Cross References">\r
+ <group name="Xrefs">\r
+ <parameter>insert.xref.page.number</parameter>\r
+ <parameter>insert.link.page.number</parameter>\r
+ <parameter>xref.with.number.and.title</parameter> \r
+ <parameter>use.role.as.xrefstyle</parameter> \r
+ <attribute-set>xref.properties</attribute-set> \r
+ </group> \r
+ <group name ="Xref labels">\r
+ <parameter>xref.label-title.separator</parameter>\r
+ <parameter>xref.label-page.separator</parameter>\r
+ <parameter>xref.title-page.separator</parameter>\r
+ </group> \r
+ <group name="Ulinks">\r
+ <parameter>ulink.show</parameter>\r
+ <parameter>ulink.hyphenate</parameter>\r
+ <parameter>ulink.hyphenate.chars</parameter>\r
+ <parameter>ulink.footnotes</parameter>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Extensions">\r
+ <group name ="Processor Extensions"> \r
+ <parameter>arbortext.extensions</parameter>\r
+ <parameter>axf.extensions</parameter>\r
+ <parameter>fop.extensions</parameter> \r
+ <parameter>fop1.extensions</parameter> \r
+ <parameter>xep.extensions</parameter> \r
+ </group> \r
+ <group name ="Stylesheet Extensions">\r
+ <parameter>use.extensions</parameter>\r
+ <parameter>tablecolumns.extension</parameter> \r
+ </group> \r
+ <group name ="Text File Extensions">\r
+ <parameter>textinsert.extension</parameter>\r
+ <parameter>textdata.default.encoding</parameter>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Math">\r
+ <group name ="Tex extensions">\r
+ <parameter>passivetex.extensions</parameter>\r
+ <parameter>tex.math.in.alt</parameter>\r
+ <parameter>tex.math.delims</parameter> \r
+ </group> \r
+ <group name ="Equation">\r
+ <attribute-set>equation.properties</attribute-set>\r
+ <attribute-set>informalequation.properties</attribute-set>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Index Generation">\r
+ <group name ="Generate index">\r
+ <parameter>generate.index</parameter>\r
+ <parameter>make.index.markup</parameter>\r
+ <parameter>index.on.type</parameter>\r
+ <parameter>index.on.role</parameter>\r
+ <parameter>index.method</parameter>\r
+ </group>\r
+ <group name ="Separators"> \r
+ <parameter>index.number.separator</parameter>\r
+ <parameter>index.range.separator</parameter>\r
+ <parameter>index.term.separator</parameter>\r
+ </group>\r
+ <group name ="Index properties">\r
+ <attribute-set>index.preferred.page.properties</attribute-set> \r
+ <attribute-set>index.entry.properties</attribute-set>\r
+ <attribute-set>index.div.title.properties</attribute-set>\r
+ <attribute-set>xep.index.item.properties</attribute-set>\r
+ </group>\r
+ </subsection> \r
+ <subsection name="Graphics">\r
+ <group>\r
+ <parameter>use.svg</parameter>\r
+ <parameter>graphic.default.extension</parameter>\r
+ <parameter>img.src.path</parameter>\r
+ <parameter>keep.relative.image.uris</parameter>\r
+ </group>\r
+ <group name ="Graphics size">\r
+ <parameter>default.image.width</parameter> \r
+ <parameter>ignore.image.scaling</parameter>\r
+ </group>\r
+ <group name ="Parameter role">\r
+ <parameter>preferred.mediaobject.role</parameter> \r
+ <parameter>use.role.for.mediaobject</parameter>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Linking">\r
+ <group>\r
+ <parameter>current.docid</parameter>\r
+ <parameter>collect.xref.targets</parameter>\r
+ <parameter>insert.olink.page.number</parameter>\r
+ <parameter>insert.olink.pdf.frag</parameter>\r
+ <parameter>olink.base.uri</parameter>\r
+ <parameter>olink.debug</parameter>\r
+ <parameter>olink.doctitle</parameter>\r
+ <parameter>olink.lang.fallback.sequence</parameter>\r
+ <attribute-set>olink.properties</attribute-set>\r
+ <parameter>prefer.internal.olink</parameter>\r
+ <parameter>target.database.document</parameter>\r
+ <parameter>targets.filename</parameter>\r
+ <parameter>use.local.olink.style</parameter>\r
+ </group> \r
+ </subsection> \r
+ <subsection name="Profiling">\r
+ <group>\r
+ <parameter>profile.arch</parameter>\r
+ <parameter>profile.condition</parameter>\r
+ <parameter>profile.conformance</parameter>\r
+ <parameter>profile.lang</parameter>\r
+ <parameter>profile.os</parameter>\r
+ <parameter>profile.revision</parameter>\r
+ <parameter>profile.revisionflag</parameter> \r
+ <parameter>profile.role</parameter>\r
+ <parameter>profile.security</parameter>\r
+ <parameter>profile.userlevel</parameter>\r
+ <parameter>profile.vendor</parameter>\r
+ <parameter>profile.attribute</parameter>\r
+ <parameter>profile.value</parameter>\r
+ <parameter>profile.separator</parameter>\r
+ </group> \r
+ </subsection> \r
+ </section>\r
+ \r
+</config>\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="windows-1250"?>\r
+<graphics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <figure name="page-format" class="cz.zcu.fav.kiv.editor.displays.PageFigure">\r
+ <parameter>page.width</parameter>\r
+ <parameter>page.height</parameter>\r
+ </figure>\r
+</graphics>\r
--- /dev/null
+<?xml version="1.0" encoding="windows-1250"?>\r
+<parameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <parameter name="paper.type">\r
+ <value>USletter</value>\r
+ <value>USlandscape</value> \r
+ <value>4A0</value> \r
+ <value>2A0</value> \r
+ <value>A0</value> \r
+ <value>A1</value> \r
+ <value>A2</value> \r
+ <value>A3</value> \r
+ <value>A4</value> \r
+ <value>A4landscape</value>\r
+ <value>A5</value> \r
+ <value>A6</value> \r
+ <value>A7</value> \r
+ <value>A8</value> \r
+ <value>A9</value>\r
+ <value>A10</value>\r
+ <value>B0</value> \r
+ <value>B1</value> \r
+ <value>B2</value> \r
+ <value>B3</value> \r
+ <value>B4</value> \r
+ <value>B5</value>\r
+ <value>B6</value> \r
+ <value>B7</value> \r
+ <value>B8</value> \r
+ <value>B9</value> \r
+ <value>B10</value> \r
+ <value>C0</value>\r
+ <value>C1</value> \r
+ <value>C2</value> \r
+ <value>C3</value> \r
+ <value>C4</value> \r
+ <value>C5</value>\r
+ <value>C6</value> \r
+ <value>C7</value> \r
+ <value>C8</value> \r
+ <value>C9</value> \r
+ <value>C10</value> \r
+ <default>USletter</default>\r
+ <component>combo-box</component>\r
+ </parameter>\r
+ \r
+ <parameter name="page.width.portrait">\r
+ <unit>in</unit> \r
+ <default>8.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="page.height.portrait">\r
+ <unit>in</unit> \r
+ <default>11</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="page.height">\r
+ <unit>in</unit>\r
+ <default>11</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="page.width">\r
+ <unit>in</unit>\r
+ <default>8.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="page.orientation">\r
+ <value>portrait</value>\r
+ <value>landscape</value> \r
+ <default>portrait</default>\r
+ <component>combo-box</component>\r
+ </parameter>\r
+ \r
+ <parameter name="page.margin.inner">\r
+ <unit>in</unit>\r
+ <default>1</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="page.margin.outer">\r
+ <unit>in</unit>\r
+ <default>1</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="page.margin.top">\r
+ <unit>in</unit>\r
+ <default>0.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="page.margin.bottom">\r
+ <unit>in</unit>\r
+ <default>0.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="double.sided"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter>\r
+\r
+ <parameter name="region.before.extent">\r
+ <unit>in</unit>\r
+ <default>0.4</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="region.after.extent">\r
+ <unit>in</unit>\r
+ <default>0.4</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="headers.on.blank.pages"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter>\r
+ \r
+ <parameter name="footers.on.blank.pages">\r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter>\r
+ \r
+ <parameter name="header.rule"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter>\r
+ \r
+ <parameter name="footer.rule"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter>\r
+ \r
+ <parameter name="header.column.widths">\r
+ <default>1 1 1</default>\r
+ <component>text-field</component> \r
+ </parameter>\r
+ \r
+ <parameter name="footer.column.widths">\r
+ <default>1 1 1</default>\r
+ <component>text-field</component> \r
+ </parameter> \r
+ \r
+ <parameter name="body.margin.top">\r
+ <unit>in</unit>\r
+ <default>0.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="body.margin.bottom">\r
+ <unit>in</unit>\r
+ <default>0.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="body.start.indent">\r
+ <unit>pc</unit>\r
+ <default>4</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="body.end.indent">\r
+ <unit>pt</unit>\r
+ <default>0</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="title.margin.left">\r
+ <unit>pt</unit>\r
+ <default>0</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="formal.title.placement">\r
+ <default>figure before\r
+example before\r
+equation before\r
+table before\r
+procedure before\r
+task before</default>\r
+ <component>text-area</component> \r
+ </parameter>\r
+ \r
+ <parameter name="line-height"> \r
+ <default>12.5</default>\r
+ <component>spinner-float</component>\r
+ </parameter> \r
+ \r
+ <parameter name="alignment"> \r
+ <value>justify</value>\r
+ <value>center</value>\r
+ <value>left</value>\r
+ <value>right</value>\r
+ <default>justify</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="hyphenate"> \r
+ <default>true</default>\r
+ <component>check-box</component>\r
+ </parameter>\r
+\r
+ <parameter name="body.font.family">\r
+ <type>font</type> \r
+ <default>serif</default>\r
+ <component>combo-box-edit</component>\r
+ </parameter> \r
+ \r
+ <parameter name="title.font.family">\r
+ <type>font</type> \r
+ <default>sans-serif</default>\r
+ <component>combo-box-edit</component>\r
+ </parameter>\r
+\r
+ <parameter name="monospace.font.family"> \r
+ <type>font</type> \r
+ <default>monospace</default>\r
+ <component>combo-box-edit</component>\r
+ </parameter>\r
+ \r
+ <parameter name="dingbat.font.family">\r
+ <type>font</type> \r
+ <default>serif</default>\r
+ <component>combo-box-edit</component>\r
+ </parameter> \r
+ \r
+ <parameter name="sans.font.family">\r
+ <type>font</type> \r
+ <default>sans-serif</default>\r
+ <component>combo-box-edit</component>\r
+ </parameter> \r
+ \r
+ <parameter name="symbol.font.family"> \r
+ <default>Symbol,ZapfDingbats</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+\r
+ <parameter name="body.font.master">\r
+ <default>10</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="body.font.size">\r
+ <unit>pt</unit>\r
+ <default>10</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+\r
+ <parameter name="footnote.font.size">\r
+ <unit>pt</unit>\r
+ <default>8</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="chapter.autolabel">\r
+ <value name="no">0</value> \r
+ <value name="1, 2, 3 ...">1</value>\r
+ <value name="A, B, C ...">A</value>\r
+ <value name="a, b, c ...">a</value> \r
+ <value name="I, II, III ...">I</value> \r
+ <value name="i, ii, iii ...">i</value> \r
+ <default>1</default>\r
+ <component>radio-button</component>\r
+ </parameter>\r
+ \r
+ <parameter name="reference.autolabel">\r
+ <value name="no">0</value> \r
+ <value name="1, 2, 3 ...">1</value>\r
+ <value name="A, B, C ...">A</value>\r
+ <value name="a, b, c ...">a</value> \r
+ <value name="I, II, III ...">I</value> \r
+ <value name="i, ii, iii ...">i</value> \r
+ <default>I</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="appendix.autolabel">\r
+ <value name="no">0</value> \r
+ <value name="1, 2, 3 ...">1</value>\r
+ <value name="A, B, C ...">A</value>\r
+ <value name="a, b, c ...">a</value> \r
+ <value name="I, II, III ...">I</value> \r
+ <value name="i, ii, iii ...">i</value> \r
+ <default>A</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="section.autolabel"> \r
+ <value name="no">0</value> \r
+ <value name="1, 2, 3 ...">1</value>\r
+ <value name="A, B, C ...">A</value>\r
+ <value name="a, b, c ...">a</value> \r
+ <value name="I, II, III ...">I</value> \r
+ <value name="i, ii, iii ...">i</value> \r
+ <default>0</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="part.autolabel"> \r
+ <value name="no">0</value> \r
+ <value name="1, 2, 3 ...">1</value>\r
+ <value name="A, B, C ...">A</value>\r
+ <value name="a, b, c ...">a</value> \r
+ <value name="I, II, III ...">I</value> \r
+ <value name="i, ii, iii ...">i</value> \r
+ <default>I</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="preface.autolabel"> \r
+ <value name="no">0</value> \r
+ <value name="1, 2, 3 ...">1</value>\r
+ <value name="A, B, C ...">A</value>\r
+ <value name="a, b, c ...">a</value> \r
+ <value name="I, II, III ...">I</value> \r
+ <value name="i, ii, iii ...">i</value> \r
+ <default>0</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="section.label.includes.component.label"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="label.from.part"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="component.label.includes.part.label"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="default.table.width">\r
+ <unit></unit>\r
+ <default></default>\r
+ <component>text-field</component> \r
+ </parameter> \r
+ \r
+ <parameter name="nominal.table.width">\r
+ <unit>in</unit>\r
+ <default>6</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="table.frame.border.thickness">\r
+ <unit>pt</unit>\r
+ <default>0.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="table.cell.border.thickness">\r
+ <unit>pt</unit>\r
+ <default>0.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="table.frame.border.style">\r
+ <value>none</value>\r
+ <value>solid</value>\r
+ <value>dotted</value>\r
+ <value>dashed</value>\r
+ <value>double</value>\r
+ <value>groove</value> \r
+ <value>ridge</value>\r
+ <value>inset</value>\r
+ <value>outset</value> \r
+ <default>solid</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="table.cell.border.style">\r
+ <value>none</value>\r
+ <value>solid</value>\r
+ <value>dotted</value>\r
+ <value>dashed</value>\r
+ <value>double</value>\r
+ <value>groove</value> \r
+ <value>ridge</value>\r
+ <value>inset</value>\r
+ <value>outset</value> \r
+ <default>solid</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="table.frame.border.color">\r
+ <type>color</type> \r
+ <default>black</default>\r
+ <component>color-chooser</component>\r
+ </parameter> \r
+ \r
+ <parameter name="table.cell.border.color"> \r
+ <type>color</type> \r
+ <default>black</default>\r
+ <component>color-chooser</component>\r
+ </parameter> \r
+ \r
+ <parameter name="arbortext.extensions"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="axf.extensions"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="fop.extensions"> \r
+ <default>0</default>\r
+ <component>check-box</component> \r
+ </parameter> \r
+ \r
+ <parameter name="passivetex.extensions"> \r
+ <default>0</default>\r
+ <component>check-box</component> \r
+ </parameter> \r
+ \r
+ <parameter name="xep.extensions">\r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="tablecolumns.extension"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="use.extensions"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter>\r
+ \r
+ <parameter name="insert.xref.page.number"> \r
+ <value name="yes">yes</value> \r
+ <value name="no">no</value>\r
+ <value name="maybe">maybe</value> \r
+ <default>no</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="insert.link.page.number"> \r
+ <value name="yes">yes</value> \r
+ <value name="no">no</value>\r
+ <value name="maybe">maybe</value> \r
+ <default>no</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="xref.with.number.and.title"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="admon.graphics"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="draft.watermark.image"> \r
+ <default>http://docbook.sourceforge.net/release/images/draft.png</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="show.comments"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="ulink.footnotes"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="shade.verbatim"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="generate.toc">\r
+ <default>/appendix toc,title\r
+article/appendix nop\r
+/article toc,title\r
+book toc,title,figure,table,example,equation\r
+/chapter toc,title\r
+part toc,title\r
+/preface toc,title\r
+qandadiv toc\r
+qandaset toc\r
+reference toc,title\r
+/sect1 toc\r
+/sect2 toc\r
+/sect3 toc\r
+/sect4 toc\r
+/sect5 toc\r
+/section toc\r
+set toc,title</default>\r
+ <component>text-area</component> \r
+ </parameter>\r
+ \r
+ <parameter name="toc.section.depth"> \r
+ <default>2</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="toc.max.depth"> \r
+ <default>8</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="generate.section.toc.level"> \r
+ <default>0</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="bibliography.numbered"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="admon.graphics.extension"> \r
+ <default>.png</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="admon.textlabel"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="linenumbering.everyNth"> \r
+ <default>5</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="linenumbering.extension"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="linenumbering.separator"> \r
+ <default> </default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="linenumbering.width"> \r
+ <default>3</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="textinsert.extension"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="textdata.default.encoding"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="section.autolabel.max.depth"> \r
+ <default>8</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="funcsynopsis.decoration"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="funcsynopsis.style"> \r
+ <value>ansi</value>\r
+ <value>kr</value> \r
+ <default>kr</default>\r
+ <component>combo-box</component>\r
+ </parameter>\r
+ \r
+ <parameter name="function.parens"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="refentry.generate.name"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="refentry.generate.title"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="refentry.pagebreak"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="refentry.xref.manvolnum"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="qandadiv.autolabel"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="qanda.inherit.numeration"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="qanda.defaultlabel"> \r
+ <value>number</value>\r
+ <value>qanda</value> \r
+ <value>none</value> \r
+ <default>number</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="biblioentry.item.separator"> \r
+ <default>. </default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="bibliography.collection"> \r
+ <default>http://docbook.sourceforge.net/release/bibliography/bibliography.xml</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="variablelist.max.termlength"> \r
+ <default>24</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="xref.label-title.separator"> \r
+ <default>: </default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="xref.label-page.separator"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="xref.title-page.separator"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="glossterm.auto.link"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="firstterm.only.link"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="glossary.collection"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="glossterm.separation">\r
+ <unit>in</unit>\r
+ <default>0.25</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="glossterm.width">\r
+ <unit>in</unit>\r
+ <default>2</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="glossary.as.blocks"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="glosslist.as.blocks"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="glossentry.show.acronym">\r
+ <value>no</value>\r
+ <value>yes</value>\r
+ <value>primary</value> \r
+ <default>no</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.defaultcolumn"> \r
+ <default>60</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.graphics"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.graphics.extension"> \r
+ <default>.png</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.graphics.number.limit"> \r
+ <default>15</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.graphics.path"> \r
+ <default>images/callouts/</default>\r
+ <component>file-chooser</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.unicode"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.unicode.font"> \r
+ <default>ZapfDingbats</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.unicode.number.limit"> \r
+ <default>10</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.unicode.start.character"> \r
+ <default>10102</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="callout.extension"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="autotoc.label.separator"> \r
+ <default>. </default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="process.empty.source.toc"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="process.source.toc"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="toc.indent.width"> \r
+ <default>24</default>\r
+ <component>spinner-float</component>\r
+ </parameter> \r
+ \r
+ <parameter name="bridgehead.in.toc"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="simplesect.in.toc"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="generate.index"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="make.index.markup"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="index.on.type"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="index.on.role"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="tex.math.in.alt"> \r
+ <value></value> \r
+ <value>plain</value> \r
+ <value>latex</value> \r
+ <default></default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="tex.math.delims"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="draft.mode"> \r
+ <value>yes</value> \r
+ <value>no</value>\r
+ <value>maybe</value> \r
+ <default>maybe</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="marker.section.level"> \r
+ <default>2</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="footnote.number.format"> \r
+ <value name="1, 2, 3 ...">1</value>\r
+ <value name="A, B, C ...">A</value>\r
+ <value name="a, b, c ...">a</value> \r
+ <value name="I, II, III ...">I</value> \r
+ <value name="i, ii, iii ...">i</value> \r
+ <default>1</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="table.footnote.number.format"> \r
+ <value name="1, 2, 3 ...">1</value>\r
+ <value name="A, B, C ...">A</value>\r
+ <value name="a, b, c ...">a</value> \r
+ <value name="I, II, III ...">I</value> \r
+ <value name="i, ii, iii ...">i</value> \r
+ <default>a</default>\r
+ <component>radio-button</component>\r
+ </parameter> \r
+ \r
+ <parameter name="footnote.number.symbols"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="table.footnote.number.symbols"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="hyphenate.verbatim"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="hyphenate.verbatim.characters"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="ulink.show"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="ulink.hyphenate"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="segmentedlist.as.table"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="variablelist.as.blocks"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="use.role.as.xrefstyle"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="menuchoice.menu.separator"> \r
+ <default> → </default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="menuchoice.separator"> \r
+ <default>+</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="default.float.class"> \r
+ <default>before</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="formal.procedures"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="runinhead.default.title.end.punct"> \r
+ <default>.</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="runinhead.title.end.punct"> \r
+ <default>.!?:</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="punct.honorific"> \r
+ <default>.</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="make.single.year.ranges"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="make.year.ranges"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="author.othername.in.middle"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="rootid"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="admon.graphics.path"> \r
+ <default>images/</default>\r
+ <component>file-chooser</component>\r
+ </parameter> \r
+ \r
+ <parameter name="use.svg"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="graphic.default.extension"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="default.image.width">\r
+ <unit></unit>\r
+ <default></default>\r
+ <component>text-field</component> \r
+ </parameter> \r
+ \r
+ <parameter name="preferred.mediaobject.role"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="use.role.for.mediaobject"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="ignore.image.scaling"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="img.src.path"> \r
+ <default></default>\r
+ <component>file-chooser</component>\r
+ </parameter> \r
+ \r
+ <parameter name="column.count.back"> \r
+ <default>1</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="column.count.body"> \r
+ <default>1</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="column.count.front"> \r
+ <default>1</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="column.count.index"> \r
+ <default>2</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="column.count.lot"> \r
+ <default>1</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="column.count.titlepage"> \r
+ <default>1</default>\r
+ <component>spinner-int</component>\r
+ </parameter> \r
+ \r
+ <parameter name="column.gap.back">\r
+ <unit>pt</unit>\r
+ <default>12</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="column.gap.body">\r
+ <unit>pt</unit>\r
+ <default>12</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="column.gap.front">\r
+ <unit>pt</unit>\r
+ <default>12</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="column.gap.index">\r
+ <unit>pt</unit>\r
+ <default>12</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="column.gap.lot">\r
+ <unit>pt</unit>\r
+ <default>12</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="column.gap.titlepage">\r
+ <unit>pt</unit>\r
+ <default>12</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="sidebar.float.type"> \r
+ <value>none</value> \r
+ <value>before</value> \r
+ <value>left</value> \r
+ <value>start</value> \r
+ <value>right</value>\r
+ <value>end</value> \r
+ <value>inside</value>\r
+ <value>outside</value> \r
+ <default>none</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="sidebar.float.width">\r
+ <unit>in</unit>\r
+ <default>1</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="margin.note.float.type"> \r
+ <value>none</value> \r
+ <value>before</value> \r
+ <value>left</value> \r
+ <value>start</value> \r
+ <value>right</value>\r
+ <value>end</value> \r
+ <value>inside</value>\r
+ <value>outside</value> \r
+ <default>none</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="margin.note.width">\r
+ <unit>in</unit>\r
+ <default>1</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="profile.arch"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.condition"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.conformance"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.lang"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.os"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.revision"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.revisionflag"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.role"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.security"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.userlevel"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.vendor"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.attribute"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.value"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="profile.separator"> \r
+ <default>;</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="l10n.gentext.language"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="l10n.gentext.default.language"> \r
+ <default>en</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="l10n.gentext.use.xref.language"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="l10n.lang.value.rfc.compliant"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="current.docid"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="collect.xref.targets"> \r
+ <value>no</value>\r
+ <value>yes</value>\r
+ <value>only</value>\r
+ <default>no</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="insert.olink.page.number"> \r
+ <value>no</value>\r
+ <value>yes</value>\r
+ <value>maybe</value>\r
+ <default>no</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="insert.olink.pdf.frag"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="olink.base.uri"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="olink.debug"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="olink.doctitle"> \r
+ <value>no</value>\r
+ <value>yes</value>\r
+ <value>maybe</value>\r
+ <default>no</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="olink.lang.fallback.sequence"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="prefer.internal.olink"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="target.database.document"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="targets.filename"> \r
+ <default>target.db</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="use.local.olink.style"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="ebnf.assignment"> \r
+ <default>::=</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="ebnf.statement.terminator"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="variablelist.term.separator"> \r
+ <default>, </default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="variablelist.term.break.after"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="itemizedlist.label.width">\r
+ <unit>em</unit>\r
+ <default>1.0</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="orderedlist.label.width">\r
+ <unit>em</unit>\r
+ <default>1.2</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="crop.marks"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="crop.mark.width">\r
+ <unit>pt</unit>\r
+ <default>0.5</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="crop.mark.offset">\r
+ <unit>pt</unit>\r
+ <default>24</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="crop.mark.bleed">\r
+ <unit>pt</unit>\r
+ <default>6</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="email.delimiters.enabled"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="footer.table.height">\r
+ <unit>pt</unit>\r
+ <default>14</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="fop1.extensions"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="header.table.height">\r
+ <unit>pt</unit>\r
+ <default>14</default>\r
+ <component>spinner-float</component> \r
+ </parameter> \r
+ \r
+ <parameter name="highlight.source"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="highlight.default.language"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter>\r
+ \r
+ <parameter name="index.method"> \r
+ <value>basic</value>\r
+ <value>kosek</value>\r
+ <value>kimber</value>\r
+ <default>basic</default>\r
+ <component>combo-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="index.number.separator"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="index.page.separator"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="index.term.separator"> \r
+ <default></default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="index.range.separator"> \r
+ <default>''</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+ \r
+ <parameter name="keep.relative.image.uris"> \r
+ <default>1</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="refclass.suppress"> \r
+ <default>0</default>\r
+ <component>check-box</component>\r
+ </parameter> \r
+ \r
+ <parameter name="ulink.hyphenate.chars"> \r
+ <default>/</default>\r
+ <component>text-field</component>\r
+ </parameter> \r
+</parameters>\r
--- /dev/null
+<?xml version="1.0" encoding="windows-1250"?>\r
+<types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+ <colors>\r
+ <color name="aqua">#00FFFF</color> \r
+ <color name="black">#000000</color> \r
+ <color name="blue">#0000FF</color> \r
+ <color name="fuchsia">#FF00FF</color> \r
+ <color name="gray">#808080</color> \r
+ <color name="green">#008000</color> \r
+ <color name="lime">#00FF00</color> \r
+ <color name="maroon">#800000</color> \r
+ <color name="navy">#000080</color> \r
+ <color name="olive">#808000</color> \r
+ <color name="purple">#800080</color>\r
+ <color name="red">#FF0000</color> \r
+ <color name="silver">#C0C0C0</color> \r
+ <color name="teal">#008080</color> \r
+ <color name="white">#FFFFFF</color>\r
+ <color name="yellow">#FFFF00</color> \r
+ </colors>\r
+ <units>\r
+ <unit>cm</unit>\r
+ <unit>mm</unit>\r
+ <unit>in</unit>\r
+ <unit>pt</unit>\r
+ <unit>pc</unit>\r
+ <unit>px</unit>\r
+ <unit>em</unit>\r
+ <unit>%</unit>\r
+ <unit></unit>\r
+ </units> \r
+ <fonts>\r
+ <font>serif</font>\r
+ <font>sans-serif</font>\r
+ <font>monospace</font>\r
+ </fonts> \r
+</types>\r
--- /dev/null
+==============================\r
+Installing FO Parameter Editor\r
+==============================\r
+ \r
+ ------------\r
+ Requirements\r
+ ------------\r
+\r
+ * Sun or Apple Java[tm] runtime 1.5.0 or above.\r
+\r
+ FO Parameter Editor is officially supported on Windows XP and Linux.\r
+ \r
+ \r
+ ------------------\r
+ Install on Windows \r
+ ------------------\r
+ \r
+ 1. Make sure that you have a Java™ 1.5.0+ runtime installed on your machine. \r
+ To check this, open a command window and type "java -version" followed by Enter. \r
+ You should get something looking like this:\r
+ \r
+ C:\> java -version\r
+ java version "1.5.0_04"\r
+ Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)\r
+ Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)\r
+ \r
+ 2. Use a tool like WinZip (http://www.winzip.com/), 7-Zip (http://www.7-zip.org/) \r
+ or Info-Zip (http://www.info-zip.org/) to unzip the FO Parameter Editor distribution \r
+ inside any directory you want:\r
+\r
+ C:\> unzip FOeditor-1_0.zip\r
+ \r
+ 3. FO Parameter Editor is intended to be used directly from the FOeditor-1_0 directory. \r
+ That is, you can start FO Parameter Editor by \r
+ - simply clicking on FOEditor.jar\r
+ - or by executing: C:\> FOeditor-1_0\run.bat\r
+\r
+ After that, you may want to add a shortcut to "C:\FOeditor\run.bat" or \r
+ "C:\FOeditor\FOEditor.jar" on your desktop. \r
+ Errors occuring during the editor run are written down in a log file error.log.\r
+ \r
+\r
+ ------------------\r
+ Install on Linux \r
+ ------------------\r
+ \r
+ 1. Make sure that you have a Java™ 1.5.0+ runtime installed on your machine. \r
+ To check this, open a command window and type "java -version" followed by Enter. \r
+ You should get something looking like this:\r
+ \r
+ # java -version\r
+ java version "1.5.0_04"\r
+ Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)\r
+ Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)\r
+ \r
+ 2. Unzip the FO Parameter Editor distribution inside any directory you want:\r
+\r
+ # unzip FOeditor-1_0.zip\r
+ \r
+ 3. FO Parameter Editor is intended to be used directly from the FOeditor-1_0 directory. \r
+ That is, you can start FO Parameter Editor by \r
+ - simply clicking on FOEditor.jar\r
+ - or by executing: # FOeditor-1_0\run.sh\r
+\r
+ After that, you may want to add a shortcut to "..\FOeditor\run.sh" or \r
+ "..\FOeditor\FOEditor.jar" on your desktop. \r
+ Errors occuring during the editor run are written down in a log file error.log.\r
+
\ No newline at end of file
--- /dev/null
+@echo off\r
+\r
+start javaw -jar FOEditor.jar\r
+\r
+exit
\ No newline at end of file
--- /dev/null
+java -jar FOEditor.jar\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Section;\r
+\r
+/**\r
+ * The <code>ConfigData</code> class represents main structure containing the list of parameter\r
+ * sections and lists of predefined type values.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ConfigData {\r
+ /** The list of sections */\r
+ private List<Section> sectionList;\r
+\r
+ /** The list of parameters - keys are parameter names */\r
+ private Map<String, Parameter> parameterList;\r
+\r
+ /** The list of properties - keys are property names */\r
+ private Map<String, Property> propertyList;\r
+\r
+ /**\r
+ * Clear values (sets default values) of all sections.\r
+ */\r
+ public void clearValues() {\r
+ for (Section section : sectionList)\r
+ section.clearValues();\r
+ }\r
+\r
+ /**\r
+ * Search for an parameter with specified name.\r
+ * \r
+ * @param name\r
+ * a name of serched parameter.\r
+ * @return the found parameter with specified name.\r
+ */\r
+ public Parameter searchParameter(String name) {\r
+ return parameterList.get(name);\r
+ }\r
+\r
+ /**\r
+ * Search for a property with specified name.\r
+ * \r
+ * @param name\r
+ * a name of serched property.\r
+ * @return the found property with specified name.\r
+ */\r
+ public Property searchProperty(String name) {\r
+ return propertyList.get(name);\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public List<Section> getSectionList() { \r
+ return sectionList != null? sectionList : Collections.EMPTY_LIST;\r
+ }\r
+\r
+ public void setSectionList(List<Section> sectionList) {\r
+ this.sectionList = sectionList;\r
+ }\r
+\r
+ public Map<String, Parameter> getParameterList() {\r
+ return parameterList;\r
+ }\r
+\r
+ public void setParameterList(Map<String, Parameter> parameterList) {\r
+ this.parameterList = parameterList;\r
+ }\r
+\r
+ public Map<String, Property> getPropertyList() {\r
+ return propertyList;\r
+ }\r
+\r
+ public void setPropertyList(Map<String, Property> propertyList) {\r
+ this.propertyList = propertyList;\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans;\r
+\r
+import org.w3c.dom.Document;\r
+\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+import cz.zcu.fav.kiv.editor.stylesheet.XslParser;\r
+\r
+/**\r
+ * The <code>OpenFile</code> class represents an open XSL stylesheet file.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OpenFile {\r
+ /** The supported file extension */\r
+ private static final String extension = ".xsl";\r
+\r
+ /** The DOM structure of open stylesheet file */\r
+ private Document wholeFile;\r
+\r
+ /** The path to the open file */\r
+ private String openFilePath;\r
+\r
+ /** The flag indicating changes in the open file */\r
+ private boolean fileChanged;\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>OpenFile</code>. Assignes the\r
+ * <code>wholeFile</code> to the new empty DOM XSL stylesheet structure. Sets the newly\r
+ * created file as not changed (<code>fileChanged</code>).\r
+ */\r
+ public OpenFile() {\r
+ this.wholeFile = XslParser.createXsltFile();\r
+ this.fileChanged = false;\r
+ }\r
+\r
+ public Document getWholeFile() {\r
+ return wholeFile;\r
+ }\r
+\r
+ /**\r
+ * Sets the new DOM structure <code>wholeFile</code> of newly opened file. Sets the opened\r
+ * file as not changed.\r
+ * \r
+ * @param wholeFile\r
+ * DOM structure of the opened file.\r
+ */\r
+ public void setWholeFile(Document wholeFile) {\r
+ this.wholeFile = wholeFile;\r
+ setFileChanged(false);\r
+ }\r
+\r
+ public String getOpenFilePath() {\r
+ return openFilePath;\r
+ }\r
+\r
+ /**\r
+ * Sets the new <code>openFilePath</code> of the opened file. If the file hasn't the extension\r
+ * XSL, then the extension is added.\r
+ * \r
+ * @param openFilePath\r
+ * a new path to the opened file.\r
+ */\r
+ public void setOpenFilePath(String openFilePath) {\r
+ if (openFilePath != null) {\r
+ if (!openFilePath.trim().endsWith(extension))\r
+ openFilePath = openFilePath + extension;\r
+ }\r
+ this.openFilePath = openFilePath;\r
+ }\r
+\r
+ public boolean isFileChanged() {\r
+ return fileChanged;\r
+ }\r
+\r
+ /**\r
+ * Sets if the opened file is changed or not. According to changes sets the status information\r
+ * about the file.\r
+ * \r
+ * @param fileChanged\r
+ * true, if the file has changed.\r
+ */\r
+ public void setFileChanged(boolean fileChanged) {\r
+ this.fileChanged = fileChanged;\r
+ MainFrame.getInstance().changeTitle();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.common;\r
+\r
+import java.util.Observable;\r
+\r
+import org.w3c.dom.Node;\r
+\r
+/**\r
+ * The <code>GeneralElement</code> class represents a parent common for all elements like\r
+ * <code>Parameter</code>, <code>Property</code> or <code>Attribute</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class GeneralElement extends Observable {\r
+ /** The name of the element */\r
+ protected String name;\r
+\r
+ /** The node associated with the element */\r
+ protected Node node;\r
+\r
+ /**\r
+ * Initializes a newly created empty<code>GeneralElement</code>.\r
+ */\r
+ public GeneralElement() {\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created empty<code>GeneralElement</code> with the specified name. The\r
+ * <code>name</code> argument is the name of the element.\r
+ * \r
+ * @param name\r
+ * a name of the element.\r
+ */\r
+ public GeneralElement(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public Node getNode() {\r
+ return node;\r
+ }\r
+\r
+ public void setNode(Node node) {\r
+ this.node = node;\r
+ }\r
+\r
+ public boolean equals(Object obj) {\r
+ return ((GeneralElement) obj).getName().equals(this.getName());\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.common;\r
+\r
+/**\r
+ * The <code>ParentParameter</code> class represents a parent common for all elements like\r
+ * <code>Parameter</code> or <code>Property</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParentParameter extends GeneralElement implements Comparable {\r
+ /** The description of the element */\r
+ protected String description;\r
+\r
+ /** The purpose of the element */\r
+ protected String purpose;\r
+\r
+ /** The flag specifying whether the element is chosen or not */\r
+ protected boolean chosen;\r
+ \r
+ protected int lineNumber;\r
+\r
+ /**\r
+ * Initializes a newly created empty<code>ParentParameter</code>.\r
+ */\r
+ public ParentParameter() {\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created empty<code>ParentParameter</code> with the specified name. The\r
+ * <code>name</code> argument is the name of the element.\r
+ * \r
+ * @param name\r
+ * a name of the element.\r
+ */\r
+ public ParentParameter(String name) {\r
+ this.name = name;\r
+ }\r
+ \r
+ public ParentParameter(String name, int lineNumber) {\r
+ this.name = name;\r
+ this.lineNumber = lineNumber;\r
+ }\r
+\r
+ public String getDescription() {\r
+ return description;\r
+ }\r
+\r
+ public void setDescription(String description) {\r
+ this.description = description;\r
+ }\r
+\r
+ public String getPurpose() {\r
+ return purpose;\r
+ }\r
+\r
+ public void setPurpose(String purpose) {\r
+ this.purpose = purpose;\r
+ }\r
+\r
+ /**\r
+ * Clear values (sets default values) of the element\r
+ * and notifies its observers.\r
+ */\r
+ public void clearValues() {\r
+ setNode(null);\r
+ this.chosen = false;\r
+ setChanged();\r
+ notifyObservers(false);\r
+ }\r
+\r
+ public Boolean isChosen() {\r
+ return chosen;\r
+ }\r
+\r
+ public void setChosen(Boolean isChosen) {\r
+ this.chosen = isChosen;\r
+ }\r
+\r
+ /**\r
+ * Choses the element - sets the flag chosen to true.\r
+ * At the same time notifies its observers.\r
+ */\r
+ public void setChosen() {\r
+ this.chosen = true;\r
+ setChanged();\r
+ notifyObservers(true);\r
+ }\r
+\r
+ public int compareTo(Object obj) {\r
+ return ((GeneralElement) obj).getName().compareTo(this.getName());\r
+ }\r
+\r
+ public int getLineNumber() {\r
+ return lineNumber;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.common;\r
+\r
+/**\r
+ * The <code>ParentSection</code> class represents a parent for all \r
+ * classes representing a group of items.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParentSection {\r
+ /** The title of the group */\r
+ protected String title;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ParentSection</code> with\r
+ * the specified name. The <code>title</code> argument is the\r
+ * title of the group.\r
+ *\r
+ * @param title a title of the group.\r
+ */\r
+ public ParentSection(String title) {\r
+ this.title = title;\r
+ }\r
+\r
+ public String getTitle() {\r
+ return title;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.graphics;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+\r
+/**\r
+ * The <code>Figure</code> class represents a graphics figure used for illustrating values of some\r
+ * parameters.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class Figure {\r
+ /** The name of the figure */\r
+ private String name;\r
+\r
+ /** The class name asociated with the figure */\r
+ private String className;\r
+\r
+ /** The list of parameters associated with the figure */\r
+ private Parameter[] parameterList;\r
+\r
+ public Figure(String name) {\r
+ this.name = name;\r
+ } \r
+\r
+ public String getClassName() {\r
+ return className;\r
+ }\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public Parameter[] getParameterList() {\r
+ return parameterList;\r
+ }\r
+\r
+ public void setParameterList(Parameter[] parameters) {\r
+ this.parameterList = parameters;\r
+ }\r
+\r
+ public boolean equals(Object obj) {\r
+ return ((Figure) obj).getName().equals(this.getName());\r
+ }\r
+\r
+ public void setClassName(String className) {\r
+ this.className = className;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.parameters;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+\r
+/**\r
+ * The <code>Parameter</code> class represents an element parameter.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class Parameter extends ParentParameter {\r
+ /** The type of the parameter */\r
+ private TypeParam type;\r
+\r
+ /**\r
+ * Initializes a newly created <code>Parameter</code> with the specified name. Parameter is\r
+ * marked as not chosen. The <code>name</code> argument is the name of the parameter.\r
+ * \r
+ * @param name\r
+ * a name of the parameter.\r
+ */\r
+ \r
+ public Parameter(String name, int lineNumber) {\r
+ super(name, lineNumber);\r
+ this.chosen = false;\r
+ this.type = new TypeParam(this);\r
+ }\r
+ \r
+ public Parameter(String name) {\r
+ super(name);\r
+ this.chosen = false;\r
+ this.type = new TypeParam(this);\r
+ }\r
+\r
+ public TypeParam getType() {\r
+ return type;\r
+ }\r
+\r
+ public void setType(TypeParam type) {\r
+ this.type = type;\r
+ }\r
+\r
+ /**\r
+ * Clear values (sets default values) of the parameter type and notify its observers.\r
+ */\r
+ public void clearValues() {\r
+ this.getType().setDefault();\r
+ super.clearValues();\r
+ }\r
+\r
+ /**\r
+ * Update the value of the <code>Figure</code>s associated with the parameter.\r
+ */\r
+ public void updateFigure() {\r
+ setChanged();\r
+ notifyObservers();\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.parameters;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+\r
+/**\r
+ * The <code>TypeParam</code> class represents a type of parameter.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TypeParam extends Type {\r
+\r
+ /** The reference to the parametet of the type */\r
+ private Parameter parameter;\r
+\r
+ /**\r
+ * Initializes a newly created <code>TypeParam</code> with reference to the appropriate\r
+ * parameter.\r
+ * \r
+ * @param param\r
+ * a reference to the type parameter.\r
+ */\r
+ public TypeParam(Parameter param) {\r
+ super();\r
+ this.parameter = param;\r
+ }\r
+\r
+ /**\r
+ * Sets the new value of the type, marks the <code>parameter</code> as chosen and update\r
+ * parameter graphics figures.\r
+ * \r
+ * @param value\r
+ * a new value of the type.\r
+ */\r
+ @Override\r
+ public void changeValue(String value) {\r
+ this.value = value;\r
+ parameter.setChosen();\r
+ parameter.updateFigure();\r
+ }\r
+\r
+ /**\r
+ * Sets the new value of the type and notifies its observers.\r
+ */\r
+ @Override\r
+ public void updateValue() {\r
+ setChanged();\r
+ notifyObservers(this.value);\r
+ if (unit != null)\r
+ unit.updateValue();\r
+ }\r
+\r
+ /**\r
+ * Sets the <code>default value</code> of the type and its unit. Notifies its observers.\r
+ */\r
+ public void setDefault() {\r
+ super.setDefault();\r
+ setChanged();\r
+ notifyObservers(value);\r
+ }\r
+\r
+ @Override\r
+ public String getOwnerName() { \r
+ return parameter.getName();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.parameters;\r
+\r
+import java.util.List;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Unit;\r
+\r
+/**\r
+ * The <code>UnitParam</code> class represents a unit of parameter type.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class UnitParam extends Unit {\r
+ /** The reference to the parametet of the unit */\r
+ private Parameter parameter;\r
+\r
+ /**\r
+ * Initializes a newly created <code>UnitParam</code> with the specified value, predefined\r
+ * units and reference to the appropriate parameter. The <code>value</code> argument is the\r
+ * value of the unit. The <code>unitList</code> is a list of predefined units. The\r
+ * <code>parameter</code> argument is an appropriate parameter.\r
+ * \r
+ * @param value\r
+ * a value of the unit.\r
+ * @param unitList\r
+ * a list of predefined units.\r
+ * @param parameter\r
+ * a reference to the unit parameter.\r
+ */\r
+ public UnitParam(String value, List<String> unitList, Parameter parameter) {\r
+ super(value, unitList);\r
+ this.parameter = parameter;\r
+ }\r
+ \r
+ public UnitParam(List<String> unitList, Parameter parameter) {\r
+ super(unitList);\r
+ this.parameter = parameter;\r
+ }\r
+\r
+ /**\r
+ * Sets the new value of unit and notifies its observers.\r
+ */\r
+ @Override\r
+ public void updateValue() {\r
+ setChanged();\r
+ notifyObservers(value);\r
+ }\r
+\r
+ /**\r
+ * Sets the new value of unit and marks its parameter as chosen.\r
+ * \r
+ * @param value\r
+ * a new value of the unit.\r
+ */\r
+ @Override\r
+ public void changeValue(String value) {\r
+ this.value = value;\r
+ parameter.setChosen();\r
+ }\r
+ \r
+ /**\r
+ * Sets the default value of the unit - assignes the default value to the main value and notifies its observers. \r
+ */\r
+ public void setDefault() {\r
+ super.setDefault();\r
+ setChanged();\r
+ notifyObservers(value);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.properties;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.GeneralElement;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>Attribute</code> class represents an atribute of property.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class Attribute extends GeneralElement implements Cloneable {\r
+ /** The list of attribute types */\r
+ private TypeAttr type;\r
+\r
+ /** The flag specifying whether the attribute is chosen or not */\r
+ private boolean chosen;\r
+\r
+ /** The temporary value of the attribute */\r
+ private boolean temporaryChosen;\r
+\r
+ public Attribute(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>Attribute</code> with the specified name and the\r
+ * type. Marks the attribute as not chosen. The <code>name</code> argument is the name of the\r
+ * attribute. The <code>type</code> argument is the type of attribute.\r
+ * \r
+ * @param name\r
+ * a name of attribute.\r
+ * @param type\r
+ * a type of attribute.\r
+ */\r
+ public Attribute(String name, TypeAttr type) {\r
+ super(name);\r
+ this.type = type;\r
+ this.chosen = false;\r
+ }\r
+\r
+ public Boolean isChosen() {\r
+ return chosen;\r
+ }\r
+\r
+ /**\r
+ * Sets the attribute <code>chosen</code> parameter according the input argument and assignes\r
+ * the value to the <code>temporaryChosen</code>.\r
+ * \r
+ * @param isChosen\r
+ * a value specifying whether the attribute is chosen or not.\r
+ */\r
+ public void setChosen(Boolean isChosen) {\r
+ this.chosen = isChosen;\r
+ this.temporaryChosen = isChosen;\r
+ }\r
+\r
+ public void setChosen() {\r
+ this.temporaryChosen = true;\r
+ setChanged();\r
+ notifyObservers(true);\r
+ }\r
+\r
+ /**\r
+ * Sets the <code>temporaryChosen</code> parameter according the input argument.\r
+ * \r
+ * @param isChosen\r
+ * a value specifying whether the attribute is chosen or not.\r
+ */\r
+ public void changeChosen(Boolean isChosen) {\r
+ this.temporaryChosen = isChosen;\r
+ }\r
+\r
+ public Object clone() {\r
+ Attribute attribute = null;\r
+ try {\r
+ attribute = (Attribute) super.clone();\r
+ attribute.setName(this.name);\r
+\r
+ attribute.setType((TypeAttr)this.type.clone());\r
+ } catch (CloneNotSupportedException ex) {\r
+ Log.error(ex);\r
+ }\r
+ return attribute;\r
+ }\r
+\r
+ /**\r
+ * Clear values (sets default values) of the attribute types.\r
+ */\r
+ public void clearValues() {\r
+ type.setDefault();\r
+ this.chosen = false;\r
+ this.node = null;\r
+ }\r
+\r
+ /**\r
+ * Sets values of all types after their temporary values. Sets <code>chosen</code> after\r
+ * <code>temporaryChosen</code>.\r
+ */\r
+ public void setValuesFromTemporary() {\r
+ type.setValuesFromTemporary();\r
+ this.chosen = temporaryChosen;\r
+ }\r
+\r
+ public void setType(TypeAttr type) {\r
+ this.type = type;\r
+ }\r
+\r
+ public TypeAttr getType() {\r
+ return type;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.properties;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentSection;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>AttributeGroup</code> class represents a group of atributes.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class AttributeGroup extends ParentSection implements Cloneable {\r
+\r
+ /** The list of attributes in the group */\r
+ private List<Attribute> attributeList;\r
+\r
+ /**\r
+ * Initializes a newly created <code>Attribute</code> with the specified name and description.\r
+ * The <code>title</code> argument is the name of the attribute group. \r
+ * \r
+ * @param title\r
+ * a name of the attribute group.\r
+ */\r
+ public AttributeGroup(String title) {\r
+ super(title);\r
+ }\r
+ \r
+ public void setTitle(String title){\r
+ this.title = title;\r
+ }\r
+\r
+ public Object clone() {\r
+ AttributeGroup group = null;\r
+ try {\r
+ group = (AttributeGroup) super.clone();\r
+ group.setTitle(this.title);\r
+\r
+ List<Attribute> newAttributes = new ArrayList<Attribute>();\r
+ for (int i = 0; i < attributeList.size(); i++) {\r
+ newAttributes.add((Attribute) attributeList.get(i).clone());\r
+ }\r
+ group.setAttributeList(newAttributes);\r
+ } catch (CloneNotSupportedException ex) {\r
+ Log.error(ex);\r
+ }\r
+ return group;\r
+ }\r
+\r
+ public List<Attribute> getAttributeList() {\r
+ return attributeList;\r
+ }\r
+\r
+ public void setAttributeList(List<Attribute> attributes) {\r
+ this.attributeList = attributes;\r
+ }\r
+\r
+ /**\r
+ * Clear values (sets default values) of all attribute types in the group.\r
+ */\r
+ public void clearValues() {\r
+ for (Attribute attr : this.attributeList) {\r
+ attr.clearValues();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Sets values of all attribute types in the group after their temporary values.\r
+ */\r
+ public void setValuesFromTemporary() {\r
+ for (Attribute at : this.getAttributeList())\r
+ at.setValuesFromTemporary();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.properties;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+\r
+/**\r
+ * The <code>Property</code> class represents an element property.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class Property extends ParentParameter {\r
+ /** The list of attribute groups */\r
+ private AttributeGroup[] attributeGroupList;\r
+\r
+ /**\r
+ * Initializes a newly created <code>Attribute</code> with the specified name and the list of\r
+ * attribute groups. The <code>name</code> argument is the name of the property. The\r
+ * <code>attributeGroups</code> argument is the list of <code>AttributeGroup</code>s.\r
+ * \r
+ * @param name\r
+ * a name of the property.\r
+ * @param attributeGroups\r
+ * a list of attribute groups.\r
+ */\r
+ public Property(String name, AttributeGroup[] attributeGroups, int lineNumber) {\r
+ super(name, lineNumber);\r
+ this.attributeGroupList = attributeGroups;\r
+ }\r
+\r
+ public AttributeGroup[] getAttributeGroupList() {\r
+ return attributeGroupList;\r
+ }\r
+\r
+ /**\r
+ * Search for an attribute with specified name.\r
+ * \r
+ * @param name\r
+ * a name of serched attribute.\r
+ * @return the found attribute with specified name.\r
+ */\r
+ public Attribute searchAttribute(String name) {\r
+ for (AttributeGroup group : attributeGroupList) {\r
+ int ind = group.getAttributeList().indexOf(new Attribute(name));\r
+ if (ind >= 0)\r
+ return group.getAttributeList().get(ind);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * Sets values of all groups of types after their temporary values.\r
+ */\r
+ public void setValuesFromTemporary() {\r
+ for (AttributeGroup pan : attributeGroupList)\r
+ pan.setValuesFromTemporary();\r
+ }\r
+\r
+ /**\r
+ * Clear values (sets default values) of all groups of types.\r
+ */\r
+ public void clearValues() {\r
+ super.clearValues();\r
+ for (AttributeGroup group : this.attributeGroupList) {\r
+ group.clearValues();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.properties;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+\r
+/**\r
+ * The <code>TypeAttr</code> class represents a type of attribute.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TypeAttr extends Type {\r
+ /** The temporary value of the attribute type */\r
+ private String temporaryValue;\r
+\r
+ /** The reference to the attribute of the type */\r
+ private Attribute attribute;\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>TypeAttr</code>.\r
+ */\r
+ public TypeAttr() {\r
+ super();\r
+ }\r
+\r
+ /**\r
+ * Sets values of the type and its unit after their temporary values.\r
+ */\r
+ public void setValuesFromTemporary() {\r
+ if (this.temporaryValue != null)\r
+ this.value = this.temporaryValue;\r
+ if (this.unit != null)\r
+ ((UnitAttr) this.unit).setValuesFromTemporary();\r
+ }\r
+\r
+ /**\r
+ * Sets the new value of the type (standard and temporary value) and marks the\r
+ * <code>attribute</code> as chosen.\r
+ * \r
+ * @param value\r
+ * a new value of the type.\r
+ */\r
+ @Override\r
+ public void changeValue(String value) {\r
+ this.temporaryValue = value;\r
+ this.attribute.setChosen();\r
+ }\r
+\r
+ /**\r
+ * Sets the new temporary value of the type.\r
+ */\r
+ @Override\r
+ public void updateValue() {\r
+ this.temporaryValue = this.value;\r
+ if (unit != null)\r
+ unit.updateValue();\r
+ }\r
+\r
+ public void setAttr(Attribute attr) {\r
+ this.attribute = attr;\r
+ }\r
+\r
+ /**\r
+ * Sets the <code>default and temporary value</code> of the type and its unit.\r
+ */\r
+ public void setDefault() {\r
+ super.setDefault();\r
+ this.temporaryValue = this.getDefaultValue().getDefaultValue();\r
+ }\r
+\r
+ @Override\r
+ public String getOwnerName() {\r
+ return attribute.getName();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.properties;\r
+\r
+import java.util.List;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Unit;\r
+\r
+/**\r
+ * The <code>UnitAttr</code> class represents a unit of attribute type.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class UnitAttr extends Unit {\r
+ /** The temporary value of the attribute unit */\r
+ protected String temporaryValue;\r
+\r
+ /** The reference to the attribute of the unit */\r
+ protected Attribute attribute;\r
+\r
+ /**\r
+ * Initializes a newly created <code>UnitAttr</code> with the specified value and predefined\r
+ * units. The <code>value</code> argument is the value of the unit. The <code>unitList</code>\r
+ * is a list of predefined units.\r
+ * \r
+ * @param value\r
+ * a value of the unit.\r
+ * @param unitList\r
+ * a list of predefined units.\r
+ */\r
+ public UnitAttr(String value, List<String> unitList) {\r
+ super(value, unitList);\r
+ }\r
+ \r
+ public UnitAttr(List<String> unitList) {\r
+ super(unitList);\r
+ }\r
+\r
+ /**\r
+ * Sets the new value of unit and marks its attribute as chosen.\r
+ * \r
+ * @param value\r
+ * a new value of the unit.\r
+ */\r
+ public void changeValue(String value) {\r
+ this.temporaryValue = value;\r
+ this.attribute.setChosen();\r
+ }\r
+\r
+ /**\r
+ * Sets the new temporary value of unit.\r
+ */\r
+ public void updateValue() {\r
+ this.temporaryValue = this.value;\r
+ }\r
+\r
+ /**\r
+ * Sets values of the unit after its temporary value.\r
+ */\r
+ public void setValuesFromTemporary() {\r
+ if (temporaryValue != null)\r
+ this.value = temporaryValue;\r
+ }\r
+\r
+ public void setAttribute(Attribute attribute) {\r
+ this.attribute = attribute;\r
+ }\r
+\r
+ /**\r
+ * Sets the <code>default and temporary value</code> of the unit.\r
+ */\r
+ public void setDefault() {\r
+ super.setDefault();\r
+ this.temporaryValue = this.defaultValue;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.sections;\r
+\r
+import java.util.List;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentSection;\r
+import cz.zcu.fav.kiv.editor.beans.graphics.Figure;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+\r
+/**\r
+ * The <code>Group</code> class represents a group of parameters and properties.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class Group extends ParentSection {\r
+ /** The graphics figure defined for parameters in the group */\r
+ private Figure figure;\r
+\r
+ /** The list of parameters and properties in the group */\r
+ private List<ParentParameter> elementList;\r
+\r
+ /**\r
+ * Initializes a newly created <code>Group</code> with the specified name. The\r
+ * <code>title</code> argument is the title of the group.\r
+ * \r
+ * @param title\r
+ * a title of the group.\r
+ */\r
+ public Group(String title) {\r
+ super(title);\r
+ }\r
+\r
+ /**\r
+ * Clear values (sets default values) of all parameters and properties.\r
+ */\r
+ public void clearValues() {\r
+ for (ParentParameter elem : this.elementList) {\r
+ if (elem instanceof Property)\r
+ ((Property) elem).clearValues();\r
+ if (elem instanceof Parameter)\r
+ ((Parameter) elem).clearValues();\r
+ }\r
+ }\r
+\r
+ public List<ParentParameter> getElementList() {\r
+ return elementList;\r
+ }\r
+\r
+ public void setElementList(List<ParentParameter> parameterList) {\r
+ this.elementList = parameterList;\r
+ }\r
+\r
+ public Figure getFigure() {\r
+ return figure;\r
+ }\r
+\r
+ public void setFigure(Figure figure) {\r
+ this.figure = figure;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.sections;\r
+\r
+import java.util.List;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentSection;\r
+\r
+/**\r
+ * The <code>Section</code> class represents a section of editor. It contains a list of\r
+ * <code>Subsection</code>s.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class Section extends ParentSection {\r
+ /** The list of subsections in the section */\r
+ private List<Subsection> subsectionList;\r
+\r
+ /**\r
+ * Initializes a newly created <code>Section</code> with the specified name. The\r
+ * <code>title</code> argument is the title of the section.\r
+ * \r
+ * @param title\r
+ * a title of the section.\r
+ */\r
+ public Section(String title) {\r
+ super(title);\r
+ }\r
+\r
+ public List<Subsection> getSubsectionList() {\r
+ return subsectionList;\r
+ }\r
+\r
+ public void setSubsectionList(List<Subsection> subsectionList) {\r
+ this.subsectionList = subsectionList;\r
+ }\r
+\r
+ /**\r
+ * Clear values (sets default values) of all subsections.\r
+ */\r
+ public void clearValues() {\r
+ for (Subsection subsection : subsectionList) {\r
+ subsection.clearValues();\r
+ subsection.setComment(null);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.sections;\r
+\r
+import java.util.List;\r
+\r
+import org.w3c.dom.Comment;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentSection;\r
+\r
+/**\r
+ * The <code>Subsection</code> class represents a subsection of a <code>Section</code>. It\r
+ * contains a list of <code>Group</code>s.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class Subsection extends ParentSection {\r
+ /** The list of group in the subsection */\r
+ private List<Group> groupList;\r
+ \r
+ /** The comment associated with the subsection */\r
+ private Comment comment;\r
+\r
+ /**\r
+ * Initializes a newly created <code>Subsection</code> with the specified name. The\r
+ * <code>title</code> argument is the title of the subsection.\r
+ * \r
+ * @param title\r
+ * a title of the subsection.\r
+ */\r
+ public Subsection(String title) {\r
+ super(title);\r
+ }\r
+\r
+ public List<Group> getGroupList() {\r
+ return groupList;\r
+ }\r
+\r
+ public void setGroupList(List<Group> groupList) {\r
+ this.groupList = groupList;\r
+ }\r
+\r
+ /**\r
+ * Clear values (sets default values) of all groups.\r
+ */\r
+ public void clearValues() {\r
+ for (Group group : groupList)\r
+ group.clearValues();\r
+ }\r
+\r
+ public Comment getComment() {\r
+ return comment;\r
+ }\r
+\r
+ public void setComment(Comment comment) {\r
+ this.comment = comment;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.types;\r
+\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+public class CommonTypes {\r
+ /** The list of unit values */\r
+ private List<String> units;\r
+\r
+ /** The list of font values */\r
+ private Map<String, String> fonts;\r
+\r
+ /** The list of color values */\r
+ private Map<String, String> colors;\r
+ \r
+ public CommonTypes(List<String> units, Map<String, String> colors, Map<String, String> fonts){\r
+ this.units = units;\r
+ this.colors = colors;\r
+ this.fonts = fonts;\r
+ }\r
+\r
+ public Map<String, String> getColors() {\r
+ return colors;\r
+ }\r
+\r
+ public Map<String, String> getFonts() {\r
+ return fonts;\r
+ }\r
+\r
+ public List<String> getUnits() {\r
+ return units;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.types;\r
+\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+public class DefaultType implements Cloneable {\r
+\r
+ /** The default value of the type */\r
+ protected String defaultValue;\r
+ \r
+ /** The list of predefined values of the type */\r
+ protected Map<String, String> valueList;\r
+ \r
+ public Object clone() {\r
+ DefaultType type = null;\r
+ try {\r
+ type = (DefaultType) super.clone();\r
+ type.setDefaultValue(defaultValue);\r
+ type.setValueList(this.valueList); \r
+ } catch (CloneNotSupportedException ex) {\r
+ Log.error(ex);\r
+ }\r
+ return type;\r
+ }\r
+\r
+ public void setDefaultValue(String defaultValue) {\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public void setValueList(Map<String, String> valueList) {\r
+ this.valueList = valueList;\r
+ }\r
+\r
+ public String getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ public Map<String, String> getValueList() {\r
+ return valueList;\r
+ }\r
+ \r
+ /**\r
+ * Returns the key for input value it it is contained in the list of predefined values.\r
+ * \r
+ * @param value\r
+ * a value of the searched value contained in the list of predefined values.\r
+ * @return a key belonging to the input value contained in the list of predefined values.\r
+ */\r
+ public String getKeyFromValue(String value) {\r
+ if (valueList != null)\r
+ for (Iterator it = valueList.entrySet().iterator(); it.hasNext();) {\r
+ Map.Entry e = (Map.Entry) it.next();\r
+ if (e.getValue().equals(value))\r
+ return e.getKey().toString();\r
+ }\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.types;\r
+\r
+import java.util.Map;\r
+import java.util.Observable;\r
+\r
+import cz.zcu.fav.kiv.editor.config.constants.TypeEnum;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.utils.TagControl;\r
+\r
+/**\r
+ * The <code>Type</code> class represents a parent for types of all elements.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public abstract class Type extends Observable implements Cloneable {\r
+ /** The name of the type */\r
+ protected TypeEnum name;\r
+\r
+ /** The default value of the type */\r
+ protected DefaultType defaultValue;\r
+\r
+ /** The value of the type */\r
+ protected String value;\r
+\r
+ /** The unit of the type */\r
+ protected Unit unit;\r
+\r
+ public void setUnit(Unit unit) {\r
+ this.unit = unit;\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created empty<code>Type</code>.\r
+ */\r
+ public Type() {\r
+ defaultValue = new DefaultType();\r
+ }\r
+ \r
+ public Type(TypeEnum name) {\r
+ this.name = name;\r
+ defaultValue = new DefaultType();\r
+ }\r
+\r
+ public void setDefaultValue(DefaultType defaultValue) {\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ public void setName(TypeEnum name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public String getValue() {\r
+ return value;\r
+ }\r
+\r
+ /**\r
+ * Sets the new value of the type with notifying of graphics items. \r
+ */\r
+ public abstract void updateValue();\r
+ \r
+\r
+ /**\r
+ * Sets the new value of the type without notifying of graphics items.\r
+ * @param value a new value of the type.\r
+ */\r
+ public abstract void changeValue(String value);\r
+\r
+ public Map<String, String> getValueList() {\r
+ return defaultValue.getValueList();\r
+ }\r
+\r
+ public void setValueList(Map<String, String> values) {\r
+ this.defaultValue.setValueList(values);\r
+ }\r
+\r
+ /**\r
+ * Returns the key for input value it it is contained in the list of predefined values.\r
+ * \r
+ * @param value\r
+ * a value of the searched value contained in the list of predefined values.\r
+ * @return a key belonging to the input value contained in the list of predefined values.\r
+ */\r
+ public String getKeyFromValue(String value) {\r
+ return defaultValue.getKeyFromValue(value);\r
+ }\r
+\r
+ public Object clone() {\r
+ Type type = null;\r
+ try {\r
+ type = (Type) super.clone();\r
+ type.setName(this.name);\r
+ type.setDefaultValue((DefaultType)this.defaultValue.clone());\r
+ type.setValue(this.value);\r
+ if (this.unit != null)\r
+ type.setUnit((Unit) this.unit.clone());\r
+ } catch (CloneNotSupportedException ex) {\r
+ Log.error(ex);\r
+ }\r
+ return type;\r
+ }\r
+\r
+ /**\r
+ * Sets the <code>default value</code> of the type and its unit.\r
+ */\r
+ public void setDefault() {\r
+ this.value = this.defaultValue.getDefaultValue();\r
+ if (this.unit != null)\r
+ this.unit.setDefault();\r
+ }\r
+\r
+ public Unit getUnit() {\r
+ return unit;\r
+ }\r
+\r
+ public DefaultType getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ public TypeEnum getName() {\r
+ return name;\r
+ }\r
+ \r
+ /**\r
+ * Assigns the new loaded value (from file, template).\r
+ * @param value the new type value.\r
+ * @throws ParserException if the value is invalid.\r
+ */\r
+ public void setLoadedValue(String value) throws ParserException {\r
+ TagControl.controlSetTypeValue(this, value);\r
+ updateValue();\r
+ }\r
+\r
+ public void setValue(String value) {\r
+ this.value = value;\r
+ }\r
+ \r
+ /**\r
+ * Assigns the default value same as value.\r
+ *\r
+ */\r
+ public void assignDefaultFromValue() {\r
+ this.defaultValue.defaultValue = value;\r
+ if (this.unit != null)\r
+ this.unit.assignDefaultFromValue();\r
+ }\r
+ \r
+ /**\r
+ * Return the name of the owner element - parameter or attribute.\r
+ *\r
+ */\r
+ public abstract String getOwnerName(); \r
+}\r
+\r
+\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.beans.types;\r
+\r
+import java.util.List;\r
+import java.util.Observable;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>Unit</code> class represents a parent for unit of elements.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public abstract class Unit extends Observable implements Cloneable {\r
+ /** The value of the unit */\r
+ protected String value;\r
+\r
+ /** The default value of the unit */\r
+ protected String defaultValue;\r
+\r
+ /** The list of predefined values of the unit */\r
+ protected List<String> valueList;\r
+\r
+ /**\r
+ * Initializes a newly created <code>Unit</code> with the specified value and predefined\r
+ * units. The <code>value</code> argument is the value of the unit. The <code>unitList</code>\r
+ * is a list of predefined units.\r
+ * \r
+ * @param value\r
+ * a value of the unit.\r
+ * @param unitList\r
+ * a list of predefined units.\r
+ */\r
+ public Unit(String value, List<String> unitList) {\r
+ this.value = value;\r
+ this.defaultValue = value;\r
+ this.valueList = unitList;\r
+ }\r
+\r
+ public Unit(List<String> unitList) {\r
+ this.valueList = unitList;\r
+ this.value = "";\r
+ this.defaultValue = "";\r
+ }\r
+\r
+ public String getDefaultValue() {\r
+ return defaultValue;\r
+ }\r
+\r
+ public void setDefaultValue(String defaultValue) {\r
+ this.defaultValue = defaultValue;\r
+ }\r
+\r
+ /**\r
+ * Sets the default value of the unit - assignes the default value to the main value.\r
+ */\r
+ public void setDefault() {\r
+ this.value = defaultValue;\r
+ }\r
+\r
+ public String getValue() {\r
+ return value;\r
+ }\r
+\r
+ public abstract void updateValue();\r
+\r
+ public abstract void changeValue(String value);\r
+\r
+ public Object clone() {\r
+ Unit unit = null;\r
+ try {\r
+ unit = (Unit) super.clone();\r
+ unit.setValue(this.value);\r
+ unit.setDefaultValue(this.defaultValue);\r
+ } catch (CloneNotSupportedException ex) {\r
+ Log.error(ex);\r
+ }\r
+ return unit;\r
+ }\r
+\r
+ /**\r
+ * Assigns the default value from value.\r
+ */\r
+ public void assignDefaultFromValue() {\r
+ this.defaultValue = this.value;\r
+ }\r
+\r
+ public List<String> getValueList() {\r
+ return valueList;\r
+ }\r
+\r
+ public void setValueList(List<String> values) {\r
+ this.valueList = values;\r
+ }\r
+\r
+ public void setValue(String value) {\r
+ this.value = value;\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config;\r
+\r
+import java.io.File;\r
+import java.util.Map;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.graphics.Figure;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.AttributeGroup;\r
+import cz.zcu.fav.kiv.editor.beans.types.CommonTypes;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ConfigException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.FileNotFoundException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>ConfigController</code> class contains methods for reading configuration files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ConfigController {\r
+ /** The data loaded from configuration files */\r
+ private static ConfigData data;\r
+ \r
+ private static CommonTypes commonTypes;\r
+\r
+ /** The parser of configuration files */\r
+ private ConfigParser parser;\r
+\r
+ /** The list of attribute groups */\r
+ private AttributeGroup[] attributeGroupList;\r
+ \r
+ /** The list of graphics figures - keys are figure names */\r
+ private Map<String, Figure> figureList;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ConfigController</code>. Simultaneously initializes new\r
+ * <code>ConfigParser</code> and <code>ConfigData</code>.\r
+ */\r
+ public ConfigController() {\r
+ data = new ConfigData();\r
+ MessageWriter.writeTitle(ResourceController.getMessage("parser.config_file.title"));\r
+ File directory = new File(OptionItems.XML_DEFINITION_PATH);\r
+ if (!directory.exists())\r
+ MessageWriter.writeError(ResourceController\r
+ .getMessage("parser.xml_definition_file.invalid_directory"));\r
+\r
+ parser = new ConfigParser();\r
+ }\r
+\r
+ /**\r
+ * Reads the configuration file with graphics figures - graphics.xml.\r
+ * \r
+ * @throws FileNotFoundException\r
+ * if the configuration file or its XML schema doesn't exist.\r
+ * @throws ConfigException\r
+ * if the configuration file or its XML schema isn't well-formed.\r
+ */\r
+ public void readFigures(Map<String, Parameter> parsedParameterList) throws FileNotFoundException, ConfigException {\r
+ if (!figureList.isEmpty())\r
+ parser.readFigures(parsedParameterList, figureList);\r
+ Log.info("info.progress_control.load_file", FileConst.CONF_FILE_FIGURES);\r
+ }\r
+\r
+ /**\r
+ * Reads the configuration file with attributes - attributes.xml.\r
+ * \r
+ * @throws ConfigException\r
+ * if the configuration file or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the configuration file or its XML schema doesn't exist.\r
+ */\r
+ public void readAttributes() throws ConfigException, FileNotFoundException {\r
+ this.attributeGroupList = parser.readAttributes(commonTypes);\r
+ Log.info("info.progress_control.load_file", FileConst.CONF_FILE_ATTRIBUTES);\r
+ }\r
+\r
+ /**\r
+ * Reads the configuration file with layout of parameters and attribute-sets - config.xml.\r
+ * \r
+ * @throws ConfigException\r
+ * if the configuration file or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the configuration file or its XML schema doesn't exist.\r
+ */\r
+ public void readConfig() throws ConfigException, FileNotFoundException {\r
+ figureList = parser.readConfig(data, attributeGroupList);\r
+ Log.info("info.progress_control.load_file", FileConst.CONF_FILE_CONFIG);\r
+ }\r
+\r
+ /**\r
+ * Reads the configuration file with types - types.xml.\r
+ * \r
+ * @throws ConfigException\r
+ * if the configuration file or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the configuration file or its XML schema doesn't exist.\r
+ */\r
+ public void readTypes() throws ConfigException, FileNotFoundException {\r
+ commonTypes = parser.readTypes();\r
+ Log.info("info.progress_control.load_file", FileConst.CONF_FILE_TYPE);\r
+ }\r
+\r
+ public ConfigData getData() {\r
+ return data;\r
+ }\r
+\r
+ public CommonTypes getCommonTypes() {\r
+ return commonTypes;\r
+ }\r
+\r
+ public Map<String, Figure> getFigureList() {\r
+ return figureList;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.Map;\r
+\r
+import javax.xml.parsers.SAXParser;\r
+import javax.xml.parsers.SAXParserFactory;\r
+\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.XMLReader;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.graphics.Figure;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.AttributeGroup;\r
+import cz.zcu.fav.kiv.editor.beans.types.CommonTypes;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.handlers.AttributeXmlHandler;\r
+import cz.zcu.fav.kiv.editor.config.handlers.ConfigXmlHandler;\r
+import cz.zcu.fav.kiv.editor.config.handlers.FigureXmlHandler;\r
+import cz.zcu.fav.kiv.editor.config.handlers.TypeXmlHandler;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ConfigException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.FileNotFoundException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.XslParserException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>ConfigParser</code> class contains methods for parsing configuration files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ConfigParser {\r
+\r
+ /** The parser key defining XML schema language */\r
+ private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";\r
+\r
+ /** The constants defining XML schema language */\r
+ private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";\r
+\r
+ /** The key defining XML schema */\r
+ private static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";\r
+\r
+ /** The XML parser used for reading configuration files */\r
+ private XMLReader parser;\r
+ \r
+ /**\r
+ * Initializes a newly created <code>ConfigParser</code>. Sets up the SAX parser used for\r
+ * parsing.\r
+ */\r
+ public ConfigParser() {\r
+ SAXParserFactory spf = SAXParserFactory.newInstance();\r
+ spf.setValidating(true);\r
+ spf.setNamespaceAware(true);\r
+\r
+ try {\r
+ SAXParser sp = spf.newSAXParser();\r
+ sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);\r
+ parser = sp.getXMLReader();\r
+ parser.setErrorHandler(new XslParserException());\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Parses the configuration file with graphics figures - graphics.xml.\r
+ * \r
+ * @param parameterList\r
+ * the list of loaded parameters.\r
+ * @param figureList\r
+ * the list of loaded figures. \r
+ * @throws ConfigException\r
+ * if the configuration file or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the configuration file or its XML schema doesn't exist.\r
+ */\r
+ public void readFigures(Map<String, Parameter> parameterList, Map<String, Figure> figureList)\r
+ throws ConfigException, FileNotFoundException {\r
+ InputStream xsdFile = ConfigParser.class\r
+ .getResourceAsStream(FileConst.CONF_FILE_FIGURES_XSD);\r
+ if (xsdFile == null)\r
+ throw new FileNotFoundException(FileConst.CONF_FILE_FIGURES_XSD);\r
+\r
+ FigureXmlHandler handler = new FigureXmlHandler(parameterList, figureList);\r
+ parser.setContentHandler(handler);\r
+ try {\r
+ parser.setProperty(JAXP_SCHEMA_SOURCE, xsdFile);\r
+ parser.parse(FileConst.CONF_FILE_FIGURES); \r
+ } catch (IOException ex) {\r
+ throw new FileNotFoundException(FileConst.CONF_FILE_FIGURES);\r
+ } catch (SAXException ex) {\r
+ throw new ConfigException(FileConst.CONF_FILE_FIGURES, ex.getMessage());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Parses the configuration file with attributes - attributes.xml.\r
+ * \r
+ * @param commonTypes\r
+ * common types of parameters.\r
+ * @return a list of loaded attributes - key is attribute name.\r
+ * @throws ConfigException\r
+ * if the configuration file or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the configuration file or its XML schema doesn't exist.\r
+ */\r
+ public AttributeGroup[] readAttributes(CommonTypes commonTypes) throws ConfigException,\r
+ FileNotFoundException {\r
+ InputStream xsdFile = ConfigParser.class\r
+ .getResourceAsStream(FileConst.CONF_FILE_ATTRIBUTES_XSD);\r
+ if (xsdFile == null)\r
+ throw new FileNotFoundException(FileConst.CONF_FILE_ATTRIBUTES_XSD);\r
+\r
+ AttributeXmlHandler handler = new AttributeXmlHandler(commonTypes);\r
+ parser.setContentHandler(handler);\r
+ try {\r
+ parser.setProperty(JAXP_SCHEMA_SOURCE, xsdFile);\r
+ parser.parse(FileConst.CONF_FILE_ATTRIBUTES);\r
+ return handler.getAttrGroupList();\r
+ } catch (IOException ex) {\r
+ throw new FileNotFoundException(FileConst.CONF_FILE_ATTRIBUTES);\r
+ } catch (SAXException ex) {\r
+ throw new ConfigException(FileConst.CONF_FILE_ATTRIBUTES, ex.getMessage());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Parses the configuration file with layout of parameters and attribute-sets - config.xml.\r
+ * \r
+ * @param configData\r
+ * so far loaded data from configuration files.\r
+ * @param attributeGroupList\r
+ * the list of attribute groups.\r
+ * @throws ConfigException\r
+ * if the configuration file or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the configuration file or its XML schema doesn't exist.\r
+ */\r
+ public Map<String, Figure> readConfig(ConfigData configData, AttributeGroup[] attributeGroupList)\r
+ throws ConfigException, FileNotFoundException {\r
+ InputStream xsdFile = ConfigParser.class\r
+ .getResourceAsStream(FileConst.CONF_FILE_CONFIG_XSD);\r
+ if (xsdFile == null)\r
+ throw new FileNotFoundException(FileConst.CONF_FILE_CONFIG_XSD);\r
+\r
+ ConfigXmlHandler handler = new ConfigXmlHandler(attributeGroupList);\r
+ parser.setContentHandler(handler);\r
+ try {\r
+ parser.setProperty(JAXP_SCHEMA_SOURCE, xsdFile);\r
+ parser.parse(FileConst.CONF_FILE_CONFIG);\r
+ configData.setSectionList(handler.getSections());\r
+ configData.setPropertyList(handler.getPropertyList());\r
+ configData.setParameterList(handler.getParameterList());\r
+ return handler.getFigureList();\r
+ } catch (IOException ex) {\r
+ throw new FileNotFoundException(FileConst.CONF_FILE_CONFIG);\r
+ } catch (SAXException ex) {\r
+ throw new ConfigException(FileConst.CONF_FILE_CONFIG, ex.getMessage());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Parses the configuration file with types - types.xml.\r
+ * \r
+ * @throws ConfigException\r
+ * if the configuration file or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the configuration file or its XML schema doesn't exist.\r
+ */\r
+ public CommonTypes readTypes() throws ConfigException, FileNotFoundException {\r
+ InputStream xsdFile = ConfigParser.class.getResourceAsStream(FileConst.CONF_FILE_TYPE_XSD);\r
+ if (xsdFile == null)\r
+ throw new FileNotFoundException(FileConst.CONF_FILE_TYPE_XSD);\r
+\r
+ TypeXmlHandler handler = new TypeXmlHandler();\r
+ parser.setContentHandler(handler);\r
+ try {\r
+ parser.setProperty(JAXP_SCHEMA_SOURCE, xsdFile);\r
+\r
+ parser.parse(FileConst.CONF_FILE_TYPE);\r
+ return new CommonTypes(handler.getUnitList(), handler.getColorList(), handler.getFontList());\r
+ } catch (IOException ex) {\r
+ throw new FileNotFoundException(FileConst.CONF_FILE_TYPE);\r
+ } catch (SAXException ex) {\r
+ throw new ConfigException(FileConst.CONF_FILE_TYPE, ex.getMessage());\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config;\r
+\r
+import java.io.File;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+import java.util.regex.Pattern;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+import cz.zcu.fav.kiv.editor.beans.graphics.Figure;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Group;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Section;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Subsection;\r
+import cz.zcu.fav.kiv.editor.beans.types.CommonTypes;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+\r
+/**\r
+ * The <code>ParamController</code> class contains method for reading XML definitions of\r
+ * parameters and properties.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParamController {\r
+ /** The model pattern used for parsing $param */\r
+ public static final String REGEX_PARAM = "\\$[\\w\\.]+";\r
+\r
+ /** The model pattern used for parsing $param */\r
+ public static Pattern patternParam = Pattern.compile(REGEX_PARAM);\r
+\r
+ /** The parser of XML parameter definitions */\r
+ private ParameterParser parameterParserXML = null;\r
+\r
+ /** The parser of XML property definitions */\r
+ private PropertyParser propertyParserXML = null;\r
+\r
+ /** The data loaded from configuration files */\r
+ private ConfigData configData;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ParamController</code>. Simultaneously initializes new\r
+ * <code>ParameterParser</code> and <code>PropertyParser</code>.\r
+ */\r
+ public ParamController(ConfigData configData, CommonTypes types) {\r
+ parameterParserXML = new ParameterParser(types);\r
+ propertyParserXML = new PropertyParser();\r
+ this.configData = configData;\r
+ }\r
+\r
+ /**\r
+ * Reads XML files for all parameters. Processes the complex paramater values that depends on\r
+ * other parameter values.\r
+ */\r
+ public void readParameters() {\r
+ File directory = new File(OptionItems.XML_DEFINITION_PATH);\r
+ if (directory.exists()) {\r
+ parameterParserXML.readParameterDefinition(configData.getParameterList());\r
+ parameterParserXML.processParameterDependency();\r
+ }\r
+\r
+ Log.info("info.progress_control.load_parameter_description");\r
+ }\r
+\r
+ /**\r
+ * Reads XML files for all properties. Processes the complex attribute values that depends on\r
+ * other parameter values.\r
+ */\r
+ public void readProperties() {\r
+ File directory = new File(OptionItems.XML_DEFINITION_PATH);\r
+ if (directory.exists()) {\r
+ propertyParserXML.readPropertyDefinition(configData.getPropertyList());\r
+ propertyParserXML.processPropertyDependency();\r
+ }\r
+ Log.info("info.progress_control.load_property_description");\r
+ }\r
+\r
+ /**\r
+ * Removes all parameters and properties that couldn't be parsed.\r
+ * \r
+ * @param figureList\r
+ * the list with graphics figures.\r
+ */\r
+ public void removeInvalidParam(Map<String, Figure> figureList) {\r
+ for (Section section : configData.getSectionList()) {\r
+ Iterator<Subsection> subsectionIter = section.getSubsectionList().iterator();\r
+ while (subsectionIter.hasNext()) {\r
+ Subsection subsection = subsectionIter.next();\r
+ Iterator<Group> groupIter = subsection.getGroupList().iterator();\r
+ while (groupIter.hasNext()) {\r
+ Group group = groupIter.next();\r
+ // parameters and properties\r
+ Iterator<ParentParameter> elementIter = group.getElementList().iterator();\r
+ while (elementIter.hasNext()) {\r
+ ParentParameter element = elementIter.next();\r
+ if (element instanceof Parameter) {\r
+ if (!parameterParserXML.getParsedParameterList().containsKey(\r
+ element.getName()))\r
+ elementIter.remove();\r
+ }\r
+ if (element instanceof Property) {\r
+ if (!propertyParserXML.getParsedPropertyList().containsKey(\r
+ element.getName()))\r
+ elementIter.remove();\r
+ }\r
+ }\r
+ // figures - remove invalid figures\r
+ if (group.getFigure() != null) {\r
+ if (!figureList.containsKey(group.getFigure().getName()))\r
+ group.setFigure(null);\r
+ }\r
+ if (group.getElementList().size() == 0)\r
+ groupIter.remove();\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ public Map<String, Parameter> getParsedParameterList() {\r
+ return parameterParserXML.getParsedParameterList();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config;\r
+\r
+import java.text.DecimalFormat;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.utils.TagControl;\r
+\r
+/**\r
+ * The <code>ParameterDependencyParser</code> class contains methods for parsing parameter complex\r
+ * values that contains references to other parameter values.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParameterDependencyParser {\r
+ /** The sign asterisk */\r
+ private static final String SIGN_ASTERISK = "*";\r
+\r
+ /** The sign plus left */\r
+ private static final String SIGN_PLUS_LEFT = "+L";\r
+\r
+ /** The sign plus right */\r
+ private static final String SIGN_PLUS_RIGHT = "+R";\r
+\r
+ /** The sign equal */\r
+ private static final String SIGN_EQUAL = "=";\r
+\r
+ /** The sign not equal */\r
+ private static final String SIGN_NOT_EQUAL = "!=";\r
+\r
+ /** The name contains */\r
+ private static final String CONTAINS = "contains";\r
+\r
+ /** The format for formating double numbers */\r
+ private static final DecimalFormat formatDouble = new DecimalFormat("0.##");\r
+\r
+ /** The parser of XML parameter definitions */\r
+ private ParameterParser paramParser;\r
+\r
+ /** The actually parsed parameter */\r
+ private Parameter parameter;\r
+\r
+ /** The flag indicating if the parameter value is valid */\r
+ private boolean valid;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ParameterDependencyParser</code>.\r
+ * \r
+ * @param parser\r
+ * the parser of XML parameter definitions.\r
+ */\r
+ public ParameterDependencyParser(ParameterParser parser) {\r
+ this.paramParser = parser;\r
+ }\r
+\r
+ /**\r
+ * Parses the complex value of the parameter.\r
+ * \r
+ * @param parameter\r
+ * the parsed parameter.\r
+ * @return true if the parameter value is successfully parsed.\r
+ */\r
+ public boolean parseParameterDependency(Parameter parameter) {\r
+ this.parameter = parameter;\r
+ valid = false;\r
+\r
+ processXslChoose(parameter.getType().getValue());\r
+\r
+ if (!valid)\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.parameters.invalid_value", FileConst.CONF_FILE_CONFIG, parameter\r
+ .getName(), parameter.getLineNumber()));\r
+ return valid;\r
+ }\r
+\r
+ /**\r
+ * Parses simple complex value.\r
+ * \r
+ * @param simpleValue\r
+ * the complex parameter value.\r
+ */\r
+ private void parseSimpleValue(String simpleValue) {\r
+ parseSimpleValue(simpleValue, "");\r
+ }\r
+\r
+ /**\r
+ * Parses simple complex value.\r
+ * \r
+ * @param complexValue\r
+ * the complex parameter value.\r
+ * @param secondAddValue\r
+ * the string creating the end of parameter value.\r
+ */\r
+ private void parseSimpleValue(String complexValue, String secondAddValue) {\r
+ // $param * number\r
+ if (complexValue.matches("\\$[\\w\\.]+\\s*\\*\\s*[\\d\\.]+")) {\r
+ String[] valueParts = complexValue.split("\\*");\r
+ evaluateSimpleValue(valueParts[0], valueParts[1], SIGN_ASTERISK, secondAddValue);\r
+ return;\r
+ }\r
+ // number * $param\r
+ if (complexValue.matches("\\d+\\s*\\*\\s*\\$[\\w\\.]+")) {\r
+ String[] valueParts = complexValue.split("\\*");\r
+ evaluateSimpleValue(valueParts[1], valueParts[0], SIGN_ASTERISK, secondAddValue);\r
+ return;\r
+ }\r
+ // $param\r
+ if (complexValue.matches("\\$[\\w\\.]+")) {\r
+ evaluateSimpleValue(complexValue, null, null, secondAddValue);\r
+ return;\r
+ }\r
+\r
+ // concat('..', $param)\r
+ if (complexValue.matches("concat\\('\\w+',\\s*\\$[\\w\\.]+\\)")) {\r
+ String[] valueParts = complexValue.split("[(,)]");\r
+ evaluateSimpleValue(valueParts[2].trim(), valueParts[1].replaceAll("'", ""),\r
+ SIGN_PLUS_LEFT, secondAddValue);\r
+ return;\r
+ }\r
+ // concat($param, '..')\r
+ if (complexValue.matches("concat\\(\\$[\\w\\.]+,\\s*'\\w+'\\)")) {\r
+ String[] valueParts = complexValue.split("[(,)]");\r
+ evaluateSimpleValue(valueParts[1].trim(), valueParts[2].replaceAll("'", ""),\r
+ SIGN_PLUS_RIGHT, secondAddValue);\r
+ return;\r
+ }\r
+ setParameterValue(complexValue);\r
+ }\r
+\r
+ /**\r
+ * Parsed the structure <xsl:value-of select="..."></xsl:value-of><xsl:text>...</xsl:text>.\r
+ * \r
+ * @param complexValue\r
+ * the complex parameter value.\r
+ */\r
+ private void processXslValueOf(String complexValue) {\r
+ String lineValue = complexValue.replaceAll("\n", "").trim();\r
+ if (lineValue\r
+ .matches("<xsl:value-of select=\".+?\"></xsl:value-of>(<xsl:text>.+?</xsl:text>)?")) {\r
+ Pattern patternXslValueOf = Pattern\r
+ .compile("<xsl:value-of select=\"(.+?)\"></xsl:value-of>(<xsl:text>(.+?)</xsl:text>)?");\r
+ Matcher matcherXslValueOf = patternXslValueOf.matcher(complexValue);\r
+ if (matcherXslValueOf.find()) {\r
+ parseSimpleValue(matcherXslValueOf.group(1),\r
+ ((matcherXslValueOf.group(3) != null) ? matcherXslValueOf.group(3) : ""));\r
+ }\r
+ return;\r
+ }\r
+ parseSimpleValue(complexValue);\r
+ }\r
+\r
+ /**\r
+ * Parsed the structure <xsl:choose>...</xsl:choose>.\r
+ * \r
+ * @param complexValue\r
+ * the complex parameter value.\r
+ */\r
+ private void processXslChoose(String complexValue) {\r
+ String lineValue = complexValue.replaceAll("\n", "");\r
+ if (lineValue.matches("<xsl:choose>.*</xsl:choose>")) {\r
+ Pattern patternWhen = Pattern.compile("<xsl:when test=\"(.+?)\">(.+?)</xsl:when>");\r
+ Matcher matcherWhen = patternWhen.matcher(lineValue);\r
+ boolean testResult = false;\r
+ while (matcherWhen.find()) {\r
+ testResult = parseXslWhenTest(matcherWhen.group(1));\r
+ if (testResult) {\r
+ processXslValueOf(matcherWhen.group(2));\r
+ break;\r
+ }\r
+ }\r
+ if (!testResult) {\r
+ Pattern patternOtherwise = Pattern.compile("<xsl:otherwise>(.*)</xsl:otherwise>");\r
+ Matcher matcherOtherwise = patternOtherwise.matcher(lineValue);\r
+ while (matcherOtherwise.find()) {\r
+ processXslValueOf(matcherOtherwise.group(1));\r
+ }\r
+ }\r
+ return;\r
+ }\r
+ processXslValueOf(complexValue);\r
+ }\r
+\r
+ /**\r
+ * Parses the condition test of the structure <xsl:when test="..."></xsl:when>.\r
+ * \r
+ * @param testAttribute\r
+ * the content of attribute test.\r
+ * @return true if the condition in the <code>test</code> attribute is true.\r
+ */\r
+ private boolean parseXslWhenTest(String testAttribute) {\r
+ // $param = 'value' or $param != 'value'\r
+ if (testAttribute.startsWith("$")) {\r
+ // control pattern: $param = 'value' or $param = value\r
+ Pattern pattern = Pattern.compile("\\$(.+?) ?(!?=) ?('?.++'?)");\r
+ Matcher matcher = pattern.matcher(testAttribute);\r
+ if (matcher.find()) {\r
+ return evaluateXslWhenTest(matcher.group(1), matcher.group(2), matcher.group(3)\r
+ .replaceAll("'", ""));\r
+ }\r
+ }\r
+\r
+ // contains($param, 'value')\r
+ if (testAttribute.startsWith(TagDefinition.ParameterTags.CONTAINS)) {\r
+ Pattern pattern = Pattern.compile("contains\\(\\$(\\$.+?), *('?.+?'?)\\)");\r
+ Matcher matcher = pattern.matcher(testAttribute);\r
+ if (matcher.find()) {\r
+ return evaluateXslWhenTest(matcher.group(1), CONTAINS, matcher.group(2).replaceAll(\r
+ "'", ""));\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * Evaluate the condition in the test attribute.\r
+ * \r
+ * @param param\r
+ * the name of parameter.\r
+ * @param sign\r
+ * the sign of the condition.\r
+ * @param value\r
+ * the value of the parameter.\r
+ * @return true if the condition is true.\r
+ */\r
+ private boolean evaluateXslWhenTest(String param, String sign, String value) {\r
+ Parameter testParam = paramParser.getParsedParameterList().get(param);\r
+ if (sign.equals(SIGN_NOT_EQUAL)) {\r
+ return !testParam.getType().getValue().equals(value);\r
+ }\r
+ if (sign.equals(SIGN_EQUAL)) {\r
+ return testParam.getType().getValue().equals(value);\r
+ }\r
+ if (sign.equals(CONTAINS)) {\r
+ return testParam.getType().getValue().contains(value);\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * Evaluates the content of the simple complex value and assigns the new value to the parameter.\r
+ * \r
+ * @param param\r
+ * the parameter on which the parameter is dependent.\r
+ * @param addValue\r
+ * the value added to the parameter value.\r
+ * @param sign\r
+ * the sign used for adding the value to the parameter value.\r
+ * @param secondAddValue\r
+ * the second value added to the parameter value.\r
+ */\r
+ private void evaluateSimpleValue(String param, String addValue, String sign,\r
+ String secondAddValue) {\r
+ // parameter name without $\r
+ String paramName = param.trim().substring(1);\r
+ // control parameter\r
+ Parameter par = paramParser.getParsedParameterList().get(paramName);\r
+ if (par == null) {\r
+ return;\r
+ }\r
+ String endValue = secondAddValue\r
+ + ((par.getType().getUnit() != null) ? par.getType().getUnit().getValue() : "");\r
+ // only param value\r
+ if ((addValue == null) && (sign == null)) {\r
+ setParameterValue(par.getType().getValue() + endValue);\r
+ return;\r
+ }\r
+\r
+ // * -> addValue must be number\r
+ if (sign.equals(SIGN_ASTERISK)) {\r
+ try {\r
+ Double result = Double.valueOf(addValue.trim())\r
+ * Double.valueOf(par.getType().getValue());\r
+ setParameterValue(formatDouble.format(result) + endValue);\r
+ } catch (NumberFormatException ex) {\r
+ }\r
+ return;\r
+ }\r
+\r
+ // + -> addValue is string\r
+ if (sign.equals(SIGN_PLUS_LEFT)) {\r
+ setParameterValue(addValue + par.getType().getValue() + endValue);\r
+ }\r
+ if (sign.equals(SIGN_PLUS_RIGHT)) {\r
+ setParameterValue(par.getType().getValue() + addValue + endValue);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Sets the new value to the parameter.\r
+ * \r
+ * @param newValue\r
+ * the new parameter value.\r
+ */\r
+ private void setParameterValue(String newValue) {\r
+ try {\r
+ TagControl.controlSetTypeValue(parameter.getType(), newValue);\r
+ parameter.getType().assignDefaultFromValue();\r
+ valid = true;\r
+ } catch (ParserException ex) {\r
+ valid = false;\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.regex.Matcher;\r
+\r
+import javax.xml.parsers.SAXParser;\r
+import javax.xml.parsers.SAXParserFactory;\r
+\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.XMLReader;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.types.CommonTypes;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.handlers.ParameterXmlHandler;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.ProgressControl;\r
+import cz.zcu.fav.kiv.editor.controller.errors.XslParserException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>ParameterParser</code> class contains methods for parsing files with XML definitions\r
+ * of parameters.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParameterParser {\r
+ \r
+ /** The max number of dependency nesting - to avoid cycle dependency **/\r
+ private static final int LIMIT_LOOP = 5;\r
+ \r
+ /** The XML parser used for reading XML files */\r
+ private XMLReader parser;\r
+ \r
+ /** The list of parsed parameters */\r
+ private Map<String, Parameter> parsedParameterList;\r
+ \r
+ /** The list of unparsed parameters */\r
+ private Map<String, Parameter> unparsedParameterList;\r
+ \r
+ /** The list of invalid parameters */\r
+ private List<String> invalidParameterList;\r
+ \r
+ /** The list of common types */\r
+ private static CommonTypes commonTypes;\r
+ \r
+ /** The parser used for parsing parameter value dependencies */\r
+ private ParameterDependencyParser paramDependencyParser;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ParameterParser</code>. Sets up the SAX parser used for\r
+ * parsing.\r
+ */\r
+ public ParameterParser(CommonTypes types) {\r
+ try {\r
+ SAXParserFactory spf = SAXParserFactory.newInstance();\r
+ spf.setValidating(false);\r
+\r
+ SAXParser saxParser = spf.newSAXParser();\r
+ parser = saxParser.getXMLReader();\r
+ parser.setErrorHandler(new XslParserException());\r
+ \r
+ commonTypes = types;\r
+ \r
+ unparsedParameterList = new HashMap<String, Parameter>();\r
+ parsedParameterList = new HashMap<String, Parameter>();\r
+ invalidParameterList = new ArrayList<String>();\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * In sequence parses for every parameter its XML definition file.\r
+ * \r
+ * @param parameterList\r
+ * the list of parameter names loaded from the main configuration file.\r
+ */\r
+ public void readParameterDefinition(Map<String, Parameter> parameterList) {\r
+ Iterator<Map.Entry<String, Parameter>> iter = parameterList.entrySet().iterator();\r
+ while (iter.hasNext()) {\r
+ Map.Entry<String, Parameter> param = iter.next();\r
+ //inform about file loading\r
+ ProgressControl.addStatMessage(ResourceController.getMessage("frame.intro.progress.read_file", OptionItems.XML_DEFINITION_PATH + File.separator + param.getValue().getName()+".xml")); \r
+ parseParameter(param.getValue());\r
+ } \r
+ }\r
+\r
+ /**\r
+ * For input parameter parses its XML definition file.\r
+ * \r
+ * @param element\r
+ * the parameter which XML file is parsed.\r
+ */\r
+ private void parseParameter(Parameter element) {\r
+ try {\r
+ ParameterXmlHandler handler = new ParameterXmlHandler(element, commonTypes);\r
+ parser.setContentHandler(handler);\r
+ parser.parse(OptionItems.XML_DEFINITION_PATH + File.separator + element.getName()\r
+ + ".xml");\r
+ if (!handler.isValid()) {\r
+ invalidParameterList.add(element.getName());\r
+ } else {\r
+ if (handler.isParsed())\r
+ parsedParameterList.put(element.getName(), element);\r
+ else\r
+ unparsedParameterList.put(element.getName(), element);\r
+ }\r
+ } catch (IOException ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.xml_definition_file.missing_file", element.getName(),\r
+ OptionItems.XML_DEFINITION_PATH));\r
+ invalidParameterList.add(element.getName());\r
+ } catch (SAXException ex) {\r
+ Log.warn("error.param_parser.parser_error", ex);\r
+ invalidParameterList.add(element.getName());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Process values of parameters from <code>unparsedParameterList</code>.\r
+ */\r
+ public void processParameterDependency() {\r
+ paramDependencyParser = new ParameterDependencyParser(this);\r
+ Map<String, Parameter> innerUnparsedParameterList = null;\r
+ StringBuilder message = new StringBuilder();\r
+ int limitLoop = 0;\r
+ while(!unparsedParameterList.isEmpty()) {\r
+ innerUnparsedParameterList = unparsedParameterList;\r
+ unparsedParameterList = new HashMap<String, Parameter>();\r
+ Iterator it = innerUnparsedParameterList.entrySet().iterator();\r
+ while (it.hasNext()) {\r
+ Map.Entry param = (Map.Entry)it.next();\r
+ if (limitLoop == LIMIT_LOOP) {\r
+ message.append(param.getKey() + ",");\r
+ } else {\r
+ //parse\r
+ parseParameterValue((Parameter)param.getValue(), innerUnparsedParameterList);\r
+ }\r
+ }\r
+ //to avoid cycle dependency\r
+ if (limitLoop == LIMIT_LOOP) { \r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.parameters.dependency_cycle", FileConst.CONF_FILE_CONFIG, message));\r
+ break; \r
+ }\r
+ limitLoop++;\r
+ }\r
+ } \r
+\r
+ public Map<String, Parameter> getParsedParameterList() {\r
+ return parsedParameterList;\r
+ }\r
+ \r
+ /**\r
+ * Parses parameter value that contains references to others parameters.\r
+ * @param param the parsed parameter.\r
+ * @param innerUnparsedParameterList the list of unparsed parameters.\r
+ */\r
+ private void parseParameterValue(Parameter param, Map<String, Parameter> innerUnparsedParameterList) {\r
+ Matcher matcher = ParamController.patternParam.matcher(param.getType().getValue());\r
+ boolean canBeParsed = true;\r
+ while(matcher.find()) {\r
+ String paramName = matcher.group().substring(1); \r
+ if (invalidParameterList.contains(paramName)) {\r
+ //parameter is invalid -> the depending parameter is invalid\r
+ invalidParameterList.add(param.getName()); \r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.parameters.invalid_value", FileConst.CONF_FILE_CONFIG, param\r
+ .getName(), param.getLineNumber()));\r
+ return;\r
+ }\r
+ if (!parsedParameterList.containsKey(paramName)) {\r
+ //param is not yet parsed\r
+ if (!innerUnparsedParameterList.containsKey(paramName))\r
+ parseParameter(new Parameter(paramName));\r
+ canBeParsed = false;\r
+ }\r
+ }\r
+ if (!canBeParsed) {\r
+ unparsedParameterList.put(param.getName(), param);\r
+ } else {\r
+ //parse parameter value\r
+ if (paramDependencyParser.parseParameterDependency(param))\r
+ parsedParameterList.put(param.getName(), param);\r
+ else\r
+ invalidParameterList.add(param.getName()); \r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config;\r
+\r
+import java.io.ByteArrayOutputStream;\r
+import java.io.InputStream;\r
+import java.io.StringReader;\r
+\r
+import javax.xml.transform.Transformer;\r
+import javax.xml.transform.TransformerFactory;\r
+import javax.xml.transform.stream.StreamResult;\r
+import javax.xml.transform.stream.StreamSource;\r
+\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+public class ParameterTransformation {\r
+ /**\r
+ * Transform text description in DocBook to HTML format.\r
+ * \r
+ * @param input\r
+ * the text in DocBook.\r
+ * @return the input text transformed to HTML.\r
+ */\r
+ public static String htmlTransform(String input) {\r
+ try {\r
+ InputStream convertFile = ConfigParser.class\r
+ .getResourceAsStream(FileConst.CONF_FILE_CONVERT);\r
+\r
+ TransformerFactory trf = TransformerFactory.newInstance();\r
+ Transformer transformer = trf.newTransformer(new StreamSource(convertFile));\r
+\r
+ ByteArrayOutputStream out = new ByteArrayOutputStream();\r
+\r
+ String tempStr = new String(input.getBytes(), "windows-1250");\r
+ transformer.transform(new StreamSource(new StringReader(tempStr)),\r
+ new StreamResult(out));\r
+\r
+ return out.toString();\r
+ } catch (Throwable ex) {\r
+ Log.warn("error.param_parser.transformation_error", ex);\r
+ }\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import javax.xml.parsers.SAXParser;\r
+import javax.xml.parsers.SAXParserFactory;\r
+\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.XMLReader;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.config.handlers.PropertyXmlHandler;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.ProgressControl;\r
+import cz.zcu.fav.kiv.editor.controller.errors.XslParserException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>PropertyParser</code> class contains methods for parsing files with XML definitions\r
+ * of properties.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class PropertyParser {\r
+ /** The XML parser used for reading XML files */\r
+ private XMLReader parser;\r
+ \r
+ /** The list of parsed properties */\r
+ private Map<String, Property> parsedPropertyList;\r
+ \r
+ /** The list of unparsed attributes */\r
+ private Map<String, Attribute> unparsedAttributeList;\r
+\r
+ /**\r
+ * Initializes a newly created <code>PropertyParser</code>. Sets up the SAX parser used for\r
+ * parsing.\r
+ */\r
+ public PropertyParser() {\r
+ try {\r
+ SAXParserFactory spf = SAXParserFactory.newInstance();\r
+ spf.setValidating(false);\r
+\r
+ SAXParser saxParser = spf.newSAXParser();\r
+ parser = saxParser.getXMLReader();\r
+ parser.setErrorHandler(new XslParserException());\r
+ \r
+ unparsedAttributeList = new HashMap<String, Attribute>();\r
+ parsedPropertyList = new HashMap<String, Property>();\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * In sequence parses for every property its XML definition file.\r
+ * \r
+ * @param propertyList\r
+ * the list of property names loaded from the main configuration file.\r
+ */\r
+ public void readPropertyDefinition(Map<String, Property> propertyList) {\r
+ Iterator<Map.Entry<String, Property>> iter = propertyList.entrySet().iterator();\r
+ while (iter.hasNext()) {\r
+ Map.Entry<String, Property> prop = iter.next();\r
+ ProgressControl.addStatMessage(ResourceController.getMessage("frame.intro.progress.read_file", OptionItems.XML_DEFINITION_PATH + File.separator + prop.getValue().getName()+".xml"));\r
+ parseProperty(prop.getValue());\r
+ } \r
+ }\r
+\r
+ /**\r
+ * For input property parses its XML definition file.\r
+ * \r
+ * @param element\r
+ * the property which XML file is parsed.\r
+ */\r
+ private void parseProperty(Property element) {\r
+ try {\r
+ PropertyXmlHandler handler = new PropertyXmlHandler(element);\r
+ parser.setContentHandler(handler);\r
+ parser.parse(OptionItems.XML_DEFINITION_PATH + File.separator + element.getName()\r
+ + ".xml");\r
+ if (handler.isValid()) {\r
+ parsedPropertyList.put(element.getName(), element);\r
+ }\r
+ //unparsed attributes\r
+ if (handler.getUnparsedAttributeList().size() > 0)\r
+ unparsedAttributeList.putAll(handler.getUnparsedAttributeList());\r
+ } catch (IOException ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.xml_definition_file.missing_file", element.getName(),\r
+ OptionItems.XML_DEFINITION_PATH));\r
+ } catch (SAXException ex) {\r
+ Log.warn("error.param_parser.parser_error", ex);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Process values of parameters from <code>unparsedAttributeList</code>.\r
+ */\r
+ public void processPropertyDependency() {\r
+//TODO parse complicated dependent attribute values \r
+// Iterator it = unparsedAttributeList.entrySet().iterator();\r
+// while (it.hasNext()) {\r
+// Map.Entry pairs = (Map.Entry)it.next();\r
+// pairs.getKey() (Attribute)pairs.getValue()\r
+// }\r
+ }\r
+\r
+ public Map<String, Property> getParsedPropertyList() {\r
+ return parsedPropertyList;\r
+ }\r
+ \r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.constants;\r
+\r
+import java.io.File;\r
+\r
+/**\r
+ * The <code>FileConst</code> class contains paths and names of configuration files and their XSL\r
+ * schemas.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class FileConst {\r
+\r
+ /** The directory where configuration files are stored */\r
+ public static final String CONF_FILE_XML_DIR = "configuration" + File.separator;\r
+\r
+ /** The directory where XML schemas of configuration files are stored */\r
+ public static final String CONF_FILE_XSD_DIR = '\u002f' + "schemas" + '\u002f';\r
+\r
+ /** The configuration file describing layout of parameters and attribute-sets */\r
+ public static final String CONF_FILE_CONFIG = CONF_FILE_XML_DIR + "config.xml";\r
+\r
+ /** The XML schema of the configuration file describing layout of parameters and attribute-sets */\r
+ public static final String CONF_FILE_CONFIG_XSD = CONF_FILE_XSD_DIR + "config.xsd";\r
+\r
+ /** The configuration file describing attributes */\r
+ public static final String CONF_FILE_ATTRIBUTES = CONF_FILE_XML_DIR + "attributes.xml";\r
+\r
+ /** The XML schema of the configuration file describing attributes */\r
+ public static final String CONF_FILE_ATTRIBUTES_XSD = CONF_FILE_XSD_DIR + "attributes.xsd";\r
+\r
+ /** The configuration file describing types */\r
+ public static final String CONF_FILE_TYPE = CONF_FILE_XML_DIR + "types.xml";\r
+\r
+ /** The XML schema of the configuration file describing types */\r
+ public static final String CONF_FILE_TYPE_XSD = CONF_FILE_XSD_DIR + "types.xsd";\r
+\r
+ /** The configuration file describing graphics figures */\r
+ public static final String CONF_FILE_FIGURES = CONF_FILE_XML_DIR + "graphics.xml";\r
+\r
+ /** The XML schema of the configuration file describing graphics figures */\r
+ public static final String CONF_FILE_FIGURES_XSD = CONF_FILE_XSD_DIR + "graphics.xsd";\r
+\r
+ /** The XSL file used for converting text in DocBook to HTML format */\r
+ public static final String CONF_FILE_CONVERT = CONF_FILE_XSD_DIR + "convert.xsl";\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.constants;\r
+\r
+/**\r
+ * The <code>TagDefinition</code> class contains enumarated lists of elements used in\r
+ * configuration files and XML parameter definition files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TagDefinition {\r
+ /** The size of buffer used for reading element contents */\r
+ public static int BUFFER_SIZE = 300;\r
+\r
+ /** The size of buffer used for reading contents of elements with descriptions */\r
+ public static int BUFFER_SIZE_DESCRIPTION = 500;\r
+\r
+ /**\r
+ * The enumerated list of elements used in the configuration file with layout of parameters and\r
+ * attribute-sets - config.xml.\r
+ */\r
+ public static enum ConfigTags {\r
+ SECTION("section"), SUBSECTION("subsection"), GROUP("group"), PARAMETER("parameter"), ATTRIBUTE_SET("attribute-set"), NULL("");\r
+\r
+ private String value;\r
+ \r
+ ConfigTags(String value) {\r
+ this.value = value;\r
+ }\r
+ \r
+ /**\r
+ * Returns predefined constant of element according to the element name.\r
+ * \r
+ * @param key\r
+ * the name of element.\r
+ * @return a constant of element with defined name.\r
+ */\r
+ public static ConfigTags getValue(String key) {\r
+ for (ConfigTags conf : values()) {\r
+ if (conf.value.equals(key))\r
+ return conf;\r
+ }\r
+ return NULL;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * The enumerated list of elements used in the configuration file with attributes -\r
+ * attributes.xml.\r
+ */\r
+ public static enum AttributeTags {\r
+ GROUP("group"), ATTRIBUTE("attribute"), NAME("name"), TYPE("type"), VALUES("values"), \r
+ COMPONENT("component"), DEFAULT("default"), UNIT("unit"), NULL("");\r
+ private String value;\r
+ \r
+ AttributeTags(String value) {\r
+ this.value = value;\r
+ }\r
+ \r
+ /**\r
+ * Returns predefined constant of element according to the element name.\r
+ * \r
+ * @param key\r
+ * the name of element.\r
+ * @return a constant of element with defined name.\r
+ */\r
+ public static AttributeTags getValue(String key) {\r
+ for (AttributeTags attr : values()) {\r
+ if (attr.value.equals(key))\r
+ return attr;\r
+ }\r
+ return NULL;\r
+ }\r
+ \r
+ public String toString() {\r
+ return this.name().toLowerCase();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * The enumerated list of elements used in files with XML parameter definitions.\r
+ */\r
+ public static enum ParameterTags {\r
+ REFSECTION("refsection"), REFPURPOSE("refpurpose"), REFMISCINFO("refmiscinfo"), REFMETA("refmeta"), \r
+ DATATYPE("datatype"), VALUE("value"), ALT("alt"), LIST_TYPE("list-type"), NULL(""), XSL_PARAM("xsl:param"),\r
+ XSL_ATTRIBUTE("xsl:attribute");\r
+\r
+ //type\r
+ public static final String OPEN = "open";\r
+ public static final String OTHERCLASS = "otherclass";\r
+ public static final String FO = "fo";\r
+ \r
+ //value\r
+ public static final String CONDITION = "condition";\r
+ public static final String SELECT = "select";\r
+ public static final String TEST = "test";\r
+ public static final String CONTAINS = "contains";\r
+ public static final String NAME = "name";\r
+\r
+ private String value;\r
+ ParameterTags(String value) {\r
+ this.value = value;\r
+ }\r
+ /**\r
+ * Returns predefined constant of element according to the element name.\r
+ * \r
+ * @param key\r
+ * the name of element.\r
+ * @return a constant of element with defined name.\r
+ */\r
+ public static ParameterTags getEnumValue(String key) {\r
+ for (ParameterTags param : values()) {\r
+ if (param.value.equals(key))\r
+ return param;\r
+ }\r
+ return NULL;\r
+ }\r
+ \r
+ public String toString() {\r
+ return this.value;\r
+ }\r
+ public String getValue() {\r
+ return value;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * The enumerated list of elements used in the configuration file with graphics figures -\r
+ * graphics.xml.\r
+ */\r
+ public static enum FigureTags {\r
+ FIGURE, PARAMETER, NULL;\r
+\r
+ /**\r
+ * Returns predefined constant of element according to the element name.\r
+ * \r
+ * @param key\r
+ * the name of element.\r
+ * @return a constant of element with defined name.\r
+ */\r
+ public static FigureTags getValue(String key) {\r
+ try {\r
+ return FigureTags.valueOf(key.toUpperCase());\r
+ } catch (IllegalArgumentException ex) {\r
+ return NULL;\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * The enumerated list of elements used in the configuration file with types - types.xml.\r
+ */\r
+ public static enum TypeTags {\r
+ COLOR("color"), UNIT("unit"), FONT("font"), NULL("");\r
+\r
+ private String value;\r
+ \r
+ \r
+ TypeTags(String value) {\r
+ this.value = value; \r
+ }\r
+ /**\r
+ * Returns predefined constant of element according to the element name.\r
+ * \r
+ * @param key\r
+ * the name of element.\r
+ * @return a constant of element with defined name.\r
+ */\r
+ public static TypeTags getValue(String key) {\r
+ for (TypeTags type : values()) {\r
+ if (type.value.equals(key))\r
+ return type;\r
+ }\r
+ return NULL;\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.constants;\r
+\r
+\r
+/**\r
+ * The <code>ComponentEnum</code> class is the enumerated list of GUI components supported by the\r
+ * application. Components are used for displaying parameter <code>Type</code>s.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public enum TypeEnum {\r
+ BOOLEAN("boolean"), STRING("string"), INTEGER("integer"), TABLE("table"), FLOAT("float"), LIST("list"), \r
+ LIST_OPEN("list-open"), LENGTH("length"), URI("uri"), NUMBER("number"), COLOR("color"), \r
+ FILENAME("filename"), RTF("rtf"), FONT("font"), ATTRIBUTE_SET("attribute set");\r
+\r
+ String value;\r
+ \r
+ TypeEnum(String value) {\r
+ this.value = value;\r
+ }\r
+ \r
+ /**\r
+ * Returns <code>ComponentEnum</code> object for the corresponding name. If the input\r
+ * component is not supported then the <code>DUMMY</code> component is returned.\r
+ * \r
+ * @param name\r
+ * the name of the component.\r
+ * @return the component for the input name.\r
+ */\r
+ public static TypeEnum getValue(String name){\r
+ for (TypeEnum type : values()) {\r
+ if (type.value.equals(name))\r
+ return type;\r
+ }\r
+ return null; \r
+ }\r
+\r
+ /**\r
+ * Specifies if the input component is among predefined components <code>ComponentEnum</code>.\r
+ * \r
+ * @param name\r
+ * the name of the component.\r
+ * @return true if the component is among predefined components.\r
+ */\r
+ public static boolean contains(String name) {\r
+ for (TypeEnum type : values()) {\r
+ if (type.value.equals(name))\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+ \r
+ public String toString() {\r
+ return this.value;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.handlers;\r
+\r
+import java.util.ArrayList;\r
+import java.util.LinkedHashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.Locator;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.beans.properties.AttributeGroup;\r
+import cz.zcu.fav.kiv.editor.beans.properties.TypeAttr;\r
+import cz.zcu.fav.kiv.editor.beans.properties.UnitAttr;\r
+import cz.zcu.fav.kiv.editor.beans.types.CommonTypes;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.config.constants.TypeEnum;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition.AttributeTags;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.utils.TagControl;\r
+\r
+/**\r
+ * The <code>AttributeXmlHandler</code> class is used for parsing the configuration file with\r
+ * attributes - attributes.xml.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class AttributeXmlHandler extends DefaultHandler {\r
+ /** The locator specifying actual line number */\r
+ private Locator locator;\r
+\r
+ /** The data containing editor data structure */\r
+ private CommonTypes commonTypes;\r
+\r
+ /** The list of attributes of one group */\r
+ private List<Attribute> atrributeList;\r
+\r
+ /** The list of groups containing attributes */\r
+ private List<AttributeGroup> attributeGroupList;\r
+\r
+ /** The group containing attributes */\r
+ private AttributeGroup attrGroup;\r
+\r
+ /** The attribute type */\r
+ private TypeAttr type;\r
+\r
+ /** The flag specifying whether the parser is inside value element */\r
+ private boolean insideAttributeElement = false;\r
+\r
+ /** The string buffer for content of value element */\r
+ private StringBuffer attributeBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /**\r
+ * Initializes a newly created <code>AttributeXmlHandler</code> with <code>ConfigData</code>.\r
+ * \r
+ * @param commonTypes\r
+ * the common types of parameters.\r
+ */\r
+ public AttributeXmlHandler(CommonTypes commonTypes) {\r
+ attributeGroupList = new ArrayList<AttributeGroup>();\r
+ this.commonTypes = commonTypes;\r
+ }\r
+\r
+ @Override\r
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {\r
+ AttributeTags enumTag = TagDefinition.AttributeTags.getValue(qName);\r
+ switch (enumTag) {\r
+ case GROUP:\r
+ attrGroup = new AttributeGroup(atts.getValue(0));\r
+ atrributeList = new ArrayList<Attribute>();\r
+ break;\r
+ case ATTRIBUTE:\r
+ type = controlAttribute(atts.getValue(AttributeTags.TYPE.toString()), atts\r
+ .getValue(AttributeTags.DEFAULT.toString()), atts.getValue(AttributeTags.VALUES\r
+ .toString()));\r
+ insideAttributeElement = true;\r
+ attributeBuffer.setLength(0);\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void endElement(String namespaceURI, String localName, String qName) {\r
+ AttributeTags enumTag = TagDefinition.AttributeTags.getValue(qName);\r
+ switch (enumTag) {\r
+ case GROUP:\r
+ attrGroup.setAttributeList(atrributeList);\r
+ attributeGroupList.add(attrGroup);\r
+ break;\r
+ case ATTRIBUTE:\r
+ if (type != null)\r
+ atrributeList.add(new Attribute(attributeBuffer.toString(), type));\r
+ insideAttributeElement = false;\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void characters(char[] ch, int start, int length) {\r
+ if (insideAttributeElement) {\r
+ attributeBuffer.append(ch, start, length);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Assignes predefined type values to the attribute type that has defined a name of predefined\r
+ * values.\r
+ */\r
+ private void addTypeValues(TypeAttr type) {\r
+ switch (type.getName()) {\r
+ case FONT:\r
+ type.setValueList(commonTypes.getFonts());\r
+ break;\r
+ case COLOR:\r
+ type.setValueList(commonTypes.getColors());\r
+ break;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Controls if the type, values and default value of the attribute are valid.\r
+ * \r
+ * @return TypeAttr if the attribute is valid.\r
+ */\r
+ private TypeAttr controlAttribute(String typeName, String defaultValue, String values) {\r
+ type = new TypeAttr();\r
+ TypeEnum typeEnum = TypeEnum.getValue(typeName);\r
+ if (typeEnum == null) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.attributes.invalid_attribute_type",\r
+ FileConst.CONF_FILE_ATTRIBUTES, this.locator.getLineNumber()));\r
+ return null;\r
+ }\r
+ type.setName(typeEnum);\r
+ // values\r
+ if (values != null) {\r
+ try {\r
+ String[] valueList = values.split(",");\r
+ Map<String, String> valueMap = new LinkedHashMap<String, String>();\r
+ for (String val : valueList) {\r
+ valueMap.put(val.trim(), val.trim());\r
+ }\r
+ type.setValueList(valueMap);\r
+ } catch (Exception ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.attributes.invalid_attribute_value",\r
+ FileConst.CONF_FILE_ATTRIBUTES, this.locator.getLineNumber()));\r
+ return null;\r
+ }\r
+ }\r
+ // add unit\r
+ if (type.getName().equals(TypeEnum.LENGTH)) {\r
+ type.setUnit(new UnitAttr(commonTypes.getUnits()));\r
+ }\r
+\r
+ // add common types values\r
+ addTypeValues(type);\r
+\r
+ // default value\r
+ try {\r
+ TagControl.controlSetTypeValue(type, defaultValue);\r
+ type.assignDefaultFromValue();\r
+ } catch (ParserException ex){\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.attributes.invalid_attribute_default_value", FileConst.CONF_FILE_ATTRIBUTES,\r
+ this.locator.getLineNumber()));\r
+ return null;\r
+ }\r
+ return type;\r
+ }\r
+\r
+ public void setDocumentLocator(Locator locator) {\r
+ this.locator = locator;\r
+ }\r
+\r
+ public AttributeGroup[] getAttrGroupList() {\r
+ return attributeGroupList.toArray(new AttributeGroup[0]);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.handlers;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.TreeMap;\r
+\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.Locator;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+import cz.zcu.fav.kiv.editor.beans.graphics.Figure;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.AttributeGroup;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Group;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Section;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Subsection;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition.ConfigTags;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>ConfigXmlHandler</code> class is used for parsing the configuration file with layout\r
+ * of parameters and attribute-sets - config.xml.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ConfigXmlHandler extends DefaultHandler {\r
+ /** The locator specifying actual line number */\r
+ private Locator locator;\r
+\r
+ /** The list of parameters - key is parameter name */\r
+ private Map<String, Parameter> parameterList;\r
+\r
+ /** The list of groups containing attributes */\r
+ private AttributeGroup[] attributeGroupList;\r
+\r
+ /** The list of properties - key is property name */\r
+ private Map<String, Property> propertyList;\r
+ \r
+ /** The list of graphics figures */\r
+ private Map<String, Figure> figureList = null;\r
+\r
+ /** The group */\r
+ private Group group;\r
+\r
+ /** The list of sections */\r
+ private List<Section> sectionList;\r
+\r
+ /** The section */\r
+ private Section section;\r
+\r
+ /** The list of subsections */\r
+ private List<Subsection> subsectionList;\r
+\r
+ /** The subsection */\r
+ private Subsection subsection;\r
+\r
+ /** The list of groups */\r
+ private List<Group> groupList;\r
+\r
+ /** The list of elements - <code>Parameter</code> and <code>Property<code> */\r
+ private List<ParentParameter> elementList;\r
+\r
+ /** The flag specifying whether the parser is inside parameter element */\r
+ private boolean insideParameterElement = false;\r
+\r
+ /** The flag specifying whether the parser is inside property element */\r
+ private boolean insidePropertyElement = false;\r
+\r
+ /** The string buffer for content of parameter element */\r
+ private StringBuffer parameterBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /** The string buffer for content of property element */\r
+ private StringBuffer propertyBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /**\r
+ * Initializes a newly created <code>ConfigXmlHandler</code> with list of\r
+ * <code>AttributeGroup</code>s.\r
+ * \r
+ * @param attributeGroupList\r
+ * the list of attribute groups.\r
+ */\r
+ public ConfigXmlHandler(AttributeGroup[] attributeGroupList) {\r
+ sectionList = new ArrayList<Section>();\r
+ this.parameterList = new TreeMap<String, Parameter>();\r
+ this.attributeGroupList = attributeGroupList;\r
+ this.propertyList = new TreeMap<String, Property>();\r
+ this.figureList = new TreeMap<String, Figure>();\r
+ }\r
+\r
+ @Override\r
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {\r
+ ConfigTags enumTag = TagDefinition.ConfigTags.getValue(qName);\r
+ switch (enumTag) {\r
+ case SECTION:\r
+ section = new Section(atts.getValue(0));\r
+ subsectionList = new ArrayList<Subsection>();\r
+ break;\r
+ case SUBSECTION:\r
+ subsection = new Subsection(atts.getValue(0));\r
+ groupList = new ArrayList<Group>();\r
+ break;\r
+ case GROUP:\r
+ group = new Group(atts.getValue(0));\r
+ if (atts.getValue(1) != null) {\r
+ Figure fig = new Figure(atts.getValue(1));\r
+ group.setFigure(fig);\r
+ figureList.put(atts.getValue(1), fig); \r
+ }\r
+ elementList = new ArrayList<ParentParameter>();\r
+ break;\r
+ case PARAMETER:\r
+ insideParameterElement = true;\r
+ parameterBuffer.setLength(0);\r
+ break;\r
+ case ATTRIBUTE_SET:\r
+ insidePropertyElement = true;\r
+ propertyBuffer.setLength(0);\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void endElement(String namespaceURI, String localName, String qName) {\r
+ ConfigTags enumTag = TagDefinition.ConfigTags.getValue(qName);\r
+ switch (enumTag) {\r
+ case SECTION:\r
+ if (subsectionList.size() != 0) {\r
+ section.setSubsectionList(subsectionList);\r
+ sectionList.add(section);\r
+ }\r
+ break;\r
+ case SUBSECTION:\r
+ if (groupList.size() != 0) {\r
+ subsection.setGroupList(groupList);\r
+ subsectionList.add(subsection);\r
+ }\r
+ break;\r
+ case GROUP:\r
+ if (elementList.size() != 0) {\r
+ group.setElementList(elementList);\r
+ groupList.add(group);\r
+ }\r
+ break;\r
+ case PARAMETER:\r
+ insideParameterElement = false;\r
+ Parameter newParameter = new Parameter(parameterBuffer.toString(), locator.getLineNumber());\r
+ if (!parameterList.containsKey(parameterBuffer.toString())) {\r
+ parameterList.put(parameterBuffer.toString(), newParameter);\r
+ elementList.add(newParameter);\r
+ } else {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.config.duplicate_parameter",\r
+ FileConst.CONF_FILE_CONFIG, parameterBuffer.toString(), this.locator.getLineNumber()));\r
+ }\r
+ break;\r
+ case ATTRIBUTE_SET:\r
+ insidePropertyElement = false;\r
+ Property newProperty = new Property(propertyBuffer.toString(), cloneGroups(attributeGroupList), locator.getLineNumber());\r
+ propertyList.put(propertyBuffer.toString(), newProperty);\r
+ elementList.add(newProperty);\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void characters(char[] ch, int start, int length) {\r
+ if (insideParameterElement) {\r
+ parameterBuffer.append(ch, start, length);\r
+ } else if (insidePropertyElement) {\r
+ propertyBuffer.append(ch, start, length);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Makes copies of all attribute groups.\r
+ * \r
+ * @param groupList\r
+ * the list of atribute groups.\r
+ * @return a copy of the input list of attribute groups.\r
+ */\r
+ private AttributeGroup[] cloneGroups(AttributeGroup[] groupList) {\r
+ AttributeGroup[] newGroups = new AttributeGroup[groupList.length];\r
+ for (int i = 0; i < groupList.length; i++) {\r
+ newGroups[i] = (AttributeGroup) groupList[i].clone();\r
+ }\r
+ return newGroups;\r
+ }\r
+\r
+ public void setDocumentLocator(Locator locator) {\r
+ this.locator = locator;\r
+ }\r
+\r
+ public List<Section> getSections() {\r
+ return sectionList;\r
+ }\r
+\r
+ public Map<String, Property> getPropertyList() {\r
+ return propertyList;\r
+ }\r
+\r
+ public Map<String, Parameter> getParameterList() {\r
+ return parameterList;\r
+ }\r
+\r
+ public Map<String, Figure> getFigureList() {\r
+ return figureList;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.handlers;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.Locator;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.graphics.Figure;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition.FigureTags;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.displays.GraphicsFigure;\r
+\r
+/**\r
+ * The <code>FigureXmlHandler</code> class is used for parsing the configuration file with\r
+ * graphics figures - graphics.xml.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class FigureXmlHandler extends DefaultHandler {\r
+ /** The locator specifying actual line number */\r
+ private Locator locator;\r
+\r
+ /** The number of the line with figure element */\r
+ private int figureLine;\r
+\r
+ /** The list of all figures - key is the figure name */\r
+ private Map<String, Figure> figureList;\r
+\r
+ /** The graphics figure */\r
+ private Figure figure;\r
+\r
+ private Boolean valid;\r
+\r
+ /** The list of parameters that belongs to a graphics figure */\r
+ private List<Parameter> classParameterList;\r
+\r
+ /** The list of all parameters - key is the parameter name */\r
+ private Map<String, Parameter> allParameterList;\r
+\r
+ /** The flag specifying whether the parser is inside parameter element */\r
+ private boolean insideParameterElement = false;\r
+\r
+ /** The string buffer for content of parameter element */\r
+ private StringBuffer parameterBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /**\r
+ * Initializes a newly created <code>FigureXmlHandler</code> with list of\r
+ * <code>Parameter</code>s.\r
+ * \r
+ * @param parameterList\r
+ * the list of all parameters.\r
+ */\r
+ public FigureXmlHandler(Map<String, Parameter> parameterList, Map<String, Figure> figList) {\r
+ figureList = figList;\r
+ this.allParameterList = parameterList;\r
+ }\r
+\r
+ @Override\r
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {\r
+ FigureTags enumTag = TagDefinition.FigureTags.getValue(qName);\r
+ switch (enumTag) {\r
+ case FIGURE: \r
+ figure = figureList.get(atts.getValue(0));\r
+ if (figure != null)\r
+ figure.setClassName(atts.getValue(1));\r
+ classParameterList = new ArrayList<Parameter>();\r
+ this.figureLine = this.locator.getLineNumber();\r
+ valid = true;\r
+ break;\r
+ case PARAMETER:\r
+ insideParameterElement = true;\r
+ parameterBuffer.setLength(0);\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void endElement(String namespaceURI, String localName, String qName) {\r
+ FigureTags enumTag = TagDefinition.FigureTags.getValue(qName);\r
+ switch (enumTag) {\r
+ case FIGURE:\r
+ if (figure != null) {\r
+ if (!valid) {\r
+ // invalid figure\r
+ figureList.remove(figure.getName());\r
+ return;\r
+ }\r
+ try {\r
+ GraphicsFigure graphicsFigure = (GraphicsFigure) Class.forName(\r
+ figure.getClassName()).newInstance();\r
+ graphicsFigure.setInputs(classParameterList.toArray(new Parameter[0]));\r
+\r
+ figure.setParameterList(classParameterList.toArray(new Parameter[0]));\r
+ } catch (Exception ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.figures.invalid_class", FileConst.CONF_FILE_FIGURES, figure\r
+ .getName(), figureLine, figure.getClassName()));\r
+ figureList.remove(figure.getName());\r
+ }\r
+ }\r
+ break;\r
+ case PARAMETER:\r
+ insideParameterElement = false;\r
+ if (figure != null) {\r
+ if (allParameterList.containsKey(parameterBuffer.toString()))\r
+ classParameterList.add(allParameterList.get(parameterBuffer.toString()));\r
+ else {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.figures.invalid_parameter_value", FileConst.CONF_FILE_FIGURES,\r
+ figure.getName(), figureLine, parameterBuffer.toString()));\r
+ valid = false;\r
+ }\r
+ }\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void characters(char[] ch, int start, int length) {\r
+ if (insideParameterElement) {\r
+ parameterBuffer.append(ch, start, length);\r
+ }\r
+ }\r
+\r
+ public void setDocumentLocator(Locator locator) {\r
+ this.locator = locator;\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.handlers;\r
+\r
+import java.util.LinkedHashMap;\r
+import java.util.Map;\r
+import java.util.regex.Matcher;\r
+\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.TypeParam;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.UnitParam;\r
+import cz.zcu.fav.kiv.editor.beans.types.CommonTypes;\r
+import cz.zcu.fav.kiv.editor.config.ParamController;\r
+import cz.zcu.fav.kiv.editor.config.ParameterTransformation;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.config.constants.TypeEnum;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition.ParameterTags;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.utils.TagControl;\r
+\r
+/**\r
+ * The <code>ParameterXmlHandler</code> class is used for parsing files with XML definitions of\r
+ * parameters.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParameterXmlHandler extends DefaultHandler {\r
+\r
+ /** The parameter which XML file is parsed */\r
+ private Parameter parameter;\r
+\r
+ /** The list of common types */\r
+ private static CommonTypes commonTypes;\r
+\r
+ /** The flag indicating if the actually parsed parameter XML is valid */\r
+ private boolean valid = true;\r
+\r
+ /**\r
+ * The flag indicating if the actually parsed parameter value can be parsed without dependencies\r
+ * on other parameters\r
+ */\r
+ private boolean parsed = false;\r
+\r
+ /** The list of default values of the parameter */\r
+ private Map<String, String> valueList;\r
+\r
+ /** The flag specifying whether the parser is inside <refsection> element */\r
+ private boolean insideRefsection = false;\r
+\r
+ /** The flag specifying whether the parser is inside <refpurpose> element */\r
+ private boolean insideRefpurpose = false;\r
+\r
+ /** The flag specifying whether the parser is inside <refmiscinfo otherclass="datatype"> element */\r
+ private boolean insideRefmiscinfoDatatype = false;\r
+\r
+ /** The flag specifying whether the parser is inside <refmiscinfo otherclass="value"> element */\r
+ private boolean insideRefmiscinfoValue = false;\r
+\r
+ /**\r
+ * The flag specifying whether the parser is inside <refmiscinfo otherclass="value"><alt>\r
+ * element\r
+ */\r
+ private boolean insideRefmiscinfoValueAlt = false;\r
+\r
+ /** The flag specifying whether the parser is inside <refmiscinfo otherclass="list-type"> element */\r
+ private boolean insideRefmiscinfoListType = false;\r
+\r
+ /** The flag specifying whether the parser is inside <xsl:param> element */\r
+ private boolean insideXslParam = false;\r
+\r
+ /** The string buffer for content of description element <refsection> */\r
+ private StringBuffer descriptionBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE_DESCRIPTION);\r
+\r
+ /** The string buffer for content of <refpurpose> element */\r
+ private StringBuffer purposeBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE_DESCRIPTION);\r
+\r
+ /** The string buffer for content of <xsl:param> element */\r
+ private StringBuffer insideXslParamBuffer = new StringBuffer(\r
+ TagDefinition.BUFFER_SIZE_DESCRIPTION);\r
+\r
+ /** The string buffer for content of <refmiscinfo otherclass="datatype"> element */\r
+ private StringBuffer refmiscinfoDatatypeBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /** The string buffer for content of <refmiscinfo otherclass="value"> element */\r
+ private StringBuffer refmiscinfoValueBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /** The string buffer for content of <refmiscinfo otherclass="value"><alt> element */\r
+ private StringBuffer refmiscinfoValueAltBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /** The string buffer for content of <refmiscinfo otherclass="list-type"> element */\r
+ private StringBuffer refmiscinfoListTypeBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>ParameterXmlHandler</code>.\r
+ */\r
+ public ParameterXmlHandler(Parameter parameter, CommonTypes types) {\r
+ this.parameter = parameter;\r
+ commonTypes = types;\r
+ }\r
+\r
+ @Override\r
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {\r
+ if (insideXslParam) {\r
+ insideXslParamBuffer.append("<" + qName);\r
+ for (int i = 0; i < atts.getLength(); i++) {\r
+ insideXslParamBuffer.append(" " + atts.getQName(i) + "=\"" + atts.getValue(i)\r
+ + "\"");\r
+ }\r
+ insideXslParamBuffer.append(">");\r
+ }\r
+ ParameterTags enumTag = ParameterTags.getEnumValue(qName);\r
+ switch (enumTag) {\r
+ case REFMETA:\r
+ valueList = new LinkedHashMap<String, String>();\r
+ break;\r
+ case REFSECTION:\r
+ insideRefsection = true;\r
+ descriptionBuffer.setLength(0);\r
+ break;\r
+ case REFPURPOSE:\r
+ insideRefpurpose = true;\r
+ purposeBuffer.setLength(0);\r
+ break;\r
+ case REFMISCINFO:\r
+ ParameterTags attrOtherClass = ParameterTags.getEnumValue(atts\r
+ .getValue(ParameterTags.OTHERCLASS));\r
+ switch (attrOtherClass) {\r
+ case DATATYPE:\r
+ insideRefmiscinfoDatatype = true;\r
+ break;\r
+ case VALUE:\r
+ insideRefmiscinfoValue = true;\r
+ refmiscinfoValueBuffer.setLength(0);\r
+ break;\r
+ case LIST_TYPE:\r
+ insideRefmiscinfoListType = true;\r
+ break;\r
+ }\r
+ break;\r
+ case ALT:\r
+ insideRefmiscinfoValueAlt = true;\r
+ refmiscinfoValueAltBuffer.setLength(0);\r
+ break;\r
+ case XSL_PARAM:\r
+ insideXslParamBuffer.setLength(0);\r
+ // parse select\r
+ if (valid)\r
+ insideXslParam = parseXslParamSelect(atts);\r
+ break;\r
+ }\r
+\r
+ if (insideRefsection) {\r
+ descriptionBuffer.append("<" + qName + ">");\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void endElement(String namespaceURI, String localName, String qName) {\r
+ if (insideRefsection) {\r
+ descriptionBuffer.append("</" + qName + ">");\r
+ }\r
+ ParameterTags enumTag = ParameterTags.getEnumValue(qName);\r
+ switch (enumTag) {\r
+ case REFMETA:\r
+ controlType();\r
+ break;\r
+ case REFSECTION:\r
+ insideRefsection = false;\r
+ if (descriptionBuffer.length() != 0)\r
+ parameter.setDescription(ParameterTransformation.htmlTransform(descriptionBuffer\r
+ .toString().trim()));\r
+ break;\r
+ case REFPURPOSE:\r
+ insideRefpurpose = false;\r
+ parameter.setPurpose(purposeBuffer.toString());\r
+ break;\r
+ case REFMISCINFO:\r
+ if (insideRefmiscinfoDatatype) {\r
+ insideRefmiscinfoDatatype = false;\r
+ }\r
+ if (insideRefmiscinfoListType) {\r
+ insideRefmiscinfoListType = false;\r
+ }\r
+ if (insideRefmiscinfoValue) {\r
+ insideRefmiscinfoValue = false;\r
+ if (refmiscinfoValueAltBuffer.length() != 0)\r
+ valueList.put(refmiscinfoValueBuffer.toString(), refmiscinfoValueAltBuffer\r
+ .toString()\r
+ + " (" + refmiscinfoValueBuffer.toString() + ")");\r
+ else\r
+ valueList.put(refmiscinfoValueBuffer.toString(), refmiscinfoValueBuffer\r
+ .toString());\r
+ }\r
+ break;\r
+ case ALT:\r
+ insideRefmiscinfoValueAlt = false;\r
+ break;\r
+ case XSL_PARAM:\r
+ if ((valid) && (insideXslParam))\r
+ controlXslParamValue();\r
+ insideXslParam = false;\r
+ break;\r
+ }\r
+ if (insideXslParam)\r
+ insideXslParamBuffer.append("</" + qName + ">");\r
+ }\r
+\r
+ @Override\r
+ public void characters(char[] ch, int start, int length) {\r
+ if (insideRefsection) {\r
+ String nextPart = new String(ch, start, length);\r
+ nextPart = nextPart.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&",\r
+ "&");\r
+ descriptionBuffer.append(nextPart);\r
+ } else if (insideRefpurpose) {\r
+ purposeBuffer.append(ch, start, length);\r
+ } else if (insideRefmiscinfoDatatype) {\r
+ refmiscinfoDatatypeBuffer.append(ch, start, length);\r
+ } else if (insideRefmiscinfoValue) {\r
+ if (insideRefmiscinfoValueAlt)\r
+ refmiscinfoValueAltBuffer.append(ch, start, length);\r
+ else\r
+ refmiscinfoValueBuffer.append(ch, start, length);\r
+ } else if (insideRefmiscinfoListType) {\r
+ refmiscinfoListTypeBuffer.append(ch, start, length);\r
+ } else if (insideXslParam) {\r
+ String nextPart = new String(ch, start, length);\r
+ nextPart = nextPart.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&",\r
+ "&");\r
+ insideXslParamBuffer.append(nextPart);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Controls if the parameter type definition is valid. Assigns to paramter type the list of\r
+ * predefined values.\r
+ */\r
+ private void controlType() {\r
+ TypeEnum typeName = TypeEnum.getValue(refmiscinfoDatatypeBuffer.toString());\r
+ if (typeName == null) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.parameters.invalid_type", FileConst.CONF_FILE_CONFIG, parameter\r
+ .getName(), parameter.getLineNumber()));\r
+ valid = false;\r
+ return;\r
+ }\r
+ parameter.getType().setName(typeName);\r
+ // open list\r
+ if ((parameter.getType().getName().equals(TypeEnum.LIST))\r
+ && (refmiscinfoListTypeBuffer.toString().equals(ParameterTags.OPEN)))\r
+ parameter.getType().setName(TypeEnum.LIST_OPEN);\r
+\r
+ // length - assigne units\r
+ if (parameter.getType().getName().equals(TypeEnum.LENGTH))\r
+ parameter.getType().setUnit(new UnitParam(commonTypes.getUnits(), parameter));\r
+\r
+ // list values\r
+ if ((parameter.getType().getName().equals(TypeEnum.LIST) || (parameter.getType().getName()\r
+ .equals(TypeEnum.LIST_OPEN)))\r
+ && (valueList.size() != 0))\r
+ parameter.getType().getDefaultValue().setValueList(valueList);\r
+ addTypeValues(parameter.getType());\r
+ }\r
+\r
+ /**\r
+ * Assigns to the parameter a list of default values.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ private void addTypeValues(TypeParam type) {\r
+ switch (type.getName()) {\r
+ case FONT:\r
+ type.setValueList(commonTypes.getFonts());\r
+ break;\r
+ case COLOR:\r
+ type.setValueList(commonTypes.getColors());\r
+ break;\r
+ }\r
+ }\r
+\r
+ public boolean isValid() {\r
+ return valid;\r
+ }\r
+\r
+ /**\r
+ * Assignes the content of the attribute <code>select</code> of the element <xsl:param> to the\r
+ * <code>insideXslParamBuffer</code>. Controls whether the parameter has no other condition\r
+ * than 'FO'.\r
+ * \r
+ * @param atts\r
+ * the attributes of the element <xsl:param>.\r
+ * @return true if the <xsl:param> has no other condition than 'FO'.\r
+ */\r
+ private boolean parseXslParamSelect(Attributes atts) {\r
+ // condition="fo"\r
+ if ((atts.getValue(ParameterTags.CONDITION) != null)\r
+ && (!atts.getValue(ParameterTags.CONDITION).equals(ParameterTags.FO)))\r
+ return false;\r
+ // select\r
+ if ((atts.getValue(ParameterTags.SELECT)) != null) {\r
+ insideXslParamBuffer.append(atts.getValue(ParameterTags.SELECT));\r
+ }\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * Controls the content of the element <xsl:param>. If the content is not simple (cannot be\r
+ * parsed without others parameters) then <code>parsed</code> is set to false. If the content\r
+ * is not valid then <code>valid</code> is set to false.\r
+ */\r
+ private void controlXslParamValue() {\r
+ String paramValue = insideXslParamBuffer.toString();\r
+ // rtf\r
+ if (parameter.getType().getName().equals(TypeEnum.RTF)) {\r
+ parameter.getType().setValue(paramValue.trim());\r
+ parameter.getType().assignDefaultFromValue();\r
+ parsed = true;\r
+ return;\r
+ }\r
+ Matcher matcher = ParamController.patternParam.matcher(paramValue);\r
+ if (!matcher.find()) {\r
+ // raw value\r
+ try {\r
+ TagControl.controlSetTypeValue(parameter.getType(), paramValue.replaceAll("'", "")\r
+ .replaceAll("<[//]?xsl:text>", ""));\r
+ parameter.getType().assignDefaultFromValue();\r
+ parsed = true;\r
+ } catch (ParserException ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.parameters.invalid_value", FileConst.CONF_FILE_CONFIG, parameter\r
+ .getName(), parameter.getLineNumber()));\r
+ valid = false;\r
+ }\r
+ } else {\r
+ parameter.getType().setValue(paramValue.trim());\r
+ }\r
+ }\r
+\r
+ public boolean isParsed() {\r
+ return parsed;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.handlers;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.regex.Matcher;\r
+\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.config.ParamController;\r
+import cz.zcu.fav.kiv.editor.config.ParameterTransformation;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.config.constants.TypeEnum;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition.ParameterTags;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.utils.TagControl;\r
+\r
+/**\r
+ * The <code>PropertyXmlHandler</code> class is used for parsing files with XML definitions of\r
+ * properties.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class PropertyXmlHandler extends DefaultHandler {\r
+\r
+ /** The property which XML file is parsed */\r
+ private Property property;\r
+\r
+ /** The flag indicating if the actually parsed proeperty XML is valid */\r
+ private boolean valid = true;\r
+\r
+ /** The name of actually parsed attribute */\r
+ private String attributeName;\r
+\r
+ /** The list of attributes that cannot be parsed */\r
+ private Map<String, Attribute> unparsedAttributeList;\r
+\r
+ /** The flag specifying whether the parser is inside <refsection> element */\r
+ private boolean insideRefsection = false;\r
+\r
+ /** The flag specifying whether the parser is inside <refpurpose> element */\r
+ private boolean insideRefpurpose = false;\r
+\r
+ /** The flag specifying whether the parser is inside <refmiscinfo otherclass="datatype"> element */\r
+ private boolean insideRefmiscinfoDatatype = false;\r
+\r
+ /** The flag specifying whether the parser is inside <xsl:attribute> element */\r
+ private boolean insideXslAttribute = false;\r
+\r
+ /** The string buffer for content of description element <refsection> */\r
+ private StringBuffer descriptionBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE_DESCRIPTION);\r
+\r
+ /** The string buffer for content of purpose element <refpurpose> */\r
+ private StringBuffer purposeBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE_DESCRIPTION);\r
+\r
+ /** The string buffer for content of <refmiscinfo otherclass="datatype"> element */\r
+ private StringBuffer refmiscinfoDatatypeBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /** The string buffer for content of purpose element <xsl:attribute> */\r
+ private StringBuffer xslAttributeBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>PropertyXmlHandler</code>.\r
+ */\r
+ public PropertyXmlHandler(Property property) {\r
+ this.property = property;\r
+ unparsedAttributeList = new HashMap<String, Attribute>();\r
+ }\r
+\r
+ @Override\r
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {\r
+ if (insideXslAttribute) {\r
+ xslAttributeBuffer.append("<" + qName);\r
+ for (int i = 0; i < atts.getLength(); i++) {\r
+ xslAttributeBuffer.append(" " + atts.getQName(i) + "=\"" + atts.getValue(i) + "\"");\r
+ }\r
+ xslAttributeBuffer.append(">");\r
+ }\r
+ ParameterTags enumTag = TagDefinition.ParameterTags.getEnumValue(qName);\r
+ switch (enumTag) {\r
+ case REFSECTION:\r
+ insideRefsection = true;\r
+ descriptionBuffer.setLength(0);\r
+ break;\r
+ case REFPURPOSE:\r
+ insideRefpurpose = true;\r
+ purposeBuffer.setLength(0);\r
+ break;\r
+ case REFMISCINFO:\r
+ if (atts.getType(ParameterTags.OTHERCLASS).equals(ParameterTags.DATATYPE.toString())) {\r
+ insideRefmiscinfoDatatype = true;\r
+ refmiscinfoDatatypeBuffer.setLength(0);\r
+ }\r
+ break;\r
+ case XSL_ATTRIBUTE:\r
+ insideXslAttribute = true;\r
+ attributeName = atts.getValue(ParameterTags.NAME);\r
+ xslAttributeBuffer.setLength(0);\r
+ break;\r
+ }\r
+\r
+ if (insideRefsection) {\r
+ descriptionBuffer.append("<" + qName + ">");\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void endElement(String namespaceURI, String localName, String qName) {\r
+ if (insideRefsection) {\r
+ descriptionBuffer.append("</" + qName + ">");\r
+ }\r
+ ParameterTags enumTag = TagDefinition.ParameterTags.getEnumValue(qName);\r
+ switch (enumTag) {\r
+ case REFSECTION:\r
+ insideRefsection = false;\r
+ if (descriptionBuffer.length() != 0)\r
+ property.setDescription(ParameterTransformation.htmlTransform(descriptionBuffer\r
+ .toString()));\r
+ break;\r
+ case REFPURPOSE:\r
+ insideRefpurpose = false;\r
+ property.setPurpose(purposeBuffer.toString());\r
+ break;\r
+ case REFMISCINFO:\r
+ if (insideRefmiscinfoDatatype) {\r
+ insideRefmiscinfoDatatype = false;\r
+ if (!TypeEnum.ATTRIBUTE_SET.toString().equals(refmiscinfoDatatypeBuffer.toString())) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.property.invalid_type", FileConst.CONF_FILE_CONFIG, property\r
+ .getName(), property.getLineNumber()));\r
+ valid = false;\r
+ }\r
+ }\r
+ break;\r
+ case XSL_ATTRIBUTE:\r
+ insideXslAttribute = true;\r
+ // save attribute value\r
+ // TODO parsing attribute values for each property according to its .xml\r
+ // if (attributeName != null)\r
+ // controlXslAttributeValue();\r
+ break;\r
+ }\r
+ if (insideXslAttribute)\r
+ xslAttributeBuffer.append("</" + qName + ">");\r
+ }\r
+\r
+ @Override\r
+ public void characters(char[] ch, int start, int length) {\r
+ if (insideRefsection) {\r
+ String nextPart = new String(ch, start, length);\r
+ nextPart = nextPart.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&",\r
+ "&");\r
+ descriptionBuffer.append(nextPart);\r
+ } else if (insideRefpurpose) {\r
+ purposeBuffer.append(ch, start, length);\r
+ } else if (insideRefmiscinfoDatatype) {\r
+ refmiscinfoDatatypeBuffer.append(ch, start, length);\r
+ } else if (insideXslAttribute) {\r
+ xslAttributeBuffer.append(ch, start, length);\r
+ }\r
+ }\r
+\r
+ public boolean isValid() {\r
+ return valid;\r
+ }\r
+\r
+ /**\r
+ * Controls if the actually parsed attribute value can be parsed - is supported and if it is\r
+ * valid and can be parsed without other parameters. If the attribute cannot be parsed, it is\r
+ * assignes to the <code>unparsedAttributeList</code>.\r
+ */\r
+ private void controlXslAttributeValue() {\r
+ Attribute attr = property.searchAttribute(attributeName);\r
+ if (attr == null) {\r
+ // unsupported attribute\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.property.unsupported_attribute", FileConst.CONF_FILE_CONFIG, property\r
+ .getName(), property.getLineNumber(), attributeName));\r
+ return;\r
+ }\r
+ String paramValue = xslAttributeBuffer.toString().trim();\r
+ Matcher matcher = ParamController.patternParam.matcher(paramValue);\r
+ if (!matcher.find()) {\r
+ // raw value\r
+ try {\r
+ TagControl.controlSetTypeValue(attr.getType(), paramValue.replaceAll("'", "")\r
+ .replaceAll("<[//]?xsl:text>", ""));\r
+ attr.getType().assignDefaultFromValue();\r
+ } catch (ParserException ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "parser.property.invalid_value", FileConst.CONF_FILE_CONFIG, property\r
+ .getName(), property.getLineNumber(), attributeName));\r
+ }\r
+ } else {\r
+ attr.getType().setValue(paramValue);\r
+ unparsedAttributeList.put(attributeName, attr);\r
+ }\r
+ }\r
+\r
+ public Map<String, Attribute> getUnparsedAttributeList() {\r
+ return unparsedAttributeList;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.config.handlers;\r
+\r
+import java.util.ArrayList;\r
+import java.util.LinkedHashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition.TypeTags;\r
+\r
+/**\r
+ * The <code>TypeXmlHandler</code> class is used for parsing the configuration file with types -\r
+ * types.xml.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TypeXmlHandler extends DefaultHandler {\r
+ /** The list of units */\r
+ private List<String> unitList;\r
+\r
+ /** The list of font - key is font name or font itself */\r
+ private Map<String, String> fontList;\r
+\r
+ /** The list of font - key is color name or color itself */\r
+ private Map<String, String> colorList;\r
+\r
+ /** The key of actually parsed element */\r
+ private String key;\r
+\r
+ /** The flag specifying whether the parser is inside unit element */\r
+ private boolean insideUnitElement = false;\r
+\r
+ /** The flag specifying whether the parser is inside color element */\r
+ private boolean insideColorElement = false;\r
+\r
+ /** The flag specifying whether the parser is inside font element */\r
+ private boolean insideFontElement = false;\r
+\r
+ /** The string buffer for content of unit element */\r
+ private StringBuffer unitBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /** The string buffer for content of color element */\r
+ private StringBuffer colorBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /** The string buffer for content of font element */\r
+ private StringBuffer fontBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>TypeXmlHandler</code>.\r
+ */\r
+ public TypeXmlHandler() {\r
+ unitList = new ArrayList<String>();\r
+ fontList = new LinkedHashMap<String, String>();\r
+ colorList = new LinkedHashMap<String, String>();\r
+ }\r
+\r
+ @Override\r
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {\r
+ TypeTags enumTag = TagDefinition.TypeTags.getValue(qName);\r
+ switch (enumTag) {\r
+ case COLOR:\r
+ insideColorElement = true;\r
+ colorBuffer.setLength(0);\r
+ key = atts.getValue(0);\r
+ break;\r
+ case UNIT:\r
+ insideUnitElement = true;\r
+ unitBuffer.setLength(0);\r
+ break;\r
+ case FONT:\r
+ insideFontElement = true;\r
+ fontBuffer.setLength(0);\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void endElement(String namespaceURI, String localName, String qName) {\r
+ TypeTags enumTag = TagDefinition.TypeTags.getValue(qName);\r
+ switch (enumTag) {\r
+ case COLOR:\r
+ insideColorElement = false;\r
+ colorList.put(key, colorBuffer.toString());\r
+ break;\r
+ case UNIT:\r
+ insideUnitElement = false;\r
+ unitList.add(unitBuffer.toString());\r
+ break;\r
+ case FONT:\r
+ insideFontElement = false;\r
+ fontList.put(fontBuffer.toString(), fontBuffer.toString());\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void characters(char[] ch, int start, int length) {\r
+ if (insideColorElement) {\r
+ colorBuffer.append(ch, start, length);\r
+ } else if (insideUnitElement) {\r
+ unitBuffer.append(ch, start, length);\r
+ } else if (insideFontElement) {\r
+ fontBuffer.append(ch, start, length);\r
+ }\r
+ }\r
+\r
+ public Map<String, String> getColorList() {\r
+ return colorList;\r
+ }\r
+\r
+ public Map<String, String> getFontList() {\r
+ return fontList;\r
+ }\r
+\r
+ public List<String> getUnitList() {\r
+ return unitList;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller;\r
+\r
+import javax.swing.UIManager;\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+import cz.zcu.fav.kiv.editor.graphics.intro.IntroException;\r
+import cz.zcu.fav.kiv.editor.graphics.intro.IntroFrame;\r
+import cz.zcu.fav.kiv.editor.graphics.intro.ProgressBar;\r
+import cz.zcu.fav.kiv.editor.utils.ErrorDialog;\r
+\r
+/**\r
+ * The <code>MainController</code> class is the main control class of the application. Controls\r
+ * loading of configurations files and creating of the application GUI.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class MainController {\r
+\r
+ /**\r
+ * Main class that controls loading of configurations files and creating of the application GUI.\r
+ * \r
+ * @param args\r
+ * main application arguments.\r
+ * @throws Exception\r
+ * if an fatal error occurs in the application.\r
+ */\r
+ public static void main(String args[]) throws Exception {\r
+\r
+ try {\r
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());\r
+\r
+ OptionController.readOptions();\r
+\r
+ IntroFrame introFrame = new IntroFrame();\r
+ ConfigData data = ProgressBar.getData();\r
+ introFrame.hideFrame();\r
+\r
+ MainFrame.createFrame(data).go();\r
+ } catch (IntroException introEx) {\r
+ } catch (Exception ex) {\r
+ Log.fatal(ex);\r
+ ErrorDialog.showDialog(ex);\r
+ System.exit(1);\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller;\r
+\r
+import java.io.File;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.OpenFile;\r
+import cz.zcu.fav.kiv.editor.controller.errors.OpenFileException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.SaveFileException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionController;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.stylesheet.XslParser;\r
+import cz.zcu.fav.kiv.editor.template.TemplateConst;\r
+import cz.zcu.fav.kiv.editor.template.TemplateController;\r
+import cz.zcu.fav.kiv.editor.utils.RunBatch;\r
+\r
+/**\r
+ * The <code>MenuController</code> class contains method that are called for every item from the\r
+ * application GUI.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class MenuController {\r
+\r
+ /**\r
+ * Creates a new empty stylesheet file, sets default values to the GUI editor element.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param openFile\r
+ * the structure containing information about actually opened file.\r
+ */\r
+ public static void newFileEmptyItem(ConfigData configData, OpenFile openFile) {\r
+ MessageWriter.writeTitle(ResourceController.getMessage("new_file.title"));\r
+ configData.clearValues(); \r
+ openFile.setOpenFilePath(null);\r
+ openFile.setWholeFile(XslParser.createXsltFile());\r
+ MessageWriter.writeInfo(ResourceController.getMessage("new_file.empty.info"));\r
+ }\r
+\r
+ /**\r
+ * Creates a new stylesheet file and sets values to the GUI editor element according to the\r
+ * default template.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param openFile\r
+ * the structure containing information about actually opened file.\r
+ */\r
+ public static void newFileDefaultItem(ConfigData configData, OpenFile openFile) {\r
+ MessageWriter.writeTitle(ResourceController.getMessage("new_file.title"));\r
+ configData.clearValues();\r
+ // load default template\r
+ try {\r
+ TemplateController.getInstance().readTemplate(configData,\r
+ TemplateConst.CONF_FILE_TEMPLATE);\r
+ MessageWriter.writeInfo(ResourceController.getMessage("new_file.default.info"));\r
+ } catch (Throwable ex) {\r
+ MessageWriter.writeError(ex.getMessage());\r
+ }\r
+ openFile.setOpenFilePath(null);\r
+ openFile.setWholeFile(XslParser.createXsltFile());\r
+ }\r
+\r
+ /**\r
+ * Creates a new stylesheet file and sets values to the GUI editor element according to the user\r
+ * template.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param openFile\r
+ * the structure containing information about actually opened file.\r
+ * @param templateFile\r
+ * the file containing user template.\r
+ */\r
+ public static void newFileStylesheetItem(ConfigData configData, OpenFile openFile,\r
+ String templateFile) {\r
+ MessageWriter.writeTitle(ResourceController.getMessage("new_file.title"));\r
+ configData.clearValues();\r
+ // load user template\r
+ try {\r
+ TemplateController.getInstance().readTemplate(configData, templateFile);\r
+ MessageWriter.writeInfo(ResourceController.getMessage("new_file.stylesheet.info",\r
+ templateFile));\r
+ } catch (Throwable ex) {\r
+ MessageWriter.writeError(ex.getMessage());\r
+ }\r
+ openFile.setOpenFilePath(null);\r
+ openFile.setWholeFile(XslParser.createXsltFile());\r
+ }\r
+\r
+ /**\r
+ * Opens specified XSL stylesheet file.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param file\r
+ * the XSL stylesheet file for opening.\r
+ * @param openFile\r
+ * the structure containing information about actually opened file.\r
+ */\r
+ public static void openFileItem(ConfigData configData, String file, OpenFile openFile) {\r
+ try {\r
+ MessageWriter.writeTitle(ResourceController.getMessage("open_file.title"));\r
+\r
+ configData.clearValues();\r
+ openFile.setOpenFilePath(file);\r
+ openFile.setWholeFile(XslParser.readXsltFile(file, configData)); \r
+\r
+ MessageWriter.writeInfo(ResourceController.getMessage("open_file.success_info", file));\r
+ } catch (OpenFileException ex) {\r
+ MessageWriter.writeError(ex.getMessage());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Saves actually opened XSL stylesheet in the file with specified name.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param saveFile\r
+ * the name of the file where the XSL stylesheet will be saved.\r
+ * @param openFile\r
+ * the structure containing information about actually opened file.\r
+ */\r
+ public static void saveAsFileItem(ConfigData configData, String saveFile, OpenFile openFile) {\r
+ openFile.setOpenFilePath(saveFile);\r
+ saveFileItem(configData, openFile);\r
+ }\r
+\r
+ /**\r
+ * Saves changes of the actually opened XSL stylesheet file.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param openFile\r
+ * the structure containing information about actually opened file.\r
+ */\r
+ public static void saveFileItem(ConfigData configData, OpenFile openFile) {\r
+ try {\r
+ MessageWriter.writeTitle(ResourceController.getMessage("save_file.title"));\r
+ // remove comments\r
+ if (OptionItems.REARRANGE_SAVE)\r
+ XslParser.removeComments(openFile.getWholeFile());\r
+\r
+ XslParser.saveXsltFile(openFile.getOpenFilePath(), openFile.getWholeFile(), configData);\r
+ openFile.setFileChanged(false);\r
+ MessageWriter.writeInfo(ResourceController.getMessage("save_file.success_info",\r
+ openFile.getOpenFilePath()));\r
+ } catch (SaveFileException ex) {\r
+ MessageWriter.writeError(ResourceController.getMessage("error.save_file", openFile\r
+ .getWholeFile())\r
+ + ex.getMessage());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Stores editor options in the application cofiguration file.\r
+ */\r
+ public static void exitItem() {\r
+ OptionController.storeOptionItems();\r
+ }\r
+\r
+ /**\r
+ * Launches a selected batch file.\r
+ * \r
+ * @param openFile\r
+ * the structure containing information about actually opened file.\r
+ */\r
+ public static void runBatchFile(OpenFile openFile) {\r
+ MessageWriter.writeTitle(ResourceController.getMessage("run_batch_file.title"));\r
+ if (openFile.getOpenFilePath() == null) {\r
+ MessageWriter.writeError(ResourceController.getMessage("run_batch_file.not_saved"));\r
+ return;\r
+ }\r
+ // exists batch file?\r
+ if (!(new File(OptionItems.BATCH_FILE)).exists()) {\r
+ MessageWriter.writeError(ResourceController\r
+ .getMessage("run_batch_file.file_not_exists"));\r
+ return;\r
+ }\r
+ try {\r
+ MessageWriter.writeInfo(ResourceController.getMessage("run_batch_file.running",\r
+ OptionItems.BATCH_FILE));\r
+ RunBatch.replaceXslName(OptionItems.BATCH_FILE, openFile.getOpenFilePath());\r
+ RunBatch.execBatch();\r
+ } catch (Throwable ex) {\r
+ Log.error(ex);\r
+ MessageWriter.writeError(ResourceController.getMessage("run_batch_file.error_running",\r
+ OptionItems.BATCH_FILE));\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.graphics.console.MessageConsole;\r
+\r
+/**\r
+ * The <code>MessageWriter</code> class provides methods for writting down information and errors\r
+ * to the editor console.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class MessageWriter {\r
+ /**\r
+ * Writes a normal information to the editor console.\r
+ * \r
+ * @param message\r
+ * the normal text message.\r
+ */\r
+ public static void write(String message) {\r
+ MessageConsole.logMessage(message);\r
+ }\r
+\r
+ /**\r
+ * Writes an emphasis information to the editor console.\r
+ * \r
+ * @param message\r
+ * the normal text message.\r
+ */\r
+ public static void writeEmphasis(String message) {\r
+ MessageConsole.logMessageEmphasis(message);\r
+ }\r
+ \r
+ /**\r
+ * Writes a title to the editor console.\r
+ * \r
+ * @param message\r
+ * the message containing title.\r
+ */\r
+ public static void writeTitle(String message) {\r
+ if (OptionItems.ERASE_CONSOLE)\r
+ MessageWriter.eraseConsole();\r
+ MessageConsole.logTitle(message);\r
+ }\r
+\r
+ /**\r
+ * Writes a warning message to the editor console.\r
+ * \r
+ * @param message\r
+ * the message containing warning.\r
+ */\r
+ public static void writeWarning(String message) {\r
+ MessageConsole.logWarning(message);\r
+ }\r
+\r
+ /**\r
+ * Writes an error message to the editor console.\r
+ * \r
+ * @param message\r
+ * the message containing error.\r
+ */\r
+ public static void writeError(String message) {\r
+ MessageConsole.logError(message);\r
+ }\r
+\r
+ /**\r
+ * Writes an information message to the editor console.\r
+ * \r
+ * @param message\r
+ * the message containing information.\r
+ */\r
+ public static void writeInfo(String message) {\r
+ MessageConsole.logInfo(message);\r
+ }\r
+\r
+ /**\r
+ * Erases the editor console.\r
+ */\r
+ public static void eraseConsole() {\r
+ MessageConsole.eraseConsole();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.config.ConfigController;\r
+import cz.zcu.fav.kiv.editor.config.ParamController;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>ProgressControl</code> class controls the progress of configuration files loading.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ProgressControl {\r
+ /** The numerical representation of the loading progress */\r
+ private int current = 0;\r
+\r
+ /** The flag indicating if the loading progress has already finished */\r
+ private boolean done = false;\r
+\r
+ /** The flag indicating if the loading progress is canceled */\r
+ private boolean canceled = false;\r
+\r
+ /** The message containing information about the loading progress */\r
+ private static String statMessage;\r
+\r
+ /** The message containing error rised during the loading progress */\r
+ private String errorMessage;\r
+\r
+ /** The char representing a new line */\r
+ private final static String NEWLINE = "\n";\r
+\r
+ /** The controll class containing methods for loading configuration files */\r
+ private ConfigController config;\r
+\r
+ /**\r
+ * Returns editor data structure loaded from configuration files.\r
+ * \r
+ * @return the editor data structure loaded from configuration files.\r
+ */\r
+ public ConfigData getData() {\r
+ return config.getData();\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>ProgressControl</code>.\r
+ */\r
+ public ProgressControl() {\r
+ }\r
+\r
+ /**\r
+ * Launches the thread which loads configuration files.\r
+ */\r
+ public void go() {\r
+ ConfigThread con = new ConfigThread();\r
+ con.setPriority(1);\r
+ con.start();\r
+ try {\r
+ con.join();\r
+ } catch (InterruptedException ex) {\r
+ Log.warn(ex);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Called from <code>ProgressBar</code> to find out how much has been done.\r
+ * \r
+ * @return the number indicating the loading progress.\r
+ */\r
+ public int getCurrent() {\r
+ return current;\r
+ }\r
+\r
+ /**\r
+ * Called from <code>ProgressBar</code> to find out if the task has completed.\r
+ * \r
+ * @return true if the task is done.\r
+ */\r
+ public boolean isDone() {\r
+ return done;\r
+ }\r
+\r
+ /**\r
+ * Called from <code>ProgressBar</code> to find out if the task is canceled.\r
+ * \r
+ * @return true if the task is camceled.\r
+ */\r
+ public boolean isCanceled() {\r
+ return canceled;\r
+ }\r
+\r
+ /**\r
+ * Returns the most recent status message.\r
+ * \r
+ * @return the most recent status message.\r
+ */\r
+ public String getMessage() {\r
+ return statMessage;\r
+ }\r
+\r
+ /**\r
+ * The <code>ConfigThread</code> class is a thread used for controling the progress of\r
+ * configuration files loading.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ class ConfigThread extends Thread {\r
+ public void run() {\r
+ try {\r
+ statMessage = "";\r
+ config = new ConfigController();\r
+\r
+ config.readTypes();\r
+ current = 10;\r
+ statMessage += ResourceController.getMessage("frame.intro.progress.read_file", FileConst.CONF_FILE_TYPE) + NEWLINE;\r
+ Thread.yield();\r
+ \r
+ config.readAttributes();\r
+ current = 20;\r
+ statMessage += ResourceController.getMessage("frame.intro.progress.read_file", FileConst.CONF_FILE_ATTRIBUTES) + NEWLINE;\r
+ Thread.yield();\r
+ \r
+ config.readConfig();\r
+ current = 30;\r
+ statMessage += ResourceController.getMessage("frame.intro.progress.read_file", FileConst.CONF_FILE_CONFIG) + NEWLINE;\r
+ Thread.yield();\r
+\r
+ ParamController configXml = new ParamController(config.getData(), config.getCommonTypes()); \r
+ configXml.readParameters();\r
+ current = 75;\r
+ \r
+ config.readFigures(configXml.getParsedParameterList());\r
+ current = 80;\r
+ statMessage += ResourceController.getMessage("frame.intro.progress.read_file", FileConst.CONF_FILE_FIGURES) + NEWLINE;\r
+ Thread.yield();\r
+ \r
+ configXml.readProperties();\r
+ current = 100; \r
+ configXml.removeInvalidParam(config.getFigureList());\r
+ \r
+ statMessage += ResourceController.getMessage("frame.intro.progress.read_ok") + NEWLINE;\r
+ done = true;\r
+ } catch (Throwable ex) {\r
+ canceled = true;\r
+ errorMessage = ex.getMessage() + NEWLINE + NEWLINE;\r
+ errorMessage += ResourceController.getMessage("frame.intro.progress.correct_error");\r
+ Log.errorText(ex.getMessage(), ex);\r
+ return;\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Returns the error message.\r
+ * \r
+ * @return the error message.\r
+ */\r
+ public String getErrorMessage() {\r
+ return errorMessage;\r
+ }\r
+\r
+ public static void addStatMessage(String statMessage) {\r
+ ProgressControl.statMessage += statMessage + NEWLINE;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.errors;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>ConfigException</code> class is used for reporting errors generated during loading configuration\r
+ * files and templates.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ConfigException extends Throwable implements java.io.Serializable {\r
+\r
+ private static final long serialVersionUID = 7020184336946762911L;\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>ConfigException</code>.\r
+ */\r
+ public ConfigException() {\r
+ super();\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>ConfigException</code> with specified error messages and\r
+ * error source file.\r
+ * \r
+ * @param fileName\r
+ * the name of file where the error was generated.\r
+ * @param message\r
+ * the error message.\r
+ */\r
+ public ConfigException(String fileName, String message) {\r
+ super(ResourceController.getMessage("error.config_error", fileName) + "\n" + message);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.errors;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>FileNotFoundException</code> class is used when a configuration file, templates or\r
+ * their XML schema is missing.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class FileNotFoundException extends Throwable implements java.io.Serializable {\r
+\r
+ private static final long serialVersionUID = -4128798341326945960L;\r
+\r
+ /**\r
+ * Initializes a newly created <code>FileNotFoundException</code> with missing file.\r
+ * \r
+ * @param fileName\r
+ * the name of the missing file.\r
+ */\r
+ public FileNotFoundException(String fileName) {\r
+ super(ResourceController.getMessage("error.file_not_found.file", fileName));\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>FileNotFoundException</code>.\r
+ */\r
+ public FileNotFoundException() {\r
+ super(ResourceController.getMessage("error.file_not_found.dir"));\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>FileNotFoundException</code> with the rised error.\r
+ * \r
+ * @param t\r
+ * the rised error.\r
+ */\r
+ public FileNotFoundException(Throwable t) {\r
+ super(t.getMessage(), t);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.errors;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>OpenFileException</code> class is used for reporting errors rised during opening XSL\r
+ * stylesheet files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OpenFileException extends Throwable implements java.io.Serializable {\r
+\r
+ private static final long serialVersionUID = 7020184336946762911L;\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>OpenFileException</code>.\r
+ */\r
+ public OpenFileException() {\r
+ super(ResourceController.getMessage("error.open_file.wrong_form"));\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>OpenFileException</code> with specified message.\r
+ * \r
+ * @param message\r
+ * the message decribing the rised error.\r
+ */\r
+ public OpenFileException(String message) {\r
+ super(ResourceController.getMessage("error.open_file.wrong_form") + message);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.errors;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>ParserException</code> class is used for reporting errors rised during parsing values\r
+ * from input files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParserException extends Throwable {\r
+\r
+ private static final long serialVersionUID = 7020184336946762911L;\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>ParserException</code>.\r
+ */\r
+ public ParserException() {\r
+ super();\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>ParserException</code> with specified message.\r
+ * \r
+ * @param message\r
+ * the message decribing the rised error.\r
+ */\r
+ public ParserException(String message) {\r
+ super(ResourceController.getMessage("error.parser_error", message));\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.errors;\r
+\r
+/**\r
+ * The <code>SaveFileException</code> class is used for reporting errors rised during saving XSL\r
+ * stylesheet files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class SaveFileException extends Throwable implements java.io.Serializable {\r
+\r
+ private static final long serialVersionUID = 7020184336946762911L;\r
+\r
+ /**\r
+ * Initializes a newly created empty <code>SaveFileException</code> with the rised error.\r
+ * \r
+ * @param t\r
+ * the rised error.\r
+ */\r
+ public SaveFileException(Throwable t) {\r
+ super(t);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.errors;\r
+\r
+import org.xml.sax.ErrorHandler;\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.SAXParseException;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>XslParserException</code> class is used for reporting errors rised during parsing\r
+ * input XML and XSL files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class XslParserException implements ErrorHandler {\r
+ /**\r
+ * Creates text containing a message with the error.\r
+ * \r
+ * @param exception\r
+ * the rised error.\r
+ * @return a message with the error.\r
+ */\r
+ private String errorText(SAXParseException exception) {\r
+ return ResourceController.getMessage("error.xslt_parser", exception.getLineNumber(), exception.getColumnNumber(), exception.getMessage());\r
+ }\r
+\r
+ /**\r
+ * Handles the warning messages rised during file parsing.\r
+ * \r
+ * @param exception\r
+ * the rised warning.\r
+ * @throws SAXException\r
+ * with the content of the rised warning.\r
+ */\r
+ public void warning(SAXParseException exception) throws SAXException {\r
+ throw new SAXException(ResourceController.getMessage("error.xslt_parser.warning") + errorText(exception));\r
+ }\r
+\r
+ /**\r
+ * Handles the error messages rised during file parsing.\r
+ * \r
+ * @param exception\r
+ * the rised error.\r
+ * @throws SAXException\r
+ * with the content of the rised error.\r
+ */\r
+ public void error(SAXParseException exception) throws SAXException {\r
+ throw new SAXException(errorText(exception));\r
+ }\r
+\r
+ /**\r
+ * Handles the fatal error messages rised during file parsing.\r
+ * \r
+ * @param exception\r
+ * the rised fatal error.\r
+ * @throws SAXException\r
+ * with the content of the rised fatal error.\r
+ */\r
+ public void fatalError(SAXParseException exception) throws SAXException {\r
+ throw new SAXException(ResourceController.getMessage("error.xslt_parser.fatal") + errorText(exception));\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.logger;\r
+\r
+import java.io.PrintWriter;\r
+import java.io.StringWriter;\r
+\r
+import org.apache.log4j.Level;\r
+import org.apache.log4j.Logger;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ErrorResourceController;\r
+\r
+/**\r
+ * The <code>Log</code> class is used for logging all errors and debug messages in the editor.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class Log {\r
+ /**\r
+ * Logs the error with its error tracing and description obtained by\r
+ * <code>ErrorResourceController</code>.\r
+ * \r
+ * @param resource\r
+ * the resource key of the error description.\r
+ * @param ex\r
+ * the rised error.\r
+ */\r
+ public static void error(String resource, Throwable ex) {\r
+ Logger.getRootLogger().log(Level.ERROR, ErrorResourceController.getMessage(resource) + "\n" + getStackTrace(ex));\r
+ }\r
+\r
+ /**\r
+ * Logs the error with its error tracing and description.\r
+ * \r
+ * @param text\r
+ * the error description.\r
+ * @param ex\r
+ * the rised error.\r
+ */\r
+ public static void errorText(String text, Throwable ex) {\r
+ Logger.getRootLogger().log(Level.ERROR, text +"\n"+ getStackTrace(ex));\r
+ }\r
+\r
+ /**\r
+ * Logs the error with its error tracing.\r
+ * \r
+ * @param ex\r
+ * the rised error.\r
+ */\r
+ public static void error(Throwable ex) {\r
+ Logger.getRootLogger().log(Level.ERROR, getStackTrace(ex));\r
+ }\r
+\r
+ /**\r
+ * Logs the information with its description obtained by <code>ErrorResourceController</code>\r
+ * with arguments.\r
+ * \r
+ * @param resource\r
+ * the resource key of the error description.\r
+ * @param args\r
+ * the arguments of the description.\r
+ */\r
+ public static void info(String resource, Object... args) {\r
+ Logger.getRootLogger().info(ErrorResourceController.getMessage(resource, args));\r
+ }\r
+\r
+ /**\r
+ * Logs the warning with its error tracing and description obtained by\r
+ * <code>ErrorResourceController</code>.\r
+ * \r
+ * @param resource\r
+ * the resource key of the error description.\r
+ * @param ex\r
+ * the rised error.\r
+ */\r
+ public static void warn(String resource, Throwable ex) {\r
+ Logger.getRootLogger().log(Level.WARN, ErrorResourceController.getMessage(resource) +"\n"+ getStackTrace(ex));\r
+ }\r
+\r
+ /**\r
+ * Logs the warning with its error tracing and description obtained by\r
+ * <code>ErrorResourceController</code> with arguments.\r
+ * \r
+ * @param resource\r
+ * the resource key of the warning description.\r
+ * @param ex\r
+ * the rised warning.\r
+ * @param args\r
+ * the arguments of the description.\r
+ */\r
+ public static void warn(String resource, Throwable ex, Object... args) {\r
+ Logger.getRootLogger().log(Level.WARN, ErrorResourceController.getMessage(resource, args) +"\n"+ getStackTrace(ex));\r
+ }\r
+\r
+ /**\r
+ * Logs the warning with its error tracing.\r
+ * \r
+ * @param ex\r
+ * the rised warning.\r
+ */\r
+ public static void warn(Throwable ex) {\r
+ Logger.getRootLogger().log(Level.WARN, getStackTrace(ex));\r
+ }\r
+\r
+ /**\r
+ * Logs the fatal error with its error tracing.\r
+ * \r
+ * @param ex\r
+ * the rised fatal error.\r
+ */\r
+ public static void fatal(Throwable ex) {\r
+ Logger.getRootLogger().log(Level.FATAL, getStackTrace(ex));\r
+ }\r
+ \r
+ public static String getStackTrace(Throwable t) {\r
+ StringWriter sw = new StringWriter();\r
+ PrintWriter pw = new PrintWriter(sw);\r
+ t.printStackTrace(pw);\r
+ pw.flush();\r
+ return sw.toString();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.options;\r
+\r
+/**\r
+ * The <code>EncodingEnum</code> class is the enumerated list of document encodings.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public enum EncodingEnum {\r
+ UTF8("UTF-8"), UTF16BE("UTF-16BE"), UTF16LE("UTF-16LE"), ASCII("US-ASCII"), WIN1250(\r
+ "WINDOWS-1250"), ISO88591("ISO-8859-1"), ISO88592("ISO-8859-2");\r
+ /** The key specifying every type of encoding */\r
+ private String key;\r
+\r
+ /**\r
+ * Initializes a newly created <code>EncodingEnum</code> with defined key.\r
+ * \r
+ * @param key\r
+ * the key of the encoding.\r
+ */\r
+ private EncodingEnum(String key) {\r
+ this.key = key;\r
+ }\r
+\r
+ public String getKey() {\r
+ return key;\r
+ }\r
+\r
+ public String toString() {\r
+ return key;\r
+ }\r
+\r
+ /**\r
+ * Returns <code>EncodingEnum</code> object for corresponding key.\r
+ * \r
+ * @param encodKey\r
+ * the key of the encoding.\r
+ * @return the encoding for the input key.\r
+ */\r
+ public static EncodingEnum getEncoding(String encodKey) {\r
+ for (int i = 0; i < EncodingEnum.values().length; i++)\r
+ if (EncodingEnum.values()[i].key.equals(encodKey))\r
+ return EncodingEnum.values()[i];\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * Specifies if the input encoding is among predefined encodings <code>EncodingEnum</code>.\r
+ * \r
+ * @param encodKey\r
+ * the key of the encoding.\r
+ * @return true if the input encoding is present in the predefined encodings\r
+ * <code>EncodingEnum</code>.\r
+ */\r
+ public static boolean containsEncoding(String encodKey) {\r
+ for (int i = 0; i < EncodingEnum.values().length; i++)\r
+ if (EncodingEnum.values()[i].key.equals(encodKey))\r
+ return true;\r
+ return false;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.options;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>NewlineEnum</code> class is the enumerated list of chars defining ends of line in the\r
+ * output XSL stylesheet.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public enum NewlineEnum {\r
+ CRLF("cr+lf", "encoding.crlf"), LF("lf", "encoding.lf"), CR("cr", "encoding.cr");\r
+ /** The resource message specifying every end of line */\r
+ private String message;\r
+\r
+ /** The key specifying every end of line */\r
+ private String key;\r
+\r
+ /**\r
+ * Initializes a newly created <code>NewlineEnum</code> with defined key and resource message.\r
+ * \r
+ * @param key\r
+ * the key of the encoding.\r
+ * @param mes\r
+ * the resource message of encoding.\r
+ */\r
+ private NewlineEnum(String key, String mes) {\r
+ this.message = mes;\r
+ this.key = key;\r
+ }\r
+\r
+ public String getMessage() {\r
+ return message;\r
+ }\r
+\r
+ public String toString() {\r
+ return ResourceController.getMessage(message);\r
+ }\r
+\r
+ /**\r
+ * Returns <code>NewlineEnum</code> object for the corresponding key.\r
+ * \r
+ * @param newLineKey\r
+ * the key of the end of line.\r
+ * @return the end of line for the input key.\r
+ */\r
+ public static NewlineEnum getNewline(String newLineKey) {\r
+ for (int i = 0; i < NewlineEnum.values().length; i++)\r
+ if (NewlineEnum.values()[i].key.equals(newLineKey))\r
+ return NewlineEnum.values()[i];\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * Specifies if the input end of line is among predefined ends of line <code>NewlineEnum</code>.\r
+ * \r
+ * @param encodKey\r
+ * the key of the end of line.\r
+ * @return true if the input end of line is present in the predefined ends of line\r
+ * <code>NewlineEnum</code>.\r
+ */\r
+ public static boolean containsNewline(String encodKey) {\r
+ for (int i = 0; i < NewlineEnum.values().length; i++)\r
+ if (NewlineEnum.values()[i].key.equals(encodKey))\r
+ return true;\r
+ return false;\r
+ }\r
+\r
+ public String getKey() {\r
+ return key;\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.options;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileOutputStream;\r
+import java.util.Locale;\r
+import java.util.Properties;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.resource.LanguageEnum;\r
+\r
+/**\r
+ * The <code>OptionController</code> class is used for loading and saving editor options.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OptionController {\r
+ /** The properties storing options of the application */\r
+ private static Properties property;\r
+\r
+ /**\r
+ * Fills application properties <code>property</code> firstly by default option values and\r
+ * then by the option values loaded from the editor configuration file. The option values loaded\r
+ * from the configuration file rewrites the corresponding default option values.\r
+ * \r
+ * Then maps values from application properties <code>property</code> to the corresponding\r
+ * variables defined in <code>OptionItems</code>.\r
+ */\r
+ public static void readOptions() {\r
+ property = new Properties();\r
+\r
+ loadDefaultOptions();\r
+ readOptionFile();\r
+\r
+ mapEditorOptionItems();\r
+ mapStylesheetOptionItems();\r
+ mapBatchOptionItems();\r
+ Log.info("info.progress_control.load_file", OptionItems.OPTION_PATH);\r
+ }\r
+\r
+ /**\r
+ * Rewrites application properties <code>property</code> by default option values specifying\r
+ * stylesheet options. Then maps values from system properties <code>property</code> (only\r
+ * those specifying stylesheet options) to the corresponding variables defined in\r
+ * <code>OptionItems</code>.\r
+ */\r
+ public static void setDefaultStylesheetOptions() {\r
+ OptionItems.getDefaultStylesheetSettings(property);\r
+ mapStylesheetOptionItems();\r
+ }\r
+\r
+ /**\r
+ * Rewrites application properties <code>property</code> by default option values specifying\r
+ * editor options. Then maps values from system properties <code>property</code> (only those\r
+ * specifying editor options) to the corresponding variables defined in <code>OptionItems</code>.\r
+ */\r
+ public static void setDefaultEditorOptions() {\r
+ OptionItems.getDefaultEditorSettings(property);\r
+ mapEditorOptionItems();\r
+ }\r
+\r
+ /**\r
+ * Loads editor configuration files and saves its content to the system properties\r
+ * <code>property</code>.\r
+ */\r
+ private static void readOptionFile() {\r
+ try {\r
+ property.loadFromXML(new FileInputStream(System.getProperty("user.dir")\r
+ + File.separator + OptionItems.OPTION_PATH));\r
+ Log.info("info.option_controller.load_file");\r
+ } catch (Exception ex) {\r
+ Log.warn("error.option_controller.file_not_found", ex, OptionItems.OPTION_PATH);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Sets all default option values to the system properties <code>property</code>.\r
+ */\r
+ private static void loadDefaultOptions() {\r
+ OptionItems.getDefaultEditorSettings(property);\r
+ OptionItems.getDefaultStylesheetSettings(property);\r
+ OptionItems.getDefaultBatchSettings(property);\r
+ Log.info("info.option_controller.load_default_option");\r
+ }\r
+\r
+ /**\r
+ * Maps values from system properties <code>property</code> to the corresponding variables\r
+ * defined in <code>OptionItems</code>. Maps only variables specifying editor options (<code>LANGUAGE</code>,\r
+ * <code>XML_DEFINITION_PATH</code>, <code>ERASE_CONSOLE</code>).\r
+ */\r
+ private static void mapEditorOptionItems() {\r
+ OptionItems.LANGUAGE = LanguageEnum.parseLocale(property\r
+ .getProperty(OptionItems.KEY_LANGUAGE));\r
+ Locale.setDefault(OptionItems.LANGUAGE);\r
+\r
+ OptionItems.XML_DEFINITION_PATH = property.getProperty(OptionItems.KEY_XML_DEFINITION_PATH);\r
+ OptionItems.ERASE_CONSOLE = Boolean.parseBoolean(property\r
+ .getProperty(OptionItems.KEY_ERASE_CONSOLE));\r
+ }\r
+\r
+ /**\r
+ * Maps values from system properties <code>property</code> to the corresponding variables\r
+ * defined in <code>OptionItems</code>. Maps only variables specifying stylesheet options (<code>ADD_FO_NAMESPACE</code>,\r
+ * <code>REARRANGE_SAVE</code>, <code>GENERATE_COMMENTS</code>,\r
+ * <code>USE_PARAM_SELECT</code>, <code>ENCODING</code>, <code>NEWLINE</code>,\r
+ * <code>STYLESHEET_VERSION</code>, <code>IMPORT_FILE</code>).\r
+ */\r
+ private static void mapStylesheetOptionItems() {\r
+ OptionItems.ADD_FO_NAMESPACE = Boolean.parseBoolean(property\r
+ .getProperty(OptionItems.KEY_ADD_FO_NAMESPACE));\r
+ OptionItems.REARRANGE_SAVE = Boolean.parseBoolean(property\r
+ .getProperty(OptionItems.KEY_REARRANGE_SAVE));\r
+ OptionItems.GENERATE_COMMENTS = Boolean.parseBoolean(property\r
+ .getProperty(OptionItems.KEY_GENERATE_COMMENTS));\r
+ OptionItems.USE_PARAM_SELECT = Boolean.parseBoolean(property\r
+ .getProperty(OptionItems.KEY_USE_PARAM_SELECT));\r
+ if (EncodingEnum.containsEncoding(property.getProperty(OptionItems.KEY_ENCODING)))\r
+ OptionItems.ENCODING = property.getProperty(OptionItems.KEY_ENCODING);\r
+ if (NewlineEnum.containsNewline(property.getProperty(OptionItems.KEY_NEWLINE)))\r
+ OptionItems.NEWLINE = NewlineEnum.getNewline(property\r
+ .getProperty(OptionItems.KEY_NEWLINE));\r
+ OptionItems.STYLESHEET_VERSION = property.getProperty(OptionItems.KEY_STYLESHEET_VERSION);\r
+ OptionItems.IMPORT_FILE = property.getProperty(OptionItems.KEY_IMPORT_FILE);\r
+\r
+ }\r
+\r
+ /**\r
+ * Maps values from system properties <code>property</code> to the corresponding variables\r
+ * defined in <code>OptionItems</code>. Maps only variables specifying batch options (<code>BATCH_FILE</code>,\r
+ * <code>SAVE_BEFORE_RUN</code>).\r
+ */\r
+ private static void mapBatchOptionItems() {\r
+ OptionItems.BATCH_FILE = property.getProperty(OptionItems.KEY_BATCH_FILE);\r
+ OptionItems.SAVE_BEFORE_RUN = Boolean.parseBoolean(property\r
+ .getProperty(OptionItems.KEY_SAVE_BEFORE_RUN));\r
+ }\r
+\r
+ /**\r
+ * Maps all variables defined in <code>OptionItems</code> to the corresponding values in the\r
+ * system properties <code>property</code>.\r
+ */\r
+ private static void saveOptionItems() {\r
+ // editor options\r
+ property.put(OptionItems.KEY_LANGUAGE, OptionItems.LANGUAGE.toString());\r
+ property.put(OptionItems.KEY_XML_DEFINITION_PATH, OptionItems.XML_DEFINITION_PATH);\r
+ property.put(OptionItems.KEY_ERASE_CONSOLE, OptionItems.ERASE_CONSOLE.toString());\r
+\r
+ // stylesheet options\r
+ property.put(OptionItems.KEY_ADD_FO_NAMESPACE, OptionItems.ADD_FO_NAMESPACE.toString());\r
+ property.put(OptionItems.KEY_REARRANGE_SAVE, OptionItems.REARRANGE_SAVE.toString());\r
+ property.put(OptionItems.KEY_GENERATE_COMMENTS, OptionItems.GENERATE_COMMENTS.toString());\r
+ property.put(OptionItems.KEY_USE_PARAM_SELECT, OptionItems.USE_PARAM_SELECT.toString());\r
+ property.put(OptionItems.KEY_ENCODING, OptionItems.ENCODING);\r
+ property.put(OptionItems.KEY_NEWLINE, OptionItems.NEWLINE.getKey());\r
+ property.put(OptionItems.KEY_IMPORT_FILE, OptionItems.IMPORT_FILE);\r
+ property.put(OptionItems.KEY_STYLESHEET_VERSION, OptionItems.STYLESHEET_VERSION);\r
+\r
+ // batch options\r
+ property.put(OptionItems.KEY_BATCH_FILE, OptionItems.BATCH_FILE);\r
+ property.put(OptionItems.KEY_SAVE_BEFORE_RUN, OptionItems.SAVE_BEFORE_RUN.toString());\r
+ }\r
+\r
+ /**\r
+ * Saves values in the system properties <code>property</code> to the editor configuration\r
+ * file.\r
+ */\r
+ public static void storeOptionItems() {\r
+ saveOptionItems();\r
+ try {\r
+ property.storeToXML(new FileOutputStream(OptionItems.OPTION_PATH),\r
+ OptionItems.OPTION_PATH);\r
+ Log.info("info.option_controller.save_file", OptionItems.OPTION_PATH);\r
+ } catch (Exception ex) {\r
+ Log.error("error.option_controller.store", ex);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.options;\r
+\r
+import java.util.Locale;\r
+import java.util.Properties;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.LanguageEnum;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.TopMenu;\r
+\r
+/**\r
+ * The <code>OptionItems</code> class contains variables defining all options used in the\r
+ * application.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OptionItems {\r
+ /** The configuration file where options of the application are stored */\r
+ public static final String OPTION_PATH = "options.xml";\r
+\r
+ /** The version of the application */\r
+ public static final String APPLICATION_VERSION = "1.0";\r
+\r
+ /** The stylesheet XSL namespace */\r
+ public static final String XSL_NAMESPACE = "http://www.w3.org/1999/XSL/Transform";\r
+\r
+ /** The stylesheet FO namespace */\r
+ public static final String FO_NAMESPACE = "http://www.w3.org/1999/XSL/Format";\r
+\r
+ // ------------- editor options ------------------------\r
+\r
+ /** The property key of the language used in the editor */\r
+ public static final String KEY_LANGUAGE = "fo_parameter_editor.language";\r
+\r
+ /** The language used in the editor */\r
+ public static Locale LANGUAGE = LanguageEnum.getDefaultLocale();\r
+\r
+ /**\r
+ * Changes language used in the editor by the input language locale, if the language locale is\r
+ * supported by the editor. Updates all text expression in the application according to the new\r
+ * language.\r
+ * \r
+ * @param language\r
+ * the locale of the language that will be set as current editor language.\r
+ */\r
+ public static void changeLanguage(Locale language) {\r
+ OptionItems.LANGUAGE = language;\r
+ ResourceController.changeInstance();\r
+ TopMenu.changeLanguage();\r
+ Locale.setDefault(language);\r
+ }\r
+\r
+ /** The property key of the path where files with XML descriptions of FO parameters are stored */\r
+ public static final String KEY_XML_DEFINITION_PATH = "fo_parameter_editor.xml_definition_path";\r
+\r
+ /** The path where files with XML descriptions of FO parameters are stored */\r
+ public static String XML_DEFINITION_PATH;\r
+\r
+ /** The property key of the flag specifying if the editor console is erased before every action */\r
+ public static final String KEY_ERASE_CONSOLE = "fo_parameter_editor.erase_console";\r
+\r
+ /** The flag specifying if the editor console is erased before every action */\r
+ public static Boolean ERASE_CONSOLE;\r
+\r
+ // ------------------- stylesheet options ---------------------\r
+\r
+ /**\r
+ * The property key of the flag specifying if the FO namespace definition is added to every new\r
+ * stylesheet file\r
+ */\r
+ public static final String KEY_ADD_FO_NAMESPACE = "fo_parameter_editor.add_fo_namespace";\r
+\r
+ /** The flag specifying if the FO namespace definition is added to every new stylesheet file */\r
+ public static Boolean ADD_FO_NAMESPACE;\r
+\r
+ /** The property key of the flag specifying if the rearrange stylesheet saving is used */\r
+ public static final String KEY_REARRANGE_SAVE = "fo_parameter_editor.rearrange_save";\r
+\r
+ /** The flag specifying if the rearrange stylesheet saving is used */\r
+ public static Boolean REARRANGE_SAVE;\r
+\r
+ /** The property key of the flag specifying if the comments in stylesheets are generated */\r
+ public static final String KEY_GENERATE_COMMENTS = "fo_parameter_editor.generate_comments";\r
+\r
+ /** The flag specifying if the comments in stylesheets are generated */\r
+ public static Boolean GENERATE_COMMENTS;\r
+\r
+ /**\r
+ * The property key of the flag specifying if attribute select is used in the stylesheet\r
+ * parameter element\r
+ */\r
+ public static final String KEY_USE_PARAM_SELECT = "fo_parameter_editor.use_param_select";\r
+\r
+ /** The flag specifying if attribute select is used in the stylesheet parameter element */\r
+ public static Boolean USE_PARAM_SELECT;\r
+\r
+ /** The property key of the actual editor encoding */\r
+ public static final String KEY_ENCODING = "fo_parameter_editor.encoding";\r
+\r
+ /** The actual editor encoding */\r
+ public static String ENCODING;\r
+\r
+ /** The property key of the actual stylesheet end of line */\r
+ public static final String KEY_NEWLINE = "fo_parameter_editor.newline";\r
+\r
+ /** The actual stylesheet end of line */\r
+ public static NewlineEnum NEWLINE;\r
+\r
+ // ----------------- xsl options ------------------------\r
+\r
+ /**\r
+ * The property key of the list specifying XSL stylesheet files imported to a new stylesheet\r
+ * file\r
+ */\r
+ public static final String KEY_IMPORT_FILE = "fo_parameter_editor.xsl_import_file";\r
+\r
+ /** The list specifying XSL stylesheet files imported to a new stylesheet file */\r
+ public static String IMPORT_FILE;\r
+\r
+ /** The property key of stylesheet version */\r
+ public static final String KEY_STYLESHEET_VERSION = "fo_parameter_editor.stylesheet_version";\r
+\r
+ /** The stylesheet version */\r
+ public static String STYLESHEET_VERSION;\r
+\r
+ // ----------------- batch options ------------------------\r
+\r
+ /** The property key of batch file path */\r
+ public static final String KEY_BATCH_FILE = "fo_parameter_editor.batch_file";\r
+\r
+ /** The batch file path */\r
+ public static String BATCH_FILE;\r
+\r
+ /**\r
+ * The property key of flag specifying if the opened stylesheet is automatically saved before\r
+ * launching batch file\r
+ */\r
+ public static final String KEY_SAVE_BEFORE_RUN = "fo_parameter_editor.save_before_run";\r
+\r
+ /**\r
+ * The flag specifying if the opened stylesheet is automatically saved before launching batch\r
+ * file\r
+ */\r
+ public static Boolean SAVE_BEFORE_RUN;\r
+\r
+ /**\r
+ * Fills application properties <code>property</code> by default option values. Maps only\r
+ * variables specifying editor options (<code>LANGUAGE</code>,\r
+ * <code>XML_DEFINITION_PATH</code>, <code>ERASE_CONSOLE</code>).\r
+ * \r
+ * @param defaultSettings\r
+ * the properties storing options of the application.\r
+ * @return the properties storing options of the application containing default editor options.\r
+ */\r
+ public static Properties getDefaultEditorSettings(Properties defaultSettings) {\r
+ defaultSettings.put(KEY_LANGUAGE, LanguageEnum.getDefaultLocale());\r
+ defaultSettings.put(KEY_XML_DEFINITION_PATH, "docbook-params");\r
+ defaultSettings.put(KEY_ERASE_CONSOLE, "false");\r
+ return defaultSettings;\r
+ }\r
+\r
+ /**\r
+ * Fills application properties <code>property</code> by default option values. Maps only\r
+ * variables specifying stylesheet options (<code>ADD_FO_NAMESPACE</code>,\r
+ * <code>REARRANGE_SAVE</code>, <code>GENERATE_COMMENTS</code>,\r
+ * <code>USE_PARAM_SELECT</code>, <code>ENCODING</code>, <code>NEWLINE</code>,\r
+ * <code>STYLESHEET_VERSION</code>, <code>IMPORT_FILE</code>).\r
+ * \r
+ * @param defaultSettings\r
+ * the properties storing options of the application.\r
+ * @return the properties storing options of the application containing default stylesheet\r
+ * options.\r
+ */\r
+ public static Properties getDefaultStylesheetSettings(Properties defaultSettings) {\r
+ defaultSettings.put(KEY_ADD_FO_NAMESPACE, "false");\r
+ defaultSettings.put(KEY_REARRANGE_SAVE, "false");\r
+ defaultSettings.put(KEY_GENERATE_COMMENTS, "true");\r
+ defaultSettings.put(KEY_USE_PARAM_SELECT, "false");\r
+ defaultSettings.put(KEY_ENCODING, EncodingEnum.UTF8.getKey());\r
+ defaultSettings.put(KEY_NEWLINE, NewlineEnum.CRLF.getKey());\r
+ defaultSettings.put(KEY_STYLESHEET_VERSION, "1.0");\r
+ defaultSettings.put(KEY_IMPORT_FILE,\r
+ "http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl;");\r
+ return defaultSettings;\r
+ }\r
+\r
+ /**\r
+ * Fills application properties <code>property</code> by default other values. Maps only\r
+ * variables specifying batch options (<code>BATCH_FILE</code>, <code>SAVE_BEFORE_RUN</code>).\r
+ * \r
+ * @param defaultSettings\r
+ * the properties storing options of the application.\r
+ * @return the properties storing options of the application containing default batch options.\r
+ */\r
+ public static Properties getDefaultBatchSettings(Properties defaultSettings) {\r
+ defaultSettings.put(KEY_BATCH_FILE, "");\r
+ defaultSettings.put(KEY_SAVE_BEFORE_RUN, "true");\r
+ return defaultSettings;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.resource;\r
+\r
+import java.text.MessageFormat;\r
+import java.util.ResourceBundle;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>ErrorResourceController</code> class contains methods for loading error text\r
+ * resources.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ErrorResourceController {\r
+\r
+ /** The bundle of text resources */\r
+ private ResourceBundle resource;\r
+\r
+ /** The instance of the <code>ErrorResourceController</code> class */\r
+ private static ErrorResourceController instance;\r
+\r
+ /**\r
+ * Singleton constructor - gets the single instance of the <code>ErrorResourceController</code> class.\r
+ * \r
+ * @return the instance of the <code>ErrorResourceController</code> class.\r
+ */\r
+ private static ErrorResourceController getInstance() {\r
+ if (instance == null)\r
+ instance = new ErrorResourceController();\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>ErrorResourceController</code> with error resource\r
+ * bundle.\r
+ */\r
+ public ErrorResourceController() {\r
+ this.resource = ResourceBundle.getBundle(ResourceConst.ERROR_RESOURCE_PATH);\r
+ }\r
+\r
+ /**\r
+ * Gets the error text resource for the input key.\r
+ * \r
+ * @param key\r
+ * the key of the error text resource.\r
+ * @return the error text resource for the input key.\r
+ */\r
+ private String getString(String key) {\r
+ return resource.getString(key);\r
+ }\r
+\r
+ /**\r
+ * Gets the error text resource for the input key.\r
+ * \r
+ * @param key\r
+ * the key of the error text resource.\r
+ * @return the error text resource for the input key.\r
+ */\r
+ public static String getMessage(String key) {\r
+ try {\r
+ return ErrorResourceController.getInstance().getString(key);\r
+ } catch (Exception ex) {\r
+ Log.warn(ex);\r
+ return key;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Gets the error text resource for the input key and arguments.\r
+ * \r
+ * @param key\r
+ * the key of the error text resource.\r
+ * @param args\r
+ * the arguments of the error text resource.\r
+ * @return the error text resource for the input key and arguments.\r
+ */\r
+ public static String getMessage(String key, Object... args) {\r
+ try {\r
+ MessageFormat format = new MessageFormat(ErrorResourceController.getInstance()\r
+ .getString(key).replaceAll("'", "''"));\r
+ return format.format(args);\r
+ } catch (Exception ex) {\r
+ Log.warn(ex);\r
+ return key;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.resource;\r
+\r
+import java.util.Locale;\r
+\r
+/**\r
+ * The <code>EncodingEnum</code> class is the enumerated list of languages used in the\r
+ * application.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public enum LanguageEnum {\r
+ EN(Locale.ENGLISH), CS(new Locale("cs"));\r
+\r
+ /** The locale specifying the language */\r
+ private Locale locale;\r
+\r
+ /**\r
+ * Initializes a newly created <code>LanguageEnum</code> with defined locale language.\r
+ * \r
+ * @param locale\r
+ * the locale of the language.\r
+ */\r
+ private LanguageEnum(Locale locale) {\r
+ this.locale = locale;\r
+ }\r
+\r
+ /**\r
+ * Returns title of the language loaded from resources <code>ResourceController</code>.\r
+ * \r
+ * @return the language title loaded from <code>ResourceController</code>.\r
+ */\r
+ public String toString() {\r
+ return ResourceController.getMessage("language." + locale.toString());\r
+ }\r
+\r
+ /**\r
+ * Returns <code>LanguageEnum</code> language for corresponding locale.\r
+ * \r
+ * @param loc\r
+ * the locale of the language.\r
+ * @return the language for the input locale.\r
+ */\r
+ public static LanguageEnum getLanguage(Locale loc) {\r
+ if (CS.locale.equals(loc))\r
+ return CS;\r
+ return EN;\r
+ }\r
+\r
+ /**\r
+ * Parses input string containing language and returns corresponding <code>locale</code>\r
+ * language.\r
+ * \r
+ * @param language\r
+ * the input text constant containing language.\r
+ * @return the locale corresponding to the input text constant.\r
+ */\r
+ public static Locale parseLocale(String language) {\r
+ if ((language != null) && (language.equals(CS.getLocale().getLanguage())))\r
+ return CS.getLocale();\r
+ return EN.getLocale();\r
+ }\r
+\r
+ public Locale getLocale() {\r
+ return locale;\r
+ }\r
+\r
+ /**\r
+ * Gets the current value of the default locale for this instance of the Java Virtual Machine.\r
+ * Returns only supported value - CS or EN.\r
+ * \r
+ * @return the locale of this instance of JVM.\r
+ */\r
+ public static Locale getDefaultLocale() {\r
+ if (Locale.getDefault().getLanguage().equals(LanguageEnum.CS.getLocale().getLanguage()))\r
+ return LanguageEnum.CS.getLocale();\r
+ return LanguageEnum.EN.getLocale();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.resource;\r
+\r
+/**\r
+ * The <code>ResourceConst</code> class contains paths of the editor text resources.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ResourceConst {\r
+ /** The editor containing text resources */\r
+ private final static String RESOURCE_DIR = "resources/";\r
+\r
+ /** The file containing the error text resources */\r
+ public final static String ERROR_RESOURCE_PATH = RESOURCE_DIR + "ErrorResource";\r
+\r
+ /** The file containing the application text resources */\r
+ public final static String TEXT_RESOURCE_PATH = RESOURCE_DIR + "TextResource";\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.controller.resource;\r
+\r
+import java.io.UnsupportedEncodingException;\r
+import java.text.MessageFormat;\r
+import java.util.Enumeration;\r
+import java.util.PropertyResourceBundle;\r
+import java.util.ResourceBundle;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+\r
+/**\r
+ * The <code>ResourceController</code> class contains methods for loading text resources.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ResourceController {\r
+\r
+ /** The bundle of text resources */\r
+ private static ResourceBundle resource;\r
+\r
+ /** The instance of the <code>ResourceController</code> class */\r
+ private static ResourceController instance;\r
+\r
+ /**\r
+ * Singleton constructor - gets the instance of the <code>ResourceController</code> class.\r
+ * \r
+ * @return the instance of the <code>ResourceController</code> class.\r
+ */\r
+ private static ResourceController getInstance() {\r
+ if (instance == null)\r
+ instance = new ResourceController();\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Changes the loaded resource bundle to the new bundle for actully chosen editor language.\r
+ */\r
+ public static void changeInstance() {\r
+ instance = new ResourceController();\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>ResourceController</code> with resource bundle for actual\r
+ * editor language.\r
+ */\r
+ private ResourceController() {\r
+ ResourceController.resource = ResourceBundle.getBundle(ResourceConst.TEXT_RESOURCE_PATH,\r
+ OptionItems.LANGUAGE);\r
+ ResourceController.resource = createUtf8PropertyResourceBundle(ResourceController.resource);\r
+ }\r
+\r
+ /**\r
+ * Gets the text resource of the actual language for the input key.\r
+ * \r
+ * @param key\r
+ * the key of the text resource.\r
+ * @return the text resource for the input key.\r
+ */\r
+ private String getString(String key) {\r
+ return resource.getString(key);\r
+ }\r
+\r
+ /**\r
+ * Gets the text resource of the actual language for the input key.\r
+ * \r
+ * @param key\r
+ * the key of the text resource.\r
+ * @return the text resource for the input key.\r
+ */\r
+ public static String getMessage(String key) {\r
+ try {\r
+ return ResourceController.getInstance().getString(key);\r
+ } catch (Exception ex) {\r
+ Log.warn("error.resource_controller.missing_key", ex, key);\r
+ return key;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Gets the text resource of the actual language for the input key and arguments.\r
+ * \r
+ * @param key\r
+ * the key of the text resource.\r
+ * @param args\r
+ * the arguments of the text resource.\r
+ * @return the text resource for the input key and arguments.\r
+ */\r
+ public static String getMessage(String key, Object... args) {\r
+ try {\r
+ MessageFormat format = new MessageFormat(ResourceController.getInstance()\r
+ .getString(key).replaceAll("'", "''"), OptionItems.LANGUAGE);\r
+ return format.format(args);\r
+ } catch (Exception ex) {\r
+ Log.warn("error.resource_controller.missing_key", ex, key);\r
+ return key;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Convert the input resource bundle to the UTF-8 resource bundle.\r
+ * \r
+ * @param bundle\r
+ * the resource bundle.\r
+ * @return the UTF-8 resource bundle converted from the input resource bundle.\r
+ */\r
+ private static ResourceBundle createUtf8PropertyResourceBundle(ResourceBundle bundle) {\r
+ if (!(bundle instanceof PropertyResourceBundle))\r
+ return bundle;\r
+\r
+ return new Utf8PropertyResourceBundle((PropertyResourceBundle) bundle);\r
+ }\r
+\r
+ /**\r
+ * The <code>Utf8PropertyResourceBundle</code> class define resource bundle that converts text\r
+ * resources from ISO-8859-1 to UTF-8 encoding.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ private static class Utf8PropertyResourceBundle extends ResourceBundle {\r
+ /** The property resource bundle */\r
+ PropertyResourceBundle bundle;\r
+\r
+ /**\r
+ * Initializes a newly created <code>Utf8PropertyResourceBundle</code> with define\r
+ * property resource bundle.\r
+ * \r
+ * @param bundle\r
+ * the property resource bundle.\r
+ */\r
+ private Utf8PropertyResourceBundle(PropertyResourceBundle bundle) {\r
+ this.bundle = bundle;\r
+ }\r
+\r
+ @Override\r
+ public Enumeration<String> getKeys() {\r
+ return bundle.getKeys();\r
+ }\r
+\r
+ @Override\r
+ protected Object handleGetObject(String key) {\r
+ String value = (String) bundle.handleGetObject(key);\r
+ try {\r
+ return new String(value.getBytes("ISO-8859-1"), "UTF-8");\r
+ } catch (UnsupportedEncodingException ex) {\r
+ Log.warn(ex);\r
+ return null;\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.displays;\r
+\r
+import javax.swing.JPanel;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+\r
+/**\r
+ * The <code>GraphicsFigure</code> class represents a parent for all graphics figures.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public abstract class GraphicsFigure extends JPanel {\r
+\r
+ private static final long serialVersionUID = -6123711841424326935L;\r
+\r
+ /**\r
+ * Sets the list of parameter that are an input data source for the graphics figure.\r
+ * \r
+ * @param parameterList\r
+ */\r
+ public abstract void setInputs(Parameter[] parameterList);\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.displays;\r
+\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+import java.awt.Graphics;\r
+import java.awt.Graphics2D;\r
+import java.awt.geom.Rectangle2D;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+\r
+/**\r
+ * The <code>PageFigure</code> class represents a graphics figure illustrating dimesions of the\r
+ * paper.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class PageFigure extends GraphicsFigure implements Observer {\r
+\r
+ private static final long serialVersionUID = 7211322657832007934L;\r
+\r
+ /** The reference to the parameter representing paper width */\r
+ private Parameter pageWidthParameter;\r
+\r
+ /** The reference to the parameter representing paper height */\r
+ private Parameter pageHeightParameter;\r
+\r
+ /** The total size of graphics figure */\r
+ private static final int SIZE = 140;\r
+\r
+ /** The maximum size of the paper */\r
+ private static final int PAPER_SIZE = 100;\r
+\r
+ /** The actual width of the graphics figure illustrating paper */\r
+ private int widthSize;\r
+\r
+ /** The actual height of the graphics figure illustrating paper */\r
+ private int heightSize;\r
+\r
+ /** The color of the graphics figure illustrating paper */\r
+ private static final Color PAPER_COLOR = new Color(0, 64, 128);\r
+\r
+ public PageFigure() {\r
+ this.setPreferredSize(new Dimension(SIZE, SIZE));\r
+ }\r
+\r
+ /**\r
+ * Repaints the graphics figure according to actual parameter values.\r
+ */\r
+ public void paintComponent(Graphics graphics) {\r
+ Graphics2D graphics2 = (Graphics2D) graphics;\r
+ super.paintComponent(graphics);\r
+ countSizes();\r
+\r
+ graphics2.setColor(PAPER_COLOR);\r
+ graphics2.fill(new Rectangle2D.Double((SIZE - PAPER_SIZE) / 2, (SIZE - PAPER_SIZE) / 2,\r
+ widthSize, heightSize));\r
+ }\r
+\r
+ @Override\r
+ public void setInputs(Parameter[] parameterList) {\r
+ this.pageWidthParameter = parameterList[0];\r
+ this.pageWidthParameter.addObserver(this);\r
+ this.pageHeightParameter = parameterList[1];\r
+ this.pageHeightParameter.addObserver(this);\r
+ }\r
+\r
+ /**\r
+ * Method is called when some dependent parameter changes his value. Then the graphics figure\r
+ * values are updated according to parameter values.\r
+ */\r
+ public void update(Observable arg0, Object arg1) {\r
+ this.repaint();\r
+ }\r
+\r
+ /**\r
+ * Counts new sizes of the graphics figure illustrating paper. New sizes are counted on the\r
+ * basis of parameter actual values.\r
+ */\r
+ private void countSizes() {\r
+ Double pageWidth = Double.valueOf(pageWidthParameter.getType().getValue().replace(",", "."));\r
+ double pageHeight = Double.valueOf(pageHeightParameter.getType().getValue().replace(",", "."));\r
+ Double max = Math.max(pageWidth, pageHeight);\r
+ max /= PAPER_SIZE;\r
+ widthSize = (int) (pageWidth / max);\r
+ heightSize = (int) (pageHeight / max);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Dimension;\r
+import java.awt.EventQueue;\r
+import java.awt.Image;\r
+\r
+import javax.swing.JComponent;\r
+import javax.swing.JFrame;\r
+import javax.swing.ToolTipManager;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.OpenFile;\r
+import cz.zcu.fav.kiv.editor.controller.MenuController;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.components.editor.EditorBody;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.FrameShower;\r
+\r
+/**\r
+ * The <code>MainFrame</code> class represents the main frame of the application.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public final class MainFrame extends JFrame {\r
+\r
+ private static final long serialVersionUID = 2955560489556252043L;\r
+\r
+ /** The instance of the <code>MainFrame</code> class */\r
+ private static MainFrame instance;\r
+\r
+ /** The main menu of the application */\r
+ private static TopMenu menuBar;\r
+\r
+ /** The data containing editor data structure */\r
+ private ConfigData configData;\r
+\r
+ /** The structure containing information about actually opened file */\r
+ private OpenFile openFile;\r
+\r
+ /**\r
+ * Initializes a newly created <code>MainFrame</code>.\r
+ */\r
+ private MainFrame() {\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>MainFrame</code> with specified data.\r
+ * \r
+ * @param data\r
+ * the data containing editor data structure.\r
+ */\r
+ private MainFrame(ConfigData data) {\r
+ this.configData = data;\r
+ this.openFile = new OpenFile();\r
+ }\r
+\r
+ /**\r
+ * Singleton constructor - gets the single instance of the <code>MainFrame</code> class.\r
+ * \r
+ * @return the single instance of <code>MainFrame</code>.\r
+ */\r
+ public static MainFrame getInstance() {\r
+ if (instance == null) {\r
+ instance = new MainFrame();\r
+ return instance;\r
+ }\r
+ return instance;\r
+\r
+ }\r
+\r
+ /**\r
+ * Creates the main application frame <code>MainFrame</code> with specified data.\r
+ * \r
+ * @param data\r
+ * the data containing editor data structure.\r
+ * @return newly created main application frame.\r
+ */\r
+ public static MainFrame createFrame(ConfigData data) {\r
+ instance = new MainFrame(data);\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * This method is called from within the constructor to initialize the form.\r
+ */\r
+ private void initComponents() {\r
+\r
+ setTitle(ResourceController.getMessage("editor.title"));\r
+\r
+ addWindowListener(new java.awt.event.WindowAdapter() {\r
+ public void windowClosing(java.awt.event.WindowEvent evt) {\r
+ exitForm(evt);\r
+ }\r
+\r
+ public void windowOpened(java.awt.event.WindowEvent evt) {\r
+ formWindowOpened(evt);\r
+ }\r
+ });\r
+\r
+ menuBar = new TopMenu(this);\r
+ setJMenuBar(menuBar);\r
+\r
+ JComponent newContentPane = new EditorBody(configData.getSectionList());\r
+ newContentPane.setOpaque(true);\r
+ this.getContentPane().add(newContentPane, BorderLayout.CENTER);\r
+\r
+ ToolTipManager.sharedInstance().setInitialDelay(0);\r
+\r
+ Dimension dim = getToolkit().getScreenSize();\r
+ Dimension abounds = getPreferredSize();\r
+ setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);\r
+\r
+ // Threadsafe startup of main frame\r
+ Runnable runner = new FrameShower(this);\r
+ EventQueue.invokeLater(runner);\r
+ }\r
+\r
+ /**\r
+ * Reaction on frame window opening.\r
+ * \r
+ * @param evt\r
+ * the opened window.\r
+ */\r
+ private void formWindowOpened(java.awt.event.WindowEvent evt) {\r
+ Image frameImage = EditorIcon.createEditorIcon();\r
+ if (frameImage != null) {\r
+ setIconImage(frameImage);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Reaction on frame window closing.\r
+ * \r
+ * @param evt\r
+ * the actually closing window.\r
+ */\r
+ private void exitForm(java.awt.event.WindowEvent evt) {\r
+ MenuController.exitItem();\r
+ shutDown();\r
+ }\r
+\r
+ /**\r
+ * Shuts down the main application frame - terminates the whole application.\r
+ * \r
+ */\r
+ public void shutDown() {\r
+ System.exit(0);\r
+ }\r
+\r
+ /**\r
+ * Initializes the form and launched it.\r
+ * \r
+ * @throws Exception\r
+ * if an error during initialization occurs.\r
+ */\r
+ public void go() throws Exception {\r
+ initComponents();\r
+ }\r
+\r
+ public ConfigData getConfigData() {\r
+ return configData;\r
+ }\r
+\r
+ public OpenFile getOpenFile() {\r
+ return openFile;\r
+ }\r
+\r
+ /**\r
+ * Changes the title of the main frame. Sets the name of the actually opened file to the title.\r
+ * If the actually opened file has been modified then the title is changed.\r
+ * \r
+ */\r
+ public void changeTitle() {\r
+ String title = ResourceController.getMessage("editor.title") + " - ";\r
+ if (openFile.isFileChanged())\r
+ title += "*";\r
+ if (openFile.getOpenFilePath() != null)\r
+ title += openFile.getOpenFilePath();\r
+ setTitle(title);\r
+ }\r
+\r
+ /**\r
+ * Specifies that the actually opened file <code>OpenFile</code> has been modified.\r
+ */\r
+ public void setFileChanged() {\r
+ if (!openFile.isFileChanged())\r
+ this.getOpenFile().setFileChanged(true);\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.awt.event.KeyEvent;\r
+import java.io.File;\r
+\r
+import javax.swing.JCheckBoxMenuItem;\r
+import javax.swing.JFileChooser;\r
+import javax.swing.JMenu;\r
+import javax.swing.JMenuBar;\r
+import javax.swing.JMenuItem;\r
+import javax.swing.KeyStroke;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.MenuController;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.frames.AboutForm;\r
+import cz.zcu.fav.kiv.editor.graphics.frames.ConfigInfoForm;\r
+import cz.zcu.fav.kiv.editor.graphics.frames.HelpFrame;\r
+import cz.zcu.fav.kiv.editor.graphics.options.OptionEditorDialog;\r
+import cz.zcu.fav.kiv.editor.graphics.options.OptionStylesheetDialog;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.OverwriteFileDialog;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.SaveFileDialog;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.XmlFilter;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.XslFilter;\r
+import cz.zcu.fav.kiv.editor.template.TemplateConst;\r
+\r
+/**\r
+ * The <code>TopMenu</code> class represents the main menu of the application.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TopMenu extends JMenuBar {\r
+\r
+ private static final long serialVersionUID = 6053686624644714331L;\r
+\r
+ /** The reference to the main frame <code>MainFrame</code> */\r
+ private MainFrame frame;\r
+\r
+ /* ---------------------- file menu ---------------------------- */\r
+\r
+ /** The file menu */\r
+ private static JMenu fileMenu = new JMenu();\r
+\r
+ /** The item 'exit' from the file menu */\r
+ private static JMenuItem exitFileMenuItem = new JMenuItem();\r
+\r
+ /** The submenu item of the item 'new' from the file menu */\r
+ private static JMenu submenuNewFile = new JMenu();\r
+\r
+ /** The item 'new empty stylesheet' of the file submenu 'new' */\r
+ private static JMenuItem newFileMenuEmptyItem = new JMenuItem();\r
+\r
+ /** The item 'new default stylesheet' of the file submenu 'new' */\r
+ private static JMenuItem newFileMenuDefaultItem = new JMenuItem();\r
+\r
+ /** The item 'new user stylesheet' of the file submenu 'new' */\r
+ private static JMenuItem newFileMenuStylesheetItem = new JMenuItem();\r
+\r
+ /** The item 'open' of the file menu */\r
+ private static JMenuItem openFileMenuItem = new JMenuItem();\r
+\r
+ /** The item 'close' of the file menu */\r
+ private static JMenuItem closeFileMenuItem = new JMenuItem();\r
+\r
+ /** The item 'save' of the file menu */\r
+ private static JMenuItem saveFileMenuItem = new JMenuItem();\r
+\r
+ /** The item 'save as' of the file menu */\r
+ private static JMenuItem saveAsFileMenuItem = new JMenuItem();\r
+\r
+ /* ---------------------- run menu ---------------------------- */\r
+ /** The run menu */\r
+ private static JMenu runMenu = new JMenu();\r
+\r
+ /** The item 'run batch' from the run menu */\r
+ private static JMenuItem runBatchMenuItem = new JMenuItem();\r
+\r
+ /** The item 'select batch' from the run menu */\r
+ private static JMenuItem selectBatchMenuItem = new JMenuItem();\r
+\r
+ /** The item 'save batch before' from the run menu */\r
+ private static JCheckBoxMenuItem batchSaveBeforeMenuItem = new JCheckBoxMenuItem();\r
+\r
+ /* ---------------------- option menu ---------------------------- */\r
+ /** The option menu */\r
+ private static JMenu optionMenu = new JMenu();\r
+\r
+ /** The item 'stylesheet option' from the option menu */\r
+ private static JMenuItem optionStylesheetMenuItem = new JMenuItem();\r
+\r
+ /** The item 'editor option' from the option menu */\r
+ private static JMenuItem optionEditorMenuItem = new JMenuItem();\r
+\r
+ /* ---------------------- help menu ---------------------------- */\r
+ /** The help menu */\r
+ private static JMenu helpMenu = new JMenu();\r
+\r
+ /** The item 'help contents' from the help menu */\r
+ private static JMenuItem helpWindowMenuItem = new JMenuItem();\r
+\r
+ /** The item 'about' from the help menu */\r
+ private static JMenuItem aboutHelpMenuItem = new JMenuItem();\r
+\r
+ /** The item 'config info' from the help menu */\r
+ private static JMenuItem configInfoMenuItem = new JMenuItem();\r
+\r
+ /** The file chooser */\r
+ private JFileChooser fileChooser = new JFileChooser();\r
+\r
+ /** The batch file chooser */\r
+ private JFileChooser batchFileChooser = new JFileChooser();\r
+ \r
+ /**\r
+ * Initializes a newly created <code>TopMenu</code> of the main frame <code>MainFrame</code>.\r
+ * Creates all items of the menu.\r
+ * \r
+ * @param frame\r
+ * the main application frame.\r
+ */\r
+ public TopMenu(MainFrame frame) {\r
+ this.frame = frame;\r
+\r
+ /* ---------------------- file ---------------------------- */\r
+ setMenuItem(fileMenu, "menu.file");\r
+\r
+ // new\r
+ submenuNewFile.setToolTipText(ResourceController.getMessage("menu_item.new.tooltip"));\r
+ setMenuItem(submenuNewFile, "menu_item.new");\r
+ fileMenu.add(submenuNewFile);\r
+\r
+ // new file - empty stylesheet\r
+ setMenuItem(newFileMenuEmptyItem, "menu_item.new_empty");\r
+ newFileMenuEmptyItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.new_empty.tooltip"));\r
+ newFileMenuEmptyItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ newFileEmptyMenuItemActionPerformed();\r
+ }\r
+ });\r
+ submenuNewFile.add(newFileMenuEmptyItem);\r
+\r
+ // new file - default stylesheet\r
+ setMenuItem(newFileMenuDefaultItem, "menu_item.new_default");\r
+ newFileMenuDefaultItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.new_default.tooltip"));\r
+ newFileMenuDefaultItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ newFileDefaultMenuItemActionPerformed();\r
+ }\r
+ });\r
+ submenuNewFile.add(newFileMenuDefaultItem);\r
+\r
+ // new file - user stylesheet\r
+ setMenuItem(newFileMenuStylesheetItem, "menu_item.new_stylesheet");\r
+ newFileMenuStylesheetItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.new_stylesheet.tooltip"));\r
+ newFileMenuStylesheetItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ newFileStylesheetMenuItemActionPerformed();\r
+ }\r
+ });\r
+ submenuNewFile.add(newFileMenuStylesheetItem);\r
+\r
+ // open\r
+ setMenuItem(openFileMenuItem, "menu_item.open");\r
+ openFileMenuItem.setToolTipText(ResourceController.getMessage("menu_item.open.tooltip"));\r
+ openFileMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ openFileMenuItemActionPerformed();\r
+ }\r
+ });\r
+ fileMenu.add(openFileMenuItem);\r
+\r
+ fileMenu.addSeparator();\r
+\r
+ // close\r
+ setMenuItem(closeFileMenuItem, "menu_item.close");\r
+ closeFileMenuItem.setToolTipText(ResourceController.getMessage("menu_item.close.tooltip"));\r
+ closeFileMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ newFileEmptyMenuItemActionPerformed();\r
+ }\r
+ });\r
+ fileMenu.add(closeFileMenuItem);\r
+\r
+ fileMenu.addSeparator();\r
+\r
+ // save\r
+ setMenuItem(saveFileMenuItem, "menu_item.save");\r
+ saveFileMenuItem.setToolTipText(ResourceController.getMessage("menu_item.save.tooltip"));\r
+ saveFileMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ saveFileMenuItemActionPerformed();\r
+ }\r
+ });\r
+ saveFileMenuItem.setAccelerator(KeyStroke\r
+ .getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));\r
+ fileMenu.add(saveFileMenuItem);\r
+\r
+ // save as\r
+ setMenuItem(saveAsFileMenuItem, "menu_item.save_as");\r
+ saveAsFileMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.save_as.tooltip"));\r
+ saveAsFileMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ saveAsFileMenuItemActionPerformed();\r
+ }\r
+ });\r
+ fileMenu.add(saveAsFileMenuItem);\r
+\r
+ fileMenu.addSeparator();\r
+\r
+ // exit\r
+ setMenuItem(exitFileMenuItem, "menu_item.exit");\r
+ exitFileMenuItem.setToolTipText(ResourceController.getMessage("menu_item.exit.tooltip"));\r
+ exitFileMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(java.awt.event.ActionEvent evt) {\r
+ exitFileMenuItemActionPerformed();\r
+ }\r
+ });\r
+ fileMenu.add(exitFileMenuItem);\r
+\r
+ this.add(fileMenu);\r
+\r
+ /* ---------------------- run ---------------------------- */\r
+ setMenuItem(runMenu, "menu_item.run");\r
+\r
+ setMenuItem(runBatchMenuItem, "menu_item.run_batch");\r
+ runBatchMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.run_batch.tooltip"));\r
+ runBatchMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ runBatchMenuItemActionPerformed();\r
+ }\r
+ });\r
+ runBatchMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0));\r
+ runMenu.add(runBatchMenuItem);\r
+\r
+ setMenuItem(selectBatchMenuItem, "menu_item.run_edit_batch");\r
+ selectBatchMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.run_edit_batch.tooltip"));\r
+ selectBatchMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ selectBatchMenuItemActionPerformed();\r
+ }\r
+ });\r
+ runMenu.add(selectBatchMenuItem);\r
+\r
+ setMenuItem(batchSaveBeforeMenuItem, "menu_item.run_batch_save");\r
+ batchSaveBeforeMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.run_batch_save.tooltip"));\r
+ batchSaveBeforeMenuItem.setSelected(OptionItems.SAVE_BEFORE_RUN);\r
+ batchSaveBeforeMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ batchSaveBeforeMenuItemActionPerformed();\r
+ }\r
+ });\r
+ runMenu.add(batchSaveBeforeMenuItem);\r
+\r
+ this.add(runMenu);\r
+\r
+ /* ---------------------- options ---------------------------- */\r
+ setMenuItem(optionMenu, "menu_item.option");\r
+\r
+ setMenuItem(optionStylesheetMenuItem, "menu_item.option_save");\r
+ optionStylesheetMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.option_save.tooltip"));\r
+ optionStylesheetMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ optionStylesheetMenuItemActionPerformed();\r
+ }\r
+ });\r
+ optionMenu.add(optionStylesheetMenuItem);\r
+\r
+ setMenuItem(optionEditorMenuItem, "menu_item.option_editor");\r
+ optionEditorMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.option_editor.tooltip"));\r
+ optionEditorMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ optionEditorMenuItemActionPerformed();\r
+ }\r
+ });\r
+ optionMenu.add(optionEditorMenuItem);\r
+\r
+ this.add(optionMenu);\r
+\r
+ /* ---------------------- help ---------------------------- */\r
+ setMenuItem(helpMenu, "menu_item.help");\r
+\r
+ setMenuItem(helpWindowMenuItem, "menu_item.help_window");\r
+ helpWindowMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.help_window.tooltip"));\r
+ helpWindowMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent e) {\r
+ helpWindowMenuItemActionPerformed();\r
+ }\r
+ });\r
+ helpMenu.add(helpWindowMenuItem);\r
+\r
+ setMenuItem(configInfoMenuItem, "menu_item.config");\r
+ configInfoMenuItem\r
+ .setToolTipText(ResourceController.getMessage("menu_item.config.tooltip"));\r
+ configInfoMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent e) {\r
+ configInfoMenuItemActionPerformed();\r
+ }\r
+ });\r
+ helpMenu.add(configInfoMenuItem);\r
+\r
+ setMenuItem(aboutHelpMenuItem, "menu_item.about");\r
+ aboutHelpMenuItem.setToolTipText(ResourceController.getMessage("menu_item.about.tooltip"));\r
+ aboutHelpMenuItem.addActionListener(new ActionListener() {\r
+ public void actionPerformed(ActionEvent e) {\r
+ aboutHelpMenuItemActionPerformed();\r
+ }\r
+ });\r
+ helpMenu.add(aboutHelpMenuItem);\r
+\r
+ this.add(helpMenu);\r
+ }\r
+\r
+ /**\r
+ * Stores application options and terminates the application.\r
+ */\r
+ private void exitFileMenuItemActionPerformed() {\r
+ MenuController.exitItem();\r
+ frame.shutDown();\r
+ }\r
+\r
+ /**\r
+ * Shows the dialog with information about the application.\r
+ */\r
+ private void aboutHelpMenuItemActionPerformed() {\r
+ AboutForm.showDialog();\r
+ }\r
+\r
+ /**\r
+ * Shows the dialog asking if the actually opened stylesheet should be saved. If the user choses\r
+ * to save the stylesheet then the method <code>saveFileMenuItemActionPerformed()</code> is\r
+ * called and the stylesheet is saved.\r
+ * \r
+ * @return if the actual stylesheet was saved.\r
+ */\r
+ private boolean saveOpenedStylesheet() {\r
+ if (frame.getOpenFile().getOpenFilePath() == null && frame.getOpenFile().isFileChanged()) {\r
+ SaveFileDialog questionDial = SaveFileDialog.showDialog(frame);\r
+ if (questionDial.getAnswer() == null)\r
+ return false;\r
+ if (questionDial.getAnswer())\r
+ return saveFileMenuItemActionPerformed();\r
+ }\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * Saves the actully opened stylesheet (if it is required). Then creates a new empty stylesheet.\r
+ */\r
+ private void newFileEmptyMenuItemActionPerformed() {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ if (saveOpenedStylesheet())\r
+ MenuController.newFileEmptyItem(frame.getConfigData(), frame.getOpenFile());\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Saves the actully opened stylesheet (if it is required). Then creates a new stylesheet\r
+ * according to the default stylesheet template.\r
+ */\r
+ private void newFileDefaultMenuItemActionPerformed() {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ if (saveOpenedStylesheet())\r
+ MenuController.newFileDefaultItem(frame.getConfigData(), frame.getOpenFile());\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Saves the actully opened stylesheet (if it is required). Then shows the open file dialog and\r
+ * user is asked to choose a user stylesheet template. Afterwards creates a new stylesheet\r
+ * according to the chosen user template.\r
+ */\r
+ private void newFileStylesheetMenuItemActionPerformed() {\r
+ if (saveOpenedStylesheet()) {\r
+ fileChooser.setFileFilter(new XmlFilter());\r
+ fileChooser.setSelectedFile(null);\r
+ fileChooser.setCurrentDirectory(new File(System.getProperty("user.dir")\r
+ + File.separator + TemplateConst.CONF_FILE_TEMPLATE_DIR));\r
+ int returnVal = fileChooser.showOpenDialog(frame);\r
+ if (returnVal == JFileChooser.APPROVE_OPTION) {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ MenuController.newFileStylesheetItem(frame.getConfigData(), frame\r
+ .getOpenFile(), fileChooser.getSelectedFile().getPath().toString());\r
+ }\r
+ });\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Saves the actully opened stylesheet (if it is required). Afterwards shows the open file\r
+ * dialog and user is asked to choose the stylesheet file to open. Then opens the choosen\r
+ * stylesheet file.\r
+ */\r
+ private void openFileMenuItemActionPerformed() {\r
+ if (saveOpenedStylesheet()) {\r
+ fileChooser.setFileFilter(new XslFilter());\r
+ fileChooser.setSelectedFile(null);\r
+ int returnVal = fileChooser.showOpenDialog(frame);\r
+ if (returnVal == JFileChooser.APPROVE_OPTION) {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ MenuController.openFileItem(frame.getConfigData(), fileChooser\r
+ .getSelectedFile().getPath().toString(), frame.getOpenFile());\r
+ }\r
+ });\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Saves the actually opened stylesheet file. If the stylesheet has not defined its name then\r
+ * the method <code>saveAsFileMenuItemActionPerformed()</code> is called.\r
+ * \r
+ * @return true if the stylesheet was saved.\r
+ */\r
+ private boolean saveFileMenuItemActionPerformed() {\r
+ if (this.frame.getOpenFile().getOpenFilePath() == null)\r
+ return saveAsFileMenuItemActionPerformed();\r
+ else\r
+ MenuController.saveFileItem(frame.getConfigData(), frame.getOpenFile());\r
+ return true;\r
+ }\r
+\r
+ /**\r
+ * Saves the actually opened stylesheet file under the chosen name. Firstly shows the save file\r
+ * dialog and user is asked to choose a new file name or an existing file. If user chooses the\r
+ * existing file, then he must approve that he really wants to rewrite the existing file.\r
+ * Finally the stylesheet is saved under the chosen name.\r
+ * \r
+ * @return true if the stylesheet was saved.\r
+ */\r
+ private boolean saveAsFileMenuItemActionPerformed() {\r
+ fileChooser.setFileFilter(new XslFilter());\r
+ fileChooser.setSelectedFile(null);\r
+ int returnVal = fileChooser.showSaveDialog(frame);\r
+ if (returnVal == JFileChooser.APPROVE_OPTION) {\r
+ if (fileChooser.getSelectedFile().exists()) {\r
+ OverwriteFileDialog questionDial = OverwriteFileDialog.showDialog(frame);\r
+ if (!questionDial.getAnswer())\r
+ return false;\r
+ }\r
+ MenuController.saveAsFileItem(frame.getConfigData(), fileChooser.getSelectedFile()\r
+ .getPath().toString(), frame.getOpenFile());\r
+ return true;\r
+\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * Shows the dialog with stylesheet options.\r
+ */\r
+ private void optionStylesheetMenuItemActionPerformed() {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ OptionStylesheetDialog.showDialog();\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Shows the dialog with editor options.\r
+ */\r
+ private void optionEditorMenuItemActionPerformed() {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ OptionEditorDialog.showDialog();\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Shows the dialog with information about configuration files.\r
+ */\r
+ private void configInfoMenuItemActionPerformed() {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ ConfigInfoForm.showDialog();\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Launches the batch file for the actually opened XSL stylesheet.\r
+ */\r
+ private void runBatchMenuItemActionPerformed() {\r
+ if (OptionItems.SAVE_BEFORE_RUN) {\r
+ if (!saveFileMenuItemActionPerformed())\r
+ return;\r
+ } else {\r
+ if (!saveOpenedStylesheet())\r
+ return;\r
+ }\r
+ MenuController.runBatchFile(frame.getOpenFile());\r
+ }\r
+\r
+ /**\r
+ * Shows the open file dialog and user is asked to choose a batch file. Then the chosen path to\r
+ * the batch file is stored.\r
+ */\r
+ private void selectBatchMenuItemActionPerformed() {\r
+ batchFileChooser.setFileFilter(null);\r
+ batchFileChooser.setSelectedFile(null);\r
+ if (OptionItems.BATCH_FILE.compareTo("") != 0)\r
+ batchFileChooser.setSelectedFile(new File(OptionItems.BATCH_FILE));\r
+ int returnVal = batchFileChooser.showOpenDialog(frame);\r
+ if (returnVal == JFileChooser.APPROVE_OPTION) {\r
+ OptionItems.BATCH_FILE = batchFileChooser.getSelectedFile().getAbsolutePath();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Changes if the actually opened XSL stylesheet should be automatically saved before launching\r
+ * of the batch file. If the item is selected, then the XSL stylesheet is automatically saved.\r
+ */\r
+ private void batchSaveBeforeMenuItemActionPerformed() {\r
+ OptionItems.SAVE_BEFORE_RUN = batchSaveBeforeMenuItem.isSelected();\r
+ }\r
+\r
+ /**\r
+ * Shows the dialog with help content.\r
+ * \r
+ */\r
+ private void helpWindowMenuItemActionPerformed() {\r
+ HelpFrame.getInstance().createHelp();\r
+ }\r
+\r
+ /**\r
+ * Changes the text titles of all menu items according to the actual application language.\r
+ */\r
+ public static void changeLanguage() {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ setMenuItem(fileMenu, "menu.file");\r
+\r
+ //new\r
+ setMenuItem(submenuNewFile, "menu_item.new");\r
+ submenuNewFile.setToolTipText(ResourceController.getMessage("menu_item.new.tooltip"));\r
+ \r
+ setMenuItem(newFileMenuEmptyItem, "menu_item.new_empty");\r
+ newFileMenuEmptyItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.new_empty.tooltip"));\r
+ \r
+ setMenuItem(newFileMenuDefaultItem, "menu_item.new_default");\r
+ newFileMenuDefaultItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.new_default.tooltip"));\r
+\r
+ setMenuItem(newFileMenuStylesheetItem, "menu_item.new_stylesheet");\r
+ newFileMenuStylesheetItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.new_stylesheet.tooltip"));\r
+ \r
+ //open\r
+ setMenuItem(openFileMenuItem, "menu_item.open");\r
+ openFileMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.open.tooltip"));\r
+ //close\r
+ setMenuItem(closeFileMenuItem, "menu_item.close");\r
+ closeFileMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.close.tooltip"));\r
+ \r
+ //save\r
+ setMenuItem(saveAsFileMenuItem, "menu_item.save_as");\r
+ saveAsFileMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.save_as.tooltip"));\r
+\r
+ setMenuItem(saveFileMenuItem, "menu_item.save");\r
+ saveFileMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.save.tooltip"));\r
+\r
+ //exit\r
+ setMenuItem(exitFileMenuItem, "menu_item.exit");\r
+ exitFileMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.exit.tooltip"));\r
+\r
+ //run\r
+ setMenuItem(runMenu, "menu_item.run");\r
+\r
+ setMenuItem(runBatchMenuItem, "menu_item.run_batch");\r
+ runBatchMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.run_batch.tooltip"));\r
+\r
+ setMenuItem(selectBatchMenuItem, "menu_item.run_edit_batch");\r
+ selectBatchMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.run_edit_batch.tooltip"));\r
+\r
+ setMenuItem(batchSaveBeforeMenuItem, "menu_item.run_batch_save");\r
+ batchSaveBeforeMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.run_batch_save.tooltip"));\r
+\r
+ //options\r
+ setMenuItem(optionMenu, "menu_item.option");\r
+\r
+ setMenuItem(optionStylesheetMenuItem, "menu_item.option_save");\r
+ optionStylesheetMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.option_save.tooltip"));\r
+\r
+ setMenuItem(optionEditorMenuItem, "menu_item.option_editor");\r
+ optionEditorMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.option_editor.tooltip"));\r
+\r
+ //help\r
+ setMenuItem(helpMenu, "menu_item.help");\r
+\r
+ setMenuItem(helpWindowMenuItem, "menu_item.help_window");\r
+ helpWindowMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.help_window.tooltip"));\r
+\r
+ setMenuItem(configInfoMenuItem, "menu_item.config");\r
+ configInfoMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.config.tooltip"));\r
+ setMenuItem(aboutHelpMenuItem, "menu_item.about");\r
+ aboutHelpMenuItem.setToolTipText(ResourceController\r
+ .getMessage("menu_item.about.tooltip"));\r
+ }\r
+ });\r
+ }\r
+\r
+ /**\r
+ * Sets the name of the menu item. Assignes the item title from the resource bundle\r
+ * <code>ResourceController</code> according to the resource key.\r
+ * \r
+ * @param item\r
+ * the item of the menu.\r
+ * @param key\r
+ * the resource key specifying the item title.\r
+ */\r
+ private static void setMenuItem(JMenuItem item, String key) {\r
+ String message = ResourceController.getMessage(key);\r
+ int pos = message.indexOf("&");\r
+ if ((pos >= 0) && ((pos + 1) < message.length())) {\r
+ item.setMnemonic(message.charAt(pos + 1));\r
+ message = message.replaceAll("&", "");\r
+ }\r
+ item.setText(message);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.event.ItemEvent;\r
+import java.awt.event.ItemListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JCheckBox;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+import cz.zcu.fav.kiv.editor.utils.TagParser;\r
+\r
+/**\r
+ * The <code>CheckBox</code> class is the component <em>check-box</em> used for displaying\r
+ * parameter with boolean values - false (no) and true (yes).\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class CheckBox extends JCheckBox implements Observer, ItemListener {\r
+\r
+ private static final long serialVersionUID = -6605204557074361719L;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /**\r
+ * Initializes a newly created <code>CheckBox</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public CheckBox(Type type) {\r
+ setSelected(type.getValue());\r
+\r
+ this.type = type;\r
+ type.addObserver(this);\r
+ this.addItemListener(this);\r
+ }\r
+\r
+ /**\r
+ * Selects or deselects the check-box according to the input value. If the input value is not\r
+ * valid boolean value, the check-box keeps its previous value.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ if (!setSelected(value.toString())) {\r
+ type.changeValue(TagParser.convertBoolean(this.isSelected()));\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "error.component.update_value", type.getOwnerName(), value));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Action performed when the check-box is selected or deselected. Assignes a new estate to the\r
+ * parameter <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void itemStateChanged(ItemEvent event) {\r
+ type.changeValue(TagParser.convertBoolean(this.isSelected()));\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+\r
+ /**\r
+ * Selects or deselects the check-box according to the input value.\r
+ * \r
+ * @param newValue\r
+ * the new boolean input value.\r
+ * @return true if the input value is valid boolean value.\r
+ */\r
+ private boolean setSelected(String newValue) {\r
+ Boolean value = TagParser.parseBoolean(newValue);\r
+ if (value != null) {\r
+ this.setSelected(value);\r
+ return true;\r
+ } else\r
+ return false;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+import java.awt.Graphics;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.awt.event.ItemEvent;\r
+import java.awt.event.ItemListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.JButton;\r
+import javax.swing.JColorChooser;\r
+import javax.swing.JComboBox;\r
+import javax.swing.JDialog;\r
+import javax.swing.JPanel;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+import cz.zcu.fav.kiv.editor.utils.TagParser;\r
+\r
+/**\r
+ * The <code>ColorChooser</code> class is the component used for choosing colors from the list of\r
+ * colors or from the color palette.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ColorChooser extends JPanel implements ActionListener, ItemListener, Observer {\r
+\r
+ private static final long serialVersionUID = -2515399651281284846L;\r
+\r
+ /** The width of the rectangle displaying the actually chosen color */\r
+ public static final int COLOR_RECT_WIDTH = 25;\r
+\r
+ /** The height of the rectangle displaying the actually chosen color */\r
+ public static final int COLOR_RECT_HEIGHT = 23;\r
+\r
+ /** The size of the button displaying the dialog with color palette */\r
+ public static final int BUTTON_SIZE = 20;\r
+\r
+ /** The width of the empty gap components */\r
+ private static final int EMPTY_GAP_WIDTH = 10;\r
+\r
+ /** The height of the empty gap components */\r
+ private static final int EMPTY_GAP_HEIGHT = 0;\r
+\r
+ /** The list of predefined colors */\r
+ private JComboBox colorBox;\r
+\r
+ /** The button displaying the dialog with color palette */\r
+ private JButton colorButton;\r
+\r
+ /** The color palette enabling choosing of colors */\r
+ private JColorChooser colorChooser;\r
+\r
+ /** The rectangle displaying the actually chosen color */\r
+ private ColorRect colorRect;\r
+\r
+ /** The dialog displaying the color palette */\r
+ private JDialog dialog;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /** The actually choosen color */\r
+ private Color color;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ColorChooser</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public ColorChooser(Type type) {\r
+ this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));\r
+ this.type = type;\r
+ type.addObserver(this);\r
+\r
+ // color combo-box\r
+ colorBox = new JComboBox(type.getValueList().keySet().toArray());\r
+ this.color = getColor(type.getValue());\r
+ setSelectedColor(type.getValue());\r
+ colorBox.setEditable(true);\r
+ colorBox.addItemListener(this);\r
+ this.add(colorBox);\r
+\r
+ this.add(Box.createRigidArea(new Dimension(EMPTY_GAP_WIDTH, EMPTY_GAP_HEIGHT)));\r
+\r
+ // button displaying the color palette\r
+ colorButton = new JButton(EditorIcon.createColorIcon());\r
+ colorButton.setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));\r
+ colorButton.addActionListener(this);\r
+ this.add(colorButton);\r
+\r
+ this.add(Box.createRigidArea(new Dimension(EMPTY_GAP_WIDTH, EMPTY_GAP_HEIGHT)));\r
+\r
+ // color rectangle\r
+ colorRect = new ColorRect();\r
+ this.add(colorRect);\r
+ }\r
+\r
+ /**\r
+ * Sets a new color according to the input value. If the input value is not valid color value,\r
+ * then the previous color is kept.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ Color newColor = getColor(value.toString());\r
+ if (newColor != null) {\r
+ setSelectedColor(value);\r
+ this.color = newColor;\r
+ } else {\r
+ type.changeValue(TagParser.createColor(color));\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "error.component.update_value", type.getOwnerName(), value));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Action performed when the button is pressed, it displays the dialog with color palette.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ colorChooser = new JColorChooser(color);\r
+ colorChooser.setPreviewPanel(new JPanel());\r
+\r
+ dialog = JColorChooser.createDialog(this, ResourceController\r
+ .getMessage("component.color_editor.title"), true, colorChooser, new ActionColor(),\r
+ null);\r
+ dialog.setVisible(true);\r
+ }\r
+\r
+ /**\r
+ * Action performed when a color from the combo-box list has been selected or a new one is\r
+ * inserted. Assignes a new value to the parameter <em>type</em>. If the inserted color is\r
+ * invalid, then the previous color is kept.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void itemStateChanged(ItemEvent event) {\r
+ if ((event.getStateChange() & ItemEvent.ITEM_STATE_CHANGED) != 0) {\r
+ Color col = getColor(colorBox.getSelectedItem().toString());\r
+ if (col != null) {\r
+ type.changeValue((String) colorBox.getSelectedItem());\r
+ this.color = col;\r
+ colorRect.repaint();\r
+ MainFrame.getInstance().setFileChanged();\r
+ } else {\r
+ setSelectedColor(type.getValue());\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Selects the input color in the list if the list contains it or adds the new color to the\r
+ * list.\r
+ * \r
+ * @param newColor\r
+ * the actually selected color.\r
+ */\r
+ private void setSelectedColor(Object newColor) {\r
+ for (int i = 0; i < colorBox.getItemCount(); i++) {\r
+ if (colorBox.getItemAt(i).equals(type.getKeyFromValue(newColor.toString()))\r
+ || colorBox.getItemAt(i).equals(newColor.toString())) {\r
+ colorBox.setSelectedIndex(i);\r
+ return;\r
+ }\r
+ }\r
+ if (colorBox.getItemCount() > type.getValueList().size())\r
+ colorBox.removeItemAt(0);\r
+ colorBox.insertItemAt(newColor, 0);\r
+ colorBox.setSelectedIndex(0);\r
+ }\r
+\r
+ /**\r
+ * The <em>ActionColor</em> inner class represents the action performed when a color is\r
+ * choosen in the color palette.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ class ActionColor implements ActionListener {\r
+ public void actionPerformed(ActionEvent event) {\r
+ color = colorChooser.getColor();\r
+\r
+ String colStr = TagParser.createColor(color);\r
+ dialog.dispose();\r
+ type.changeValue(colStr);\r
+ setSelectedColor(colStr);\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Creates <em>Color</em> from the string containing a color in the hexadecimal format #rrggbb\r
+ * or containing a color name.\r
+ * \r
+ * @param color\r
+ * the string containing a color in the hexadecimal format #rrggbb or containing a\r
+ * color name.\r
+ * @return the color parsed from the string.\r
+ */\r
+ private Color getColor(String color) {\r
+ if (type.getValueList().get(color) != null)\r
+ return TagParser.parseColor(type.getValueList().get(color));\r
+ else\r
+ return TagParser.parseColor(color);\r
+ }\r
+\r
+ /**\r
+ * The <code>ColorRect</code> inner class represents the rectangle displaying actually choosen\r
+ * color.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ class ColorRect extends JPanel {\r
+\r
+ private static final long serialVersionUID = 5631478801104148565L;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ColorRect</code>class.\r
+ */\r
+ public ColorRect() {\r
+ this.setPreferredSize(new Dimension(COLOR_RECT_WIDTH, COLOR_RECT_HEIGHT));\r
+ }\r
+\r
+ /**\r
+ * Changes the color of the rectangle according to the actually chosen color.\r
+ */\r
+ public void paintComponent(Graphics graphics) {\r
+ super.paintComponent(graphics);\r
+ graphics.setColor(color);\r
+ graphics.fillRect(0, 0, COLOR_RECT_WIDTH, COLOR_RECT_HEIGHT);\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JComboBox;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>ComboBox</code> class is the component <em>combo-box</em> used for displaying a\r
+ * list of predefined values of a parameter.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ComboBox extends JComboBox implements Observer, ActionListener {\r
+\r
+ private static final long serialVersionUID = -151909741397111994L;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ComboBox</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public ComboBox(Type type) {\r
+ super(type.getValueList().values().toArray());\r
+\r
+ this.setSelectedItem(type.getValueList().get(type.getValue()));\r
+\r
+ this.type = type;\r
+ type.addObserver(this);\r
+ this.addActionListener(this);\r
+ }\r
+\r
+ /**\r
+ * Selects the input value in the list if the list contains it. If the input value is not in the\r
+ * list then the previously selected item is left as selected.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ String newValue = type.getValueList().get(value.toString());\r
+ if (newValue != null)\r
+ this.setSelectedItem(newValue);\r
+ else {\r
+ type.changeValue((String) type.getValueList().get(this.getSelectedItem()));\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "error.component.update_value", type.getOwnerName(), value));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Action performed when an item of the combo-box list has been selected. Assignes a new value\r
+ * to the parameter <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the action event.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ type.changeValue((String) type.getKeyFromValue(this.getSelectedItem().toString()));\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.event.ItemEvent;\r
+import java.awt.event.ItemListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JComboBox;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>ComboBoxEdit</code> class is the component <em>combo-box</em> used for displaying a\r
+ * list of predefined values of a parameter. It enables to insert a new value to the list.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ComboBoxEdit extends JComboBox implements Observer, ItemListener {\r
+\r
+ private static final long serialVersionUID = -5008301149696067333L;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ComboBoxEdit</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public ComboBoxEdit(Type type) {\r
+ super(type.getValueList().values().toArray());\r
+\r
+ this.type = type;\r
+ // selected value\r
+ setSelectedIndex(type.getValue());\r
+\r
+ type.addObserver(this);\r
+ this.setEditable(true);\r
+ this.addItemListener(this);\r
+ }\r
+\r
+ /**\r
+ * Selects the input parameter value in the list if the list contains it. If the input value is\r
+ * not in the list then inserts it to the list.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ setSelectedIndex(value);\r
+ }\r
+\r
+ /**\r
+ * Action performed when an item in the combo-box list has been selected or a new one has been\r
+ * inserted. Assignes a new value to the parameter <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void itemStateChanged(ItemEvent event) {\r
+ if ((event.getStateChange() & ItemEvent.ITEM_STATE_CHANGED) != 0) {\r
+ String newValue = type.getDefaultValue().getKeyFromValue(this.getSelectedItem().toString());\r
+ if (newValue != null)\r
+ type.changeValue(newValue);\r
+ else\r
+ type.changeValue(this.getSelectedItem().toString());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Selects the input value in the list if the list contains it. If the input value is not in the\r
+ * list then inserts it to the list.\r
+ * \r
+ * @param obj\r
+ * the input parameter value.\r
+ */\r
+ private void setSelectedIndex(Object obj) {\r
+ for (int i = 0; i < this.getItemCount(); i++) {\r
+ if (this.getItemAt(i).equals(type.getValueList().get(obj))) {\r
+ this.setSelectedIndex(i);\r
+ return;\r
+ }\r
+ }\r
+ this.addItem(obj);\r
+ this.setSelectedIndex(this.getItemCount() - 1);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JComboBox;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Unit;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>ComboBoxUnit</code> class is the component <em>combo-box</em> used for displaying a\r
+ * list of predefined units of a parameter.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ComboBoxUnit extends JComboBox implements Observer, ActionListener {\r
+\r
+ private static final long serialVersionUID = -5900614666148972102L;\r
+\r
+ /** The parameter unit which values the component displays */\r
+ private Unit unit;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ComboBoxUnit</code> with the parameter unit.\r
+ * \r
+ * @param unit\r
+ * the parameter unit.\r
+ */\r
+ public ComboBoxUnit(Unit unit) {\r
+ super(unit.getValueList().toArray());\r
+ int selected = unit.getValueList().indexOf(unit.getValue());\r
+ if (selected >= 0)\r
+ this.setSelectedIndex(selected);\r
+ this.unit = unit;\r
+ unit.addObserver(this);\r
+ this.addActionListener(this);\r
+ }\r
+\r
+ /**\r
+ * Selects the input value in the list.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ int selected = unit.getValueList().indexOf(value.toString());\r
+ if (selected >= 0)\r
+ this.setSelectedIndex(selected);\r
+ }\r
+\r
+ /**\r
+ * Action performed when an item in the combo-box list has been selected. Assignes a new value\r
+ * to the parameter <em>unit</em>.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ unit.changeValue((String) this.getSelectedItem());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.io.File;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.JButton;\r
+import javax.swing.JFileChooser;\r
+import javax.swing.JPanel;\r
+import javax.swing.JTextField;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>FileChooser</code> class is the component <em>text-field</em> and <em>button</em>\r
+ * used for choosing a directory path with the <em>file-chooser</em>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class FileChooser extends JPanel implements Observer, ActionListener {\r
+\r
+ private static final long serialVersionUID = -151909741397111994L;\r
+\r
+ /** The width of the text-field */\r
+ private static final int WIDTH = 180;\r
+\r
+ /** The width of the empty gap between the text-field and the button */\r
+ private static final int EMPTY_GAP_WIDTH = 10;\r
+ \r
+ /** The height of the empty gap between the text-field and the button */\r
+ private static final int EMPTY_GAP_HEIGHT = 0;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /** The text-field displaying directory path */\r
+ private JTextField textField;\r
+\r
+ /** The file-chooser used for choosing a directory path */\r
+ JFileChooser fileChooser = new JFileChooser();\r
+\r
+ /**\r
+ * Initializes a newly created <code>FileChooser</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public FileChooser(Type type) {\r
+ this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));\r
+\r
+ // text-field\r
+ textField = new JTextField(type.getValue());\r
+ textField.setPreferredSize(new Dimension(WIDTH, textField.getPreferredSize().height));\r
+ this.add(textField);\r
+\r
+ this.add(Box.createRigidArea(new Dimension(EMPTY_GAP_WIDTH, EMPTY_GAP_HEIGHT)));\r
+\r
+ // chooser button\r
+ JButton chooseButton = new JButton(ResourceController\r
+ .getMessage("option_editor.xml_definition_path.button"));\r
+ chooseButton.addActionListener(this);\r
+ this.add(chooseButton);\r
+\r
+ this.type = type;\r
+ type.addObserver(this);\r
+ }\r
+\r
+ /**\r
+ * Sets a new parameter value to the text-field.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ textField.setText(value.toString());\r
+ }\r
+\r
+ /**\r
+ * Action performed when the button is pressed, it displays the file-chooser enabling to choose\r
+ * a direcotory path. Assignes a new value to the parameter <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ File directory = new File(textField.getText());\r
+ if (directory.exists())\r
+ fileChooser.setCurrentDirectory(directory);\r
+\r
+ int returnVal = fileChooser.showOpenDialog(MainFrame.getInstance());\r
+ if (returnVal == JFileChooser.APPROVE_OPTION) {\r
+ textField.setText(fileChooser.getSelectedFile().getPath());\r
+ type.changeValue(fileChooser.getSelectedFile().getPath());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.GridLayout;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.ButtonGroup;\r
+import javax.swing.JPanel;\r
+import javax.swing.JRadioButton;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>RadioButton</code> class is the component containing a group of <em>radio-button</em>s\r
+ * used for choosing one of predefined values.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class RadioButton extends JPanel implements Observer, ActionListener {\r
+\r
+ private static final long serialVersionUID = 7530690462466562523L;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /** The list of <em>radio-button</em>s */\r
+ private JRadioButton[] radioList;\r
+\r
+ /**\r
+ * Initializes a newly created <code>RadioButton</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public RadioButton(Type type) {\r
+ this.setLayout(new GridLayout(0, 3));\r
+ this.type = type;\r
+ ButtonGroup group = new ButtonGroup();\r
+ radioList = new JRadioButton[type.getValueList().size()];\r
+\r
+ int i = 0;\r
+ for (Iterator it = type.getValueList().entrySet().iterator(); it.hasNext();) {\r
+ Map.Entry e = (Map.Entry) it.next();\r
+ radioList[i] = new JRadioButton(e.getKey().toString());\r
+ radioList[i].setName(e.getValue().toString());\r
+ radioList[i].addActionListener(this);\r
+ if (e.getValue().equals(type.getValue()))\r
+ radioList[i].setSelected(true);\r
+ group.add(radioList[i]);\r
+ this.add(radioList[i]);\r
+ i++;\r
+ }\r
+ type.addObserver(this);\r
+ }\r
+\r
+ /**\r
+ * Selects one radio-button representing the input value. If the input value is not among the\r
+ * values of radio-buttons, then the previous selection of a radio-button is kept.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ boolean selected = false;\r
+ for (int i = 0; i < radioList.length; i++) {\r
+ if (radioList[i].getName().equals(value.toString())) {\r
+ radioList[i].setSelected(true);\r
+ selected = true;\r
+ break;\r
+ }\r
+ }\r
+ if (!selected) {\r
+ for (int i = 0; i < radioList.length; i++) {\r
+ if (radioList[i].isSelected())\r
+ type.changeValue(radioList[i].getName());\r
+ }\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "error.component.update_value", type.getOwnerName(), value));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Action performed when one of radio-buttons is selected. Assignes a new value to the parameter\r
+ * <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ type.changeValue(((JRadioButton) event.getSource()).getName());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.text.DecimalFormat;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JSpinner;\r
+import javax.swing.SpinnerNumberModel;\r
+import javax.swing.event.ChangeEvent;\r
+import javax.swing.event.ChangeListener;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>SpinnerFloat</code> class is the component <em>spinner</em> used for displaying and\r
+ * changing decimal numbers.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class SpinnerFloat extends JSpinner implements Observer, ChangeListener {\r
+\r
+ private static final long serialVersionUID = 3179056596219532766L;\r
+\r
+ /** The step of the <em>spinner</em> */\r
+ private static final double STEP = 0.1;\r
+\r
+ /** The number of columns in the <em>spinner</em> */\r
+ private static final int SPINNER_SIZE = 4;\r
+\r
+ /** The number format used for converting a decimal value to the string */\r
+ private static final DecimalFormat formatDouble = new DecimalFormat("0.##");\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /**\r
+ * Creates the spinner used for displaying and changing decimal numbers.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ * @return the newly created spinner used form decimal numbers.\r
+ */\r
+ public static SpinnerFloat createSpinnerFloat(Type type) {\r
+ SpinnerNumberModel spinnerModel = new SpinnerNumberModel();\r
+ spinnerModel.setValue(convertDouble(type.getValue()));\r
+ spinnerModel.setStepSize(STEP);\r
+ return new SpinnerFloat(spinnerModel, type);\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>SpinnerFloat</code> with the parameter type and spinner\r
+ * model.\r
+ * \r
+ * @param spinnerModel\r
+ * the spinner model.\r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ private SpinnerFloat(SpinnerNumberModel spinnerModel, Type type) {\r
+ super(spinnerModel);\r
+ this.type = type;\r
+ type.addObserver(this);\r
+ this.addChangeListener(this);\r
+ ((JSpinner.DefaultEditor) this.getEditor()).getTextField().setColumns(SPINNER_SIZE);\r
+ }\r
+\r
+ /**\r
+ * Updates the spinner number value according to the input value. If the input value is not a\r
+ * valid decimal number, then the previous spinner value is kept.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ try {\r
+ ((SpinnerNumberModel) this.getModel()).setValue(convertDouble(value.toString()));\r
+ } catch (NumberFormatException ex) {\r
+ type.changeValue(formatDouble.format(convertDouble(this.getModel().getValue()\r
+ .toString())));\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "error.component.update_value", type.getOwnerName(), value));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Action performed when the spinner value is changed. Assignes a new value to the parameter\r
+ * <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void stateChanged(ChangeEvent event) {\r
+ type.changeValue(formatDouble.format(convertDouble(this.getModel().getValue().toString())));\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+\r
+ /**\r
+ * Converts the input text containing a decimal number to a double number.\r
+ * \r
+ * @param number\r
+ * the input text containing a decimal number.\r
+ * @return converted double number.\r
+ */\r
+ private static Double convertDouble(String number) {\r
+ return Double.parseDouble(number.replace(",", "."));\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import static java.lang.Integer.parseInt;\r
+\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JSpinner;\r
+import javax.swing.SpinnerModel;\r
+import javax.swing.SpinnerNumberModel;\r
+import javax.swing.event.ChangeEvent;\r
+import javax.swing.event.ChangeListener;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>SpinnerInt</code> class is the component <em>spinner</em> used for displaying and\r
+ * changing integer numbers.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class SpinnerInt extends JSpinner implements Observer, ChangeListener {\r
+\r
+ private static final long serialVersionUID = 6920036545501669043L;\r
+\r
+ /** The number of columns in the <em>spinner</em> */\r
+ private static final int SPINNER_SIZE = 4;\r
+\r
+ /** The step of the <em>spinner</em> */\r
+ private final static int STEP = 1;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /**\r
+ * Creates the spinner used for displaying and changing integer numbers.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ * @return the newly created spinner used form integer numbers.\r
+ */\r
+ public static SpinnerInt createSpinnerInt(Type type) {\r
+ SpinnerNumberModel spinnerModel = new SpinnerNumberModel();\r
+ spinnerModel.setValue(parseInt(type.getValue()));\r
+ spinnerModel.setStepSize(STEP);\r
+ return new SpinnerInt(spinnerModel, type);\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>SpinnerInt</code> with the parameter type and spinner\r
+ * model.\r
+ * \r
+ * @param spinnerModel\r
+ * the spinner model.\r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ private SpinnerInt(SpinnerModel spinnerModel, Type type) {\r
+ super(spinnerModel);\r
+ this.type = type;\r
+ type.addObserver(this);\r
+ this.addChangeListener(this);\r
+ ((JSpinner.DefaultEditor) this.getEditor()).getTextField().setColumns(SPINNER_SIZE);\r
+ }\r
+\r
+ /**\r
+ * Updates the spinner number value according to the input value. If the input value is not a\r
+ * valid integer number, then the previous spinner value is kept.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ try {\r
+ ((SpinnerNumberModel) this.getModel()).setValue(Integer.valueOf(value.toString()));\r
+ } catch (NumberFormatException ex) {\r
+ type.changeValue(this.getModel().getValue().toString());\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "error.component.update_value", type.getOwnerName(), value));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Action performed when the spinner value is changed. Assignes a new value to the parameter\r
+ * <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the item event.\r
+ */\r
+ public void stateChanged(ChangeEvent event) {\r
+ type.changeValue(this.getModel().getValue().toString());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.event.FocusEvent;\r
+import java.awt.event.FocusListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JTextArea;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>TextArea</code> class is the component <em>text-area</em> used for displaying\r
+ * longer texts.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TextArea extends JTextArea implements Observer, FocusListener {\r
+\r
+ private static final long serialVersionUID = -2338840101614677876L;\r
+\r
+ /** The width of the <em>text-area</em> */\r
+ private static final int TEXTAREA_WIDTH = 25;\r
+\r
+ /** The height of the <em>text-area</em> */\r
+ private static final int TEXTAREA_HEIGHT = 15;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /**\r
+ * Initializes a newly created <code>TextArea</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public TextArea(Type type) {\r
+ super(TEXTAREA_HEIGHT, TEXTAREA_WIDTH);\r
+ this.setText(type.getValue());\r
+ this.addFocusListener(this);\r
+ this.type = type;\r
+ type.addObserver(this);\r
+ }\r
+\r
+ /**\r
+ * Action performed when the <em>text-area</em> losts focus. Assignes a new value to the\r
+ * parameter <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the focus event.\r
+ */\r
+ public void focusLost(FocusEvent event) {\r
+ type.changeValue(this.getText());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+\r
+ /**\r
+ * Action performed when the <em>text-area</em> gains focus - does nothing.\r
+ */\r
+ public void focusGained(FocusEvent event) {\r
+ }\r
+\r
+ /**\r
+ * Sets the content of the <em>text-area</em> according to the input text.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ this.setText(value.toString());\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components;\r
+\r
+import java.awt.event.FocusEvent;\r
+import java.awt.event.FocusListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JTextField;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>TextField</code> class is the component <em>text-field</em> used for displaying\r
+ * shorter single-line texts.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TextField extends JTextField implements Observer, FocusListener {\r
+\r
+ private static final long serialVersionUID = 4818192876380891610L;\r
+\r
+ /** The size of the <em>text-field</em> */\r
+ private static final int TEXTFIELD_SIZE = 25;\r
+\r
+ /** The parameter type which values the component displays */\r
+ private Type type;\r
+\r
+ /**\r
+ * Initializes a newly created <code>TextField</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public TextField(Type type) {\r
+ super(TEXTFIELD_SIZE);\r
+ this.setText(type.getValue());\r
+ this.addFocusListener(this);\r
+ this.type = type;\r
+ type.addObserver(this);\r
+ }\r
+\r
+ /**\r
+ * Action performed when the <em>text-field</em> losts focus. Assignes a new value to the\r
+ * parameter <em>type</em>.\r
+ * \r
+ * @param event\r
+ * the focus event.\r
+ */\r
+ public void focusLost(FocusEvent event) {\r
+ type.changeValue(this.getText());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+\r
+ /**\r
+ * Action performed when the <em>text-field</em> gains focus - does nothing.\r
+ */\r
+ public void focusGained(FocusEvent event) {\r
+ }\r
+\r
+ /**\r
+ * Sets the content of the <em>text-field</em> according to the input text.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new parameter value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ this.setText(value.toString());\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.attributes;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.JButton;\r
+import javax.swing.JPanel;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+\r
+/**\r
+ * The <code>AttributeButton</code> class represents the <em>button</em> displaying the dialog\r
+ * with attributes <code>AttributeDialog</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class AttributeButton extends JPanel implements ActionListener {\r
+\r
+ private static final long serialVersionUID = 6410143984336194601L;\r
+\r
+ /** The size of horizontal empty gap */\r
+ private static final int EMPTY_GAP_HORIZONTAL = 10;\r
+\r
+ /** The size of vertical empty gap */\r
+ private static final int EMPTY_GAP_VERTICAL = 0;\r
+\r
+ /** The property which dialog dialog displays */\r
+ private Property property;\r
+\r
+ /**\r
+ * Initializes a newly created <code>AttributeButton</code> with the property.\r
+ * \r
+ * @param property\r
+ * the property with <code>Attribute</code>s.\r
+ */\r
+ public AttributeButton(Property property) {\r
+ this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));\r
+\r
+ this.add(Box.createRigidArea(new Dimension(EMPTY_GAP_HORIZONTAL, EMPTY_GAP_VERTICAL)));\r
+\r
+ JButton button = new JButton(property.getName());\r
+ button.addActionListener(this);\r
+ this.add(button);\r
+\r
+ this.property = property;\r
+ }\r
+\r
+ /**\r
+ * Action performed when the button is pressed. It displays the dialog with attributes\r
+ * <code>AttributeDialog</code>.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ javax.swing.SwingUtilities.invokeLater(new Runnable() {\r
+ public void run() {\r
+ AttributeDialog.showDialog(property);\r
+ }\r
+ });\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.attributes;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JCheckBox;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>AttributeCheckBox</code> class is the component <em>check-box</em>, that displays\r
+ * whether the corresponding <code>Attribute</code> of the <code>Property</code> is selected or\r
+ * not.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class AttributeCheckBox extends JCheckBox implements Observer, ActionListener {\r
+\r
+ private static final long serialVersionUID = -6845824213536903733L;\r
+\r
+ /** The attribute which estate the component displays */\r
+ private Attribute attribute;\r
+\r
+ /**\r
+ * Initializes a newly created <code>AttributeCheckBox</code> with the <code>Attribute</code>.\r
+ * \r
+ * @param attribute\r
+ * the attribute of the <code>Property</code>.\r
+ */\r
+ public AttributeCheckBox(Attribute attribute) {\r
+ super();\r
+\r
+ this.attribute = attribute;\r
+ setSelected(attribute.isChosen());\r
+\r
+ attribute.addObserver(this);\r
+ this.addActionListener(this);\r
+ }\r
+\r
+ /**\r
+ * Selects or deselects the check-box according to the input value.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new <em>check-box</em> value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ this.setSelected((Boolean) value);\r
+ }\r
+\r
+ /**\r
+ * Action performed when the check-box is selected or deselected. Assignes a new estate to the\r
+ * <code>Attribute</code>.\r
+ * \r
+ * @param event\r
+ * the action event.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ attribute.changeChosen(this.isSelected());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.attributes;\r
+\r
+import java.awt.BorderLayout;\r
+import java.util.List;\r
+\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.SpringLayout;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.SpringUtilities;\r
+\r
+/**\r
+ * The <code>AttributeComponent</code> class is the panel containing the <em>Attribute</em>s\r
+ * belonging to one <code>AttributeGroup</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class AttributeComponent extends JPanel {\r
+\r
+ private static final long serialVersionUID = -1735079147977227649L;\r
+\r
+ /** The number of one component items in the panel */\r
+ private static final int ITEMS = 3;\r
+\r
+ /** The size of component margin */\r
+ private static final int MARGIN = 3;\r
+\r
+ /**\r
+ * Initializes a newly created <code>AttributeComponent</code> with the list of attributes.\r
+ * \r
+ * @param attributeList\r
+ * the list of attributes.\r
+ */\r
+ public AttributeComponent(List<Attribute> attributeList) {\r
+ this.setLayout(new BorderLayout());\r
+\r
+ // parameters panel\r
+ JPanel paramPane = new JPanel();\r
+ paramPane.setLayout(new SpringLayout());\r
+\r
+ for (Attribute attr : attributeList) {\r
+ // checkbox\r
+ paramPane.add(new AttributeCheckBox(attr));\r
+\r
+ // attribute name\r
+ paramPane.add(new JLabel(attr.getName()));\r
+\r
+ // attribute types\r
+ paramPane.add(new AttributeTypeForm(attr));\r
+ }\r
+\r
+ SpringUtilities.makeCompactGrid(paramPane, attributeList.size(), ITEMS, MARGIN, MARGIN,\r
+ MARGIN, MARGIN);\r
+\r
+ this.add(paramPane, BorderLayout.LINE_START);\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.attributes;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Container;\r
+import java.awt.Dimension;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+\r
+import javax.swing.ImageIcon;\r
+import javax.swing.JButton;\r
+import javax.swing.JDialog;\r
+import javax.swing.JPanel;\r
+import javax.swing.JTabbedPane;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.properties.AttributeGroup;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+\r
+/**\r
+ * The <code>AttributeDialog</code> class is the dialog with <code>Attribute</code>s of one\r
+ * <code>Property</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class AttributeDialog extends JDialog implements ActionListener {\r
+\r
+ private static final long serialVersionUID = -6526357047305363516L;\r
+\r
+ /** The dialog representing the <code>Property</code> */\r
+ private static AttributeDialog dialog;\r
+\r
+ /** The property which <code>Attribute</code>s the dialog displays */\r
+ private static Property property;\r
+\r
+ /** The save command */\r
+ private static final String SAVE_COMMAND = "save";\r
+\r
+ /** The size of margin */\r
+ private static final int MARGIN = 10;\r
+\r
+ /**\r
+ * Displays the dialog with property attributes.\r
+ * \r
+ * @param prop\r
+ * the property with attributes.\r
+ */\r
+ public static void showDialog(Property prop) {\r
+ property = prop;\r
+ dialog = new AttributeDialog();\r
+ dialog.setVisible(true);\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>AttributeDialog</code>.\r
+ */\r
+ private AttributeDialog() {\r
+ super(MainFrame.getInstance(), ResourceController.getMessage("frame.attribute.title")\r
+ + property.getName(), true);\r
+\r
+ Container pan = new JPanel(new BorderLayout());\r
+\r
+ ImageIcon icon = EditorIcon.createTabIcon();\r
+\r
+ JTabbedPane tabPanel = new JTabbedPane(JTabbedPane.TOP);\r
+ for (AttributeGroup panel : property.getAttributeGroupList()) {\r
+ tabPanel.addTab(panel.getTitle(), icon,\r
+ new AttributeComponent(panel.getAttributeList()));\r
+ }\r
+ pan.add(tabPanel, BorderLayout.CENTER);\r
+\r
+ // Create and initialize the buttons.\r
+ JButton cancelButton = new JButton(ResourceController.getMessage("button.cancel"));\r
+ cancelButton.addActionListener(this);\r
+\r
+ JButton setButton = new JButton(ResourceController.getMessage("button.save"));\r
+ setButton.setActionCommand(SAVE_COMMAND);\r
+ setButton.addActionListener(this);\r
+ getRootPane().setDefaultButton(setButton);\r
+\r
+ // Lay out the buttons from left to right.\r
+ JPanel buttonPane = new JPanel();\r
+ buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));\r
+ buttonPane.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN));\r
+ buttonPane.add(Box.createHorizontalGlue());\r
+ buttonPane.add(setButton);\r
+ buttonPane.add(Box.createRigidArea(new Dimension(MARGIN, MARGIN)));\r
+ buttonPane.add(cancelButton);\r
+\r
+ pan.add(buttonPane, BorderLayout.PAGE_END);\r
+\r
+ this.getContentPane().add(pan, BorderLayout.CENTER);\r
+\r
+ this.pack();\r
+ this.setLocationRelativeTo(MainFrame.getInstance());\r
+ }\r
+\r
+ /**\r
+ * Action performed when a button of the dialog is pressed. If the <em>Save</em> button is\r
+ * pressed, then the changed attribute values are saved.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ if (SAVE_COMMAND.equals(event.getActionCommand())) {\r
+ property.setValuesFromTemporary();\r
+ property.setChosen();\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+ AttributeDialog.dialog.setVisible(false);\r
+ AttributeDialog.dialog.dispose();\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.attributes;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.FlowLayout;\r
+\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.beans.properties.UnitAttr;\r
+import cz.zcu.fav.kiv.editor.graphics.components.CheckBox;\r
+import cz.zcu.fav.kiv.editor.graphics.components.ColorChooser;\r
+import cz.zcu.fav.kiv.editor.graphics.components.ComboBox;\r
+import cz.zcu.fav.kiv.editor.graphics.components.ComboBoxEdit;\r
+import cz.zcu.fav.kiv.editor.graphics.components.ComboBoxUnit;\r
+import cz.zcu.fav.kiv.editor.graphics.components.FileChooser;\r
+import cz.zcu.fav.kiv.editor.graphics.components.SpinnerFloat;\r
+import cz.zcu.fav.kiv.editor.graphics.components.SpinnerInt;\r
+import cz.zcu.fav.kiv.editor.graphics.components.TextArea;\r
+import cz.zcu.fav.kiv.editor.graphics.components.TextField;\r
+\r
+/**\r
+ * The <code>AttributeTypeForm</code> class is the panel containing the components used for\r
+ * editing <code>Attribute</code> value.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class AttributeTypeForm extends JPanel {\r
+\r
+ private static final long serialVersionUID = -2218273286123231184L;\r
+ \r
+ private static final int WIDTH = 200;\r
+\r
+ /**\r
+ * Initializes a newly created <code>AttributeTypeForm</code> with the attribute.\r
+ * \r
+ * @param attribute\r
+ * the attribute.\r
+ */\r
+ public AttributeTypeForm(Attribute attribute) {\r
+ this.setLayout(new FlowLayout(FlowLayout.LEFT));\r
+\r
+ attribute.getType().setAttr(attribute);\r
+ switch (attribute.getType().getName()) {\r
+ case BOOLEAN:\r
+ this.add(new CheckBox(attribute.getType()));\r
+ break;\r
+ case STRING:\r
+ case URI:\r
+ this.add(new TextField(attribute.getType()));\r
+ break;\r
+ case LIST:\r
+ this.add(new ComboBox(attribute.getType()));\r
+ break;\r
+ case LIST_OPEN:\r
+ case FONT:\r
+ this.add(new ComboBoxEdit(attribute.getType()));\r
+ break; \r
+ case FILENAME:\r
+ this.add(new FileChooser(attribute.getType()));\r
+ break;\r
+ case COLOR:\r
+ this.add(new ColorChooser(attribute.getType()));\r
+ break;\r
+ case LENGTH:\r
+ this.add(SpinnerFloat.createSpinnerFloat(attribute.getType()));\r
+ ((UnitAttr) attribute.getType().getUnit()).setAttribute(attribute);\r
+ this.add(new ComboBoxUnit(attribute.getType().getUnit()));\r
+ break;\r
+ case NUMBER:\r
+ case INTEGER:\r
+ this.add(SpinnerInt.createSpinnerInt(attribute.getType()));\r
+ break;\r
+ case RTF:\r
+ case TABLE:\r
+ TextArea area = new TextArea(attribute.getType());\r
+ this.add(area);\r
+ JScrollPane scrollPane = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,\r
+ JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);\r
+ this.add(scrollPane);\r
+ break; \r
+ case FLOAT:\r
+ this.add(SpinnerFloat.createSpinnerFloat(attribute.getType()));\r
+ break;\r
+ }\r
+\r
+ this.setMaximumSize(new Dimension(this.getPreferredSize().width + WIDTH,\r
+ this.getPreferredSize().height));\r
+ this.setPreferredSize(new Dimension(this.getPreferredSize().width + WIDTH,\r
+ this.getPreferredSize().height));\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.editor;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JSplitPane;
+import javax.swing.plaf.basic.BasicSplitPaneUI;
+
+import cz.zcu.fav.kiv.editor.beans.sections.Section;
+import cz.zcu.fav.kiv.editor.graphics.console.MessageConsole;
+
+/**
+ * The <code>EditorBody</code> class represents the body of the editor.
+ *
+ * @author Marta Vaclavikova
+ * @version 1.0, 05/2007
+ */
+public class EditorBody extends JPanel {
+
+ private static final long serialVersionUID = 6221409996382853643L;
+
+ /** The size of vertical panel margin */
+ private static final int MARGIN_VERTICAL = 3;
+
+ /** The size of horizontal panel margin */
+ private static final int MARGIN_HORIZONTAL = 5;
+
+ /** The height of the top part of the panel */
+ private static final int PANEL_TOP_HEIGHT = 500;
+
+ /** The width of the tree menu of the panel */
+ private static final int PANEL_TREE_WIDTH = 200;
+
+ /** The height of the panel */
+ private static final int PANEL_HEIGHT = 600;
+
+ /** The width of the panel */
+ public static final int PANEL_WIDTH = 820;
+
+ /** The split pane of the editor */
+ private JSplitPane splitPaneTop;
+
+ /**
+ * Initializes a newly created <code>EditorBody</code> with the list of <en>Section</em>s
+ * with parameters.
+ *
+ * @param sectionList
+ * the list of sections with parameters.
+ */
+ public EditorBody(List<Section> sectionList) {
+ this.setLayout(new BorderLayout(MARGIN_VERTICAL, MARGIN_HORIZONTAL));
+
+ // split tree menu x right panel
+ splitPaneTop = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ splitPaneTop.setDividerLocation(PANEL_TREE_WIDTH);
+ splitPaneTop.setBorder(null);
+ ((BasicSplitPaneUI) splitPaneTop.getUI()).getDivider().setBorder(
+ BorderFactory.createEmptyBorder());
+
+ // tree menu
+ TreeMenu treeMenu = TreeMenu.getInstance(this, sectionList);
+ JScrollPane treeView = new JScrollPane(treeMenu);
+ treeView.setPreferredSize(new Dimension(PANEL_TREE_WIDTH, PANEL_TOP_HEIGHT));
+ treeView.setBorder(null);
+ splitPaneTop.setLeftComponent(treeView);
+
+ // right panel
+ splitPaneTop.setRightComponent(treeMenu.getFirstSheet());
+
+ // split console x top panel
+ JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+ splitPane.setBorder(null);
+ ((BasicSplitPaneUI) splitPane.getUI()).getDivider().setBorder(
+ BorderFactory.createEmptyBorder());
+ splitPane.setTopComponent(splitPaneTop);
+ splitPane.setBottomComponent(MessageConsole.getInstance());
+ splitPane.setDividerLocation(PANEL_TOP_HEIGHT);
+
+ add(splitPane, BorderLayout.CENTER);
+
+ this.setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
+ }
+
+ /**
+ * Changes the right panel of the editor body to the actually selected panel.
+ *
+ * @param panel
+ * the new selected panel.
+ */
+ public void setEditorSheet(JPanel panel) {
+ splitPaneTop.setRightComponent(panel);
+ }
+}
\ No newline at end of file
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.editor;\r
+\r
+import java.util.List;\r
+\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.SpringLayout;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.graphics.components.attributes.AttributeButton;\r
+import cz.zcu.fav.kiv.editor.graphics.components.parameters.HelpLabel;\r
+import cz.zcu.fav.kiv.editor.graphics.components.parameters.ParameterCheckBox;\r
+import cz.zcu.fav.kiv.editor.graphics.components.parameters.ParameterTypeForm;\r
+import cz.zcu.fav.kiv.editor.graphics.components.parameters.UrlLabel;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.SpringUtilities;\r
+\r
+/**\r
+ * The <code>GroupItemsPanel</code> class is the panel containing the <em>ParentParameter</em>s\r
+ * belonging to one <em>Group</em>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class GroupItemsPanel extends JPanel {\r
+\r
+ private static final long serialVersionUID = 6783434567893822418L;\r
+\r
+ /** The number of one component items in the panel */\r
+ private static final int ITEMS = 5;\r
+\r
+ /** The size of component margin */\r
+ private static final int MARGIN = 4;\r
+\r
+ /**\r
+ * Initializes a newly created <code>GroupItemsPanel</code> with the list of parameters.\r
+ * \r
+ * @param elementList\r
+ * the list of parameters.\r
+ */\r
+ public GroupItemsPanel(List<ParentParameter> elementList) {\r
+ int componentCount = 0;\r
+\r
+ // parameters panel\r
+ this.setLayout(new SpringLayout());\r
+\r
+ for (ParentParameter element : elementList) {\r
+ // checkbox\r
+ this.add(new ParameterCheckBox(element));\r
+\r
+ // interrogation mark\r
+ this.add(new HelpLabel(element));\r
+\r
+ // url link\r
+ this.add(new UrlLabel(element.getName()));\r
+\r
+ // parameter name\r
+ this.add( new JLabel(element.getName()));\r
+\r
+ // parameter type\r
+ if (element instanceof Parameter) \r
+ this.add(new ParameterTypeForm(((Parameter) element).getType()));\r
+ \r
+ // property button\r
+ if (element instanceof Property)\r
+ this.add(new AttributeButton((Property) element));\r
+\r
+ componentCount++;\r
+ }\r
+\r
+ SpringUtilities.makeCompactGrid(this, componentCount, ITEMS, MARGIN, MARGIN, MARGIN,\r
+ MARGIN);\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.editor;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.JPanel;\r
+import javax.swing.SpringLayout;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.sections.Group;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.displays.GraphicsFigure;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.SpringUtilities;\r
+\r
+/**\r
+ * The <code>GroupPanel</code> class is the panel containing the <em>Group</em> of parameters.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class GroupPanel extends JPanel {\r
+\r
+ private static final long serialVersionUID = 6783432227893822418L;\r
+\r
+ /** The size of vertical title margin */\r
+ private static final int VERTICAL_MARGIN_TITLE = 0;\r
+\r
+ /** The size of horizontal title margin */\r
+ private static final int HORIZONTAL_MARGIN_TITLE = 10;\r
+\r
+ /** The size of vertical margin of empty title */\r
+ private static final int VERTICAL_MARGIN_EMPTY_TITLE = 5;\r
+\r
+ /** The size of margin of components in the group panel */\r
+ private static final int COMPONENT_MARGIN = 3;\r
+\r
+ /** The number of rows in the group panel */\r
+ private static final int ROW = 1;\r
+\r
+ /**\r
+ * Initializes a newly created <code>SubsectionSheet</code> with the group.\r
+ * \r
+ * @param group\r
+ * the group with parameters.\r
+ */\r
+ public GroupPanel(Group group) {\r
+ if (group.getTitle() != null)\r
+ this.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(\r
+ VERTICAL_MARGIN_TITLE, HORIZONTAL_MARGIN_TITLE, VERTICAL_MARGIN_TITLE,\r
+ HORIZONTAL_MARGIN_TITLE), BorderFactory.createTitledBorder(group.getTitle())));\r
+ else\r
+ this.setBorder(BorderFactory.createEmptyBorder(VERTICAL_MARGIN_EMPTY_TITLE,\r
+ HORIZONTAL_MARGIN_TITLE, VERTICAL_MARGIN_EMPTY_TITLE, HORIZONTAL_MARGIN_TITLE));\r
+\r
+ int componentCount = 1;\r
+\r
+ this.setLayout(new SpringLayout());\r
+\r
+ this.add(new GroupItemsPanel(group.getElementList()));\r
+\r
+ if (group.getFigure() != null)\r
+ try {\r
+ GraphicsFigure graphicsFigure = (GraphicsFigure) Class.forName(\r
+ group.getFigure().getClassName()).newInstance();\r
+ graphicsFigure.setInputs(group.getFigure().getParameterList());\r
+ this.add(graphicsFigure);\r
+ componentCount++;\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ }\r
+\r
+ SpringUtilities.makeCompactGrid(this, ROW, componentCount, COMPONENT_MARGIN,\r
+ COMPONENT_MARGIN, COMPONENT_MARGIN, COMPONENT_MARGIN);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.editor;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Dimension;\r
+import java.awt.Font;\r
+\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JSeparator;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.sections.Group;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Subsection;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.GridLayoutUtilities;\r
+\r
+/**\r
+ * The <code>SubsectionSheet</code> class is the panel containing groups of parameters, that\r
+ * belongs to the <em>Subsection</em>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class SubsectionSheet extends JPanel {\r
+\r
+ private static final long serialVersionUID = -1940480099930144654L;\r
+\r
+ /** The name of the sheet section */\r
+ private String name;\r
+\r
+ /** The number of sheet columns */\r
+ private static int COLUMN = 1;\r
+\r
+ /** The size of the sheet horizontal margin */\r
+ private static final int MARGIN_HORIZONTAL = 0;\r
+\r
+ /** The size of the sheet vertical margin */\r
+ private static final int MARGIN_VERTICAL = 5;\r
+\r
+ /** The size of the font used for sheet title */\r
+ private static final int TITLE_FONT = 13;\r
+\r
+ /**\r
+ * Initializes a newly created <code>SubsectionSheet</code> with the subsection.\r
+ * \r
+ * @param subsection\r
+ * the subsection with groups of parameters.\r
+ */\r
+ public SubsectionSheet(Subsection subsection) {\r
+ this.name = subsection.getTitle();\r
+ this.setLayout(new BorderLayout());\r
+\r
+ // top with title\r
+ JPanel topPanel = new JPanel();\r
+ topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));\r
+ topPanel.add(Box.createRigidArea(new Dimension(MARGIN_HORIZONTAL, MARGIN_VERTICAL)));\r
+\r
+ JLabel titleLabel = new JLabel(name, JLabel.LEFT);\r
+ titleLabel.setFont(new Font("Sans-Serif", Font.BOLD, TITLE_FONT));\r
+ topPanel.add(titleLabel);\r
+\r
+ topPanel.add(Box.createRigidArea(new Dimension(MARGIN_HORIZONTAL, MARGIN_VERTICAL)));\r
+ topPanel.add(new JSeparator(JSeparator.HORIZONTAL));\r
+ topPanel.add(Box.createRigidArea(new Dimension(MARGIN_HORIZONTAL, 2 * MARGIN_VERTICAL)));\r
+ this.add(topPanel, BorderLayout.PAGE_START);\r
+\r
+ // panel with parameters\r
+ JPanel groupPanel = new JPanel();\r
+ groupPanel.setLayout(new GridLayoutUtilities(subsection.getGroupList().size(), COLUMN));\r
+\r
+ for (Group group : subsection.getGroupList()) {\r
+ groupPanel.add(new GroupPanel(group));\r
+ }\r
+ JScrollPane sheetPanel = new JScrollPane(groupPanel,\r
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
+ sheetPanel.setBorder(null);\r
+ this.add(sheetPanel, BorderLayout.CENTER);\r
+ }\r
+\r
+ /**\r
+ * Returns the name of the sheet section.\r
+ */\r
+ public String toString() {\r
+ return name;\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.editor;\r
+\r
+import java.awt.Color;\r
+import java.util.List;\r
+\r
+import javax.swing.ImageIcon;\r
+import javax.swing.JPanel;\r
+import javax.swing.JTree;\r
+import javax.swing.tree.DefaultMutableTreeNode;\r
+import javax.swing.tree.DefaultTreeCellRenderer;\r
+import javax.swing.tree.TreePath;\r
+import javax.swing.tree.TreeSelectionModel;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.sections.Section;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Subsection;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+\r
+/**\r
+ * The <code>TreeMenu</code> class is the panel containing the tree menu of the editor.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TreeMenu extends JPanel {\r
+\r
+ private static final long serialVersionUID = 8347821460376344167L;\r
+\r
+ /** The single instance of the panel with the tree menu */\r
+ private static TreeMenu instance;\r
+\r
+ /** The tree menu */\r
+ private JTree tree;\r
+\r
+ /** The list of tree nodes */\r
+ private DefaultMutableTreeNode nodeList;\r
+\r
+ /**\r
+ * Singleton constructor - gets the single instance of the <code>TreeMenu</code> class.\r
+ * \r
+ * @param editorBody\r
+ * the body of the editor.\r
+ * @param sectionList\r
+ * the list of sections.\r
+ * @return the single instance of the <code>TreeMenu</code>.\r
+ */\r
+ public static TreeMenu getInstance(EditorBody editorBody, List<Section> sectionList) {\r
+ if (instance == null) {\r
+ instance = new TreeMenu(editorBody, sectionList);\r
+ }\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>TreeMenu</code> with the list of <en>Section</em>s with\r
+ * parameters and the editor body which part the <code>TreeMenu</code> creates.\r
+ * \r
+ * @param editorBody\r
+ * the body of the editor.\r
+ * @param sectionList\r
+ * the list of sections.\r
+ */\r
+ public TreeMenu(EditorBody editorBody, List<Section> sectionList) {\r
+ nodeList = createNodes(sectionList);\r
+ tree = new JTree(nodeList);\r
+ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);\r
+\r
+ // Listen for when the selection changes.\r
+ tree.addTreeSelectionListener(new TreeSelectAction(editorBody));\r
+\r
+ // leaf icon\r
+ DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();\r
+ ImageIcon leafIcon = EditorIcon.createTabIcon();\r
+ renderer.setLeafIcon(leafIcon);\r
+\r
+ // select leaf\r
+ TreePath treePath = new TreePath(nodeList.getFirstLeaf().getPath());\r
+ tree.setSelectionPath(treePath);\r
+\r
+ tree.setRootVisible(false);\r
+ this.add(tree);\r
+ this.setBackground(Color.white);\r
+ }\r
+\r
+ /**\r
+ * Creates the structure of tree nodes containing parameter sections.\r
+ * \r
+ * @param sectionList\r
+ * the list of sections.\r
+ * @return the root node of the tree menu.\r
+ */\r
+ private DefaultMutableTreeNode createNodes(List<Section> sectionList) {\r
+ DefaultMutableTreeNode top = new DefaultMutableTreeNode();\r
+ DefaultMutableTreeNode sectionNode = null;\r
+\r
+ for (Section section : sectionList) {\r
+ sectionNode = new DefaultMutableTreeNode(section.getTitle());\r
+ top.add(sectionNode);\r
+ // subsections\r
+ for (Subsection subsection : section.getSubsectionList()) {\r
+ sectionNode.add(new DefaultMutableTreeNode(new SubsectionSheet(subsection)));\r
+ }\r
+ }\r
+ return top;\r
+ }\r
+\r
+ /**\r
+ * Gets the section sheet belonging to the first tree node.\r
+ * \r
+ * @return the section sheet belonging to the first tree node.\r
+ */\r
+ public SubsectionSheet getFirstSheet() {\r
+ return (SubsectionSheet) nodeList.getFirstLeaf().getUserObject();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.editor;\r
+\r
+import javax.swing.JTree;\r
+import javax.swing.event.TreeSelectionEvent;\r
+import javax.swing.event.TreeSelectionListener;\r
+import javax.swing.tree.DefaultMutableTreeNode;\r
+\r
+/**\r
+ * The <code>TreeSelectAction</code> class represents the action performed when a leaf of tree\r
+ * menu is selected. Displays the <em>SubsectionSheet</em> belonging to the selected leaf.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TreeSelectAction implements TreeSelectionListener {\r
+\r
+ /** The panel representing the editor body */\r
+ private EditorBody editorBody;\r
+\r
+ /**\r
+ * Initializes a newly created <code>TreeSelectAction</code>.\r
+ * \r
+ * @param editorBody\r
+ * the panel representing the editor body.\r
+ */\r
+ public TreeSelectAction(EditorBody editorBody) {\r
+ this.editorBody = editorBody;\r
+ }\r
+\r
+ /**\r
+ * Action performed when a tree node is selected. Displays the subsection sheet belonging to the\r
+ * selected node.\r
+ */\r
+ public void valueChanged(TreeSelectionEvent selectEvent) {\r
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) ((JTree) selectEvent.getSource())\r
+ .getLastSelectedPathComponent();\r
+ if (node.isLeaf()) {\r
+ this.editorBody.setEditorSheet((SubsectionSheet) node.getUserObject());\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.parameters;\r
+\r
+import java.awt.datatransfer.Clipboard;\r
+import java.awt.datatransfer.ClipboardOwner;\r
+import java.awt.datatransfer.StringSelection;\r
+import java.awt.datatransfer.Transferable;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.awt.event.MouseAdapter;\r
+import java.awt.event.MouseEvent;\r
+import javax.swing.JMenuItem;\r
+import javax.swing.JPopupMenu;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.OpenBrowser;\r
+\r
+/**\r
+ * The <code>BrowserListener</code> class represents the action performed when the mouse is\r
+ * pressed above the <code>UrlLabel</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class BrowserListener extends MouseAdapter implements ClipboardOwner {\r
+\r
+ /** The popup menu displaying when the right mouse button is pressed */\r
+ private JPopupMenu popup;\r
+\r
+ /**\r
+ * The name of the parameter - is the same as the URL path of the web page with parameter\r
+ * description\r
+ */\r
+ private String name;\r
+\r
+ /**\r
+ * Creates the popup menu displaying when the right mouse button is pressed above\r
+ * <code>UrlLabel</code>.\r
+ * \r
+ * @return the popup menu of the <em>UrlLabel</em>.\r
+ */\r
+ private JPopupMenu createPopupMenu() {\r
+ JPopupMenu popup = new JPopupMenu();\r
+ // item opening the web browser\r
+ JMenuItem menuItem = new JMenuItem(ResourceController\r
+ .getMessage("editor.browser.menu.open_browser"));\r
+ menuItem.addActionListener(new OpenBrowserListener());\r
+ popup.add(menuItem);\r
+ // item copying the URL path to the clippboard\r
+ menuItem = new JMenuItem(ResourceController.getMessage("editor.browser.menu.copy_location"));\r
+ menuItem.addActionListener(new CopyToClipboardListener());\r
+ popup.add(menuItem);\r
+ return popup;\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>BrowserListener</code> with the parameter name.\r
+ * \r
+ * @param name\r
+ * the name of the parameter.\r
+ */\r
+ public BrowserListener(String name) {\r
+ this.name = name;\r
+ popup = createPopupMenu();\r
+ }\r
+\r
+ /**\r
+ * Action performed when the mouse button is pressed. Shows the popup menu if the right mouse\r
+ * button has been pressed.\r
+ */\r
+ public void mouseReleased(MouseEvent event) {\r
+ maybeShowPopup(event);\r
+ }\r
+\r
+ /**\r
+ * Shows the popup menu if the right mouse button has been pressed.\r
+ * \r
+ * @param event\r
+ * the mouse event.\r
+ */\r
+ private void maybeShowPopup(MouseEvent event) {\r
+ if (event.isPopupTrigger())\r
+ popup.show(event.getComponent(), event.getX(), event.getY());\r
+ else\r
+ OpenBrowser.openURL(ResourceController.getMessage("url.parameter_description", name));\r
+ }\r
+\r
+ /**\r
+ * The inner class <code>BrowserListener</code> represents the action performed when the left\r
+ * mouse button above the <code>UrlLabel</code> is pressed. It opens the web browser with the\r
+ * web page containg the parameter description.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ class OpenBrowserListener implements ActionListener {\r
+ /**\r
+ * The action performed when the left mouse button above the <code>UrlLabel</code> is\r
+ * pressed. It opens the web browser with the web page containg the parameter description.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ OpenBrowser.openURL(ResourceController.getMessage("url.parameter_description", name));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * The inner class <code>CopyToClipboardListener</code> represents the action performed when\r
+ * the popup menu item <em>Copy to clipboard</em> is chosen. It copies the URL of the page\r
+ * with the parameter description to the clipboard.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ class CopyToClipboardListener implements ActionListener {\r
+\r
+ /**\r
+ * The action performed when the popup menu item <em>Copy to clipboard</em> is chosen. It\r
+ * copies the URL of the page with the parameter description to the clipboard.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ Clipboard clipboard = MainFrame.getInstance().getToolkit().getSystemClipboard();\r
+ clipboard.setContents(new StringSelection(name), BrowserListener.this);\r
+ }\r
+ }\r
+\r
+ public void lostOwnership(Clipboard arg0, Transferable arg1) {\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.parameters;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+import java.awt.event.FocusEvent;\r
+import java.awt.event.FocusListener;\r
+import javax.swing.JDialog;\r
+import javax.swing.JEditorPane;\r
+import javax.swing.JLabel;\r
+import javax.swing.JScrollPane;\r
+\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>DescriptionForm</code> class is the dialog displaying parameter description.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class DescriptionForm extends JDialog implements FocusListener {\r
+\r
+ private static final long serialVersionUID = -4632340976081227454L;\r
+\r
+ /** The width of the dialog */\r
+ private static final int WIDTH = 300;\r
+\r
+ /** The height width of the dialog */\r
+ private static final int HEIGHT = 150;\r
+\r
+ /** The color of the background dialog */\r
+ private static final Color BACKGROUND_COLOR = new Color(255, 255, 225);\r
+\r
+ /** The single instance of the dialog */\r
+ private static DescriptionForm instance;\r
+\r
+ /** The inner width of the dialog */\r
+ private JEditorPane contentArea;\r
+\r
+ /**\r
+ * Creates and shows the dialog with parameter description.\r
+ * \r
+ * @param content\r
+ * the description of parameter.\r
+ * @param label\r
+ * the label with parameter name.\r
+ */\r
+ public static void showDialog(String content, JLabel label) {\r
+ instance = getInstance();\r
+ instance.setContentArea(content);\r
+ instance.setLocationRelativeTo(label);\r
+ instance.setVisible(true);\r
+ }\r
+\r
+ /**\r
+ * Gets the single instance of the dialog with parameter description.\r
+ * \r
+ * @return the single instance of the dialog with parameter description.\r
+ */\r
+ private static DescriptionForm getInstance() {\r
+ if (instance == null)\r
+ instance = new DescriptionForm();\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>DescriptionForm</code>.\r
+ */\r
+ private DescriptionForm() {\r
+ super(MainFrame.getInstance());\r
+\r
+ this.setLayout(new BorderLayout());\r
+\r
+ contentArea = new JEditorPane();\r
+ contentArea.setEditable(false);\r
+ contentArea.setContentType("text/html");\r
+\r
+ contentArea.setBackground(BACKGROUND_COLOR);\r
+\r
+ JScrollPane scrollBar = new JScrollPane(contentArea);\r
+ scrollBar.setPreferredSize(new Dimension(WIDTH, HEIGHT));\r
+ this.add(scrollBar, BorderLayout.PAGE_START);\r
+\r
+ contentArea.addFocusListener(this);\r
+ this.setUndecorated(true);\r
+ pack();\r
+ }\r
+\r
+ /**\r
+ * Action performed when the dialog gains focus - does nothing.\r
+ */\r
+ public void focusGained(FocusEvent event) {\r
+ }\r
+\r
+ /**\r
+ * Action performed when the dialog losts focus - hides the dialog.\r
+ */\r
+ public void focusLost(FocusEvent event) {\r
+ this.setVisible(false);\r
+ }\r
+\r
+ /**\r
+ * Sets a new parameter description to the content of the dialog.\r
+ * \r
+ * @param content\r
+ * the description of a parameter.\r
+ */\r
+ public void setContentArea(String content) {\r
+ this.contentArea.setText(content);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.parameters;\r
+\r
+import java.awt.Cursor;\r
+import java.awt.event.MouseAdapter;\r
+import java.awt.event.MouseEvent;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import javax.swing.JLabel;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+\r
+/**\r
+ * The <code>HelpLabel</code> class is the icon button displaying the tooltip with parameter purpose and\r
+ * the dialog with parameter description.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class HelpLabel extends JLabel {\r
+\r
+ private static final long serialVersionUID = -2256167369619643267L;\r
+\r
+ /** The parameter description */\r
+ private String description = null;\r
+\r
+ /**\r
+ * Initializes a newly created <code>HelpLabel</code> with the parameter.\r
+ * \r
+ * @param element\r
+ * the parameter.\r
+ */\r
+ public HelpLabel(ParentParameter element) {\r
+ if (element.getDescription() != null)\r
+ description = insertStylesheet(element.getDescription(), element.getName());\r
+\r
+ this.setToolTipText(element.getPurpose());\r
+ this.setIcon(EditorIcon.createHelpIcon());\r
+ this.addMouseListener(new ShowHelpListener());\r
+ this.setCursor(new Cursor(Cursor.HAND_CURSOR));\r
+ }\r
+\r
+ /**\r
+ * Inserts the parameter title to the HTML description of the parameter.\r
+ * \r
+ * @param text\r
+ * the description of the parameter.\r
+ * @param title\r
+ * the title of the parameter.\r
+ * @return the description of the parameter with the title.\r
+ */\r
+ private String insertTitle(String text, String title) {\r
+ Pattern pattern = Pattern.compile("<body>");\r
+ Matcher matcher = pattern.matcher(text);\r
+ if (matcher.find()) {\r
+ return text.substring(0, matcher.end()) + "<h4>" + title + "</h4>"\r
+ + text.substring(matcher.end());\r
+ }\r
+ return text;\r
+ }\r
+\r
+ /**\r
+ * Inserts the CSS stylesheet to the HTML description of the parameter.\r
+ * \r
+ * @param text\r
+ * the description of the parameter.\r
+ * @param title\r
+ * the title of the parameter.\r
+ * @return the description of the parameter with the CSS stylesheet.\r
+ */\r
+ private String insertStylesheet(String text, String title) {\r
+ text = text.replaceAll("<head>.*</head>", "");\r
+ Pattern pattern = Pattern.compile("<html>");\r
+ Matcher matcher = pattern.matcher(text);\r
+ if (matcher.find()) {\r
+ text = matcher.group()\r
+ + "<head><style>p {margin:0} body {font-size:10px;} h4 {margin:0; text-align:center} ul {margin-left:5px}</style></head>"\r
+ + text.substring(matcher.end());\r
+ }\r
+ return insertTitle(text, title);\r
+ }\r
+\r
+ /**\r
+ * The inner class <em>ShowHelpListener</em> represents action performed when the mouse is\r
+ * pressed above the help icon. Then the dialog with parameter description is displayed.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ class ShowHelpListener extends MouseAdapter {\r
+ /**\r
+ * Action performed when the mouse is pressed above the help icon, it displays the dialog\r
+ * with parameter description.\r
+ */\r
+ public void mousePressed(MouseEvent event) {\r
+ if (description != null)\r
+ DescriptionForm.showDialog(description, (JLabel) event.getSource());\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.parameters;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.util.Observable;\r
+import java.util.Observer;\r
+\r
+import javax.swing.JCheckBox;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>ParameterCheckBox</code> class is the component <em>check-box</em>, that displays\r
+ * whether the corresponding <code>Parameter</code> is selected or not.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParameterCheckBox extends JCheckBox implements Observer, ActionListener {\r
+\r
+ private static final long serialVersionUID = -6845824213536903733L;\r
+\r
+ /** The parameter which estate the component displays */\r
+ private ParentParameter parameter;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ParameterCheckBox</code> with the <code>Parameter</code>.\r
+ * \r
+ * @param parameter\r
+ * the parameter.\r
+ */\r
+ public ParameterCheckBox(ParentParameter parameter) {\r
+ super();\r
+\r
+ this.parameter = parameter;\r
+ setSelected(parameter.isChosen());\r
+\r
+ parameter.addObserver(this);\r
+ this.addActionListener(this);\r
+ }\r
+\r
+ /**\r
+ * Selects or deselects the check-box according to the input value.\r
+ * \r
+ * @param observable\r
+ * the observable object.\r
+ * @param value\r
+ * the new <em>check-box</em> value.\r
+ */\r
+ public void update(Observable observable, Object value) {\r
+ if (value != null)\r
+ this.setSelected((Boolean) value);\r
+ }\r
+\r
+ /**\r
+ * Action performed when the check-box is selected or deselected. Assignes a new estate to the\r
+ * <code>Parameter</code>.\r
+ * \r
+ * @param event\r
+ * the action event.\r
+ */\r
+ public void actionPerformed(ActionEvent event) {\r
+ parameter.setChosen(this.isSelected());\r
+ MainFrame.getInstance().setFileChanged();\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.parameters;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.FlowLayout;\r
+\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.parameters.TypeParam;\r
+import cz.zcu.fav.kiv.editor.graphics.components.CheckBox;\r
+import cz.zcu.fav.kiv.editor.graphics.components.ColorChooser;\r
+import cz.zcu.fav.kiv.editor.graphics.components.ComboBox;\r
+import cz.zcu.fav.kiv.editor.graphics.components.ComboBoxEdit;\r
+import cz.zcu.fav.kiv.editor.graphics.components.ComboBoxUnit;\r
+import cz.zcu.fav.kiv.editor.graphics.components.FileChooser;\r
+import cz.zcu.fav.kiv.editor.graphics.components.SpinnerFloat;\r
+import cz.zcu.fav.kiv.editor.graphics.components.SpinnerInt;\r
+import cz.zcu.fav.kiv.editor.graphics.components.TextArea;\r
+import cz.zcu.fav.kiv.editor.graphics.components.TextField;\r
+\r
+/**\r
+ * The <code>ParameterTypeForm</code> class is the panel containing the component used for editing\r
+ * <code>Parameter</code> value.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ParameterTypeForm extends JPanel {\r
+\r
+ private static final long serialVersionUID = 6613158285413029141L;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ParameterTypeForm</code> with the parameter type.\r
+ * \r
+ * @param type\r
+ * the parameter type.\r
+ */\r
+ public ParameterTypeForm(TypeParam type) {\r
+ this.setLayout(new FlowLayout(FlowLayout.LEADING));\r
+ switch (type.getName()) {\r
+ case BOOLEAN:\r
+ this.add(new CheckBox(type));\r
+ break;\r
+ case STRING:\r
+ case URI:\r
+ this.add(new TextField(type));\r
+ break;\r
+ case LIST:\r
+ this.add(new ComboBox(type));\r
+ break;\r
+ case LIST_OPEN:\r
+ case FONT:\r
+ this.add(new ComboBoxEdit(type));\r
+ break; \r
+ case FILENAME:\r
+ this.add(new FileChooser(type));\r
+ break;\r
+ case COLOR:\r
+ this.add(new ColorChooser(type));\r
+ break;\r
+ case LENGTH:\r
+ this.add(SpinnerFloat.createSpinnerFloat(type));\r
+ this.add(new ComboBoxUnit(type.getUnit()));\r
+ break;\r
+ case NUMBER:\r
+ case INTEGER:\r
+ this.add(SpinnerInt.createSpinnerInt(type));\r
+ break;\r
+ case RTF:\r
+ case TABLE:\r
+ TextArea area = new TextArea(type);\r
+ this.add(area);\r
+ JScrollPane scrollPane = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,\r
+ JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);\r
+ this.add(scrollPane);\r
+ break; \r
+ case FLOAT:\r
+ this.add(SpinnerFloat.createSpinnerFloat(type));\r
+ break;\r
+ }\r
+\r
+ this.setMaximumSize(new Dimension(this.getPreferredSize().width,\r
+ this.getPreferredSize().height));\r
+ this.setPreferredSize(new Dimension(this.getPreferredSize().width,\r
+ this.getPreferredSize().height));\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.components.parameters;\r
+\r
+import java.awt.Cursor;\r
+\r
+import javax.swing.JLabel;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+\r
+/**\r
+ * The <code>UrlLabel</code> class is the icon button opening the web browser with the parameter\r
+ * description.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class UrlLabel extends JLabel {\r
+\r
+ private static final long serialVersionUID = 2760298589328490225L;\r
+\r
+ /**\r
+ * Initializes a newly created <code>UrlLabel</code> with the parameter name.\r
+ * \r
+ * @param elementName\r
+ * the name of the parameter.\r
+ */\r
+ public UrlLabel(String elementName) {\r
+ this.setToolTipText(ResourceController.getMessage("editor.browser.description",\r
+ ResourceController.getMessage("url.parameter_description", elementName)));\r
+ this.setIcon(EditorIcon.createBrowserIcon());\r
+ this.addMouseListener(new BrowserListener(elementName));\r
+ this.setCursor(new Cursor(Cursor.HAND_CURSOR));\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.console;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+import java.awt.Font;\r
+import java.awt.GridLayout;\r
+\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTextPane;\r
+import javax.swing.text.BadLocationException;\r
+import javax.swing.text.MutableAttributeSet;\r
+import javax.swing.text.SimpleAttributeSet;\r
+import javax.swing.text.StyleConstants;\r
+import javax.swing.text.StyledDocument;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.components.editor.EditorBody;\r
+\r
+/**\r
+ * The <code>MessageConsole</code>class represents the output console that displays messages,\r
+ * errors and warnings to user.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class MessageConsole extends JPanel {\r
+\r
+ private static final long serialVersionUID = 5544740912147120927L;\r
+\r
+ /** The size of the console height */\r
+ private static final int FRAME_CONSOLE_HEIGHT = 70;\r
+\r
+ /** The char specifying the end of line used in the console */\r
+ private static final String NEWLINE = "\n";\r
+\r
+ /** The size of font used in the console */\r
+ private static final int FONT_SIZE = 12;\r
+\r
+ /** The single instance of the console */\r
+ private static MessageConsole instance;\r
+\r
+ /** The mutable attribute set of the <code>JTextPane</code> */\r
+ private MutableAttributeSet mutAttr;\r
+\r
+ /** The styled document of the <code>JTextPane</code> */\r
+ private StyledDocument styledDoc;\r
+\r
+ /** The text pane creating the content of the console */\r
+ private JTextPane editor;\r
+\r
+ /**\r
+ * Singleton constructor - gets the single instance of the <code>MessageConsole</code> class.\r
+ * \r
+ * @return the single instance of <code>MessageConsole</code>.\r
+ */\r
+ public static MessageConsole getInstance() {\r
+ if (instance == null)\r
+ instance = new MessageConsole();\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>MessageConsole</code>.\r
+ */\r
+ private MessageConsole() {\r
+ this.setLayout(new GridLayout(1, 1));\r
+\r
+ editor = new JTextPane();\r
+ editor.setEditable(false);\r
+ editor.setFont(new Font("DialogInput", Font.PLAIN, FONT_SIZE));\r
+ mutAttr = new SimpleAttributeSet();\r
+ styledDoc = editor.getStyledDocument();\r
+ StyleConstants.setForeground(mutAttr, Color.black);\r
+\r
+ JScrollPane scrollBar = new JScrollPane(editor);\r
+ scrollBar.setPreferredSize(new Dimension(EditorBody.PANEL_WIDTH, FRAME_CONSOLE_HEIGHT));\r
+\r
+ add(scrollBar, BorderLayout.CENTER);\r
+ }\r
+\r
+ /**\r
+ * Appends the input text to the console.\r
+ * \r
+ * @param message\r
+ * the text that will be appended to the console.\r
+ */\r
+ private void appendText(String message) {\r
+ try {\r
+ styledDoc.insertString(styledDoc.getLength(), message, mutAttr);\r
+ editor.setCaretPosition(styledDoc.getLength());\r
+ } catch (BadLocationException ex) {\r
+ Log.error(ex);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Erases the content of the whole console.\r
+ */\r
+ private void erase() {\r
+ try {\r
+ styledDoc.remove(0, styledDoc.getLength());\r
+ } catch (BadLocationException ex) {\r
+ Log.error(ex);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Appends to the console a new line.\r
+ * \r
+ * @param message\r
+ * the text that will be appended to the console as a new line.\r
+ */\r
+ private void appendLine(String message) {\r
+ appendText(message + NEWLINE);\r
+ }\r
+\r
+ /**\r
+ * Appends to the console a new word.\r
+ * \r
+ * @param message\r
+ * the text that will be appended to the console as a new word.\r
+ */\r
+ private void appendWord(String message) {\r
+ appendText(message);\r
+ }\r
+\r
+ /**\r
+ * Writes a normal information to the console.\r
+ * \r
+ * @param message\r
+ * the normal text message.\r
+ */\r
+ public static void logMessage(String message) {\r
+ StyleConstants.setForeground(MessageConsole.getInstance().getMutAttr(), Color.black);\r
+ MessageConsole.getInstance().appendLine(message);\r
+ }\r
+ \r
+ /**\r
+ * Writes a emphasis information to the console.\r
+ * \r
+ * @param message\r
+ * the normal text message.\r
+ */\r
+ public static void logMessageEmphasis(String message) {\r
+ StyleConstants.setForeground(MessageConsole.getInstance().getMutAttr(), Color.black);\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), true);\r
+ MessageConsole.getInstance().appendLine(message);\r
+ }\r
+\r
+ /**\r
+ * Writes a warning message to the console.\r
+ * \r
+ * @param message\r
+ * the message containing warning.\r
+ */\r
+ public static void logWarning(String message) {\r
+ StyleConstants.setForeground(MessageConsole.getInstance().getMutAttr(), new Color(0, 64,\r
+ 128));\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), true);\r
+ MessageConsole.getInstance().appendWord(\r
+ ResourceController.getMessage("message_writer.warning"));\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), false);\r
+ StyleConstants.setForeground(MessageConsole.getInstance().getMutAttr(), Color.black);\r
+ MessageConsole.getInstance().appendLine(message);\r
+ }\r
+\r
+ /**\r
+ * Writes an error message to the console.\r
+ * \r
+ * @param message\r
+ * the message containing error.\r
+ */\r
+ public static void logError(String message) {\r
+ StyleConstants.setForeground(MessageConsole.getInstance().getMutAttr(), new Color(208, 9,\r
+ 32));\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), true);\r
+ MessageConsole.getInstance().appendWord(\r
+ ResourceController.getMessage("message_writer.error"));\r
+ MessageConsole.getInstance().appendLine(message);\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), false);\r
+ }\r
+\r
+ /**\r
+ * Writes an information message to the console.\r
+ * \r
+ * @param message\r
+ * the message containing information.\r
+ */\r
+ public static void logInfo(String message) {\r
+ StyleConstants.setForeground(MessageConsole.getInstance().getMutAttr(), new Color(217, 121,\r
+ 36));\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), true);\r
+ MessageConsole.getInstance().appendWord(\r
+ ResourceController.getMessage("message_writer.info"));\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), false);\r
+ StyleConstants.setForeground(MessageConsole.getInstance().getMutAttr(), Color.black);\r
+ MessageConsole.getInstance().appendLine(message);\r
+ }\r
+\r
+ /**\r
+ * Writes a title to the console.\r
+ * \r
+ * @param message\r
+ * the message containing title.\r
+ */\r
+ public static void logTitle(String message) {\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), true);\r
+ StyleConstants.setForeground(MessageConsole.getInstance().getMutAttr(),\r
+ new Color(128, 0, 0));\r
+ MessageConsole.getInstance().appendLine(" * * * " + message.toUpperCase() + " * * *");\r
+ StyleConstants.setBold(MessageConsole.getInstance().getMutAttr(), false);\r
+ }\r
+\r
+ /**\r
+ * Erases the content of the console.\r
+ */\r
+ public static void eraseConsole() {\r
+ MessageConsole.getInstance().erase();\r
+ }\r
+\r
+ public MutableAttributeSet getMutAttr() {\r
+ return mutAttr;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.frames;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Font;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+\r
+/**\r
+ * The <code>AboutForm</code> class is the dialog displaying information about application.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class AboutForm extends InfoDialog {\r
+\r
+ private static final long serialVersionUID = -4631230976081227814L;\r
+\r
+ /** The size of the title font */\r
+ private static final int TITLE_FONT = 12;\r
+\r
+ /** The single instance of the dialog */\r
+ private static AboutForm instance;\r
+\r
+ /**\r
+ * Initializes a newly created <code>AboutForm</code> with its title.\r
+ */\r
+ public AboutForm() {\r
+ super("frame.about.title");\r
+ }\r
+\r
+ /**\r
+ * Creates and shows the dialog with information about application.\r
+ */\r
+ public static void showDialog() {\r
+ instance = new AboutForm();\r
+ instance.setVisible(true);\r
+ }\r
+\r
+ @Override\r
+ protected JPanel createContent() {\r
+ JPanel content = new JPanel();\r
+ JPanel panelImage = new JPanel();\r
+ JLabel logoLabel = new JLabel();\r
+\r
+ logoLabel.setIcon(EditorIcon.createLargeEditorIcon());\r
+ panelImage.add(logoLabel);\r
+\r
+ JPanel panelText = new JPanel();\r
+ panelText.setLayout(new BoxLayout(panelText, BoxLayout.Y_AXIS));\r
+ panelText.setBorder(BorderFactory.createEmptyBorder(HORIZONTAL_MARGIN, VERTICAL_MARGIN,\r
+ HORIZONTAL_MARGIN, VERTICAL_MARGIN));\r
+\r
+ JLabel titleLabel = new JLabel(ResourceController.getMessage("editor.title"));\r
+ titleLabel.setFont(new Font("SansSerif", Font.BOLD, TITLE_FONT));\r
+ titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 30));\r
+\r
+ panelText.add(titleLabel);\r
+ panelText.add(Box.createHorizontalGlue());\r
+ panelText.add(new JLabel(ResourceController.getMessage("frame.about.version",\r
+ OptionItems.APPLICATION_VERSION)));\r
+ panelText.add(new JLabel(ResourceController.getMessage("frame.about.author")));\r
+\r
+ content.add(panelImage, BorderLayout.WEST);\r
+ content.add(panelText, BorderLayout.EAST);\r
+ return content;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.frames;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.Font;\r
+import java.io.File;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.ImageIcon;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JTextField;\r
+import javax.swing.SpringLayout;\r
+\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.SpringUtilities;\r
+import cz.zcu.fav.kiv.editor.template.TemplateConst;\r
+\r
+/**\r
+ * The <code>ConfigInfoForm</code> class is the dialog displaying information about configuratio\r
+ * files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ConfigInfoForm extends InfoDialog {\r
+\r
+ private static final long serialVersionUID = -4631230976081227814L;\r
+\r
+ /** The width of the line */\r
+ private static final int LINE_WIDTH = 80;\r
+\r
+ /** The number of rows in the dialog */\r
+ private static final int ROW_COUNT = 4;\r
+\r
+ /** The number of columns in the dialog */\r
+ private static final int COLUMN_COUNT = 3;\r
+\r
+ /** The size of the font */\r
+ private static final int FONT_SIZE = 11;\r
+\r
+ /** The size of the margin */\r
+ private static final int MARGIN = 3;\r
+\r
+ /** The size of the right margin */\r
+ private static final int MARGIN_RIGHT = 10;\r
+\r
+ /** The inner width of the dialog */\r
+ private static final int DIALOG_INNER_WIDTH = 490;\r
+\r
+ /** The outer width of the dialog */\r
+ private static final int DIALOG_OUTER_WIDTH = 500;\r
+\r
+ /** The single instance of the dialog */\r
+ private static ConfigInfoForm instance;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ConfigInfoForm</code> with its title.\r
+ */\r
+ public ConfigInfoForm() {\r
+ super("frame.config_info.title");\r
+ }\r
+\r
+ /**\r
+ * Creates and shows the dialog with information about application.\r
+ */\r
+ public static void showDialog() {\r
+ instance = new ConfigInfoForm();\r
+ instance.setVisible(true);\r
+ }\r
+\r
+ @Override\r
+ protected JPanel createContent() {\r
+ JPanel content = new JPanel();\r
+\r
+ JPanel dirPanel = new JPanel();\r
+ dirPanel.setBorder(BorderFactory.createTitledBorder(ResourceController\r
+ .getMessage("frame.config_info.directory")));\r
+ String labelText = System.getProperty("user.dir") + File.separator\r
+ + OptionItems.XML_DEFINITION_PATH;\r
+ labelText = wrapLabel(labelText);\r
+ JLabel dirLabel = new JLabel("<html>" + labelText + "</html>");\r
+ dirLabel.setFont(new Font("Sans-Serif", Font.BOLD, FONT_SIZE));\r
+ dirPanel.add(dirLabel);\r
+ dirPanel.setPreferredSize(new Dimension(DIALOG_INNER_WIDTH,\r
+ dirPanel.getPreferredSize().height));\r
+\r
+ content.add(dirPanel);\r
+ JPanel filePanel = filePanel();\r
+ content.add(filePanel());\r
+ JPanel templatePanel = templatePanel();\r
+ content.add(templatePanel);\r
+\r
+ content.setPreferredSize(new Dimension(DIALOG_OUTER_WIDTH,\r
+ dirPanel.getPreferredSize().height + filePanel.getPreferredSize().height\r
+ + templatePanel.getPreferredSize().height + 20));\r
+\r
+ return content;\r
+ }\r
+\r
+ /**\r
+ * Creates the panel contenting the information about stylesheet template.\r
+ * \r
+ * @return the panel contenting the information about stylesheet template.\r
+ */\r
+ private JPanel templatePanel() {\r
+ JPanel templatePanel = new JPanel();\r
+ templatePanel.setBorder(BorderFactory.createTitledBorder(ResourceController\r
+ .getMessage("frame.config_info.template.title")));\r
+\r
+ String labelText = System.getProperty("user.dir") + File.separator\r
+ + TemplateConst.CONF_FILE_TEMPLATE;\r
+ labelText = wrapLabel(labelText);\r
+ JLabel dirLabel = new JLabel("<html>" + labelText + "</html>");\r
+ dirLabel.setFont(new Font("Sans-Serif", Font.BOLD, FONT_SIZE));\r
+ templatePanel.add(dirLabel);\r
+\r
+ templatePanel.setPreferredSize(new Dimension(DIALOG_INNER_WIDTH, templatePanel\r
+ .getPreferredSize().height));\r
+ return templatePanel;\r
+ }\r
+\r
+ /**\r
+ * Creates the panel contenting the information about configuration files.\r
+ * \r
+ * @return the panel contenting the information about configuration files.\r
+ */\r
+ private JPanel filePanel() {\r
+ ImageIcon img = EditorIcon.createHelpIcon();\r
+\r
+ JPanel configPanel = new JPanel();\r
+ configPanel.setBorder(BorderFactory.createTitledBorder(ResourceController\r
+ .getMessage("frame.config_info.files.title")));\r
+ configPanel.setLayout(new SpringLayout());\r
+\r
+ // config.xml\r
+ JLabel iconLabel = new JLabel();\r
+ iconLabel.setIcon(img);\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("frame.config_info.files.config.description"));\r
+ configPanel.add(iconLabel);\r
+ configPanel.add(new JLabel(FileConst.CONF_FILE_CONFIG.substring(FileConst.CONF_FILE_CONFIG\r
+ .indexOf(File.separator) + 1)));\r
+ JTextField valueField = new JTextField(System.getProperty("user.dir") + File.separator\r
+ + FileConst.CONF_FILE_CONFIG);\r
+ valueField.setEditable(false);\r
+ configPanel.add(valueField);\r
+\r
+ // attributes.xml\r
+ iconLabel = new JLabel();\r
+ iconLabel.setIcon(img);\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("frame.config_info.files.attributes.description"));\r
+ configPanel.add(iconLabel);\r
+ configPanel.add(new JLabel(FileConst.CONF_FILE_ATTRIBUTES\r
+ .substring(FileConst.CONF_FILE_ATTRIBUTES.indexOf(File.separator) + 1)));\r
+ valueField = new JTextField(System.getProperty("user.dir") + File.separator\r
+ + FileConst.CONF_FILE_ATTRIBUTES);\r
+ valueField.setEditable(false);\r
+ configPanel.add(valueField);\r
+\r
+ // types.xml\r
+ iconLabel = new JLabel();\r
+ iconLabel.setIcon(img);\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("frame.config_info.files.types.description"));\r
+ configPanel.add(iconLabel);\r
+ configPanel.add(new JLabel(FileConst.CONF_FILE_TYPE.substring(FileConst.CONF_FILE_TYPE\r
+ .indexOf(File.separator) + 1)));\r
+ valueField = new JTextField(System.getProperty("user.dir") + File.separator\r
+ + FileConst.CONF_FILE_TYPE);\r
+ valueField.setEditable(false);\r
+ configPanel.add(valueField);\r
+\r
+ // graphics\r
+ iconLabel = new JLabel();\r
+ iconLabel.setIcon(img);\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("frame.config_info.files.graphics.description"));\r
+ configPanel.add(iconLabel);\r
+ configPanel.add(new JLabel(FileConst.CONF_FILE_FIGURES\r
+ .substring(FileConst.CONF_FILE_FIGURES.indexOf(File.separator) + 1)));\r
+ valueField = new JTextField(System.getProperty("user.dir") + File.separator\r
+ + FileConst.CONF_FILE_FIGURES);\r
+ valueField.setEditable(false);\r
+ configPanel.add(valueField);\r
+\r
+ SpringUtilities.makeCompactGrid(configPanel, ROW_COUNT, COLUMN_COUNT, MARGIN, MARGIN,\r
+ MARGIN_RIGHT, MARGIN);\r
+ configPanel.setPreferredSize(new Dimension(DIALOG_INNER_WIDTH, configPanel\r
+ .getPreferredSize().height));\r
+ return configPanel;\r
+ }\r
+\r
+ /**\r
+ * Wraps string line - adds <br>\r
+ * if the line is longer than <code>LINE_WIDTH</code>.\r
+ * \r
+ * @param text\r
+ * not wrapped text.\r
+ * @return the wrapped text.\r
+ */\r
+ private String wrapLabel(String text) {\r
+ if (text.length() > LINE_WIDTH)\r
+ text = text.substring(0, LINE_WIDTH) + "<br>"\r
+ + text.substring(LINE_WIDTH, text.length());\r
+ return text;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.frames;\r
+\r
+import java.net.URL;\r
+\r
+import javax.help.HelpBroker;\r
+import javax.help.HelpSet;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+\r
+/**\r
+ * The <code>HelpFrame</code> class is the frame displaying application help.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class HelpFrame {\r
+ private static final String HELPSET = "jhelpset.hs";\r
+\r
+ /** The help set */\r
+ private HelpSet helpSet;\r
+\r
+ /** The help broker */\r
+ private HelpBroker helpBroker;\r
+\r
+ /** The single instance of the frame */\r
+ private static HelpFrame instance;\r
+\r
+ /**\r
+ * Returns the single instance of the help frame.\r
+ * \r
+ * @return single instance of the help frame.\r
+ */\r
+ public static HelpFrame getInstance() {\r
+ if (instance == null)\r
+ instance = new HelpFrame();\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>HelpFrame</code>.\r
+ */\r
+ public HelpFrame() {\r
+ }\r
+\r
+ /**\r
+ * Creates the new help content according to the actual application language locale.\r
+ */\r
+ public void createHelp() {\r
+ if ((helpSet != null) && (!helpSet.getLocale().equals(OptionItems.LANGUAGE)))\r
+ helpSet = null;\r
+ if (helpSet == null) {\r
+ createHelpSet();\r
+ helpBroker = helpSet.createHelpBroker();\r
+ }\r
+ helpBroker.setDisplayed(true);\r
+ }\r
+\r
+ /**\r
+ * Initializes the help set according to the file jhelpset.hs.\r
+ */\r
+ private void createHelpSet() {\r
+ ClassLoader loader = this.getClass().getClassLoader();\r
+ try {\r
+ URL url = HelpSet.findHelpSet(loader, HELPSET);\r
+ helpSet = new HelpSet(null, url);\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.frames;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Container;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.JButton;\r
+import javax.swing.JDialog;\r
+import javax.swing.JPanel;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The abstract class <code>InfoDialog</code> is the dialog used for displaying various information.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public abstract class InfoDialog extends JDialog implements ActionListener {\r
+\r
+ private static final long serialVersionUID = -4632123976081227814L;\r
+\r
+ /** The size of horizontal margin */\r
+ protected static final int HORIZONTAL_MARGIN = 8;\r
+\r
+ /** The size of vertical margin */\r
+ protected static final int VERTICAL_MARGIN = 25;\r
+\r
+ /**\r
+ * Initializes a newly created <code>InfoDialog</code> with specified title.\r
+ * \r
+ * @param title\r
+ * the title of the dialog.\r
+ */\r
+ protected InfoDialog(String title) {\r
+ super(MainFrame.getInstance(), ResourceController.getMessage(title), true);\r
+ this.setLocationRelativeTo(MainFrame.getInstance());\r
+ }\r
+\r
+ /**\r
+ * Initializes the content of the dialog.\r
+ */\r
+ public void dialogInit() {\r
+ JPanel buttonPane = new JPanel();\r
+ buttonPane.setBorder(BorderFactory.createEmptyBorder(HORIZONTAL_MARGIN, VERTICAL_MARGIN,\r
+ HORIZONTAL_MARGIN, VERTICAL_MARGIN));\r
+ buttonPane.add(Box.createHorizontalGlue());\r
+ buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));\r
+\r
+ JButton button = new JButton(ResourceController.getMessage("button.ok"));\r
+ button.addActionListener(this);\r
+ buttonPane.add(button);\r
+\r
+ super.dialogInit();\r
+ Container content = this.getContentPane();\r
+ content.add(createContent(), BorderLayout.PAGE_START);\r
+ content.add(buttonPane, BorderLayout.PAGE_END);\r
+\r
+ pack();\r
+ }\r
+\r
+ /**\r
+ * Creates the panel forming the content of the dialog.\r
+ * \r
+ * @return the panel forming the content of the dialog.\r
+ */\r
+ abstract protected JPanel createContent();\r
+\r
+ /**\r
+ * Action performed when a button of dialog is pressed - then the dialog closes.\r
+ */\r
+ public void actionPerformed(ActionEvent e) {\r
+ this.setVisible(false);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.images;\r
+\r
+import java.awt.Image;\r
+\r
+import javax.swing.ImageIcon;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>EditorIcon</code>class is used for loading images used in the editor.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class EditorIcon {\r
+ /** The path to the directory where images are stored */\r
+ private static final String ICON_PATH = '\u002f'\r
+ + EditorIcon.class.getPackage().getName().replace('.', '\u002f') + '\u002f'\r
+ + "resources" + '\u002f';\r
+\r
+ /** The name of the image file representing main editor icon */\r
+ private static final String EDITOR_ICON_PATH = ICON_PATH + "icon.png";\r
+\r
+ /** The name of the image file representing tab */\r
+ private static final String TAB_ICON_PATH = ICON_PATH + "tab.png";\r
+\r
+ /** The name of the image file representing help */\r
+ private static final String HELP_ICON_PATH = ICON_PATH + "help.png";\r
+\r
+ /** The name of the image file representing browser */\r
+ private static final String BROWSER_ICON_PATH = ICON_PATH + "browser.png";\r
+\r
+ /** The name of the image file representing colors chooser */\r
+ private static final String COLOR_ICON_PATH = ICON_PATH + "colors.png";\r
+\r
+ /**\r
+ * Loads the main editor icon.\r
+ * \r
+ * @return the main editor icon.\r
+ */\r
+ public static Image createEditorIcon() {\r
+ final ImageIcon imageIcon = createIcon(EDITOR_ICON_PATH);\r
+ return imageIcon != null ? imageIcon.getImage() : null;\r
+ }\r
+\r
+ /**\r
+ * Loads the icon from the input file.\r
+ * \r
+ * @param image\r
+ * the name of the file where the icon is stored.\r
+ * @return the icon loaded from the input file.\r
+ */\r
+ private static ImageIcon createIcon(String image) {\r
+ try {\r
+ return new ImageIcon(EditorIcon.class.getResource(image));\r
+ } catch (Exception ex) {\r
+ Log.error("error.editor_icon", ex);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * Loads the large editor icon.\r
+ * \r
+ * @return the large editor icon.\r
+ */\r
+ public static ImageIcon createLargeEditorIcon() {\r
+ return createIcon(EDITOR_ICON_PATH);\r
+ }\r
+\r
+ /**\r
+ * Loads the tab icon.\r
+ * \r
+ * @return the tab icon.\r
+ */\r
+ public static ImageIcon createTabIcon() {\r
+ return createIcon(TAB_ICON_PATH);\r
+ }\r
+\r
+ /**\r
+ * Loads the help icon.\r
+ * \r
+ * @return the help icon.\r
+ */\r
+ public static ImageIcon createHelpIcon() {\r
+ return createIcon(HELP_ICON_PATH);\r
+ }\r
+\r
+ /**\r
+ * Loads the browser icon.\r
+ * \r
+ * @return the browser icon.\r
+ */\r
+ public static ImageIcon createBrowserIcon() {\r
+ return createIcon(BROWSER_ICON_PATH);\r
+ }\r
+\r
+ /**\r
+ * Loads the colors chooser icon.\r
+ * \r
+ * @return the colors chooser icon.\r
+ */\r
+ public static ImageIcon createColorIcon() {\r
+ return createIcon(COLOR_ICON_PATH);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.intro;
+
+
+/**
+ * The <code>IntroException</code> class is used for reporting errors generated in the intro frame during loading configuration
+ * files.
+ *
+ * @author Marta Vaclavikova
+ * @version 1.0, 05/2007
+ */
+public class IntroException extends Exception {
+
+ private static final long serialVersionUID = -5259345670724739417L;
+
+ /**
+ * Initializes a newly created empty <code>IntroException</code>.
+ */
+ public IntroException() {
+ super();
+ }
+}
\ No newline at end of file
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.intro;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.EventQueue;\r
+\r
+import javax.swing.JComponent;\r
+import javax.swing.JFrame;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.FrameShower;\r
+\r
+/**\r
+ * The <code>IntroFrame</code> class represents the intro frame displaying the loading of configuration files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class IntroFrame extends JFrame {\r
+\r
+ private static final long serialVersionUID = 1293269978761922832L;\r
+\r
+ /**\r
+ * Initializes a newly created <code>IntroFrame</code> and launches loading of configuration files.\r
+ * @throws IntroException if an error occurs during loading of configuration files.\r
+ */\r
+ public IntroFrame() throws IntroException {\r
+ super(ResourceController.getMessage("frame.intro.title"));\r
+ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r
+\r
+ setIconImage(EditorIcon.createEditorIcon());\r
+\r
+ // Create and set up the content pane.\r
+ JComponent newContentPane = new ProgressBar();\r
+ newContentPane.setOpaque(true); \r
+ this.setContentPane(newContentPane);\r
+\r
+ Dimension dim = getToolkit().getScreenSize();\r
+ Dimension abounds = getPreferredSize();\r
+ this.setLocation((dim.width - abounds.width) / 2, (dim.height - abounds.height) / 2);\r
+ this.setResizable(false);\r
+ \r
+ // Display the window.\r
+ Runnable runner = new FrameShower(this);\r
+ try {\r
+ EventQueue.invokeAndWait(runner);\r
+ } catch (Exception ex) {\r
+ Log.warn(ex);\r
+ }\r
+\r
+ ProgressBar.getTimer().start();\r
+ ProgressBar.getTask().go();\r
+\r
+ if (ProgressBar.getTask().isCanceled())\r
+ throw new IntroException();\r
+ }\r
+\r
+ /**\r
+ * Hides and dispose the intro frame.\r
+ */\r
+ public void hideFrame() {\r
+ this.setVisible(false);\r
+ this.dispose();\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.intro;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Color;\r
+import java.awt.Dimension;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.JPanel;\r
+import javax.swing.JProgressBar;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTextPane;\r
+import javax.swing.Timer;\r
+import javax.swing.text.MutableAttributeSet;\r
+import javax.swing.text.SimpleAttributeSet;\r
+import javax.swing.text.StyleConstants;\r
+import javax.swing.text.StyledDocument;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.controller.ProgressControl;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>ProgressBar</code> class is the progress bar used for displaying the progress of\r
+ * configuration files loading.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ProgressBar extends JPanel {\r
+\r
+ private static final long serialVersionUID = 1982246205327449245L;\r
+\r
+ /** The width of the progress bar */\r
+ private static final int WIDTH = 400;\r
+\r
+ /** The height of the progress bar */\r
+ private static final int HEIGHT = 150;\r
+\r
+ /** The size of margin of the progress bar */\r
+ private static final int MARGIN = 10;\r
+\r
+ /** The interval of timer launching */\r
+ private final static int TIME_INTERVAL = 50;\r
+\r
+ /** The progress bar */\r
+ private static JProgressBar progressBar;\r
+\r
+ /** The timer controlling the displaying of progress */\r
+ private static Timer timer;\r
+\r
+ /** The text pane displaying information about progress */\r
+ private JTextPane editor;\r
+\r
+ /** The mutable attribute set of the <code>JTextPane</code> */\r
+ private MutableAttributeSet mutAttr;\r
+\r
+ /** The styled document of the <code>JTextPane</code> */\r
+ private StyledDocument styledDoc;\r
+\r
+ /** The class controlling the loading the configuration files */\r
+ private static ProgressControl task;\r
+\r
+ /**\r
+ * Initializes a newly created <code>ProgressBar</code>. Starts the task that loads the\r
+ * configuration files and simultaneously starts the timer.\r
+ */\r
+ public ProgressBar() {\r
+ super(new BorderLayout(MARGIN, MARGIN));\r
+\r
+ task = new ProgressControl();\r
+ progressBar = new JProgressBar();\r
+ progressBar.setValue(0);\r
+ progressBar.setStringPainted(true);\r
+ \r
+ JProgressBar progressBarIndetermin = new JProgressBar();\r
+ progressBarIndetermin.setIndeterminate(true);\r
+ progressBarIndetermin.setStringPainted(true);\r
+ progressBarIndetermin.setString(ResourceController.getMessage("frame.intro.progress.loading_file"));\r
+ \r
+ editor = new JTextPane();\r
+ mutAttr = new SimpleAttributeSet();\r
+ styledDoc = editor.getStyledDocument();\r
+ StyleConstants.setForeground(mutAttr, Color.black);\r
+\r
+ add(progressBar, BorderLayout.PAGE_START);\r
+ add(progressBarIndetermin, BorderLayout.PAGE_END);\r
+ \r
+ JScrollPane scrollBar = new JScrollPane(editor);\r
+ scrollBar.setPreferredSize(new Dimension(WIDTH, HEIGHT));\r
+ add(scrollBar, BorderLayout.CENTER);\r
+ this.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN));\r
+\r
+ // Create a timer.\r
+ timer = new Timer(TIME_INTERVAL, new ActionListener() {\r
+ public void actionPerformed(ActionEvent evt) {\r
+ progressBar.setValue(task.getCurrent());\r
+ try {\r
+ if ((task.getMessage() != null) && (!task.isCanceled())) {\r
+ if (styledDoc.getLength() < task.getMessage().length()) {\r
+ styledDoc.remove(0, styledDoc.getLength());\r
+ styledDoc.insertString(0, task.getMessage(), mutAttr);\r
+ }\r
+ }\r
+ if (task.isDone()) {\r
+ timer.stop();\r
+ progressBar.setValue(progressBar.getMaximum());\r
+ styledDoc.insertString(0, task.getMessage(), mutAttr);\r
+ }\r
+ if (task.isCanceled()) {\r
+ timer.stop();\r
+ styledDoc.remove(0, styledDoc.getLength());\r
+ styledDoc.insertString(0, task.getMessage(), mutAttr);\r
+ StyleConstants.setForeground(mutAttr, Color.red);\r
+ styledDoc.insertString(styledDoc.getLength(), task.getErrorMessage(),\r
+ mutAttr);\r
+ progressBar.setIndeterminate(false);\r
+ }\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ }\r
+ }\r
+ });\r
+ }\r
+\r
+ public static ConfigData getData() {\r
+ return task.getData();\r
+ }\r
+\r
+ public static Timer getTimer() {\r
+ return timer;\r
+ }\r
+\r
+ public static ProgressControl getTask() {\r
+ return task;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.options;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+import java.io.File;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.ImageIcon;\r
+import javax.swing.JButton;\r
+import javax.swing.JCheckBox;\r
+import javax.swing.JComboBox;\r
+import javax.swing.JFileChooser;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JTextField;\r
+import javax.swing.SpringLayout;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.LanguageEnum;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.SpringUtilities;\r
+\r
+/**\r
+ * The <code>EditorOptionForm</code>class is the form with stylesheet options. It makes the content\r
+ * of the <code>OptionEditorDialog</code> dialog.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class EditorOptionForm extends JPanel {\r
+\r
+ private static final long serialVersionUID = -1040245299541084094L;\r
+\r
+ /** The number of rows in the form */\r
+ private static final int ROW_COUNT = 3;\r
+\r
+ /** The number of columns in the form */\r
+ private static final int COLUMN_COUNT = 3;\r
+\r
+ /** The width of the field with file path */\r
+ private static final int FILE_FIELD_WIDTH = 200;\r
+\r
+ /** The size of component margin */\r
+ private static final int COMPONENT_MARGIN = 3;\r
+\r
+ /** The label containing option name */\r
+ private JLabel iconLabel;\r
+\r
+ /** The icon image representing option item help */\r
+ private ImageIcon image;\r
+\r
+ /**\r
+ * The text-field specifying path of the directory with files containing XML definitions of\r
+ * parameters\r
+ */\r
+ private JTextField xmlDefPathField;\r
+\r
+ /** The combo-box specifying language of the editor */\r
+ private JComboBox languageBox;\r
+\r
+ /** The check-box specifying whether the editor console is erased before every action */\r
+ private JCheckBox eraseConsoleCheck;\r
+\r
+ /**\r
+ * Initializes a newly created <code>EditorOptionForm</code>.\r
+ */\r
+ public EditorOptionForm() {\r
+ this.setLayout(new SpringLayout());\r
+\r
+ this.setBorder(BorderFactory.createEtchedBorder());\r
+\r
+ image = EditorIcon.createHelpIcon();\r
+\r
+ optionLanguage();\r
+ optionXmlDefPath();\r
+ optionEraseConsole();\r
+\r
+ SpringUtilities.makeCompactGrid(this, ROW_COUNT, COLUMN_COUNT, COMPONENT_MARGIN,\r
+ COMPONENT_MARGIN, COMPONENT_MARGIN, COMPONENT_MARGIN);\r
+ }\r
+\r
+ /**\r
+ * Adds to the form the option item specifying language of the editor.\r
+ */\r
+ private void optionLanguage() {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_editor.language.description"));\r
+ iconLabel.setIcon(image);\r
+ this.add(iconLabel);\r
+ // name\r
+ this.add(new JLabel(ResourceController.getMessage("option_editor.language")));\r
+ // value\r
+ languageBox = new JComboBox(LanguageEnum.values());\r
+ languageBox.setSelectedItem(LanguageEnum.getLanguage(OptionItems.LANGUAGE));\r
+ this.add(languageBox);\r
+ }\r
+\r
+ /**\r
+ * Adds to the form the option item specifying the path directory with files containing XML\r
+ * definitions of parameters.\r
+ */\r
+ private void optionXmlDefPath() {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_editor.xml_definition_path.description"));\r
+ iconLabel.setIcon(image);\r
+ this.add(iconLabel);\r
+ // name\r
+ this.add(new JLabel(ResourceController.getMessage("option_editor.xml_definition_path")));\r
+ // value\r
+ this.add(createFileChooser());\r
+ }\r
+\r
+ /**\r
+ * Creates the panel with a text-field and button that shows a file chooser dialog. The chosen\r
+ * file path is saved to the text-field.\r
+ * \r
+ * @return the panel used for choosing file paths.\r
+ */\r
+ private JPanel createFileChooser() {\r
+ JPanel valuePanel = new JPanel();\r
+ xmlDefPathField = new JTextField(OptionItems.XML_DEFINITION_PATH);\r
+ xmlDefPathField.setPreferredSize(new Dimension(FILE_FIELD_WIDTH, xmlDefPathField\r
+ .getPreferredSize().height));\r
+ valuePanel.add(xmlDefPathField);\r
+ JButton chooseButton = new JButton(ResourceController\r
+ .getMessage("option_editor.xml_definition_path.button"));\r
+ chooseButton.addActionListener(new ChoosePath());\r
+ valuePanel.add(chooseButton);\r
+ return valuePanel;\r
+ }\r
+\r
+ /**\r
+ * Adds to the form the option item specifying whether the editor console is erased before every\r
+ * action.\r
+ */\r
+ private void optionEraseConsole() {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_editor.erase_console.description"));\r
+ iconLabel.setIcon(image);\r
+ this.add(iconLabel);\r
+ // name\r
+ this.add(new JLabel(ResourceController.getMessage("option_editor.erase_console")));\r
+ // value\r
+ eraseConsoleCheck = new JCheckBox();\r
+ if (OptionItems.ERASE_CONSOLE)\r
+ eraseConsoleCheck.setSelected(true);\r
+ this.add(eraseConsoleCheck);\r
+ }\r
+\r
+ /**\r
+ * Saves the changes of editor options made in the dialog by user.\r
+ */\r
+ public void saveChanges() {\r
+ OptionItems.XML_DEFINITION_PATH = xmlDefPathField.getText();\r
+ if (!((LanguageEnum) languageBox.getSelectedItem()).getLocale()\r
+ .equals(OptionItems.LANGUAGE))\r
+ OptionItems.changeLanguage(((LanguageEnum) languageBox.getSelectedItem()).getLocale());\r
+ OptionItems.ERASE_CONSOLE = eraseConsoleCheck.isSelected();\r
+ Log.info("info.option_form.editor.save_values");\r
+ }\r
+\r
+ /**\r
+ * Sets default values to all editor options in the dialog.\r
+ */\r
+ public void updateValues() {\r
+ languageBox.setSelectedItem(LanguageEnum.getLanguage(OptionItems.LANGUAGE));\r
+ xmlDefPathField.setText(OptionItems.XML_DEFINITION_PATH);\r
+ eraseConsoleCheck.setSelected(OptionItems.ERASE_CONSOLE);\r
+ Log.info("info.option_form.editor.update_values");\r
+ }\r
+\r
+ /**\r
+ * The <code>ChoosePath</code> class shows the open file dialog that enables to choose a\r
+ * directory. Then the chosen directory path is saved to the <code>xmlDefPathField</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ class ChoosePath implements ActionListener {\r
+ public void actionPerformed(ActionEvent e) {\r
+ JFileChooser fc = new JFileChooser();\r
+ File directory = new File(OptionItems.XML_DEFINITION_PATH);\r
+ if (directory.exists())\r
+ fc.setCurrentDirectory(directory);\r
+ fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);\r
+ int returnVal = fc.showOpenDialog(MainFrame.getInstance());\r
+ if (returnVal == JFileChooser.APPROVE_OPTION) {\r
+ xmlDefPathField.setText(fc.getSelectedFile().getPath());\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.options;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Container;\r
+import java.awt.Dimension;\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.JButton;\r
+import javax.swing.JDialog;\r
+import javax.swing.JPanel;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The abstract class <code>OptionDialog</code> is the dialog used for editing application\r
+ * options.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public abstract class OptionDialog extends JDialog implements ActionListener {\r
+\r
+ private static final long serialVersionUID = -6526357047305363516L;\r
+\r
+ /** The width of the dialog */\r
+ private static final int DIALOG_WIDTH = 500;\r
+\r
+ /** The size of margin */\r
+ private static final int MARGIN = 10;\r
+\r
+ /** The command SAVE */\r
+ private static final String SAVE_COMMAND = "save";\r
+\r
+ /** The option dialog */\r
+ protected static OptionDialog dialog;\r
+\r
+ /**\r
+ * Initializes a newly created <code>OptionDialog</code> with specified title.\r
+ * \r
+ * @param title\r
+ * the title of the dialog.\r
+ */\r
+ protected OptionDialog(String title) {\r
+ super(MainFrame.getInstance(), ResourceController.getMessage(title), true);\r
+\r
+ Container pan = new JPanel(new BorderLayout());\r
+\r
+ JPanel contentPanel = new JPanel();\r
+ contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS));\r
+\r
+ contentPanel.add(createForm());\r
+\r
+ pan.add(contentPanel, BorderLayout.PAGE_START);\r
+ pan.add(createButtonPane(), BorderLayout.PAGE_END);\r
+\r
+ this.getContentPane().add(pan, BorderLayout.CENTER);\r
+ this.setResizable(false);\r
+\r
+ this.pack();\r
+ this.setSize(new Dimension(DIALOG_WIDTH, this.getHeight()));\r
+ this.setLocationRelativeTo(MainFrame.getInstance());\r
+ }\r
+\r
+ /**\r
+ * Creates the form that makes the content of the dialog.\r
+ * \r
+ * @return the form creating the dialog content.\r
+ */\r
+ protected abstract JPanel createForm();\r
+\r
+ /**\r
+ * Saves the changes of options made in the dialog by user.\r
+ */\r
+ protected abstract void saveChanges();\r
+\r
+ /**\r
+ * Sets default values to all options in the dialog.\r
+ */\r
+ protected abstract void updateValues();\r
+\r
+ /**\r
+ * Action performed when a button of dialog is pressed. If the button is Save, then the changes\r
+ * of options are saved.\r
+ */\r
+ public void actionPerformed(ActionEvent e) {\r
+ if (SAVE_COMMAND.equals(e.getActionCommand())) {\r
+ saveChanges();\r
+ }\r
+\r
+ OptionDialog.dialog.setVisible(false);\r
+ OptionDialog.dialog.dispose();\r
+ }\r
+\r
+ /**\r
+ * Creates the dialog panel with buttons.\r
+ * \r
+ * @return the panel with buttons.\r
+ */\r
+ private JPanel createButtonPane() {\r
+ JButton defaultButton = new JButton(ResourceController.getMessage("button.default"));\r
+ defaultButton.addActionListener(new ChangeDefault());\r
+\r
+ JButton cancelButton = new JButton(ResourceController.getMessage("button.cancel"));\r
+ cancelButton.addActionListener(this);\r
+\r
+ JButton setButton = new JButton(ResourceController.getMessage("button.save"));\r
+ setButton.setActionCommand(SAVE_COMMAND);\r
+ setButton.addActionListener(this);\r
+ getRootPane().setDefaultButton(setButton);\r
+\r
+ // Lay out the buttons from left to right.\r
+ JPanel buttonPane = new JPanel();\r
+ buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));\r
+ buttonPane.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN));\r
+ buttonPane.add(Box.createHorizontalGlue());\r
+ buttonPane.add(defaultButton);\r
+ buttonPane.add(Box.createRigidArea(new Dimension(3 * MARGIN, 0)));\r
+ buttonPane.add(setButton);\r
+ buttonPane.add(Box.createRigidArea(new Dimension(MARGIN, 0)));\r
+ buttonPane.add(cancelButton);\r
+\r
+ return buttonPane;\r
+ }\r
+\r
+ /**\r
+ * The inner class <code>ChangeDefault</code> class sets default values to options in the\r
+ * dialog when the button Restore Defaults is set.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+ class ChangeDefault implements ActionListener {\r
+ public void actionPerformed(ActionEvent e) {\r
+ updateValues();\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.options;\r
+\r
+import javax.swing.JPanel;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionController;\r
+\r
+/**\r
+ * The <code>OptionEditorDialog</code>class is the dialog used for editing editor options.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OptionEditorDialog extends OptionDialog {\r
+\r
+ private static final long serialVersionUID = 7118079845557600112L;\r
+\r
+ /** The editor option dialog */\r
+ private EditorOptionForm editorOptionForm;\r
+\r
+ /**\r
+ * Creates and shows the dialog with editor options.\r
+ */\r
+ public static void showDialog() {\r
+ dialog = new OptionEditorDialog();\r
+ dialog.setVisible(true);\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>OptionEditorDialog</code> with its title.\r
+ */\r
+ public OptionEditorDialog() {\r
+ super("frame.option.editor.title");\r
+ }\r
+\r
+ @Override\r
+ protected JPanel createForm() {\r
+ editorOptionForm = new EditorOptionForm();\r
+ return editorOptionForm;\r
+ }\r
+\r
+ @Override\r
+ protected void saveChanges() {\r
+ editorOptionForm.saveChanges();\r
+ }\r
+\r
+ @Override\r
+ protected void updateValues() {\r
+ OptionController.setDefaultEditorOptions();\r
+ editorOptionForm.updateValues();\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.options;\r
+\r
+import javax.swing.JPanel;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionController;\r
+\r
+/**\r
+ * The <code>OptionStylesheetDialog</code>class is the dialog used for editing stylesheet\r
+ * options.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OptionStylesheetDialog extends OptionDialog {\r
+\r
+ private static final long serialVersionUID = 7118079159557600112L;\r
+\r
+ /** The stylesheet option dialog */\r
+ private StylesheetOptionForm stylesheetOptionForm;\r
+\r
+ /**\r
+ * Shows the dialog with stylesheet options.\r
+ */\r
+ public static void showDialog() {\r
+ dialog = new OptionStylesheetDialog();\r
+ dialog.setVisible(true);\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>OptionStylesheetDialog</code> with its title.\r
+ */\r
+ public OptionStylesheetDialog() {\r
+ super("frame.option.save.title");\r
+ }\r
+\r
+ @Override\r
+ protected JPanel createForm() {\r
+ stylesheetOptionForm = new StylesheetOptionForm();\r
+ return stylesheetOptionForm;\r
+ }\r
+\r
+ @Override\r
+ protected void saveChanges() {\r
+ stylesheetOptionForm.saveChanges();\r
+ }\r
+\r
+ @Override\r
+ protected void updateValues() {\r
+ OptionController.setDefaultStylesheetOptions();\r
+ stylesheetOptionForm.updateValues();\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.options;\r
+\r
+import java.awt.Dimension;\r
+import java.awt.Font;\r
+\r
+import javax.swing.BorderFactory;\r
+import javax.swing.Box;\r
+import javax.swing.BoxLayout;\r
+import javax.swing.ImageIcon;\r
+import javax.swing.JCheckBox;\r
+import javax.swing.JComboBox;\r
+import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
+import javax.swing.JScrollPane;\r
+import javax.swing.JTextArea;\r
+import javax.swing.JTextField;\r
+import javax.swing.SpringLayout;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.EncodingEnum;\r
+import cz.zcu.fav.kiv.editor.controller.options.NewlineEnum;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ErrorResourceController;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.images.EditorIcon;\r
+import cz.zcu.fav.kiv.editor.graphics.utils.SpringUtilities;\r
+\r
+/**\r
+ * The <code>StylesheetOptionForm</code>class is the form with editor options. It makes the\r
+ * content of the <code>OptionStylesheetDialog</code> dialog.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class StylesheetOptionForm extends JPanel {\r
+\r
+ private static final long serialVersionUID = -1040245299541084094L;\r
+\r
+ /** The number of columns in the form */\r
+ private static final int COLUMN_COUNT = 3;\r
+\r
+ /** The number of rows in the first panel of the form */\r
+ private static final int ROW_1_COUNT = 3;\r
+\r
+ /** The number of rows in the second panel of the form */\r
+ private static final int ROW_2_COUNT = 3;\r
+\r
+ /** The number of rows in the third panel of the form */\r
+ private static final int ROW_3_COUNT = 2;\r
+\r
+ /** The inner width of the form panel */\r
+ private static final int PANEL_INNER_WIDTH = 490;\r
+\r
+ /** The outer width of the form panel */\r
+ private static final int PANEL_OUTER_WIDTH = 500;\r
+\r
+ /** The size of component margin */\r
+ private static final int COMPONENT_MARGIN = 3;\r
+\r
+ /** The label containing option name */\r
+ private JLabel iconLabel;\r
+\r
+ /** The icon image representing option item help */\r
+ private ImageIcon image;\r
+\r
+ /** The check-box specifying whether FO namespace is appended to the stylesheet definiton */\r
+ private JCheckBox addFoNamespaceCheck;\r
+\r
+ /** The check-box specifying whether the rearrange saving is used */\r
+ private JCheckBox changeSaveCheck;\r
+\r
+ /** The check-box specifying whether comments are generated in the stylesheet */\r
+ private JCheckBox generateCommentsCheck;\r
+\r
+ /** The check-box specifying whether attribute <em>select</em> is used in parameter elements */\r
+ private JCheckBox useParamSelectCheck;\r
+\r
+ /** The combo-box specifying encoding of output files */\r
+ private JComboBox encodingBox;\r
+\r
+ /** The combo-box specifying char of ends of lines in output files */\r
+ private JComboBox newlineBox;\r
+\r
+ /** The text-field specifying stylesheet version */\r
+ private JTextField stylesheetVersionField;\r
+\r
+ /** The text-area specifying imported stylesheet files */\r
+ private JTextArea importFileArea;\r
+\r
+ /**\r
+ * Initializes a newly created <code>StylesheetOptionForm</code>.\r
+ */\r
+ public StylesheetOptionForm() {\r
+ image = EditorIcon.createHelpIcon();\r
+\r
+ JPanel panelOne = createPanelOne();\r
+ this.add(panelOne);\r
+\r
+ JPanel panelTwo = createPanelTwo();\r
+ this.add(panelTwo);\r
+\r
+ JPanel panelThree = createPanelThree();\r
+ this.add(panelThree);\r
+ this.setPreferredSize(new Dimension(PANEL_OUTER_WIDTH, panelOne.getPreferredSize().height\r
+ + panelTwo.getPreferredSize().height + panelThree.getPreferredSize().height + 20));\r
+ }\r
+\r
+ /**\r
+ * Creates the first form panel with options of new stylesheets.\r
+ * \r
+ * @return the panel with options of new stylesheets.\r
+ */\r
+ private JPanel createPanelOne() {\r
+ JPanel panel = new JPanel();\r
+ panel.setLayout(new SpringLayout());\r
+ panel.setBorder(BorderFactory.createTitledBorder(ResourceController\r
+ .getMessage("option_save.new_file_template.title")));\r
+ optionImportedFiles(panel);\r
+ optionStylesheetVersion(panel);\r
+ optionAddFoNamespace(panel);\r
+ SpringUtilities.makeCompactGrid(panel, ROW_1_COUNT, COLUMN_COUNT, COMPONENT_MARGIN,\r
+ COMPONENT_MARGIN, COMPONENT_MARGIN, COMPONENT_MARGIN);\r
+ panel.setPreferredSize(new Dimension(PANEL_INNER_WIDTH, panel.getPreferredSize().height));\r
+ return panel;\r
+ }\r
+\r
+ /**\r
+ * Creates the second form panel with options of all stylesheets.\r
+ * \r
+ * @return the panel with options of stylesheets.\r
+ */\r
+ private JPanel createPanelTwo() {\r
+ JPanel panel = new JPanel();\r
+ panel.setLayout(new SpringLayout());\r
+ panel.setBorder(BorderFactory.createTitledBorder(ResourceController\r
+ .getMessage("option_save.stylesheet_format.title")));\r
+ optionChangeSave(panel);\r
+ optionGenerateComments(panel);\r
+ optionUseParamSelect(panel);\r
+ SpringUtilities.makeCompactGrid(panel, ROW_2_COUNT, COLUMN_COUNT, COMPONENT_MARGIN,\r
+ COMPONENT_MARGIN, COMPONENT_MARGIN, COMPONENT_MARGIN);\r
+ panel.setPreferredSize(new Dimension(PANEL_INNER_WIDTH, panel.getPreferredSize().height));\r
+ return panel;\r
+ }\r
+\r
+ /**\r
+ * Creates the third form panel with options of output files.\r
+ * \r
+ * @return the panel with options of output files.\r
+ */\r
+ private JPanel createPanelThree() {\r
+ JPanel panel = new JPanel();\r
+ panel.setLayout(new SpringLayout());\r
+ panel.setBorder(BorderFactory.createTitledBorder(ResourceController\r
+ .getMessage("option_save.output_file.title")));\r
+ optionEncoding(panel);\r
+ optionNewline(panel);\r
+ SpringUtilities.makeCompactGrid(panel, ROW_3_COUNT, COLUMN_COUNT, COMPONENT_MARGIN,\r
+ COMPONENT_MARGIN, COMPONENT_MARGIN, COMPONENT_MARGIN);\r
+ panel.setPreferredSize(new Dimension(PANEL_INNER_WIDTH, panel.getPreferredSize().height));\r
+ return panel;\r
+ }\r
+\r
+ /**\r
+ * Adds to the panel the option item specifying whether FO namespace is appended to the\r
+ * stylesheet definiton.\r
+ * \r
+ * @param panel\r
+ * the parent panel.\r
+ */\r
+ private void optionAddFoNamespace(JPanel panel) {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_save.add_fo_namespace.description"));\r
+ iconLabel.setIcon(image);\r
+ panel.add(iconLabel);\r
+ // name\r
+ panel.add(new JLabel(ResourceController.getMessage("option_save.add_fo_namespace")));\r
+ // value\r
+ addFoNamespaceCheck = new JCheckBox();\r
+ if (OptionItems.ADD_FO_NAMESPACE)\r
+ addFoNamespaceCheck.setSelected(true);\r
+ panel.add(addFoNamespaceCheck);\r
+ }\r
+\r
+ /**\r
+ * Adds to the panel the option item specifying whether the rearrange saving is used.\r
+ * \r
+ * @param panel\r
+ * the parent panel.\r
+ */\r
+ private void optionChangeSave(JPanel panel) {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_save.change_save.description"));\r
+ iconLabel.setIcon(image);\r
+ panel.add(iconLabel);\r
+ // name\r
+ panel.add(new JLabel(ResourceController.getMessage("option_save.change_save")));\r
+ // value\r
+ JPanel valuePanel = new JPanel();\r
+ valuePanel.setLayout(new BoxLayout(valuePanel, BoxLayout.LINE_AXIS));\r
+ changeSaveCheck = new JCheckBox();\r
+ if (OptionItems.REARRANGE_SAVE)\r
+ changeSaveCheck.setSelected(true);\r
+ valuePanel.add(changeSaveCheck);\r
+ valuePanel.add(Box.createRigidArea(new Dimension(10, 0)));\r
+ valuePanel\r
+ .add(new JLabel(ResourceController.getMessage("option_save.change_save.warning")));\r
+ panel.add(valuePanel);\r
+ }\r
+\r
+ /**\r
+ * Adds to the panel the option item specifying whether comments are generated in the\r
+ * stylesheet.\r
+ * \r
+ * @param panel\r
+ * the parent panel.\r
+ */\r
+ private void optionGenerateComments(JPanel panel) {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_save.generate_com.description"));\r
+ iconLabel.setIcon(image);\r
+ panel.add(iconLabel);\r
+ // name\r
+ panel.add(new JLabel(ResourceController.getMessage("option_save.generate_com")));\r
+ // value\r
+ generateCommentsCheck = new JCheckBox();\r
+ if (OptionItems.GENERATE_COMMENTS)\r
+ generateCommentsCheck.setSelected(true);\r
+ panel.add(generateCommentsCheck);\r
+ }\r
+\r
+ /**\r
+ * Adds to the panel the option item specifying whether attribute <em>select</em> is used in\r
+ * parameter elements\r
+ * \r
+ * @param panel\r
+ * the parent panel.\r
+ */\r
+ private void optionUseParamSelect(JPanel panel) {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_save.use_param_select.description"));\r
+ iconLabel.setIcon(image);\r
+ panel.add(iconLabel);\r
+ // name\r
+ panel.add(new JLabel(ResourceController.getMessage("option_save.use_param_select")));\r
+ // value\r
+ useParamSelectCheck = new JCheckBox();\r
+ if (OptionItems.USE_PARAM_SELECT)\r
+ useParamSelectCheck.setSelected(true);\r
+ panel.add(useParamSelectCheck);\r
+ }\r
+\r
+ /**\r
+ * Adds to the panel the option item specifying encoding of output files.\r
+ * \r
+ * @param panel\r
+ * the parent panel.\r
+ */\r
+ private void optionEncoding(JPanel panel) {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController.getMessage("option_save.encoding.description"));\r
+ iconLabel.setIcon(image);\r
+ panel.add(iconLabel);\r
+ // name\r
+ panel.add(new JLabel(ResourceController.getMessage("option_save.encoding")));\r
+ // value\r
+ encodingBox = new JComboBox(EncodingEnum.values());\r
+ encodingBox.setSelectedItem(EncodingEnum.getEncoding(OptionItems.ENCODING));\r
+ panel.add(encodingBox);\r
+ }\r
+\r
+ /**\r
+ * Adds to the panel the option item specifying char of ends of lines in output files.\r
+ * \r
+ * @param panel\r
+ * the parent panel.\r
+ */\r
+ private void optionNewline(JPanel panel) {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController.getMessage("option_save.newline.description"));\r
+ iconLabel.setIcon(image);\r
+ panel.add(iconLabel);\r
+ // name\r
+ panel.add(new JLabel(ResourceController.getMessage("option_save.newline")));\r
+ // value\r
+ newlineBox = new JComboBox(NewlineEnum.values());\r
+ newlineBox.setSelectedItem(OptionItems.NEWLINE);\r
+ panel.add(newlineBox);\r
+ }\r
+\r
+ /**\r
+ * Adds to the panel the option item specifying stylesheet version.\r
+ * \r
+ * @param panel\r
+ * the parent panel.\r
+ */\r
+ private void optionStylesheetVersion(JPanel panel) {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_save.stylesheet_version.description"));\r
+ iconLabel.setIcon(image);\r
+ panel.add(iconLabel);\r
+ // name\r
+ panel.add(new JLabel(ResourceController.getMessage("option_save.stylesheet_version")));\r
+ // value\r
+ stylesheetVersionField = new JTextField(OptionItems.STYLESHEET_VERSION);\r
+ panel.add(stylesheetVersionField);\r
+ }\r
+\r
+ /**\r
+ * Adds to the panel the option item specifying imported stylesheet files.\r
+ * \r
+ * @param panel\r
+ * the parent panel.\r
+ */\r
+ private void optionImportedFiles(JPanel panel) {\r
+ // interrogation mark\r
+ iconLabel = new JLabel();\r
+ iconLabel.setToolTipText(ResourceController\r
+ .getMessage("option_save.import_file.description"));\r
+ iconLabel.setIcon(image);\r
+ panel.add(iconLabel);\r
+ // name\r
+ panel.add(new JLabel(ResourceController.getMessage("option_save.import_file")));\r
+ // textarea\r
+ importFileArea = new JTextArea(3, 5);\r
+ importFileArea.setText(OptionItems.IMPORT_FILE);\r
+ importFileArea.setLineWrap(true);\r
+ importFileArea.setFont(new Font("SansSerif", Font.PLAIN, 12));\r
+ JScrollPane scrollBar = new JScrollPane(importFileArea,\r
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
+ panel.add(scrollBar);\r
+ }\r
+\r
+ /**\r
+ * Saves the changes of stylesheet options made in the dialog by user.\r
+ */\r
+ public void saveChanges() {\r
+ OptionItems.IMPORT_FILE = importFileArea.getText();\r
+ OptionItems.ADD_FO_NAMESPACE = addFoNamespaceCheck.isSelected();\r
+ OptionItems.REARRANGE_SAVE = changeSaveCheck.isSelected();\r
+ OptionItems.GENERATE_COMMENTS = generateCommentsCheck.isSelected();\r
+ OptionItems.USE_PARAM_SELECT = useParamSelectCheck.isSelected();\r
+ OptionItems.ENCODING = ((EncodingEnum) encodingBox.getSelectedItem()).getKey();\r
+ OptionItems.NEWLINE = (NewlineEnum) newlineBox.getSelectedItem();\r
+ OptionItems.STYLESHEET_VERSION = stylesheetVersionField.getText();\r
+ Log.info("info.option_form.save.save_values");\r
+ }\r
+\r
+ /**\r
+ * Sets default values to all stylesheet options in the dialog.\r
+ */\r
+ public void updateValues() {\r
+ importFileArea.setText(OptionItems.IMPORT_FILE);\r
+ addFoNamespaceCheck.setSelected(OptionItems.ADD_FO_NAMESPACE);\r
+ changeSaveCheck.setSelected(OptionItems.REARRANGE_SAVE);\r
+ generateCommentsCheck.setSelected(OptionItems.GENERATE_COMMENTS);\r
+ useParamSelectCheck.setSelected(OptionItems.USE_PARAM_SELECT);\r
+ encodingBox.setSelectedItem(EncodingEnum.getEncoding(OptionItems.ENCODING));\r
+ newlineBox.setSelectedItem(OptionItems.NEWLINE);\r
+ stylesheetVersionField.setText(OptionItems.STYLESHEET_VERSION);\r
+ Log.info(ErrorResourceController.getMessage("info.option_form.save.update_values"));\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.utils;\r
+\r
+import javax.swing.JFrame;\r
+\r
+/**\r
+ * The <code>FrameShower</code> class is used for displaying the frame in the thread safe mode.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class FrameShower implements Runnable {\r
+ /** The frame */\r
+ private final JFrame frame;\r
+\r
+ /**\r
+ * Initializes a newly created <code>FrameShower</code> with the specified frame.\r
+ * \r
+ * @param frame\r
+ * the frame.\r
+ */\r
+ public FrameShower(JFrame frame) {\r
+ this.frame = frame;\r
+ }\r
+\r
+ /**\r
+ * Launches the <code>frame</code> in the thread safe mode.\r
+ */\r
+ public void run() {\r
+ frame.pack();\r
+ frame.setVisible(true);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.utils;\r
+\r
+import java.awt.Component;\r
+import java.awt.Container;\r
+import java.awt.Dimension;\r
+import java.awt.GridLayout;\r
+import java.awt.Insets;\r
+\r
+/**\r
+ * The <code>GridLayoutUtilities</code> class is used for laying out components within a\r
+ * container in the grid.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class GridLayoutUtilities extends GridLayout {\r
+\r
+ private static final long serialVersionUID = -659668560032059816L;\r
+\r
+ /**\r
+ * Initializes a newly created <code>GridLayoutUtilities</code> with specified number of rows\r
+ * and columns.\r
+ * \r
+ * @param rows\r
+ * the number of rows.\r
+ * @param cols\r
+ * the number of columns.\r
+ */\r
+ public GridLayoutUtilities(int rows, int cols) {\r
+ this(rows, cols, 0, 0);\r
+ }\r
+\r
+ /**\r
+ * Initializes a newly created <code>GridLayoutUtilities</code> with specified number of rows\r
+ * and columns and size of gaps.\r
+ * \r
+ * @param rows\r
+ * the number of rows.\r
+ * @param cols\r
+ * the number of columns.\r
+ * @param hgap\r
+ * the size of horizontal gap.\r
+ * @param vgap\r
+ * the size of vertical gap.\r
+ */\r
+ public GridLayoutUtilities(int rows, int cols, int hgap, int vgap) {\r
+ super(rows, cols, hgap, vgap);\r
+ }\r
+\r
+ @Override\r
+ public Dimension preferredLayoutSize(Container parent) {\r
+ synchronized (parent.getTreeLock()) {\r
+ Insets insets = parent.getInsets();\r
+ int ncomponents = parent.getComponentCount();\r
+ int nrows = getRows();\r
+ int ncols = getColumns();\r
+ if (nrows > 0) {\r
+ ncols = (ncomponents + nrows - 1) / nrows;\r
+ } else {\r
+ nrows = (ncomponents + ncols - 1) / ncols;\r
+ }\r
+ int[] w = new int[ncols];\r
+ int[] h = new int[nrows];\r
+ for (int i = 0; i < ncomponents; i++) {\r
+ int r = i / ncols;\r
+ int c = i % ncols;\r
+ Component comp = parent.getComponent(i);\r
+ Dimension d = comp.getPreferredSize();\r
+ if (w[c] < d.width) {\r
+ w[c] = d.width;\r
+ }\r
+ if (h[r] < d.height) {\r
+ h[r] = d.height;\r
+ }\r
+ }\r
+ int nw = 0;\r
+ for (int j = 0; j < ncols; j++) {\r
+ nw += w[j];\r
+ }\r
+ int nh = 0;\r
+ for (int i = 0; i < nrows; i++) {\r
+ nh += h[i];\r
+ }\r
+ return new Dimension(insets.left + insets.right + nw + (ncols - 1) * getHgap(),\r
+ insets.top + insets.bottom + nh + (nrows - 1) * getVgap());\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public Dimension minimumLayoutSize(Container parent) {\r
+ synchronized (parent.getTreeLock()) {\r
+ Insets insets = parent.getInsets();\r
+ int ncomponents = parent.getComponentCount();\r
+ int nrows = getRows();\r
+ int ncols = getColumns();\r
+ if (nrows > 0) {\r
+ ncols = (ncomponents + nrows - 1) / nrows;\r
+ } else {\r
+ nrows = (ncomponents + ncols - 1) / ncols;\r
+ }\r
+ int[] w = new int[ncols];\r
+ int[] h = new int[nrows];\r
+ for (int i = 0; i < ncomponents; i++) {\r
+ int r = i / ncols;\r
+ int c = i % ncols;\r
+ Component comp = parent.getComponent(i);\r
+ Dimension d = comp.getMinimumSize();\r
+ if (w[c] < d.width) {\r
+ w[c] = d.width;\r
+ }\r
+ if (h[r] < d.height) {\r
+ h[r] = d.height;\r
+ }\r
+ }\r
+ int nw = 0;\r
+ for (int j = 0; j < ncols; j++) {\r
+ nw += w[j];\r
+ }\r
+ int nh = 0;\r
+ for (int i = 0; i < nrows; i++) {\r
+ nh += h[i];\r
+ }\r
+ return new Dimension(insets.left + insets.right + nw + (ncols - 1) * getHgap(),\r
+ insets.top + insets.bottom + nh + (nrows - 1) * getVgap());\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void layoutContainer(Container parent) {\r
+ synchronized (parent.getTreeLock()) {\r
+ Insets insets = parent.getInsets();\r
+ int ncomponents = parent.getComponentCount();\r
+ int nrows = getRows();\r
+ int ncols = getColumns();\r
+ if (ncomponents == 0) {\r
+ return;\r
+ }\r
+ if (nrows > 0) {\r
+ ncols = (ncomponents + nrows - 1) / nrows;\r
+ } else {\r
+ nrows = (ncomponents + ncols - 1) / ncols;\r
+ }\r
+ int hgap = getHgap();\r
+ int vgap = getVgap();\r
+\r
+ int[] w = new int[ncols];\r
+ int[] h = new int[nrows];\r
+ for (int i = 0; i < ncomponents; i++) {\r
+ int r = i / ncols;\r
+ int c = i % ncols;\r
+ Component comp = parent.getComponent(i);\r
+ Dimension d = comp.getPreferredSize();\r
+ w[c] = parent.getWidth();\r
+\r
+ if (h[r] < d.height) {\r
+ h[r] = d.height;\r
+ }\r
+ }\r
+ for (int c = 0, x = insets.left; c < ncols; c++) {\r
+ for (int r = 0, y = insets.top; r < nrows; r++) {\r
+ int i = r * ncols + c;\r
+ if (i < ncomponents) {\r
+ parent.getComponent(i).setBounds(x, y, w[c], h[r]);\r
+ }\r
+ y += h[r] + vgap;\r
+ }\r
+ x += w[c] + hgap;\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.utils;\r
+\r
+import java.lang.reflect.Method;\r
+\r
+import javax.swing.JOptionPane;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>OpenBrowser</code> class is used for launching the main web browser of the operating\r
+ * system.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OpenBrowser {\r
+\r
+ /**\r
+ * Launches the main web browser of any operating system (Mac, Windows or Unix).\r
+ * \r
+ * @param url\r
+ * the url of the page that will be opened in the web browser.\r
+ */\r
+ public static void openURL(String url) {\r
+ String osName = System.getProperty("os.name");\r
+ try {\r
+ if (osName.startsWith("Mac OS")) {\r
+ Class fileMgr = Class.forName("com.apple.eio.FileManager");\r
+ Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });\r
+ openURL.invoke(null, new Object[] { url });\r
+ } else if (osName.startsWith("Windows")) {\r
+ Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);\r
+ } else { // assume Unix or Linux\r
+ String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla",\r
+ "netscape" };\r
+ String browser = null;\r
+ for (int count = 0; count < browsers.length && browser == null; count++)\r
+ if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] })\r
+ .waitFor() == 0)\r
+ browser = browsers[count];\r
+ if (browser == null)\r
+ throw new Exception("Could not find web browser");\r
+ else\r
+ Runtime.getRuntime().exec(new String[] { browser, url });\r
+ }\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ JOptionPane.showMessageDialog(null, ResourceController.getMessage("error.open_browser")\r
+ + ":\n" + ex.getLocalizedMessage(), ResourceController\r
+ .getMessage("error.open_browser.title"), JOptionPane.WARNING_MESSAGE);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.utils;\r
+\r
+import java.beans.PropertyChangeEvent;\r
+import java.beans.PropertyChangeListener;\r
+\r
+import javax.swing.JDialog;\r
+import javax.swing.JFrame;\r
+import javax.swing.JOptionPane;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>OverwriteFileDialog</code> class is the dialog used for asking the user if the chosen\r
+ * file should be overwritten or not.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OverwriteFileDialog {\r
+ /** The dialog panel with options */\r
+ private final JOptionPane optionPane;\r
+\r
+ /** The single instance of the dialog */\r
+ private static OverwriteFileDialog instance;\r
+\r
+ /**\r
+ * Shows the <code>OverwriteFileDialog</code> dialog with three options : yes, no and cancel.\r
+ * \r
+ * @param frame\r
+ * the parent frame of the option dialog.\r
+ * @return the single instance of the dialog.\r
+ */\r
+ public static OverwriteFileDialog showDialog(final JFrame frame) {\r
+ instance = new OverwriteFileDialog(frame);\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Initializes and shows a newly created <code>OverwriteFileDialog</code> dialog with three\r
+ * options : yes, no and cancel.\r
+ * \r
+ * @param frame\r
+ * the parent frame of the option dialog.\r
+ */\r
+ private OverwriteFileDialog(JFrame frame) {\r
+ optionPane = new JOptionPane(ResourceController\r
+ .getMessage("save_file.dialog_file_exist.text"), JOptionPane.QUESTION_MESSAGE,\r
+ JOptionPane.YES_NO_OPTION, null, new Object[] {\r
+ ResourceController.getMessage("button.yes"),\r
+ ResourceController.getMessage("button.cancel") }, ResourceController\r
+ .getMessage("button.yes"));\r
+ final JDialog dialog = new JDialog(frame, ResourceController\r
+ .getMessage("save_file.dialog_file_exist.title"), true);\r
+ dialog.setContentPane(optionPane);\r
+ dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);\r
+\r
+ optionPane.addPropertyChangeListener(new PropertyChangeListener() {\r
+ public void propertyChange(PropertyChangeEvent e) {\r
+ String prop = e.getPropertyName();\r
+\r
+ if (dialog.isVisible() && (e.getSource() == optionPane)\r
+ && (prop.equals(JOptionPane.VALUE_PROPERTY))) {\r
+ dialog.setVisible(false);\r
+ }\r
+ }\r
+ });\r
+ dialog.pack();\r
+ dialog.setLocationRelativeTo(frame);\r
+ dialog.setVisible(true);\r
+ }\r
+\r
+ /**\r
+ * Gets the user answer chosen in the option dialog.\r
+ * \r
+ * @return true if the user has chosen the option yes.\r
+ */\r
+ public boolean getAnswer() {\r
+ String value = optionPane.getValue().toString();\r
+ if (value.equals(ResourceController.getMessage("button.yes")))\r
+ return true;\r
+ else\r
+ return false;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.utils;\r
+\r
+import java.beans.PropertyChangeEvent;\r
+import java.beans.PropertyChangeListener;\r
+\r
+import javax.swing.JDialog;\r
+import javax.swing.JFrame;\r
+import javax.swing.JOptionPane;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>OverwriteFileDialog</code> class is the dialog used for asking the user if the actual\r
+ * file should be saved or not.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class SaveFileDialog {\r
+ /** The dialog panel with options */\r
+ private JOptionPane optionPane;\r
+\r
+ /** The single instance of the dialog */\r
+ private static SaveFileDialog instance;\r
+\r
+ /**\r
+ * Shows the <code>SaveFileDialog</code> dialog with three options : yes, no and cancel.\r
+ * \r
+ * @param frame\r
+ * the parent frame of the save dialog.\r
+ * @return the single instance of the dialog.\r
+ */\r
+ public static SaveFileDialog showDialog(final JFrame frame) {\r
+ instance = new SaveFileDialog(frame);\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Initializes and shows a newly created <code>SaveFileDialog</code> dialog with three options :\r
+ * yes, no and cancel.\r
+ * \r
+ * @param frame\r
+ * the parent frame of the save dialog.\r
+ */\r
+ private SaveFileDialog(final JFrame frame) {\r
+ optionPane = new JOptionPane(ResourceController\r
+ .getMessage("save_file.dialog_save_changes.text"), JOptionPane.QUESTION_MESSAGE,\r
+ JOptionPane.YES_NO_CANCEL_OPTION, null, new Object[] {\r
+ ResourceController.getMessage("button.yes"),\r
+ ResourceController.getMessage("button.no"),\r
+ ResourceController.getMessage("button.cancel") }, ResourceController\r
+ .getMessage("button.yes"));\r
+ final JDialog dialog = new JDialog(frame, ResourceController\r
+ .getMessage("save_file.dialog_save_changes.title"), true);\r
+ dialog.setContentPane(optionPane);\r
+ dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);\r
+\r
+ optionPane.addPropertyChangeListener(new PropertyChangeListener() {\r
+ public void propertyChange(PropertyChangeEvent e) {\r
+ String prop = e.getPropertyName();\r
+\r
+ if (dialog.isVisible() && (e.getSource() == optionPane)\r
+ && (prop.equals(JOptionPane.VALUE_PROPERTY))) {\r
+ dialog.setVisible(false);\r
+ }\r
+ }\r
+ });\r
+\r
+ dialog.pack();\r
+ dialog.setLocationRelativeTo(frame);\r
+ dialog.setVisible(true);\r
+ }\r
+\r
+ /**\r
+ * Gets the user answer chosen in the save dialog.\r
+ * \r
+ * @return true if the user has chosen the option yes.\r
+ */\r
+ public Boolean getAnswer() {\r
+ String value = optionPane.getValue().toString();\r
+ if (value.equals(ResourceController.getMessage("button.yes")))\r
+ return true;\r
+ else if (value.equals(ResourceController.getMessage("button.no")))\r
+ return false;\r
+ else\r
+ return null;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.utils;\r
+\r
+import java.awt.Component;\r
+import java.awt.Container;\r
+\r
+import javax.swing.Spring;\r
+import javax.swing.SpringLayout;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>SpringUtilities</code> class is used for laying out components within a container in\r
+ * the compact grid.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class SpringUtilities {\r
+\r
+ /**\r
+ * Gets the constraints for the specified cell.\r
+ * \r
+ * @param row\r
+ * row where the cell is placed.\r
+ * @param col\r
+ * column where the cell is placed.\r
+ * @param parent\r
+ * the parent container of the cell.\r
+ * @param cols\r
+ * number of columns.\r
+ * @return the constraints for the cell.\r
+ */\r
+ private static SpringLayout.Constraints getConstraintsForCell(int row, int col,\r
+ Container parent, int cols) {\r
+ SpringLayout layout = (SpringLayout) parent.getLayout();\r
+ Component c = parent.getComponent(row * cols + col);\r
+\r
+ return layout.getConstraints(c);\r
+ }\r
+\r
+ /**\r
+ * Aligns the first <code>rows</code> * <code>cols</code> components of <code>parent</code>\r
+ * in a grid. Each component in a column is as wide as the maximum preferred width of the\r
+ * components in that column; height is similarly determined for each row. The parent is made\r
+ * just big enough to fit them all.\r
+ * \r
+ * @param rows\r
+ * number of rows.\r
+ * @param cols\r
+ * number of columns.\r
+ * @param initialX\r
+ * x location to start the grid at.\r
+ * @param initialY\r
+ * y location to start the grid at.\r
+ * @param xPad\r
+ * x padding between cells.\r
+ * @param yPad\r
+ * y padding between cells.\r
+ */\r
+ public static void makeCompactGrid(Container parent, int rows, int cols, int initialX,\r
+ int initialY, int xPad, int yPad) {\r
+ SpringLayout layout;\r
+ try {\r
+ layout = (SpringLayout) parent.getLayout();\r
+ } catch (ClassCastException exc) {\r
+ Log.error(exc);\r
+ return;\r
+ }\r
+\r
+ // Align all cells in each column and make them the same width.\r
+ Spring x = Spring.constant(initialX);\r
+ for (int c = 0; c < cols; c++) {\r
+ Spring width = Spring.constant(0);\r
+ for (int r = 0; r < rows; r++) {\r
+ width = Spring.max(width, getConstraintsForCell(r, c, parent, cols).getWidth());\r
+ }\r
+ for (int r = 0; r < rows; r++) {\r
+ SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);\r
+ constraints.setX(x);\r
+ constraints.setWidth(width);\r
+ }\r
+ x = Spring.sum(x, Spring.sum(width, Spring.constant(xPad)));\r
+ }\r
+\r
+ // Align all cells in each row and make them the same height.\r
+ Spring y = Spring.constant(initialY);\r
+ for (int r = 0; r < rows; r++) {\r
+ Spring height = Spring.constant(0);\r
+ for (int c = 0; c < cols; c++) {\r
+ height = Spring.max(height, getConstraintsForCell(r, c, parent, cols).getHeight());\r
+ }\r
+\r
+ for (int c = 0; c < cols; c++) {\r
+ SpringLayout.Constraints constraints = getConstraintsForCell(r, c, parent, cols);\r
+ constraints.setY(y);\r
+ constraints.setHeight(height);\r
+ }\r
+ y = Spring.sum(y, Spring.sum(height, Spring.constant(yPad)));\r
+ }\r
+\r
+ // Set the parent's size.\r
+ SpringLayout.Constraints pCons = layout.getConstraints(parent);\r
+ pCons.setConstraint(SpringLayout.SOUTH, y);\r
+ pCons.setConstraint(SpringLayout.EAST, x);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.utils;\r
+\r
+import java.io.File;\r
+\r
+import javax.swing.filechooser.FileFilter;\r
+\r
+/**\r
+ * The <code>XmlFilter</code> class is used for showing only XML files in the directory listing of\r
+ * a <code>JFileChooser</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class XmlFilter extends FileFilter {\r
+ /** The xml extension */\r
+ public final static String xml = "xml";\r
+\r
+ @Override\r
+ public boolean accept(File f) {\r
+ if (f.isDirectory())\r
+ return true;\r
+\r
+ String extension = getExtension(f);\r
+ if ((extension != null) && (extension.equals(xml)))\r
+ return true;\r
+\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "XML files (*.xml)";\r
+ }\r
+\r
+ /**\r
+ * Parses the file extension of the input file (part of the file name situated behind '.').\r
+ * \r
+ * @param file\r
+ * the name of the file.\r
+ * @return the extension of the file.\r
+ */\r
+ private String getExtension(File file) {\r
+ String ext = null;\r
+ int i = file.getName().lastIndexOf('.');\r
+\r
+ if (i > 0 && i < file.getName().length() - 1) {\r
+ ext = file.getName().substring(i + 1).toLowerCase();\r
+ }\r
+ return ext;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.graphics.utils;\r
+\r
+import java.io.File;\r
+\r
+import javax.swing.filechooser.FileFilter;\r
+\r
+/**\r
+ * The <code>XmlFilter</code> class is used for showing only XSL files in the directory listing of\r
+ * a <code>JFileChooser</code>.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class XslFilter extends FileFilter {\r
+ /** The xsl extension */\r
+ public final static String xsl = "xsl";\r
+\r
+ @Override\r
+ public boolean accept(File f) {\r
+ if (f.isDirectory())\r
+ return true;\r
+\r
+ String extension = getExtension(f);\r
+ if ((extension != null) && (extension.equals(xsl)))\r
+ return true;\r
+\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public String getDescription() {\r
+ return "XSL files (*.xsl)";\r
+ }\r
+\r
+ /**\r
+ * Parses the file extension of the input file (part of the file name situated behind '.').\r
+ * \r
+ * @param file\r
+ * the name of the file.\r
+ * @return the extension of the file.\r
+ */\r
+ private String getExtension(File file) {\r
+ String ext = null;\r
+ int i = file.getName().lastIndexOf('.');\r
+\r
+ if (i > 0 && i < file.getName().length() - 1) {\r
+ ext = file.getName().substring(i + 1).toLowerCase();\r
+ }\r
+ return ext;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.stylesheet;\r
+\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+\r
+/**\r
+ * The <code>FileStreamOutput</code> class is used for changing chars of ends of line (CR+LF, CR,\r
+ * LF) in the output XSL stylesheet file stream.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class FileStreamOutput extends OutputStream {\r
+ /** The output XSL file stream */\r
+ private final FileOutputStream file;\r
+\r
+ /** The char defining CR (carriage return) */\r
+ private static final int CR = 13;\r
+\r
+ /** The char defining CR (line feed) */\r
+ private static final int LF = 10;\r
+\r
+ /**\r
+ * Initializes a newly created <code>FileStreamOutput</code> with defined file output stream.\r
+ * \r
+ * @param outputStream\r
+ * the output file stream.\r
+ */\r
+ public FileStreamOutput(final FileOutputStream outputStream) {\r
+ super();\r
+ this.file = outputStream;\r
+ }\r
+\r
+ @Override\r
+ public void write(int b) throws IOException {\r
+ file.write(b);\r
+ }\r
+\r
+ @Override\r
+ public void close() throws IOException {\r
+ file.close();\r
+ super.close();\r
+ }\r
+\r
+ @Override\r
+ public void flush() throws IOException {\r
+ file.flush();\r
+ }\r
+\r
+ @Override\r
+ public void write(byte[] b, int off, int len) throws IOException {\r
+ replaceNewline(b, off, len);\r
+ }\r
+\r
+ @Override\r
+ public void write(byte[] b) throws IOException {\r
+ replaceNewline(b, 0, b.length);\r
+ }\r
+\r
+ /**\r
+ * Replaces chars at ends of lines. There are defined 3 types of chars: CR, LF, or CR+LF.\r
+ * \r
+ * @param byteArrray\r
+ * the array of byte representing a text.\r
+ * @param begin\r
+ * the begin of the actually processing part of the byte array.\r
+ * @param length\r
+ * the length of the actually processing part of the byte array.\r
+ * @throws IOException\r
+ */\r
+ private void replaceNewline(byte[] byteArrray, int begin, int length) throws IOException {\r
+ for (int i = begin; i < length; i++) {\r
+ switch (OptionItems.NEWLINE) {\r
+ case CRLF:\r
+ if ((byteArrray[i] == CR) && (byteArrray[i + 1] != LF)) {\r
+ file.write(byteArrray[i]);\r
+ file.write(LF);\r
+ } else if ((byteArrray[i] != CR) && (byteArrray.length > (i + 1))\r
+ && (byteArrray[i + 1] == LF)) {\r
+ file.write(byteArrray[i]);\r
+ file.write(CR);\r
+ } else {\r
+ file.write(byteArrray[i]);\r
+ }\r
+ break;\r
+ case CR:\r
+ if (byteArrray[i] != LF)\r
+ file.write(byteArrray[i]);\r
+ break;\r
+ case LF:\r
+ if (byteArrray[i] != CR)\r
+ file.write(byteArrray[i]);\r
+ break;\r
+ default:\r
+ file.write(byteArrray[i]);\r
+ }\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.stylesheet;\r
+\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>OpenFileHadler</code> class contains methods for processing elements of loading XSL\r
+ * stylesheet files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class OpenFileHadler {\r
+\r
+ /**\r
+ * Parses node 'parameter' and its value in the input XSL file.\r
+ * \r
+ * @param node\r
+ * the node 'parameter' in the input XSL file.\r
+ * @param line\r
+ * the number of line where is the node 'parameter' in the input XSL file.\r
+ * @param data\r
+ * the data containing editor data structure.\r
+ */\r
+ public static void parserParameterTag(Element node, int line, ConfigData data) {\r
+ String paramName = null;\r
+ String paramValue = null;\r
+ try {\r
+ paramName = node.getAttributeNode(XslTagConst.NAME).getNodeValue();\r
+ // param has both - select and text value\r
+ if (node.hasAttribute(XslTagConst.SELECT) && (node.hasChildNodes()))\r
+ throw new ParserException();\r
+\r
+ if (node.hasAttribute(XslTagConst.SELECT))\r
+ paramValue = node.getAttribute(XslTagConst.SELECT);\r
+ else {\r
+ Node text = node.getFirstChild(); // Text\r
+ paramValue = text.getNodeValue().toString();\r
+ }\r
+\r
+ Parameter param = data.searchParameter(paramName);\r
+ if (param != null) {\r
+ parserValue(param.getType(), paramValue);\r
+ param.setNode(node);\r
+ param.setChosen();\r
+ } else {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "open_file.parameter_exist", line, paramName));\r
+ }\r
+ } catch (Throwable ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage("open_file.parameter_invalid",\r
+ line, paramName));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Parses node 'attribute-set' and its value in the input XSL file.\r
+ * \r
+ * @param node\r
+ * the node 'attribute-set' in the input XSL file.\r
+ * @param line\r
+ * the number of line where is the node 'attribute-set' in the input XSL file.\r
+ * @param data\r
+ * the data containing editor data structure.\r
+ * @return the editor property corresponding to the node 'attribute-set'\r
+ */\r
+ public static Property parserPropertyTag(Element node, int line, ConfigData data) {\r
+ String propName = null;\r
+ Property prop = null;\r
+ try {\r
+ propName = node.getAttributeNode(XslTagConst.NAME).getNodeValue();\r
+\r
+ prop = data.searchProperty(propName);\r
+ if (prop != null) {\r
+ prop.setNode(node);\r
+ prop.setChosen();\r
+ } else\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "open_file.attribute_set_exist", line, propName));\r
+\r
+ } catch (Throwable ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "open_file.attribute_set_invalid", line, propName));\r
+ }\r
+ return prop;\r
+ }\r
+\r
+ /**\r
+ * Parses node 'attribute' of the node 'attribute-set' and its value in the input XSL file.\r
+ * \r
+ * @param node\r
+ * the node 'attribute' in the input XSL file.\r
+ * @param line\r
+ * the number of line where is the node 'attribute' in the input XSL file.\r
+ * @param propery\r
+ * the parent property of attribute.\r
+ */\r
+ public static void parserPropertyAttribute(Element node, int line, Property propery) {\r
+ String attrName = null;\r
+ String attrValue = null;\r
+ try {\r
+ attrName = node.getAttributeNode(XslTagConst.NAME).getNodeValue();\r
+ Node text = node.getFirstChild(); // Text\r
+ attrValue = text.getNodeValue().toString();\r
+\r
+ Attribute attr = propery.searchAttribute(attrName);\r
+ if (attr != null) {\r
+ parserValue(attr.getType(), attrValue);\r
+ attr.setChosen(true);\r
+ attr.setNode(node);\r
+ } else\r
+ MessageWriter.writeWarning(ResourceController.getMessage(\r
+ "open_file.attribute_exist", line, attrName));\r
+\r
+ } catch (Throwable ex) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage("open_file.attribute_invalid",\r
+ line, attrName));\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Parses the value of node 'parameter' and assignes it to the corresponding parameter.\r
+ * <code>Type</code>.\r
+ * \r
+ * @param type\r
+ * the type of parameter.\r
+ * @param typeValue\r
+ * the new value of the type.\r
+ * @throws ParserException\r
+ * if the new value is not valid.\r
+ */\r
+ private static void parserValue(Type type, String typeValue) throws ParserException {\r
+ typeValue = typeValue.trim().replaceAll("'", "");\r
+ type.setLoadedValue(typeValue);\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.stylesheet;\r
+\r
+import org.w3c.dom.Comment;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.Text;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.common.ParentParameter;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.TypeParam;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.beans.properties.AttributeGroup;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.beans.properties.TypeAttr;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Group;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Section;\r
+import cz.zcu.fav.kiv.editor.beans.sections.Subsection;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+\r
+/**\r
+ * The <code>SaveFileHandler</code> class contains methods for saving changes of actually opened\r
+ * XSL stylesheet file.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class SaveFileHandler {\r
+\r
+ /**\r
+ * Saves changes of actually opened XSL stylesheet file.\r
+ * \r
+ * @param doc\r
+ * DOM structure of the opened XSL document.\r
+ * @param data\r
+ * the data containing editor data structure.\r
+ */\r
+ public static void saveStylesheet(Document doc, ConfigData data) {\r
+ Node stylesheet = doc.getElementsByTagName(XslTagConst.STYLESHEET).item(0);\r
+ Node firstNode = null;\r
+ boolean newInSection;\r
+ boolean isInserted = false;\r
+ for (Section section : data.getSectionList()) { \r
+ for (Subsection subsection : section.getSubsectionList()) {\r
+ if ((OptionItems.REARRANGE_SAVE)&&(subsection.getComment() != null))\r
+ subsection.setComment(null); \r
+ firstNode = null;\r
+ newInSection = false;\r
+ for (Group gr : subsection.getGroupList()) {\r
+ for (ParentParameter elem : gr.getElementList()) {\r
+ if (elem instanceof Parameter) {\r
+ if (OptionItems.REARRANGE_SAVE)\r
+ isInserted = rearrangeParameter((Parameter) elem, doc, stylesheet);\r
+ else {\r
+ isInserted = changeParameter((Parameter) elem, doc, stylesheet, subsection.getComment()); \r
+ } \r
+ }\r
+ if (elem instanceof Property) {\r
+ isInserted = changeProperty((Property) elem, doc, stylesheet, subsection.getComment()); \r
+ }\r
+ if (elem.getNode() != null) {\r
+ //first node inserted in section -> insert comment\r
+ if ((isInserted)&&(!newInSection)) { \r
+ newInSection = true;\r
+ firstNode = elem.getNode(); \r
+ }\r
+ }\r
+ }\r
+ }\r
+ //has comment?\r
+ if ((OptionItems.GENERATE_COMMENTS) && (firstNode != null)\r
+ && (subsection.getComment() == null)\r
+ && (newInSection)) { \r
+ Comment comment = doc.createComment(" " + section.getTitle() + " :: "\r
+ + subsection.getTitle() + " ");\r
+ subsection.setComment(comment);\r
+ stylesheet.insertBefore(comment, firstNode); \r
+ }\r
+ //remove comment - no parameters\r
+ if ((subsection.getComment() != null)\r
+ && (subsection.getComment().getNextSibling() instanceof Comment)) { \r
+ XslParser.removeNode(subsection.getComment());\r
+ subsection.setComment(null); \r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Changes the parameter value and places the parameter at the end of stylesheet file.\r
+ * \r
+ * @param param\r
+ * the changing parameter.\r
+ * @param doc\r
+ * DOM structure of the opened XSL document.\r
+ * @param stylesheet\r
+ * the node of 'stylesheet' element.\r
+ * @return true if the parameter was inserted at the end of stylesheet.\r
+ */\r
+ private static boolean rearrangeParameter(Parameter param, Document doc, Node stylesheet) {\r
+ if (param.getNode() != null) {\r
+ XslParser.removeNode(param.getNode());\r
+ param.setNode(null);\r
+ }\r
+ // add node at the end\r
+ return addNewParameter(param, doc, stylesheet, null);\r
+ }\r
+\r
+ /**\r
+ * Change parameter value in the opened stylesheet file. If the parameter is yet in the opened\r
+ * stylesheet then it is inserted at the end of stylesheet.\r
+ * \r
+ * @param param\r
+ * the changing parameter.\r
+ * @param doc\r
+ * DOM structure of the opened XSL document.\r
+ * @param stylesheet\r
+ * the node of 'stylesheet' element.\r
+ * @param lastNode\r
+ * the last node of the same subsection. \r
+ * @return true if the parameter was inserted at the end of stylesheet.\r
+ */\r
+ private static boolean changeParameter(Parameter param, Document doc, Node stylesheet, Node lastNode) {\r
+ if (param.getNode() != null) {\r
+ if (!param.isChosen()) {\r
+ XslParser.removeNode(param.getNode());\r
+ param.setNode(null);\r
+ } else {\r
+ Node newNode = createParamElement(param, doc);\r
+ param.getNode().getParentNode().replaceChild(newNode, param.getNode());\r
+ param.setNode(newNode);\r
+ }\r
+ return false;\r
+ }\r
+ return addNewParameter(param, doc, stylesheet, lastNode);\r
+ }\r
+\r
+ /**\r
+ * Inserts a new parameter at the end of stylesheet file \r
+ * or after the 'lastNode' it it is not null.\r
+ * \r
+ * @param param\r
+ * the changing parameter.\r
+ * @param doc\r
+ * DOM structure of the opened XSL document.\r
+ * @param stylesheet\r
+ * the node of 'stylesheet' element.\r
+ * @param lastNode\r
+ * the last node of the same subsection. \r
+ * @return true if the parameter was inserted at the end of stylesheet file.\r
+ */\r
+ private static boolean addNewParameter(Parameter param, Document doc, Node stylesheet, Node lastNode) {\r
+ if (param.isChosen()) {\r
+ Node node = createParamElement(param, doc);\r
+ if (lastNode != null)\r
+ stylesheet.insertBefore(node, lastNode.getNextSibling());\r
+ else\r
+ stylesheet.appendChild(node);\r
+ param.setNode(node);\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * Changes or inserts property in the stylesheet file.\r
+ * \r
+ * @param prop\r
+ * the changing property.\r
+ * @param doc\r
+ * DOM structure of the opened XSL document.\r
+ * @param stylesheet\r
+ * the node of 'stylesheet' element.\r
+ * @return true if the property was inserted at the end of stylesheet file.\r
+ */\r
+ private static boolean changeProperty(Property prop, Document doc, Node stylesheet, Node lastNode) {\r
+ if ((prop.getNode() == null) && (prop.isChosen())) {\r
+ Element attrSetElem = doc.createElement(XslTagConst.ATTRIBUTE_SET);\r
+ attrSetElem.setAttribute(XslTagConst.NAME, prop.getName());\r
+ changeAttributes(prop.getAttributeGroupList(), attrSetElem, doc);\r
+ // add new property\r
+ if (attrSetElem.getChildNodes().getLength() > 0) {\r
+ if (lastNode != null)\r
+ stylesheet.insertBefore(attrSetElem, lastNode.getNextSibling());\r
+ else\r
+ stylesheet.appendChild(attrSetElem);\r
+ prop.setNode(attrSetElem);\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+ // property is not chosen and was in the opened stylesheet file\r
+ if ((prop.getNode() != null) && (!prop.isChosen())) {\r
+ XslParser.removeNode(prop.getNode());\r
+ return false;\r
+ }\r
+\r
+ if ((prop.getNode() != null) && (prop.isChosen())) {\r
+ changeAttributes(prop.getAttributeGroupList(), prop.getNode(), doc);\r
+ // move property to the end\r
+ if (OptionItems.REARRANGE_SAVE) {\r
+ stylesheet.appendChild(prop.getNode());\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ /**\r
+ * Changes property attributes and their values.\r
+ * \r
+ * @param attributeGroups\r
+ * the groups of attributes of the parent property.\r
+ * @param parent\r
+ * the node of parent property.\r
+ * @param doc\r
+ * DOM structure of the opened XSL document.\r
+ */\r
+ private static void changeAttributes(AttributeGroup[] attributeGroups, Node parent, Document doc) {\r
+ Node node;\r
+ for (AttributeGroup panel : attributeGroups)\r
+ for (Attribute attr : panel.getAttributeList()) {\r
+ if (attr.isChosen()) {\r
+ if (attr.getNode() != null) {\r
+ attr.getNode().setTextContent(createNewValueAttr(attr.getType()));\r
+ } else {\r
+ node = createAttributeElement(attr, doc);\r
+ parent.appendChild(node);\r
+ attr.setNode(node);\r
+ }\r
+ } else {\r
+ if (attr.getNode() != null) {\r
+ XslParser.removeNode(attr.getNode());\r
+ attr.setNode(null);\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Creates a new node from parameter.\r
+ * \r
+ * @param param\r
+ * the parameter used for creating the node.\r
+ * @param doc\r
+ * DOM structure of the opened XSL document.\r
+ * @return the new parameter node.\r
+ */\r
+ private static Element createParamElement(Parameter param, Document doc) {\r
+ Element paramElem = doc.createElement(XslTagConst.PARAM);\r
+ // name\r
+ paramElem.setAttribute(XslTagConst.NAME, param.getName());\r
+\r
+ String paramValue = createNewValueParam(param.getType());\r
+\r
+ if (OptionItems.USE_PARAM_SELECT) {\r
+ paramElem.setAttribute(XslTagConst.SELECT, addApostrophe(paramValue));\r
+ } else {\r
+ Text text = doc.createTextNode(paramValue);\r
+ paramElem.appendChild(text);\r
+ }\r
+\r
+ return paramElem;\r
+ }\r
+\r
+ /**\r
+ * Creates a new node from attribute.\r
+ * \r
+ * @param attr\r
+ * the attribute used for creating the node.\r
+ * @param doc\r
+ * DOM structure of the opened XSL document.\r
+ * @return the new attribute node.\r
+ */\r
+ private static Element createAttributeElement(Attribute attr, Document doc) {\r
+ Element element = doc.createElement(XslTagConst.ATTRIBUTE);\r
+\r
+ Text text = doc.createTextNode(createNewValueAttr(attr.getType()));\r
+ element.appendChild(text);\r
+\r
+ // name\r
+ element.setAttribute(XslTagConst.NAME, attr.getName());\r
+ return element;\r
+ }\r
+\r
+ /**\r
+ * Creates a new value content of the parameter node.\r
+ * \r
+ * @param type\r
+ * the parameter type with value.\r
+ * @return the new value content of the parameter node.\r
+ */\r
+ private static String createNewValueParam(TypeParam type) {\r
+ StringBuilder value = new StringBuilder(type.getValue());\r
+ if (type.getUnit() != null)\r
+ value.append(type.getUnit().getValue());\r
+ return value.toString();\r
+ }\r
+\r
+ /**\r
+ * Creates a new value content of the attribute node.\r
+ * \r
+ * @param types\r
+ * the attribute type with value.\r
+ * @return the new value content of the attribute node.\r
+ */\r
+ private static String createNewValueAttr(TypeAttr type) {\r
+ StringBuilder attrValue = new StringBuilder();\r
+ attrValue.append(type.getValue().toString());\r
+ if (type.getUnit() != null)\r
+ attrValue.append(type.getUnit().getValue());\r
+\r
+ return attrValue.toString().trim();\r
+ }\r
+\r
+ /**\r
+ * Adds apostrophes around the value if the value isnt't a number.\r
+ * \r
+ * @param value\r
+ * the changing value.\r
+ * @return value with apostrophes if the value isn't a number.\r
+ */\r
+ private static String addApostrophe(String value) {\r
+ try {\r
+ Float.parseFloat(value);\r
+ } catch (NumberFormatException e) {\r
+ value = "'" + value.trim() + "'";\r
+ }\r
+ return value;\r
+ }\r
+ \r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.stylesheet;\r
+\r
+import java.io.File;\r
+import java.io.FileOutputStream;\r
+import java.io.OutputStreamWriter;\r
+import java.nio.charset.Charset;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import javax.xml.parsers.DocumentBuilder;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+import javax.xml.parsers.ParserConfigurationException;\r
+import javax.xml.parsers.SAXParser;\r
+import javax.xml.parsers.SAXParserFactory;\r
+import javax.xml.transform.OutputKeys;\r
+import javax.xml.transform.Transformer;\r
+import javax.xml.transform.TransformerFactory;\r
+import javax.xml.transform.dom.DOMSource;\r
+import javax.xml.transform.stream.StreamResult;\r
+\r
+import org.w3c.dom.DOMImplementation;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.traversal.DocumentTraversal;\r
+import org.w3c.dom.traversal.NodeFilter;\r
+import org.w3c.dom.traversal.NodeIterator;\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.XMLReader;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.controller.errors.OpenFileException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.SaveFileException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.XslParserException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.options.OptionItems;\r
+\r
+/**\r
+ * The <code>XslParser</code> class contains methods for reading and saving XSL stylesheet files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class XslParser {\r
+\r
+ /** The size of indent used in output XSL files */\r
+ public static final int INDENT = 2;\r
+\r
+ /**\r
+ * Opens and reads the input XSL file. Creates a DOM structure of the opened XSL document.\r
+ * \r
+ * @param file\r
+ * the name of the XSL file that will be opened.\r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @return DOM structure of the opened XSL document.\r
+ * @throws OpenFileException\r
+ * if the file cannot be opened.\r
+ */\r
+ public static Document readXsltFile(String file, ConfigData configData)\r
+ throws OpenFileException {\r
+ Document doc = null;\r
+ try {\r
+ SAXParserFactory spf = SAXParserFactory.newInstance();\r
+ spf.setValidating(false);\r
+ spf.setNamespaceAware(true);\r
+\r
+ SAXParser sp = spf.newSAXParser();\r
+ XMLReader parser = sp.getXMLReader();\r
+ parser.setErrorHandler(new XslParserException());\r
+\r
+ XsltFileHandler handler = new XsltFileHandler(configData);\r
+ parser.setContentHandler(handler);\r
+ parser.setProperty("http://xml.org/sax/properties/lexical-handler", handler);\r
+ parser.setProperty("http://xml.org/sax/properties/declaration-handler", handler);\r
+\r
+ parser.parse(file);\r
+\r
+ doc = handler.getDocument();\r
+ } catch (SAXException ex) {\r
+ Log.error(ex);\r
+ throw new OpenFileException(ex.getMessage());\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ throw new OpenFileException();\r
+ }\r
+ return doc;\r
+ }\r
+\r
+ /**\r
+ * Saves changes of actually opened XSL stylesheet file and saves the DOM structure to the XSL file.\r
+ * \r
+ * @param file\r
+ * the name of the XSL file that will be saved.\r
+ * @param document\r
+ * the DOM structure of the file that will be saved.\r
+ * @throws SaveFileException\r
+ * if the file cannot be saved.\r
+ */\r
+ public static void saveXsltFile(String file, Document document, ConfigData configData) throws SaveFileException {\r
+ SaveFileHandler.saveStylesheet(document, configData);\r
+ try {\r
+ TransformerFactory tf = TransformerFactory.newInstance();\r
+ tf.setAttribute("indent-number", INDENT);\r
+ Transformer writer = tf.newTransformer();\r
+ writer.setOutputProperty(OutputKeys.INDENT, "yes");\r
+ writer.setOutputProperty("encoding", OptionItems.ENCODING);\r
+\r
+ writer.setOutputProperty(OutputKeys.METHOD, "xml");\r
+\r
+ OutputStreamWriter osw = new OutputStreamWriter(new FileStreamOutput(\r
+ new FileOutputStream(new File(file))), Charset.forName(OptionItems.ENCODING));\r
+\r
+ writer.transform(new DOMSource(document), new StreamResult(osw));\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ throw new SaveFileException(ex);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Creates a new DOM structure of an empty XSL stylesheet.\r
+ * \r
+ * @return a DOM structure of an empty XSL stylesheet.\r
+ */\r
+ public static Document createXsltFile() {\r
+ Document doc = null;\r
+ try {\r
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
+ DocumentBuilder builder = dbf.newDocumentBuilder();\r
+ DOMImplementation impl = builder.getDOMImplementation();\r
+ doc = impl.createDocument(OptionItems.XSL_NAMESPACE, "xsl:stylesheet", null);\r
+ // XSL namespace\r
+ Element element = doc.getDocumentElement();\r
+ element.setAttribute("xmlns:xsl", OptionItems.XSL_NAMESPACE);\r
+ // FO namespace\r
+ if (OptionItems.ADD_FO_NAMESPACE)\r
+ element.setAttribute("xmlns:fo", OptionItems.FO_NAMESPACE);\r
+ element.setAttribute("version", OptionItems.STYLESHEET_VERSION);\r
+\r
+ // add imports\r
+ addImportFiles(doc);\r
+ } catch (ParserConfigurationException ex) {\r
+ Log.error(ex);\r
+ }\r
+ return doc;\r
+ }\r
+\r
+ /**\r
+ * Adds to the DOM structure elements defining import of other XSL stylesheets.\r
+ * \r
+ * @param document\r
+ * the DOM structure of the XSL stylesheet.\r
+ */\r
+ private static void addImportFiles(Document document) {\r
+ Element importElem;\r
+ int lastChar = 0;\r
+ Pattern pattern = Pattern.compile(";");\r
+ Matcher matcher = pattern.matcher(OptionItems.IMPORT_FILE);\r
+ while (matcher.find()) {\r
+ importElem = document.createElement("xsl:import");\r
+ importElem.setAttribute("href", OptionItems.IMPORT_FILE.substring(lastChar,\r
+ matcher.start()).trim());\r
+ lastChar = matcher.end();\r
+ document.getDocumentElement().appendChild(importElem);\r
+ }\r
+ if (lastChar < OptionItems.IMPORT_FILE.trim().length()) {\r
+ importElem = document.createElement("xsl:import");\r
+ importElem.setAttribute("href", OptionItems.IMPORT_FILE.substring(lastChar,\r
+ OptionItems.IMPORT_FILE.trim().length()));\r
+ document.getDocumentElement().appendChild(importElem);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Removes all comments in DOM structure of the XSL stylesheet.\r
+ * \r
+ * @param document\r
+ * the DOM structure of the XSL stylesheet.\r
+ */\r
+ public static void removeComments(Document document) {\r
+ NodeIterator nodeList = ((DocumentTraversal) document).createNodeIterator(document\r
+ .getDocumentElement(), NodeFilter.SHOW_COMMENT, null, false);\r
+ Node comment;\r
+ List<Node> commentList = new ArrayList<Node>();\r
+ while ((comment = nodeList.nextNode()) != null)\r
+ commentList.add(comment);\r
+ removeNodes(commentList);\r
+ }\r
+\r
+ /**\r
+ * Removes all nodes from the list.\r
+ * \r
+ * @param nodeList\r
+ * the list of nodes that will be removed.\r
+ */\r
+ public static void removeNodes(List<Node> nodeList) {\r
+ for (Node node : nodeList) {\r
+ removeNode(node);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Remove the input node.\r
+ * \r
+ * @param node\r
+ * the node that will be removed.\r
+ */\r
+ public static void removeNode(Node node) {\r
+ node.getParentNode().removeChild(node);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.stylesheet;\r
+\r
+/**\r
+ * The <code>XslTagConst</code> class contains elements used in XSL stylesheet files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class XslTagConst {\r
+ public static final String STYLESHEET = "xsl:stylesheet";\r
+\r
+ public static final String IMPORT = "xsl:import";\r
+\r
+ public static final String HREF = "href";\r
+\r
+ public static final String PARAM = "xsl:param";\r
+\r
+ public static final String NAME = "name";\r
+\r
+ public static final String SELECT = "select";\r
+\r
+ public static final String ATTRIBUTE_SET = "xsl:attribute-set";\r
+\r
+ public static final String ATTRIBUTE = "xsl:attribute";\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.stylesheet;\r
+\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+import java.util.Stack;\r
+import javax.xml.parsers.DocumentBuilder;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+\r
+import org.w3c.dom.Comment;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+import org.w3c.dom.Text;\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.ContentHandler;\r
+import org.xml.sax.DTDHandler;\r
+import org.xml.sax.Locator;\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.ext.DeclHandler;\r
+\r
+import org.xml.sax.ext.LexicalHandler;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>XsltFileHandler</code> class reads the input XSL stylesheet file element by element and creates from them a DOM structure.\r
+ * Simultaneously reports all errros in the input XSL file.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class XsltFileHandler extends DefaultHandler implements ContentHandler, LexicalHandler,\r
+ DeclHandler, DTDHandler {\r
+ private ConfigData data;\r
+\r
+ // locator\r
+ private Locator locator;\r
+\r
+ private Document document;\r
+\r
+ private Element element = null;\r
+\r
+ private Element stylesheet;\r
+\r
+ private Comment comment;\r
+\r
+ private Stack<Element> stack;\r
+\r
+ private int parameterBeginLine;\r
+\r
+ private int attributeBeginLine;\r
+\r
+ private Property property;\r
+\r
+ private Map<String, String> namespaces;\r
+ \r
+ private boolean insideCDATA;\r
+\r
+ // string buffers\r
+ private StringBuffer commentBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ private StringBuffer elementBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+ \r
+ private StringBuffer cdataBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ public XsltFileHandler(ConfigData data) {\r
+ super();\r
+ this.data = data;\r
+ }\r
+\r
+ public void startDocument() {\r
+ try {\r
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
+ DocumentBuilder builder = dbf.newDocumentBuilder();\r
+\r
+ document = builder.newDocument();\r
+ stylesheet = document.createElement(XslTagConst.STYLESHEET);\r
+ } catch (Exception ex) {\r
+\r
+ }\r
+ stack = new Stack<Element>();\r
+ namespaces = new HashMap<String, String>();\r
+ }\r
+\r
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts)\r
+ throws SAXException {\r
+ if (qName.equals(XslTagConst.STYLESHEET)) {\r
+ //attributes\r
+ if (atts.getLength() > 0)\r
+ appendAttributes(stylesheet, atts);\r
+ \r
+ // namespaces\r
+ if (namespaces.size() > 0) {\r
+ appendNamespaces(stylesheet);\r
+ }\r
+\r
+ document.appendChild(stylesheet);\r
+ stack.push(stylesheet);\r
+ } else {\r
+ if (stack.empty())\r
+ throw new SAXException(ResourceController\r
+ .getMessage("open_file.stylesheet_invalid"));\r
+ element = document.createElement(qName);\r
+ //attributes\r
+ if (atts.getLength() > 0)\r
+ appendAttributes(element, atts);\r
+ \r
+ // namespaces\r
+ if (namespaces.size() > 0) \r
+ appendNamespaces(element);\r
+ \r
+ stack.peek().appendChild(element);\r
+ stack.push(element);\r
+ }\r
+\r
+ if (qName.equals(XslTagConst.PARAM)) {\r
+ parameterBeginLine = locator.getLineNumber();\r
+ } else if (qName.equals(XslTagConst.ATTRIBUTE)) {\r
+ attributeBeginLine = locator.getLineNumber();\r
+ } else if ((qName.equals(XslTagConst.ATTRIBUTE_SET))\r
+ && (stack.peek().getParentNode().getNodeName().equals(XslTagConst.STYLESHEET))) {\r
+ property = OpenFileHadler\r
+ .parserPropertyTag(stack.peek(), locator.getLineNumber(), data);\r
+ }\r
+\r
+ elementBuffer.setLength(0);\r
+ }\r
+\r
+ private void appendNamespaces(Element node) {\r
+ for (Iterator it = namespaces.entrySet().iterator(); it.hasNext();) {\r
+ Map.Entry entry = (Map.Entry) it.next();\r
+ if (entry.getKey().toString().length() > 0)\r
+ node.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:"\r
+ + entry.getKey().toString(), entry.getValue().toString());\r
+ else\r
+ node.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", entry.getValue()\r
+ .toString());\r
+ }\r
+ namespaces = new HashMap<String, String>();\r
+ }\r
+ \r
+ private void appendAttributes(Element node, Attributes atts) {\r
+ for (int i = 0; i < atts.getLength(); i++) {\r
+ node.setAttribute(atts.getQName(i), atts.getValue(i));\r
+ }\r
+ }\r
+\r
+ public void endElement(String namespaceURI, String localName, String qName) {\r
+ if (elementBuffer.length() > 0) {\r
+ if (elementBuffer.toString().trim().length() > 0) {\r
+ Text text = document.createTextNode(elementBuffer.toString().trim());\r
+ stack.peek().appendChild(text);\r
+ }\r
+ elementBuffer.setLength(0);\r
+ }\r
+\r
+ if (qName.equals(XslTagConst.PARAM)\r
+ && (stack.peek().getParentNode().getNodeName().equals(XslTagConst.STYLESHEET))) {\r
+ OpenFileHadler.parserParameterTag(stack.peek(), parameterBeginLine, data);\r
+ } else if (qName.equals(XslTagConst.ATTRIBUTE_SET)) {\r
+ property = null;\r
+ } else if ((qName.equals(XslTagConst.ATTRIBUTE)) && (property != null)) {\r
+ OpenFileHadler.parserPropertyAttribute(stack.peek(), attributeBeginLine, property);\r
+ }\r
+\r
+ stack.pop();\r
+ }\r
+\r
+ public void characters(char[] ch, int start, int length) {\r
+ if (insideCDATA)\r
+ cdataBuffer.append(ch, start, length);\r
+ else\r
+ elementBuffer.append(ch, start, length);\r
+ }\r
+\r
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {\r
+ namespaces.put(prefix, uri);\r
+ }\r
+\r
+ public void setDocumentLocator(Locator locator) {\r
+ this.locator = locator;\r
+ }\r
+\r
+ public void comment(char[] ch, int start, int length) throws SAXException {\r
+ commentBuffer.append(ch, start, length);\r
+ comment = document.createComment(commentBuffer.toString());\r
+ if (!stack.empty())\r
+ stack.peek().appendChild(comment);\r
+ else\r
+ document.appendChild(comment);\r
+ commentBuffer.setLength(0);\r
+ }\r
+\r
+ public void endCDATA() throws SAXException {\r
+ insideCDATA = false;\r
+ stack.peek().appendChild(document.createCDATASection(cdataBuffer.toString()));\r
+ cdataBuffer.setLength(0);\r
+ }\r
+\r
+ public void endDTD() throws SAXException {\r
+ }\r
+\r
+ public void endEntity(String name) throws SAXException {\r
+ }\r
+\r
+ public void startCDATA() throws SAXException {\r
+ insideCDATA = true;\r
+ }\r
+\r
+ public void startDTD(String name, String publicId, String systemId) throws SAXException {\r
+ }\r
+\r
+ public void startEntity(String name) throws SAXException {\r
+ }\r
+\r
+ public Document getDocument() {\r
+ return document;\r
+ }\r
+\r
+ public void attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4)\r
+ throws SAXException {\r
+ }\r
+\r
+ public void elementDecl(String arg0, String arg1) throws SAXException {\r
+ }\r
+\r
+ public void externalEntityDecl(String arg0, String arg1, String arg2) throws SAXException {\r
+ }\r
+\r
+ public void internalEntityDecl(String arg0, String arg1) throws SAXException {\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.template;\r
+\r
+import java.io.File;\r
+\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+\r
+/**\r
+ * The <code>TemplateConst</code> class contains enumarated lists of elements used in XML template\r
+ * and XML schema of the template and path and name of the default template.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TemplateConst {\r
+ /** The size of buffer used for reading element contents */\r
+ public static int BUFFER_SIZE = 300;\r
+\r
+ /** The directory where default template is stored */\r
+ public static final String CONF_FILE_TEMPLATE_DIR = "templates" + File.separator;\r
+\r
+ /** The file with default template */\r
+ public static final String CONF_FILE_TEMPLATE = CONF_FILE_TEMPLATE_DIR + "template.xml";\r
+\r
+ /** The XML schema of the file with default template */\r
+ public static final String CONF_FILE_TEMPLATE_XSD = FileConst.CONF_FILE_XSD_DIR\r
+ + "template.xsd";\r
+\r
+ /**\r
+ * The enumerated list of elements used in templates.\r
+ */\r
+ public static enum TemplateTags {\r
+ ATTRIBUTE_SET("attribute-set"), ATTRIBUTE("attribute"), PARAMETER("parameter");\r
+\r
+ String value;\r
+ \r
+ TemplateTags(String value) {\r
+ this.value = value;\r
+ }\r
+ \r
+ /**\r
+ * Returns predefined constant of element according to the element name.\r
+ * \r
+ * @param key\r
+ * the name of element.\r
+ * @return a constant of element with defined name.\r
+ */\r
+ public static TemplateTags getValue(String key) {\r
+ for (TemplateTags type : values()) {\r
+ if (type.value.equals(key))\r
+ return type;\r
+ }\r
+ return null;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.template;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ConfigException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.FileNotFoundException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+\r
+/**\r
+ * The <code>TemplateController</code> class contains method for reading templates.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TemplateController {\r
+\r
+ /** The instance of <code>TemplateController</code> */\r
+ private static TemplateController instance;\r
+\r
+ /**\r
+ * Static methods return instance of <code>TemplateController</code>. If the\r
+ * <code>instance</code> is null, initializes a new one.\r
+ * \r
+ * @return the instance of <code>TemplateController</code>.\r
+ */\r
+ public static TemplateController getInstance() {\r
+ if (instance != null)\r
+ return instance;\r
+ return new TemplateController();\r
+ }\r
+\r
+ /** The parser of XML templates */\r
+ private TemplateParser parser;\r
+\r
+ /**\r
+ * Initializes a newly created <code>TemplateController</code>. Simultaneously initializes\r
+ * new <code>TemplateParser</code>.\r
+ */\r
+ private TemplateController() {\r
+ parser = new TemplateParser();\r
+ }\r
+\r
+ /**\r
+ * Reads a template defined by its path <code>templateFile</code>.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param templateFile\r
+ * the path to the file with template.\r
+ * @throws ConfigException\r
+ * if the template or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the template or its XML schema doesn't exist.\r
+ */\r
+ public void readTemplate(ConfigData configData, String templateFile) throws ConfigException,\r
+ FileNotFoundException {\r
+ MessageWriter.writeInfo(ResourceController.getMessage(\r
+ "new_file_template.load_template.title", TemplateConst.CONF_FILE_TEMPLATE));\r
+ parser.readTemplate(configData, templateFile);\r
+ Log.info("info.template_control.load_template", TemplateConst.CONF_FILE_TEMPLATE);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.template;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
+import javax.xml.parsers.SAXParser;\r
+import javax.xml.parsers.SAXParserFactory;\r
+\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.XMLReader;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ConfigException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.FileNotFoundException;\r
+import cz.zcu.fav.kiv.editor.controller.errors.XslParserException;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>TemplateParser</code> class contains method for parsing template files.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TemplateParser {\r
+ /** The parser key defining XML schema language */\r
+ private static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";\r
+\r
+ /** The constants defining XML schema language */\r
+ private static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";\r
+\r
+ /** The key defining XML schema */\r
+ private static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";\r
+\r
+ /** The XML parser used for reading template files */\r
+ private XMLReader parser;\r
+\r
+ /**\r
+ * Initializes a newly created <code>TemplateParser</code>. Sets up the SAX parser used for\r
+ * parsing.\r
+ */\r
+ public TemplateParser() {\r
+ SAXParserFactory spf = SAXParserFactory.newInstance();\r
+ spf.setValidating(true);\r
+ spf.setNamespaceAware(true);\r
+\r
+ try {\r
+ SAXParser sp = spf.newSAXParser();\r
+ sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);\r
+ parser = sp.getXMLReader();\r
+ parser.setErrorHandler(new XslParserException());\r
+ } catch (Exception ex) {\r
+ Log.error(ex);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Parses the file with template.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param templateFile\r
+ * the path to the file with template.\r
+ * @throws ConfigException\r
+ * if the template or its XML schema isn't well-formed.\r
+ * @throws FileNotFoundException\r
+ * if the template or its XML schema doesn't exist.\r
+ */\r
+ public void readTemplate(ConfigData configData, String templateFile) throws ConfigException,\r
+ FileNotFoundException {\r
+ InputStream xsdFile = TemplateParser.class.getResourceAsStream(TemplateConst.CONF_FILE_TEMPLATE_XSD);\r
+ if (xsdFile == null)\r
+ throw new FileNotFoundException(TemplateConst.CONF_FILE_TEMPLATE_XSD);\r
+\r
+ TemplateXmlHandler handler = new TemplateXmlHandler(configData, templateFile);\r
+ parser.setContentHandler(handler);\r
+ try {\r
+ parser.setProperty(JAXP_SCHEMA_SOURCE, xsdFile);\r
+ parser.parse(templateFile);\r
+ } catch (IOException ex) {\r
+ throw new FileNotFoundException(templateFile);\r
+ } catch (SAXException ex) {\r
+ throw new ConfigException(templateFile, ex.getMessage());\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.template;\r
+\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.Locator;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.ConfigData;\r
+import cz.zcu.fav.kiv.editor.beans.parameters.Parameter;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Attribute;\r
+import cz.zcu.fav.kiv.editor.beans.properties.Property;\r
+import cz.zcu.fav.kiv.editor.config.constants.FileConst;\r
+import cz.zcu.fav.kiv.editor.config.constants.TagDefinition;\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.template.TemplateConst.TemplateTags;\r
+\r
+/**\r
+ * The <code>TemplateXmlHandler</code> class is used for parsing file with template.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TemplateXmlHandler extends DefaultHandler {\r
+ /** The locator specifying actual line number */\r
+ private Locator locator;\r
+\r
+ /** The data containing editor data structure */\r
+ private ConfigData configData;\r
+\r
+ /** The name of the file with template */\r
+ private String templateFile;\r
+\r
+ /** The number of the line with property element */\r
+ private int propertyLine;\r
+\r
+ /** The property with attribute */\r
+ private Property property;\r
+\r
+ /** The list of attribute values */\r
+ private String attributeValue;\r
+\r
+ /** The name of parameter */\r
+ private String parameterValue;\r
+\r
+ /** The flag specifying whether the parser is inside attribute element */\r
+ private boolean insideAttributeElement = false;\r
+\r
+ /** The flag specifying whether the parser is inside parameter element */\r
+ private boolean insideParameterElement = false;\r
+\r
+ /** The string buffer for content of attribute element */\r
+ private StringBuffer attributeBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /** The string buffer for content of parameter element */\r
+ private StringBuffer parameterBuffer = new StringBuffer(TagDefinition.BUFFER_SIZE);\r
+\r
+ /**\r
+ * Initializes a newly created <code>TemplateXmlHandler</code> with <code>ConfigData</code>\r
+ * and template name <code>templateFile</code>.\r
+ * \r
+ * @param configData\r
+ * the data containing editor data structure.\r
+ * @param template\r
+ * the name of the file with template.\r
+ */\r
+ public TemplateXmlHandler(ConfigData configData, String template) {\r
+ this.configData = configData;\r
+ this.templateFile = template;\r
+ }\r
+\r
+ @Override\r
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {\r
+ TemplateTags enumTag = TemplateConst.TemplateTags.getValue(qName);\r
+ if (enumTag != null)\r
+ switch (enumTag) {\r
+ case ATTRIBUTE_SET:\r
+ property = configData.searchProperty(atts.getValue(0));\r
+ if (property == null)\r
+ MessageWriter.writeWarning(ResourceController.getMessage("parser.template.find_property", FileConst.CONF_FILE_CONFIG, atts.getValue(0), templateFile, locator.getLineNumber()));\r
+ else\r
+ property.setChosen();\r
+\r
+ this.propertyLine = locator.getLineNumber();\r
+ break;\r
+ case ATTRIBUTE:\r
+ insideAttributeElement = true;\r
+ attributeBuffer.setLength(0); \r
+ attributeValue = atts.getValue(0); \r
+ break;\r
+ case PARAMETER:\r
+ insideParameterElement = true;\r
+ parameterBuffer.setLength(0);\r
+ parameterValue = atts.getValue(0);\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void endElement(String namespaceURI, String localName, String qName) {\r
+ TemplateTags enumTag = TemplateConst.TemplateTags.getValue(qName);\r
+ if (enumTag != null)\r
+ switch (enumTag) {\r
+ case ATTRIBUTE:\r
+ insideAttributeElement = false;\r
+ try {\r
+ if (property != null)\r
+ changeAttribute(attributeBuffer.toString());\r
+ } catch (ParserException ce) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage("parser.template.parse_attribute_value", templateFile, attributeBuffer.toString(), this.propertyLine));\r
+ }\r
+ break;\r
+ case PARAMETER:\r
+ insideParameterElement = false;\r
+ try {\r
+ changeParameter();\r
+ } catch (ParserException ce) {\r
+ MessageWriter.writeWarning(ResourceController.getMessage("parser.template.parse_parameter_value", templateFile, attributeBuffer.toString(), this.propertyLine));\r
+ }\r
+ break;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void characters(char[] ch, int start, int length) {\r
+ if (insideAttributeElement) {\r
+ attributeBuffer.append(ch, start, length);\r
+ } else if (insideParameterElement) {\r
+ parameterBuffer.append(ch, start, length);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Change type value of the actual parsed parameter.\r
+ * \r
+ * @throws ParserException\r
+ * if the parameter value is not valid.\r
+ */\r
+ private void changeParameter() throws ParserException {\r
+ Parameter parameter = configData.searchParameter(parameterBuffer.toString());\r
+ if (parameter == null)\r
+ MessageWriter.writeWarning(ResourceController.getMessage("parser.template.find_parameter", FileConst.CONF_FILE_CONFIG, parameterBuffer.toString(), templateFile, locator.getLineNumber()));\r
+ else {\r
+ // set new parameter value\r
+ parameter.getType().setLoadedValue(parameterValue);\r
+ parameter.setChosen();\r
+ }\r
+\r
+ }\r
+\r
+ /**\r
+ * Change type values of the actual parsed attribute specified by name.\r
+ * \r
+ * @param attrName\r
+ * an attribute name.\r
+ * @throws ParserException\r
+ * if the attribute values are not valid.\r
+ */\r
+ private void changeAttribute(String attrName) throws ParserException {\r
+ Attribute searchAttr = property.searchAttribute(attrName);\r
+ if (searchAttr != null) {\r
+ if (attributeValue != null)\r
+ searchAttr.getType().setLoadedValue(attributeValue);\r
+ searchAttr.setChosen(true);\r
+ } else\r
+ MessageWriter.writeWarning(ResourceController.getMessage("parser.template.find_attribute", FileConst.CONF_FILE_ATTRIBUTES, attributeBuffer.toString(), templateFile, this.propertyLine));\r
+ }\r
+\r
+ public void setDocumentLocator(Locator locator) {\r
+ this.locator = locator;\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.utils;\r
+\r
+import javax.swing.JOptionPane;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.resource.ResourceController;\r
+import cz.zcu.fav.kiv.editor.graphics.MainFrame;\r
+\r
+/**\r
+ * The <code>ErrorDialog</code> class displays the error dialog containing the description of the\r
+ * application error.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class ErrorDialog {\r
+\r
+ /**\r
+ * Shows the error dialog with the description of the input error.\r
+ * \r
+ * @param error\r
+ * the error to display in the error dialog.\r
+ */\r
+ public static void showDialog(Exception error) {\r
+ JOptionPane.showMessageDialog(MainFrame.getInstance(), error.getStackTrace(),\r
+ ResourceController.getMessage("error_dialog.title"), JOptionPane.ERROR_MESSAGE);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.utils;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.BufferedWriter;\r
+import java.io.File;\r
+import java.io.FileReader;\r
+import java.io.FileWriter;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.InputStreamReader;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.MessageWriter;\r
+import cz.zcu.fav.kiv.editor.controller.logger.Log;\r
+\r
+/**\r
+ * The <code>StreamWriter</code> class is used for reporting messages and errors generated during\r
+ * lauch of the batch file.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+class StreamWriter extends Thread {\r
+ /** The constant defining error message */\r
+ public static final String ERROR = "error";\r
+\r
+ /** The constant defining output message */\r
+ public static final String OUTPUT = "output";\r
+\r
+ /** The input message stream */\r
+ private InputStream inputStream;\r
+\r
+ /** The type of output message */\r
+ private String type;\r
+\r
+ /**\r
+ * Initializes a newly created <code>StreamWriter</code> with defined <code>InputStream</code>\r
+ * and message type.\r
+ * \r
+ * @param is\r
+ * the input stream.\r
+ * @param type\r
+ * the type of message.\r
+ */\r
+ public StreamWriter(InputStream is, String type) {\r
+ this.inputStream = is;\r
+ this.type = type;\r
+ }\r
+\r
+ /**\r
+ * Launches the message writer.\r
+ */\r
+ public void run() {\r
+ try {\r
+ InputStreamReader input = new InputStreamReader(inputStream);\r
+ BufferedReader reader = new BufferedReader(input);\r
+ String line = null;\r
+ while ((line = reader.readLine()) != null) {\r
+ if (type.equals(ERROR))\r
+ MessageWriter.writeEmphasis(line);\r
+ else\r
+ MessageWriter.write(line);\r
+ }\r
+ } catch (IOException ioe) {\r
+ Log.error(ioe);\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ * The <code>RunBatch</code> class launches a batch file defined by user.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class RunBatch {\r
+ /** The constant defining file separator */\r
+ private static final String FILE_SEPARATOR = "\\" + File.separator;\r
+\r
+ /** The in the batch file that determine place where the actual XSL stylesheet is placed */\r
+ private static final String XSL = "\\[XSL\\]";\r
+\r
+ /** The constant defining quote */\r
+ private static final String QUOTE = "\"";\r
+\r
+ /** The name of the auxiliary batch file */\r
+ public static final String RUN_BAT = "transformation.bat";\r
+\r
+ /**\r
+ * Executes the batch file.\r
+ * \r
+ * @throws Throwable\r
+ * if the batch file cannot be executed.\r
+ */\r
+ public static void execBatch() throws Throwable {\r
+ String osName = System.getProperty("os.name");\r
+ String[] cmd = new String[3];\r
+ if (osName.startsWith("Windows")) {\r
+ cmd[0] = "cmd.exe";\r
+ cmd[1] = "/C";\r
+ cmd[2] = RUN_BAT;\r
+ }\r
+\r
+ Runtime rt = Runtime.getRuntime();\r
+ Process proc = rt.exec(cmd);\r
+ // any error message?\r
+ StreamWriter errorGobbler = new StreamWriter(proc.getErrorStream(), StreamWriter.ERROR);\r
+\r
+ // any output?\r
+ StreamWriter outputGobbler = new StreamWriter(proc.getInputStream(), StreamWriter.OUTPUT);\r
+\r
+ // kick them off\r
+ errorGobbler.start();\r
+ outputGobbler.start();\r
+ }\r
+\r
+ /**\r
+ * Replace the mark [XSL] in the batch file by the actual opened XSL stylesheet file.\r
+ * \r
+ * @param batchName\r
+ * the name of the batch file.\r
+ * @param xslName\r
+ * the name of the actually opened XSL stylesheet file.\r
+ * @throws Throwable\r
+ * if the batch file is invalid.\r
+ */\r
+ public static void replaceXslName(String batchName, String xslName) throws Throwable {\r
+ FileReader fileRead = new FileReader(batchName);\r
+ BufferedReader in = new BufferedReader(fileRead);\r
+ FileWriter fw = new FileWriter(RUN_BAT);\r
+ BufferedWriter out = new BufferedWriter(fw);\r
+\r
+ String line;\r
+ while ((line = in.readLine()) != null) {\r
+ line = line.replaceAll(XSL, QUOTE\r
+ + xslName.replaceAll(FILE_SEPARATOR, FILE_SEPARATOR + FILE_SEPARATOR) + QUOTE);\r
+\r
+ out.write(line);\r
+ out.newLine();\r
+ }\r
+ fileRead.close();\r
+ out.close();\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.utils;\r
+\r
+import cz.zcu.fav.kiv.editor.beans.types.Type;\r
+import cz.zcu.fav.kiv.editor.beans.types.Unit;\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+\r
+/**\r
+ * The <code>TagControl</code> class controls the components and values of parameters and\r
+ * attributes.\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TagControl {\r
+\r
+ /**\r
+ * Controls if the input value corresponds to the <code>Type</code> component.\r
+ * \r
+ * @param type\r
+ * the type with the component.\r
+ * @param value\r
+ * the new value for controlling.\r
+ */\r
+ public static void controlSetTypeValue(Type type, String value) throws ParserException {\r
+ switch (type.getName()) {\r
+ case LIST:\r
+ controlList(type, value);\r
+ break;\r
+ case INTEGER:\r
+ controlInteger(type, value);\r
+ break;\r
+ case NUMBER:\r
+ controlInteger(type, value); \r
+ break;\r
+ case FLOAT:\r
+ controlFloat(type, value);\r
+ break;\r
+ case COLOR:\r
+ controlColor(type, value);\r
+ break;\r
+ case BOOLEAN:\r
+ controlBoolean(type, value);\r
+ break;\r
+ case LENGTH:\r
+ controlLength(type, value);\r
+ break;\r
+ default:\r
+ type.setValue(value);\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Controls if the list of predefined units in <code>Unit</code> contains the input unit name.\r
+ * \r
+ * @param unit\r
+ * the unit with the list of predefined units.\r
+ * @param unitName\r
+ * the name of input unit.\r
+ * @return true if the <code>Unit</code> contains the input unit name.\r
+ */\r
+ private static void controlTypeUnit(Unit unit, String unitName) throws ParserException {\r
+ if (unit.getValueList().contains(unitName))\r
+ unit.setValue(unitName);\r
+ else \r
+ throw new ParserException();\r
+ }\r
+\r
+ /**\r
+ * Controls if the input value is a valid value for component combo-box.\r
+ * \r
+ * @param type\r
+ * the type with component combo-box.\r
+ * @param value\r
+ * the input value for controlling.\r
+ * @return true if the input value is valid for the component combo-box.\r
+ */\r
+ private static void controlList(Type type, String value) throws ParserException{\r
+ if ((type.getValueList() != null)\r
+ &&(type.getValueList().containsKey(value)))\r
+ type.setValue(value);\r
+ else \r
+ throw new ParserException();\r
+ }\r
+\r
+ /**\r
+ * Controls if the input value is a valid value for component spinner-int.\r
+ * \r
+ * @param value\r
+ * the input value for controlling.\r
+ * @return true if the input value is valid for the component spinner-int.\r
+ */\r
+ private static void controlInteger(Type type, String value) throws ParserException {\r
+ try {\r
+ Integer.parseInt(value);\r
+ type.setValue(value);\r
+ } catch (Exception pe) {\r
+ throw new ParserException();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Controls if the input value is a valid value for component spinner-float.\r
+ * \r
+ * @param value\r
+ * the input value for controlling.\r
+ * @return true if the input value is valid for the component spinner-float.\r
+ */\r
+ private static void controlFloat(Type type, String value) throws ParserException {\r
+ try {\r
+ Double.parseDouble(value);\r
+ type.setValue(value);\r
+ } catch (NumberFormatException pe) {\r
+ throw new ParserException();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Controls if the input value is a valid value for component color-chooser.\r
+ * \r
+ * @param type\r
+ * the type with component color-chooser.\r
+ * @param value\r
+ * the input value for controlling.\r
+ * @return true if the input value is valid for the component color-chooser.\r
+ */\r
+ private static void controlColor(Type type, String value) throws ParserException {\r
+ if ((type.getValueList() != null)\r
+ &&(type.getValueList().get(value) == null)\r
+ &&(TagParser.parseColor(value) == null))\r
+ throw new ParserException();\r
+ else\r
+ type.setValue(value);\r
+ }\r
+\r
+ /**\r
+ * Controls if the input value is a valid value for component check-box.\r
+ * \r
+ * @param value\r
+ * the input value for controlling.\r
+ * @return true if the input value is valid for the component check-box.\r
+ */\r
+ private static void controlBoolean(Type type, String value) throws ParserException {\r
+ if (value.equals("0") || value.equals("1"))\r
+ type.setValue(value);\r
+ else\r
+ throw new ParserException();\r
+ }\r
+\r
+ private static void controlLength(Type type,String value) throws ParserException {\r
+ String number = TagParser.parserNumber(value);\r
+ String unit = TagParser.parserUnit(value);\r
+ controlTypeUnit(type.getUnit(), unit);\r
+ type.setValue(number);\r
+ }\r
+}\r
--- /dev/null
+package cz.zcu.fav.kiv.editor.utils;\r
+\r
+import java.awt.Color;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+import cz.zcu.fav.kiv.editor.controller.errors.ParserException;\r
+\r
+/**\r
+ * The <code>TagParser</code> class parses values of parameters, properties and attributes loaded\r
+ * from input files (configuration and XSL stylesheet).\r
+ * \r
+ * @author Marta Vaclavikova\r
+ * @version 1.0, 05/2007\r
+ */\r
+public class TagParser {\r
+\r
+ /**\r
+ * Parses the number from the string containing number with unit e.g. parses 12.4 from 12.4em.\r
+ * \r
+ * @param text\r
+ * the input text containing number and unit.\r
+ * @throws ParserException\r
+ * if the input text doesn't contain a number.\r
+ * @return a number parsed from the input text.\r
+ */\r
+ public static String parserNumber(String text) throws ParserException {\r
+ text = text.trim().replaceAll("'", "");\r
+ Pattern pattern = Pattern.compile("\\+?\\-?\\d+\\.?\\d*");\r
+ Matcher matcher = pattern.matcher(text);\r
+ if (matcher.find())\r
+ return matcher.group();\r
+ else\r
+ throw new ParserException(text);\r
+ }\r
+\r
+ /**\r
+ * Parses the unit from the string containing number with unit e.g. parses em from 12.4em.\r
+ * \r
+ * @param text\r
+ * the input text containing number and unit.\r
+ * @return a unit parsed from the input text.\r
+ */\r
+ public static String parserUnit(String text) {\r
+ Pattern pattern = Pattern.compile("[a-z]+");\r
+ Matcher matcher = pattern.matcher(text);\r
+ if (matcher.find())\r
+ return matcher.group();\r
+ else\r
+ return "";\r
+ }\r
+\r
+ /**\r
+ * Transformes a string containing color in hexadecimal format (#rrggbb) to <code>Color</code>.\r
+ * \r
+ * @param color\r
+ * the input color <code>Color</code>.\r
+ * @return transformed input color to a string containg the color in hexadecimal format\r
+ * (#rrggbb).\r
+ */\r
+ public static String createColor(Color color) {\r
+ String red = Integer.toHexString(color.getRed()).toUpperCase();\r
+ String green = Integer.toHexString(color.getGreen()).toUpperCase();\r
+ String blue = Integer.toHexString(color.getBlue()).toUpperCase();\r
+\r
+ if (red.length() == 1)\r
+ red = "0" + red;\r
+ if (green.length() == 1)\r
+ green = "0" + green;\r
+ if (blue.length() == 1)\r
+ blue = "0" + blue;\r
+\r
+ return "#" + red + green + blue;\r
+ }\r
+\r
+ /**\r
+ * Parses the string containing color in hexadecimal format (#rrggbb) and converts it to the\r
+ * <em>Color</em>.\r
+ * \r
+ * @param hexCol\r
+ * the string containing a color in in hexadecimal format (#rrggbb).\r
+ * @return a color parsed from the input string. If the input color is invalid, then\r
+ * <em>null</em> is returned.\r
+ */\r
+ public static Color parseColor(String hexCol) {\r
+ if (hexCol.length() != 7)\r
+ return null;\r
+ try {\r
+ return new Color(Integer.parseInt(hexCol.substring(1, 3), 16), Integer.parseInt(hexCol\r
+ .substring(3, 5), 16), Integer.parseInt(hexCol.substring(5, 7), 16));\r
+ } catch (Throwable e) {\r
+ return null;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Parses boolean value from the input string containig 1/0 or true/false.\r
+ * \r
+ * @param boolValue\r
+ * the string containing 1/0 or true/false.\r
+ * @return a parsed boolean value - true or false.\r
+ */\r
+ public static Boolean parseBoolean(String boolValue) {\r
+ try {\r
+ return (Integer.valueOf(boolValue) == 0) ? false : true;\r
+ } catch (NumberFormatException ex) {\r
+ if (boolValue.equals("true") || boolValue.equals("false"))\r
+ return Boolean.valueOf(boolValue);\r
+ }\r
+ return null;\r
+ }\r
+\r
+ /**\r
+ * Converts the boolean value to the string value "1" or "0".\r
+ * \r
+ * @param boolValue\r
+ * the input boolean value.\r
+ * @return a string "1" if the input was true, "0" if the input was false.\r
+ */\r
+ public static String convertBoolean(boolean boolValue) {\r
+ return boolValue ? "1" : "0";\r
+ }\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>\r
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">\r
+\r
+<log4j:configuration>\r
+ \r
+ <appender name="fileLog" class="org.apache.log4j.RollingFileAppender">\r
+ <param name="File" value="error.log"/> \r
+ <param name="MaxFileSize" value="100KB"/> \r
+ <param name="MaxBackupIndex" value="0"/> \r
+ <layout class="org.apache.log4j.PatternLayout">\r
+ <param name="ConversionPattern"\r
+ value="%d{dd.MM.yyyy HH:mm:ss} %4p - %m%n"/>\r
+ </layout> \r
+ </appender>\r
+ \r
+ <appender name="consoleLog" class="org.apache.log4j.ConsoleAppender">\r
+ <layout class="org.apache.log4j.PatternLayout">\r
+ <param name="ConversionPattern"\r
+ value="%d{dd.MM.yyyy HH:mm:ss} %4p - %m%n"/>\r
+ </layout> \r
+ </appender>\r
+\r
+ <root>\r
+ <!--priority value ="debug" /-->\r
+ <priority value ="error" />\r
+ <!--appender-ref ref="fileLog"/-->\r
+ <appender-ref ref="consoleLog"/>\r
+ </root>\r
+\r
+</log4j:configuration>
\ No newline at end of file
--- /dev/null
+\r
+#OptionController\r
+error.option_controller.file_not_found=File {0} not found.\r
+error.option_controller.store=Couldn't store {0}.\r
+info.option_controller.load_default_option=Default option loaded.\r
+info.option_controller.load_file=Option file loaded.\r
+info.option_controller.load_option_items=Option items loaded.\r
+info.option_controller.save_file=Option file saved.\r
+\r
+#ProgressControl\r
+info.progress_control.load_file=File {0} successfully loaded.\r
+info.progress_control.load_parameter_description=Files with parameter descriptions successfully loaded.\r
+info.progress_control.load_property_description=Files with property descriptions successfully loaded.\r
+\r
+#TemplateControl\r
+info.template_control.load_template=File {0} succesfully loaded.\r
+\r
+#ResourceController\r
+error.resource_controller.missing_key=Missing string key {0}.\r
+\r
+#ParamXmlParser\r
+error.param_parser.transformation_error=Cannot transform description.\r
+error.param_parser.parser_error=Cannot parser .xml definition file.\r
+\r
+#EditorIcon\r
+error.editor_icon=File image not found.\r
+\r
+#TypeParam - relations\r
+error.update_value=Cannot update component value.\r
+\r
+#OptionForm\r
+info.option_form.editor.update_values=Restored default editor option values.\r
+info.option_form.editor.save_values=Saved editor option values.\r
+info.option_form.save.update_values=Restored default stylesheet option values.\r
+info.option_form.save.save_values=Saved stylesheet option values.\r
--- /dev/null
+#main frame\r
+editor.title=Editor FO parametrů\r
+\r
+editor.browser.description=Otevře stránku s popisem {0} ve webovém prohlížeči.\r
+editor.browser.menu.open_browser=Otevřít webový prohlížeč\r
+editor.browser.menu.copy_location=Kopírovat umístění\r
+\r
+#attribute frame\r
+frame.attribute.title=Atributy - \r
+\r
+#intro frame\r
+frame.intro.title=Editor FO parametrů - načítání...\r
+\r
+frame.intro.progress.loading_file=Načítání konfiguračních souborů...\r
+frame.intro.progress.read_file=Soubor {0} úspěšně načten.\r
+frame.intro.progress.read_ok=OK\r
+frame.intro.progress.correct_error=Prosím opravte výše uvedenou chybu a spusťte editor znovu.\r
+\r
+parser.config_file.title=Načítání konfiguračních souborů\r
+parser.config.duplicate_parameter={0} - <parameter> {1} (řádka {2}) se vyskytuje vícekrát.\r
+parser.attributes.invalid_attribute_value={0} - <attribute> (řádka {1}) má nepodporované hodnoty hodnotu.\r
+parser.attributes.invalid_attribute_default_value={0} - <attribute> (řádka {1}) nepodporovanou hodnotu <default>.\r
+parser.attributes.invalid_attribute_type={0} - <attribute> (řádka {1}) má nepodporovaný typ.\r
+parser.figures.invalid_parameter_value={0} - <figure> "{1}" (řádka {2}) má nepodporovaný parametr "{3}".\r
+parser.figures.invalid_class={0} - <figure> "{1}" (řádka {2}) odkazuje na nepodporovanou třídu {3}.\r
+parser.xml_definition_file.invalid_directory=Cesta k adresáři s XML specifikacemi FO parametrů není správně nastavena (Nastavení/Vlastnosti editoru.../Specifikace FO parametrů). \r
+parser.xml_definition_file.missing_file=Chybí soubor "{0}.xml" v adresáři "{1}".\r
+parser.parameters.invalid_type={0} - <parameter> "{1}" (řádka {2}) má nepodporovaný "data-type" ({1}.xml).\r
+parser.parameters.invalid_value={0} - <parameter> "{1}" (řádka {2}) má nepodporovanou hodnotu <xsl:param> ({1}.xml).\r
+parser.parameters.dependency_cycle={0} - cyklicky závislé parametry: {1}. \r
+parser.property.invalid_value={0} - <attribute-set> "{1}" (řádka {2}) má nepodporovanou hodnotu atributu <xsl:attribute> {3} ({1}.xml).\r
+parser.property.invalid_type={0} - <attribute-set> {1} (řádka {2}) má nepodporovaný "data-type" ({1}.xml).\r
+parser.property.unsupported_attribute={0} - <attribute-set> {1} (řádka {2}) má nepodporovaný atribut {3} ({1}.xml).\r
+\r
+#template\r
+parser.template.find_property={0} - nelze najít <attribute-set> "{1}" definovaný v {2} (řádka {3}).\r
+parser.template.find_attribute={0} - nelze najít <attribute> "{1}" definovaný v {2} (řádka {3}).\r
+parser.template.find_parameter={0} - nelze najít <parameter> "{1}" definovaný v {2} (řádka {3}).\r
+parser.template.parse_attribute_value={0} - nelze přečíst hodnotu <attribute> "{1}" (řádka {2}).\r
+parser.template.parse_parameter_value={0} - nelze přečíst hodnotu <parameter> "{1}" (řádka {2}).\r
+\r
+#frame about\r
+frame.about.title=O programu Editor FO parametrů\r
+frame.about.version=Verze: {0}\r
+frame.about.author=Autor: Marta Vaclavikova\r
+\r
+#frame info\r
+frame.config_info.title=Informace o konfiguračních souborech\r
+frame.config_info.directory=Adresář s XML specifikacemi FO parametrů\r
+frame.config_info.files.title=Konfigurační soubory\r
+frame.config_info.files.config.description=Definuje rozmístění parametrů a sad atributů v editoru.\r
+frame.config_info.files.attributes.description=Definuje vlastnosti a rozmístění atributů.\r
+frame.config_info.files.types.description=Definuje typy parametrů a atributů.\r
+frame.config_info.files.graphics.description=Definuje grafické prvky.\r
+frame.config_info.template.title=Standardní šablona \r
+\r
+#frame option\r
+frame.option.save.title=Vlastnosti stylu\r
+frame.option.editor.title=Vlastnosti editoru\r
+\r
+option_editor.language=Jazyk editoru\r
+option_editor.language.description=Změnit jazykovou verzi prohlížeče.\r
+option_editor.xml_definition_path=XML specifikace FO parametrů\r
+option_editor.xml_definition_path.description=Cesta k adresáři, kde jsou uloženy XML specifikace FO parametrů.\r
+option_editor.xml_definition_path.button=Projít...\r
+option_editor.erase_console=Smazat konzoli\r
+option_editor.erase_console.description=Smazat konzoli pred každou akcí editoru.\r
+\r
+option_save.new_file_template.title=Nový XSL styl\r
+option_save.stylesheet_format.title=XSL styl\r
+option_save.output_file.title=Výstupní soubor\r
+option_save.add_fo_namespace=Přidat jmenný prostor FO\r
+option_save.add_fo_namespace.description=Přidat jmenný prostor FP do definice elementu xsl:stylesheet.\r
+option_save.change_save=Uložení s přeuspořádáním\r
+option_save.change_save.description=Přeuspořádat všechny známé parametry při ukládání XSL stylu.\r
+option_save.change_save.warning=Všechny komentáře v otevřeném souboru se odstraní!\r
+option_save.generate_com=Generovat komentáře\r
+option_save.generate_com.description=Generovat komentáře k parametrům v XSL stylu.\r
+option_save.use_param_select=Použít 'select' v parametrech\r
+option_save.use_param_select.description=Použít atribut 'select' v definicích parametrů, např. <xsl:param name="page.orientation" select="'portrait'"/>.\r
+option_save.encoding=Kódování\r
+option_save.encoding.description=Kódování výstupního XSL souboru, např. <?xml version="1.0" encoding="utf-8"?>.\r
+option_save.newline=Konec řádky\r
+option_save.newline.description=Znak konce řádky používaný ve výstupních XSL souborech.\r
+option_save.stylesheet_version=Verze XSL stylu\r
+option_save.stylesheet_version.description=Verze XSL stylu, např. <xsl:stylesheet version="1.0">.\r
+option_save.import_file=Importovaný styl \r
+option_save.import_file.description=Standardní XSL styl importovaný editovaným XSL stylem, např. <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>. Write down path separated by ';'.\r
+\r
+# open file\r
+open_file.title=Otevírání souboru\r
+open_file.success_info=Soubor {0} úspěšně načten.\r
+open_file.stylesheet_invalid=Element typu <xsl:stylesheet> je na nesprávné pozici.\r
+open_file.parameter_exist=Řádka {0} - <xsl:param> "{1}" není dosud podporovaný editorem.\r
+open_file.parameter_invalid=Řádka {0} - <xsl:param> "{1}" má nepodporovaný formát.\r
+open_file.attribute_set_exist=Řádka {0} - <xsl:attribute-set> "{1}" není dosud podporovaný editorem.\r
+open_file.attribute_set_invalid=Řádka {0} - <xsl:attribute-set> "{1}" má nepodporovaný formát.\r
+open_file.attribute_exist=Řádka {0} - <xsl:attribute> "{1}" není dosud podporovaný editorem.\r
+open_file.attribute_invalid=Řádka {0} - <xsl:attribute> "{1}" má nepodporovaný formát.\r
+\r
+#save file\r
+save_file.dialog_file_exist.title=Přepsat soubor\r
+save_file.dialog_file_exist.text=Přepsat existující soubor?\r
+save_file.dialog_save_changes.title=Uložit změny\r
+save_file.dialog_save_changes.text=Soubor s XSL stylem byl změněn.\nChcete uložit změny?\r
+save_file.title=Ukládání souboru\r
+save_file.success_info=Soubor {0} úspěšně uložen.\r
+\r
+#new file\r
+new_file.title=Vytváření nového souboru\r
+new_file.empty.info=Nový prázdný soubor úspěšně vytvořen.\r
+new_file.default.info=Nový soubor podle standardní šablony úspěšně vytvořen.\r
+new_file.stylesheet.info=Nový soubor podle šablony {0} úspěšně vytvořen.\r
+new_file_template.load_template.title=Načítání souboru se šablonou {0}.\r
+\r
+#run batch\r
+run_batch_file.title=Spuštění dávkového souboru\r
+run_batch_file.running=Spuštění dávkového souboru {0}.\r
+run_batch_file.not_saved=Nelze spustit dávkový soubor - soubor se stylem není uložen.\r
+run_batch_file.file_not_exists=Nelze spustit dávkový soubor - dávkový soubor neexistuje. Prosím vyberte dávkový soubor.\r
+run_batch_file.error_running=Chyba při běhu dávkového souboru {0}.\r
+\r
+#errors\r
+error.config_error=Chyba v souboru {0}.\r
+error.xslt_parser=Řádka {0}, sloupec {1} \n {2}\r
+error.xslt_parser.fatal=Závažná chyba: \r
+error.xslt_parser.warning=Varování:\r
+error.file_not_found.file=Nelze najít soubor {0}.\r
+error.file_not_found.dir=Cesta k adresáři s XML specifikacemi parametrů není správně nastavena.\r
+error.parser_error=Nelze přečíst {0}.\r
+error.open_file.wrong_form=Soubor není validní\n\r
+error.save_file=Chyba při ukládání souboru {0}:\r
+error.component.update_value=Nelze změnit hodnotu komponenty {0} na novou hodnotu {1}.\r
+error_dialog.title=Chyba v aplikaci\r
+error.open_browser=Chyba při spouštění webového prohlížeče.\r
+error.open_browser.title=Chyba spouštění webového prohlížeče\r
+\r
+#menu\r
+menu.file=&Soubor\r
+menu_item.new=&Nový\r
+menu_item.new.tooltip=Vytvořit nový XSL styl\r
+menu_item.new_empty=&Prázdný\r
+menu_item.new_empty.tooltip=Vytvořit nový prázdný XSL styl\r
+menu_item.new_default=&Standardní šablona\r
+menu_item.new_default.tooltip=Vytvořit nový styl podle standardní šablony\r
+menu_item.new_stylesheet=&Vybrat šablonu...\r
+menu_item.new_stylesheet.tooltip=Vytvořit nový styl podle uživatelovy šablony\r
+menu_item.open=&Otevřít...\r
+menu_item.open.tooltip=Otevřít XSL soubor se stylem\r
+menu_item.close=&Zavřít\r
+menu_item.close.tooltip=Zavřít XSL soubor se stylem\r
+menu_item.save_as=&Uložit jako...\r
+menu_item.save_as.tooltip=Uložit XSL soubor se stylem\r
+menu_item.save=&Uložit\r
+menu_item.save.tooltip=Uložit XSL soubor se stylem\r
+menu_item.exit=&Konec\r
+menu_item.exit.tooltip=Zavřít editor\r
+menu_item.option=&Nastavení\r
+menu_item.option_save=Vlastnosti &stylu...\r
+menu_item.option_save.tooltip=Změnit vlastnosti stylu\r
+menu_item.option_editor=Vlastnosti &editoru...\r
+menu_item.option_editor.tooltip=Změnit vlastnosti editoru\r
+menu_item.run=&Spustit\r
+menu_item.run_batch=&Spustit dávku\r
+menu_item.run_batch.tooltip=Spustit vybraný dávkový soubor\r
+menu_item.run_edit_batch=&Změnit dávkový soubor..\r
+menu_item.run_edit_batch.tooltip=Vybrat dávkový soubor\r
+menu_item.run_batch_save=&Uložit před spuštěním\r
+menu_item.run_batch_save.tooltip=Uložit aktuální soubor se stylem před spuštěním dávky\r
+menu_item.help=&Nápověda\r
+menu_item.help_window=&Obsah\r
+menu_item.help_window.tooltip=Zobrazit obsah nápovědy\r
+menu_item.config=&Konfigurace...\r
+menu_item.config.tooltip=Zobrazit informace o konfiguračních souborech\r
+menu_item.about=&O programu...\r
+menu_item.about.tooltip=Zobrazit dialog O programu\r
+\r
+#language\r
+language.en=Anglicky\r
+language.cs=Česky\r
+\r
+#newline\r
+encoding.crlf=WIN (CR+LF)\r
+encoding.lf=UNIX (LF)\r
+encoding.cr=MAC (CR)\r
+\r
+#button\r
+button.cancel=Zrušit\r
+button.save=Uložit\r
+button.default=Obnovit původní\r
+button.yes=Ano\r
+button.no=Ne\r
+button.ok=OK\r
+\r
+#url\r
+url.parameter_description=http://docbook.sourceforge.net/release/xsl/current/doc/fo/{0}.html\r
+\r
+#color editor\r
+component.color_editor.title=Editor barev\r
+component.color_editor.error_parsing_color=Nelze přečíst barvu {0}. Nastavena standardní barva.\r
+\r
+# message writer\r
+message_writer.warning=VAROVÁNÍ: \r
+message_writer.error=CHYBA: \r
+message_writer.info=INFO: \r
--- /dev/null
+#main frame\r
+editor.title=FO Parameter Editor\r
+\r
+editor.browser.description=Open description page {0} in web browser.\r
+editor.browser.menu.open_browser=Open web browser\r
+editor.browser.menu.copy_location=Copy location\r
+\r
+#attribute frame\r
+frame.attribute.title=Attributes - \r
+\r
+#intro frame\r
+frame.intro.title=FO Parameter Editor - loading...\r
+\r
+frame.intro.progress.loading_file=Loading configuration files...\r
+frame.intro.progress.read_file=File {0} successfully loaded.\r
+frame.intro.progress.read_ok=OK\r
+frame.intro.progress.correct_error=Please correct last mentioned error and launch the editor again.\r
+\r
+parser.config_file.title=Loading configuration files\r
+parser.config.duplicate_parameter={0} - <parameter> {1} (line {2}) is duplicated.\r
+parser.attributes.invalid_attribute_value={0} - <attribute> (line {1}) has unsupported values.\r
+parser.attributes.invalid_attribute_default_value={0} - <attribute> (line {1}) has unsupported <default> value.\r
+parser.attributes.invalid_attribute_type={0} - <attribute> (line {1}) has unsupported type.\r
+parser.figures.invalid_parameter_value={0} - <figure> "{1}" (line {2}) has unsupported parameter "{3}".\r
+parser.figures.invalid_class={0} - <figure> "{1}" (line {2}) has reference to unsupported class {3}.\r
+parser.xml_definition_file.invalid_directory=Path to the directory containing XML specifications of FO parameters is not properly set (Options/Editor options.../FO parameter specification). \r
+parser.xml_definition_file.missing_file=Missing file "{0}.xml" in "{1}" directory.\r
+parser.parameters.invalid_type={0} - <parameter> "{1}" (line {2}) has unsupported "data-type" ({1}.xml).\r
+parser.parameters.invalid_value={0} - <parameter> "{1}" (line {2}) has unsupported value <xsl:param> ({1}.xml).\r
+parser.parameters.dependency_cycle={0} - cycle dependent parameters: {1}. \r
+parser.property.invalid_value={0} - <attribute-set> "{1}" (line {2}) has unsupported value <xsl:attribute> of the attribute {3} ({1}.xml).\r
+parser.property.invalid_type={0} - <attribute-set> {1} (line {2}) has unsupported "data-type" ({1}.xml).\r
+parser.property.unsupported_attribute={0} - <attribute-set> {1} (line {2}) has unsupported attribute {3} ({1}.xml).\r
+\r
+#template\r
+parser.template.find_property={0} - can’t find <attribute-set> "{1}" defined in {2} (line {3}).\r
+parser.template.find_attribute={0} - can’t find <attribute> "{1}" defined in {2} (line {3}).\r
+parser.template.find_parameter={0} - can’t find <parameter> "{1}" defined in {2} (line {3}).\r
+parser.template.parse_attribute_value={0} - can’t parse value of <attribute> "{1}" (line {2}).\r
+parser.template.parse_parameter_value={0} - can’t parse value of <parameter> "{1}" (line {2}).\r
+\r
+#frame about\r
+frame.about.title=About FO Parameters Editor\r
+frame.about.version=Version: {0}\r
+frame.about.author=Author: Marta Vaclavikova\r
+\r
+#frame info\r
+frame.config_info.title=Configuration Files Info\r
+frame.config_info.directory=Directory with FO parameter XML specification\r
+frame.config_info.files.title=Configuration files\r
+frame.config_info.files.config.description=Defines layout of parameters and attribute-sets in the editor.\r
+frame.config_info.files.attributes.description=Defines features and layout of attributes in the attribute-sets.\r
+frame.config_info.files.types.description=Defines parameter and attribute types.\r
+frame.config_info.files.graphics.description=Defines graphics figures.\r
+frame.config_info.template.title=Default template \r
+\r
+#frame option\r
+frame.option.save.title=Stylesheet Options\r
+frame.option.editor.title=Editor Options\r
+\r
+option_editor.language=Editor language\r
+option_editor.language.description=Change language used in the editor.\r
+option_editor.xml_definition_path=FO parameter XML specification\r
+option_editor.xml_definition_path.description=Path to the directory where files with XML specifications of FO parameters are stored.\r
+option_editor.xml_definition_path.button=Browse...\r
+option_editor.erase_console=Erase console\r
+option_editor.erase_console.description=Erase error console before every editor action.\r
+\r
+option_save.new_file_template.title=New XSL stylesheet\r
+option_save.stylesheet_format.title=XSL stylesheet\r
+option_save.output_file.title=Output file\r
+option_save.add_fo_namespace=Add FO namespace\r
+option_save.add_fo_namespace.description=Add FO namespace to the xsl:stylesheet definition.\r
+option_save.change_save=Rearrange save\r
+option_save.change_save.description=Rearrange all known parameters by saving XSL stylesheet.\r
+option_save.change_save.warning=All comments in the opened file will be erased!\r
+option_save.generate_com=Generate comments\r
+option_save.generate_com.description=Generate parameter comments in the XSL stylesheet.\r
+option_save.use_param_select=Use 'select' in parameters\r
+option_save.use_param_select.description=Use attribute 'select' in parameter definitions, e.g. <xsl:param name="page.orientation" select="'portrait'"/>.\r
+option_save.encoding=Output encoding\r
+option_save.encoding.description=Output XSL file encoding, e.g. <?xml version="1.0" encoding="utf-8"?>.\r
+option_save.newline=End of line\r
+option_save.newline.description=End of line character used in output XSL files.\r
+option_save.stylesheet_version=Stylesheet version\r
+option_save.stylesheet_version.description=Stylesheet version, e.g. <xsl:stylesheet version="1.0">.\r
+option_save.import_file=Imported stylesheet \r
+option_save.import_file.description=Standard stylesheet file imported by edited stylesheet, e.g. <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>. Write down path separated by ';'.\r
+\r
+# open file\r
+open_file.title=Opening file\r
+open_file.success_info=File {0} succesfully opened.\r
+open_file.stylesheet_invalid=The element <xsl:stylesheet> isn’t well placed.\r
+open_file.parameter_exist=Line {0} - <xsl:param> "{1}" isn’t supported by the editor yet.\r
+open_file.parameter_invalid=Line {0} - <xsl:param> "{1}" hasn’t supported format.\r
+open_file.attribute_set_exist=Line {0} - <xsl:attribute-set> "{1}" isn’t supported by the editor yet.\r
+open_file.attribute_set_invalid=Line {0} - <xsl:attribute-set> "{1}" hasn’t supported format.\r
+open_file.attribute_exist=Line {0} - <xsl:attribute> "{1}" isn’t supported by the editor yet.\r
+open_file.attribute_invalid=Line {0} - <xsl:attribute> "{1}" hasn’t supported format.\r
+\r
+#save file\r
+save_file.dialog_file_exist.title=Overwrite file\r
+save_file.dialog_file_exist.text=Overwrite existing file?\r
+save_file.dialog_save_changes.title=Save changes\r
+save_file.dialog_save_changes.text=Stylesheet file has changed.\nDo you want to save the changes?\r
+save_file.title=Saving file\r
+save_file.success_info=File {0} succesfully saved.\r
+\r
+#new file\r
+new_file.title=Creating new file\r
+new_file.empty.info=New empty file succesfully created.\r
+new_file.default.info=New file according to the default template succesfully created.\r
+new_file.stylesheet.info=New file according to the stylesheet {0} succesfully created.\r
+new_file_template.load_template.title=Loading template file {0}.\r
+\r
+#run batch\r
+run_batch_file.title=Running batch file\r
+run_batch_file.running=Running batch file {0}.\r
+run_batch_file.not_saved=Cannot run batch file - stylesheet file is not saved.\r
+run_batch_file.file_not_exists=Cannot run batch file - batch file doesn't exist. Please choose a batch file.\r
+run_batch_file.error_running=Error running batch file {0}.\r
+\r
+#errors\r
+error.config_error=Error in the file {0}.\r
+error.xslt_parser=Line {0}, column {1} \n {2}\r
+error.xslt_parser.fatal=Fatal error: \r
+error.xslt_parser.warning=Warning:\r
+error.file_not_found.file=Could not find file {0}.\r
+error.file_not_found.dir=Path to the directory with XML parameter specifications is not properly set.\r
+error.parser_error=Cannot parse {0}.\r
+error.open_file.wrong_form=File is not well-formed\n\r
+error.save_file=Error saving file {0}:\r
+error.component.update_value=Cannot update value of the parameter/attribute {0} by new value {1}.\r
+error_dialog.title=Application Error\r
+error.open_browser=Error attempting to launch web browser.\r
+error.open_browser.title=Error launching web browser\r
+\r
+#menu\r
+menu.file=&File\r
+menu_item.new=&New\r
+menu_item.new.tooltip=Create new XSL file\r
+menu_item.new_empty=&Empty\r
+menu_item.new_empty.tooltip=Create a new empty stylesheet\r
+menu_item.new_default=&Default Template\r
+menu_item.new_default.tooltip=Create a new stylesheet according the default template\r
+menu_item.new_stylesheet=&Choose Template...\r
+menu_item.new_stylesheet.tooltip=Create a new stylesheet according the user template\r
+menu_item.open=&Open...\r
+menu_item.open.tooltip=Open XSL stylesheet file\r
+menu_item.close=&Close\r
+menu_item.close.tooltip=Close XSL stylesheet file\r
+menu_item.save_as=S&ave As...\r
+menu_item.save_as.tooltip=Save XSL stylesheet file\r
+menu_item.save=&Save\r
+menu_item.save.tooltip=Save XSL stylesheet file\r
+menu_item.exit=&Exit\r
+menu_item.exit.tooltip=Close editor\r
+menu_item.option=&Options\r
+menu_item.option_save=&Stylesheet Options...\r
+menu_item.option_save.tooltip=Change stylesheet options\r
+menu_item.option_editor=&Editor Options...\r
+menu_item.option_editor.tooltip=Change editor options\r
+menu_item.run=&Run\r
+menu_item.run_batch=&Run Batch\r
+menu_item.run_batch.tooltip=Run selected batch file\r
+menu_item.run_edit_batch=&Change Batch File..\r
+menu_item.run_edit_batch.tooltip=Select batch file\r
+menu_item.run_batch_save=&Save Before Run\r
+menu_item.run_batch_save.tooltip=Save actual stylesheet file before running batch file\r
+menu_item.help=&Help\r
+menu_item.help_window=&Help Contents\r
+menu_item.help_window.tooltip=Show help contents\r
+menu_item.config=&Config Info...\r
+menu_item.config.tooltip=Show information about configuration files\r
+menu_item.about=&About...\r
+menu_item.about.tooltip=Show about dialog\r
+\r
+#language\r
+language.en=English\r
+language.cs=Czech\r
+\r
+#newline\r
+encoding.crlf=WIN (CR+LF)\r
+encoding.lf=UNIX (LF)\r
+encoding.cr=MAC (CR)\r
+\r
+#button\r
+button.cancel=Cancel\r
+button.save=Save\r
+button.default=Restore Defaults\r
+button.yes=Yes\r
+button.no=No\r
+button.ok=OK\r
+\r
+#url\r
+url.parameter_description=http://docbook.sourceforge.net/release/xsl/current/doc/fo/{0}.html\r
+\r
+#color editor\r
+component.color_editor.title=Color Editor\r
+component.color_editor.error_parsing_color=Cannot parse color {0}. Set default color.\r
+\r
+# message writer\r
+message_writer.warning=WARNING: \r
+message_writer.error=ERROR: \r
+message_writer.info=INFO: \r
--- /dev/null
+<?xml version="1.0"?>\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">\r
+\r
+<xs:simpleType name="stringtype">\r
+ <xs:restriction base="xs:string"/>\r
+</xs:simpleType>\r
+\r
+<xs:complexType name="attributetype">\r
+ <xs:simpleContent> \r
+ <xs:extension base="stringtype">\r
+ <xs:attribute name="type" type="stringtype" use="required"/>\r
+ <xs:attribute name="default" type="stringtype" use="required"/>\r
+ <xs:attribute name="values" type="stringtype"/>\r
+ </xs:extension>\r
+ </xs:simpleContent> \r
+</xs:complexType>\r
+\r
+<xs:complexType name="grouptype">\r
+ <xs:sequence>\r
+ <xs:element name="attribute" type="attributetype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+ <xs:attribute name="name" type="stringtype" use="required"/>\r
+</xs:complexType>\r
+\r
+<xs:complexType name="attributestype">\r
+ <xs:sequence>\r
+ <xs:element name="group" type="grouptype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:element name="attributes" type="attributestype"/>\r
+\r
+</xs:schema>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">\r
+\r
+<xs:simpleType name="stringtype">\r
+ <xs:restriction base="xs:string"/>\r
+</xs:simpleType>\r
+\r
+<xs:complexType name="grouptype">\r
+ <xs:choice minOccurs="0" maxOccurs="unbounded">\r
+ <xs:element name="parameter" type="stringtype" minOccurs="0" maxOccurs="unbounded"/>\r
+ <xs:element name="attribute-set" type="stringtype" minOccurs="0" maxOccurs="unbounded"/>\r
+ </xs:choice>\r
+ <xs:attribute name="name" type="stringtype"/>\r
+ <xs:attribute name="graphics" type="stringtype"/> \r
+</xs:complexType>\r
+\r
+<xs:complexType name="subsectiontype">\r
+ <xs:choice minOccurs="0" maxOccurs="unbounded">\r
+ <xs:element name="group" type="grouptype" minOccurs="0" maxOccurs="unbounded"/>\r
+ </xs:choice>\r
+ <xs:attribute name="name" type="stringtype" use="required"/>\r
+</xs:complexType>\r
+\r
+<xs:complexType name="sectiontype">\r
+ <xs:sequence>\r
+ <xs:element name="subsection" type="subsectiontype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+ <xs:attribute name="name" type="stringtype" use="required"/>\r
+</xs:complexType>\r
+\r
+<xs:complexType name="configtype">\r
+ <xs:sequence>\r
+ <xs:element name="section" type="sectiontype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:element name="config" type="configtype"/>\r
+\r
+</xs:schema>\r
--- /dev/null
+<?xml version="1.0" encoding="windows-1250"?>\r
+<!DOCTYPE stylesheet [\r
+<!ENTITY amp \r
+"<xsl:text disable-output-escaping='yes'>&amp;</xsl:text>">\r
+]>\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+<xsl:output method="html" encoding="utf-8"/>\r
+\r
+\r
+<xsl:template match="/">\r
+ <html><body>\r
+ <xsl:apply-templates/>\r
+ </body></html>\r
+</xsl:template>\r
+\r
+<xsl:template match="para">\r
+ <p><xsl:apply-templates/></p>\r
+</xsl:template>\r
+\r
+<xsl:template match="title">\r
+ \r
+</xsl:template>\r
+\r
+<xsl:template match="//ulink|//literal|//parameter|//varname|//sgmltag">\r
+ <b><xsl:value-of select="."/></b>\r
+</xsl:template>\r
+\r
+<xsl:template match="//quote">\r
+ <cite><xsl:value-of select="."/></cite>\r
+</xsl:template>\r
+\r
+<xsl:template match="//programlisting|//screen">\r
+ <pre><xsl:value-of select="."/></pre>\r
+</xsl:template>\r
+\r
+<xsl:template match="//variablelist">\r
+ <ul>\r
+ <xsl:for-each select="./varlistentry">\r
+ <li><b><xsl:value-of select="term"/></b> - <xsl:value-of select="listitem"/></li>\r
+ </xsl:for-each>\r
+ </ul>\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">\r
+\r
+<xs:simpleType name="stringtype">\r
+ <xs:restriction base="xs:string"/>\r
+</xs:simpleType>\r
+\r
+<xs:complexType name="figuretype">\r
+ <xs:sequence>\r
+ <xs:element name="parameter" type="stringtype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+ <xs:attribute name="name" type="stringtype" use="required"/>\r
+ <xs:attribute name="class" type="stringtype" use="required"/> \r
+</xs:complexType>\r
+\r
+<xs:complexType name="graphicstype">\r
+ <xs:sequence>\r
+ <xs:element name="figure" type="figuretype" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:element name="graphics" type="graphicstype"/>\r
+\r
+</xs:schema>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">\r
+\r
+<xs:simpleType name="stringtype">\r
+ <xs:restriction base="xs:string"/>\r
+</xs:simpleType>\r
+\r
+<xs:complexType name="attributetype">\r
+ <xs:simpleContent>\r
+ <xs:extension base="stringtype">\r
+ <xs:attribute name="default" type="stringtype"/>\r
+ </xs:extension>\r
+ </xs:simpleContent> \r
+</xs:complexType>\r
+\r
+<xs:complexType name="propertytype">\r
+ <xs:sequence>\r
+ <xs:element name="attribute" type="attributetype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+ <xs:attribute name="name" type="stringtype" use="required"/>\r
+</xs:complexType>\r
+\r
+<xs:complexType name="parametertype">\r
+ <xs:simpleContent>\r
+ <xs:extension base="stringtype">\r
+ <xs:attribute name="default" type="stringtype"/>\r
+ </xs:extension>\r
+ </xs:simpleContent> \r
+</xs:complexType>\r
+\r
+<xs:complexType name="propertiestype">\r
+ <xs:sequence>\r
+ <xs:element name="attribute-set" type="propertytype" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:complexType name="parameterstype">\r
+ <xs:sequence>\r
+ <xs:element name="parameter" type="parametertype" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:complexType name="templatetype">\r
+ <xs:sequence>\r
+ <xs:element name="attribute-sets" type="propertiestype" maxOccurs="1"/>\r
+ <xs:element name="parameters" type="parameterstype" maxOccurs="1"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:element name="template" type="templatetype"/>\r
+\r
+</xs:schema>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">\r
+\r
+<xs:simpleType name="stringtype">\r
+ <xs:restriction base="xs:string"/>\r
+</xs:simpleType>\r
+\r
+<xs:complexType name="colortype">\r
+ <xs:simpleContent>\r
+ <xs:extension base="stringtype">\r
+ <xs:attribute name="name" type="stringtype" use="required"/>\r
+ </xs:extension>\r
+ </xs:simpleContent> \r
+</xs:complexType>\r
+\r
+<xs:complexType name="colorstype">\r
+ <xs:sequence>\r
+ <xs:element name="color" type="colortype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence> \r
+</xs:complexType>\r
+\r
+<xs:complexType name="unitstype">\r
+ <xs:sequence>\r
+ <xs:element name="unit" type="stringtype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:complexType name="fonttype">\r
+ <xs:sequence>\r
+ <xs:element name="font" type="stringtype" minOccurs="1" maxOccurs="unbounded"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:complexType name="typestype">\r
+ <xs:sequence>\r
+ <xs:element name="colors" type="colorstype" minOccurs="1" maxOccurs="1"/>\r
+ <xs:element name="units" type="unitstype" minOccurs="1" maxOccurs="1"/>\r
+ <xs:element name="fonts" type="fonttype" minOccurs="1" maxOccurs="1"/>\r
+ </xs:sequence>\r
+</xs:complexType>\r
+\r
+<xs:element name="types" type="typestype"/>\r
+\r
+</xs:schema>\r
--- /dev/null
+<?xml version="1.0" encoding="windows-1250"?>\r
+<template xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+<attribute-sets>\r
+ <attribute-set name="monospace.properties">\r
+ <attribute default="3.0in">start-indent</attribute>\r
+ <attribute default="4.0in">end-indent</attribute>\r
+ </attribute-set>\r
+\r
+ <attribute-set name="abstract.title.properties">\r
+ <attribute default="bold">font-weight</attribute>\r
+ <attribute default="always">keep-with-next.within-column</attribute>\r
+ <attribute default="false">hyphenate</attribute>\r
+ <attribute default="center">text-align</attribute>\r
+ </attribute-set>\r
+ \r
+ <attribute-set name="component.title.properties">\r
+ <attribute default="always">keep-with-next.within-column</attribute>\r
+ <attribute default="false">hyphenate</attribute> \r
+ </attribute-set> \r
+ \r
+ <attribute-set name="formal.object.properties">\r
+ <attribute default="0.5em">space-before.minimum</attribute>\r
+ <attribute default="1em">space-before.optimum</attribute>\r
+ <attribute default="2em">space-before.maximum</attribute>\r
+ <attribute default="0.5em">space-after.minimum</attribute>\r
+ <attribute default="1em">space-after.optimum</attribute>\r
+ <attribute default="2em">space-after.maximum</attribute>\r
+ <attribute default="always">keep-with-next.within-column</attribute>\r
+ </attribute-set> \r
+</attribute-sets>\r
+\r
+<parameters>\r
+ <parameter default="1">double.sided</parameter>\r
+ <parameter default="A4">paper.type</parameter>\r
+</parameters>\r
+</template>\r