|
From: <ru...@us...> - 2007-09-10 05:58:44
|
Revision: 5
http://tomtesttool.svn.sourceforge.net/tomtesttool/?rev=5&view=rev
Author: rumbi
Date: 2007-09-09 22:58:46 -0700 (Sun, 09 Sep 2007)
Log Message:
-----------
RR:
- implemented undo/redo
- wrote INSTALL
- bumped version to 1.0.1
- ran FindBugs and changed some small problems it found
Modified Paths:
--------------
trunk/docs/BUGS
trunk/docs/ChangeLog
trunk/docs/INSTALL
trunk/docs/TODO
trunk/en.lang
trunk/fr.lang
trunk/src/de/sopra/controller/AnalysisHandler.java
trunk/src/de/sopra/controller/ConfigurationParser.java
trunk/src/de/sopra/controller/Controller.java
trunk/src/de/sopra/controller/ExecutionHandler.java
trunk/src/de/sopra/controller/LocaleHandler.java
trunk/src/de/sopra/controller/MainHandler.java
trunk/src/de/sopra/controller/PreparationHandler.java
trunk/src/de/sopra/controller/TOM.java
trunk/src/de/sopra/controller/pdf/ReportGenerator.java
trunk/src/de/sopra/controller/xml/XMLLoader.java
trunk/src/de/sopra/controller/xml/XMLParser.java
trunk/src/de/sopra/model/TOMVersion.java
trunk/src/de/sopra/model/Time.java
trunk/src/de/sopra/model/execution/ExecutedTestCase.java
trunk/src/de/sopra/model/preparation/ElementContainer.java
trunk/src/de/sopra/model/preparation/TestCase.java
trunk/src/de/sopra/model/preparation/TestElement.java
trunk/src/de/sopra/model/userdata/User.java
trunk/src/de/sopra/view/FailSafeErrorNotifier.java
trunk/src/de/sopra/view/GlobalExecutionListener.java
trunk/src/de/sopra/view/GlobalMenuListener.java
trunk/src/de/sopra/view/TOMFrame.java
trunk/src/de/sopra/view/ViewUtilities.java
trunk/src/de/sopra/view/menus/PopupPreparationTree.java
trunk/src/de/sopra/view/perspectives/SelectionPane.java
trunk/src/de/sopra/view/perspectives/WelcomePane.java
trunk/src/de/sopra/view/perspectives/analysis/AnalysisPane.java
trunk/src/de/sopra/view/perspectives/analysis/AnalysisTableModel.java
trunk/src/de/sopra/view/perspectives/analysis/ListPane.java
trunk/src/de/sopra/view/perspectives/execution/ExecutionCasePane.java
trunk/src/de/sopra/view/perspectives/execution/ExecutionEndPane.java
trunk/src/de/sopra/view/perspectives/execution/ExecutionPane.java
trunk/src/de/sopra/view/perspectives/execution/ExecutionSequencePane.java
trunk/src/de/sopra/view/perspectives/execution/ExecutionStartPane.java
trunk/src/de/sopra/view/perspectives/preparation/InputWatcher.java
trunk/src/de/sopra/view/perspectives/preparation/PreparationCasePane.java
trunk/src/de/sopra/view/perspectives/preparation/PreparationCasesPane.java
trunk/src/de/sopra/view/perspectives/preparation/PreparationSequencePane.java
trunk/src/de/sopra/view/perspectives/userdata/NewUserDialog.java
trunk/src/de/sopra/view/perspectives/userdata/UserPane.java
trunk/src/de/sopra/view/tree/DataTree.java
trunk/src/de/sopra/view/tree/DataTreeCellRenderer.java
trunk/src/de/sopra/view/tree/DataTreeModel.java
trunk/src/de/sopra/view/tree/DataTreeSelectionListener.java
trunk/src/de/sopra/view/tree/DataTreeTransferContainer.java
trunk/src/de/sopra/view/tree/TreePane.java
trunk/src/resources/config/std_de.lang
Added Paths:
-----------
trunk/src/de/sopra/view/UndoRedoListener.java
Property Changed:
----------------
trunk/
Property changes on: trunk
___________________________________________________________________
Name: svn:ignore
- build
dist
tom.cfg
bin
+ build
dist
tom.cfg
bin
.fbprefs
Modified: trunk/docs/BUGS
===================================================================
--- trunk/docs/BUGS 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/docs/BUGS 2007-09-10 05:58:46 UTC (rev 5)
@@ -1,6 +1,8 @@
+see SourceForge's bugtracker
+
Found during the system test of TOM:
------------------------------------
-
+
-- Found during the second iteration of the system test:
JM: NOT-NICE: ViewUtilities#DATE_TIME_FORMAT is hard coded, should depend on the
@@ -10,6 +12,6 @@
Found during unsystematic tests:
--------------------------------
-
+
RR: Tree behaviour sucks during import of default/non-default test sequences and
manipulation via table.
Modified: trunk/docs/ChangeLog
===================================================================
--- trunk/docs/ChangeLog 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/docs/ChangeLog 2007-09-10 05:58:46 UTC (rev 5)
@@ -1,3 +1,22 @@
+2007-09-08 Reinhold Rumberger <ru...@us...>
+ * fixed a stupid bug introduced while fixing bugs found by FindBugs
+ (preparatioHandler wasn't notified of path changes in the tree)
+ * implemented making edits in TextComponents un-/redoable
+ * added UndoRedoListener
+
+2007-09-07 Reinhold Rumberger <ru...@us...>
+ * reverted several transients, as they were misplaced
+ * made a new method for getting resources, saving between 50 and 100 LOCs
+ * added some content to INSTALL
+ * incremented versions of the files changed
+ * bumped TOM's version
+
+2007-09-05 Reinhold Rumberger <ru...@us...>
+ * ran FindBugs
+ * fixed lots of potential bugs found by FindBugs
+ * there are now several "transient" fields since FindBugs complained about them
+ not being transient. Need to recheck.
+
2007-08-22 Reinhold Rumberger <ru...@us...>
* added new ideas to the TODO list
* translated BUGS to english
Modified: trunk/docs/INSTALL
===================================================================
--- trunk/docs/INSTALL 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/docs/INSTALL 2007-09-10 05:58:46 UTC (rev 5)
@@ -0,0 +1,28 @@
+Installing the standard .jar:
+#############################
+
+Nothing special has to be done. Just copy the JAR to a directory of your choice and use your platform's default way of starting from an executable JAR. You may want to change some settings in the tom.cfg.
+If you want the manual to work, you need to place a copy into the same directory as the JAR.
+
+
+Installing using a different language:
+######################################
+
+Follow the instructions above. In the tom.cfg created after TOM's first start, change the "languagefile" option to point to a file containing the appropriate translation (normally a .lang file that was shipped with TOM or in a langs.* archive).
+
+
+Installing from SVN:
+####################
+
+You'll need ant and a JDK!
+
+If you only want the TOM.jar ant the manual, calling
+
+ant TOM.jar
+
+in the directory containing the build.xml file should suffice.
+Should you want more (the javadocs, the language pack), you should run
+
+ant dist
+
+and get ready to wait for some time. The manual will currently not be rebuilt and should be taken care of separately (the version in SVN should be up-to-date).
Modified: trunk/docs/TODO
===================================================================
--- trunk/docs/TODO 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/docs/TODO 2007-09-10 05:58:46 UTC (rev 5)
@@ -1,9 +1,15 @@
- buildsettings.properties: javadoc link for itext
- graphical preferences editor
- write README
- - write INSTALL
- add a way of undoing changes during execution after the 'Next' Button has been
pressed (either via a 'Back' Button, a way to asynchroneously select previously
executed test cases, or both)
- Enter bugs in sf's bugtracker
- Make the manual available to svn
+ - context menu for editable text components (copy, cut, paste, ...)
+
+
+Done:
+
+ - (RR) write INSTALL
+ - (RR) undo/redo for editable text components
Modified: trunk/en.lang
===================================================================
--- trunk/en.lang 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/en.lang 2007-09-10 05:58:46 UTC (rev 5)
@@ -8,7 +8,7 @@
LOCALE_NAME=en
# version of TOM as defined in TOM.java for checking if this language file is
# up-to-date
-version=1.0.0
+version=1.0.1
SAVE_FILE_EXTENSION_NAME=TOM project files (*.tom)
#This is the german manual. You may change this to the filename of an english manual if one exists.
@@ -287,7 +287,7 @@
SURE_TO_ABORT_EXECUTION=Are you sure that you want to abort the test execution?\nAlready executed test cases will be saved.
EXECUTION_PERSPECTIVE_CANNOT_BE_LEFT=You are currently executing a test sequence. To leave the execution perspective, either finish the execution or abort it.
-AUTOSAVE_EXECUTION_WAS_CANCELLED_HERE=The test execution advanced as far as this when an automatic save occurred. The success of this test case may not be final.
+AUTOSAVE_EXECUTION_WAS_CANCELLED_HERE=The test execution advanced as far as this when an automatic save occurred. The success of this test case may not be final.
AUTOSAVED_EXECUTION=Incomplete test execution due to automatic save!
#PDF export
FILE_EXPORT_TITLE=Export
@@ -324,7 +324,7 @@
ABOUT_DEFAULT_TITLE=About TOM
ABOUT_COPYRIGHT_NOTICE=Copyright \u00a9 2007 Falko K\u00f6tter, Jens M\u00fcller, Reinhold Rumberger
-ABOUT_VERSION=Version:
+ABOUT_VERSION=Version:
ABOUT_DESCRIPTION=<html><body><p style="font-size: large; font-weight: bold; padding: 0px; margin: 0px;"><em>TOM</em> \u2014 a tool for testing software.</p><p><b><em>TOM</em> was developed during the Softwarepraktikum 2007 at the Universität Stuttgart.</b></p></body></html>
AUTHOR_TOOLTIP=Author: %s
Modified: trunk/fr.lang
===================================================================
--- trunk/fr.lang 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/fr.lang 2007-09-10 05:58:46 UTC (rev 5)
@@ -11,7 +11,7 @@
LOCALE_NAME=fr
# version of TOM as defined in TOM.java for checking if this language file is
# up-to-date
-version=1.0.0
+version=1.0.1
SAVE_FILE_EXTENSION_NAME=Fichier de projet TOM (*.tom)
@@ -241,13 +241,13 @@
NO_DESCRIPTION_ENTERED=Il n'y a pas de description.
NO_INITIAL_SITUATION_ENTERED=Il n'y a pas de situation initiale.
NO_USER_ACTION_ENTERED=Il n'y a pas d'action de test.
-NO_EXPECTED_RESULT_ENTERED=Il n'y a pas de r\u00e9sultat esp\u00e9r\u00e9.
+NO_EXPECTED_RESULT_ENTERED=Il n'y a pas de r\u00e9sultat esp\u00e9r\u00e9.
NO_AUTHOR_CHOSEN=Vous n'avez pas s\u00e9lectionn\u00e9 un auteur.
INACTIVE_AUTHOR_CHOSEN=Vous avez s\u00e9lectionn\u00e9 un auteur invalable.
INVALID_ESTIMATED_TIME=Le temps estim\u00e9 est invalable.
NO_PRIORITY_CHOSEN=Vous n'avez pas s\u00e9lectionn\u00e9 une priorit\u00e9.
ILLEGAL_DEFAULT_SEQUENCE_MOVEMENT=Une s\u00e9quence de test standard ne peut pas \u00eatre d\u00e9plac\u00e9 ici.
-ILLEGAL_MOVEMENT_IN_SUBTREE=Un \u00e9l\u00e9ment ne peut pas \u00eatre d\u00e9plac\u00e9 dans un de ces \u00e9l\u00e9ments enfants.
+ILLEGAL_MOVEMENT_IN_SUBTREE=Un \u00e9l\u00e9ment ne peut pas \u00eatre d\u00e9plac\u00e9 dans un de ces \u00e9l\u00e9ments enfants.
ILLEGAL_MOVEMENT_OF_TEST_CASE_IN_ROOT=Un cas des test ne peut pas \u00eatre d\u00e9plac\u00e9 ici.
ERROR_WHILE_MOVING_ELEMENT=Erreur en d\u00e9pla\u00e7ant un \u00e9l\u00e9ment.
DEFAULT_SEQUENCES_MAY_NOT_BE_ERASED=Une s\u00e9quence de test standard ne peut pas \u00eatre effac\u00e9.
@@ -297,7 +297,7 @@
AUTOSAVED_EXECUTION=Ex\u00e9cution de test incompl\u00e8te \u00e0 cause du sauvegardement automatique.
#PDF export
FILE_EXPORT_TITLE=Export
-EXP_TITLE=Ex\u00e9cution de test %1$s - %2$s
+EXP_TITLE=Ex\u00e9cution de test %1$s - %2$s
EXP_BY_USER=par
EXP_TOC_ID=Num\u00e9ro
EXP_TOC_NAME=Nom
@@ -330,7 +330,7 @@
ABOUT_DEFAULT_TITLE=A propos de TOM
ABOUT_COPYRIGHT_NOTICE=Copyright \u00a9 2007 Falko K\u00f6tter, Jens M\u00fcller, Reinhold Rumberger
-ABOUT_VERSION=Version:
+ABOUT_VERSION=Version:
ABOUT_DESCRIPTION=<html><body><p style="font-size: large; font-weight: bold; padding: 0px; margin: 0px;"><em>TOM</em> \u2014 un outil pour faire des test de logiciels.</p><p><b><em>TOM</em> a \u00e9t\u00e9 d\u00e9velopp\u00e9 comme "Softwarepraktikum" 2007 \u00e0 l'universit\u00e9 de Stuttgart.</b></p></body></html>
AUTHOR_TOOLTIP=Auteur: %s
Modified: trunk/src/de/sopra/controller/AnalysisHandler.java
===================================================================
--- trunk/src/de/sopra/controller/AnalysisHandler.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/AnalysisHandler.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,21 +2,21 @@
* AnalysisHandler.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: 05.05.2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
@@ -35,7 +35,7 @@
/**
* The part of the controller that handles events coming from the view that are
* related to the analysis perspective.
- *
+ *
* @author Reinhold Rumberger
*/
public class AnalysisHandler implements HandlerInterface {
@@ -48,7 +48,7 @@
/**
* Allows to set an implementation of <code>{@link AnalysisInterface}</code>
* for communication with the view.
- *
+ *
* @param view
* The new view.
*/
@@ -83,14 +83,14 @@
}
} else {
Controller.getInstance().viewLink.notify(LocaleHandler
- .getInstance().getMessage("PLEASE_CHOOSE_AN_EXECUTION"), LocaleHandler
- .getInstance().getMessage("DELETE_EXECUTION"));
+ .getInstance().getMessage("PLEASE_CHOOSE_AN_EXECUTION"),
+ LocaleHandler.getInstance().getMessage("DELETE_EXECUTION"));
}
}
/**
* Asks the handler if it allows to exit the current perspective.
- *
+ *
* @return <code>true</code> if perspective may be changed.
*/
public boolean allowExit() {
@@ -100,41 +100,37 @@
/**
* Asks the handler if it allows to exit the program.
- *
+ *
* @return <code>true</code> if program may be closed.
*/
public boolean allowProgramClose() {
return this.allowExit();
}
-
+
/**
* Clean up the perspective after leaving it.
*/
public void cleanup() {
// nothing needs to be done here
-
}
/**
* Prepare the perspective before switching to it.
*/
public void prepareForDisplay() {
-
viewLink.displayExecutionList(Controller.getInstance().testProject
.getExecutions());
viewLink.displayFilteredExecution(viewLink.getExecution());
-
}
/**
* Is also used by executionFilterChanged.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface
*/
public void changeActiveExecution() {
if (viewLink.getExecution() != null) {
-
ReadableTestExecution filteredExecution = viewLink.getExecution()
.getFiltered(viewLink.getSuccessFilter());
@@ -156,25 +152,25 @@
/**
* Tell the controller to export the currently selected
* <code>{@link TestExecution}</code>.
- *
+ *
* @param execution
* The <code>{@link TestExecution}</code> to be exported.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#exportTestExecution(ReadableTestExecution)
*/
public void exportTestExecution(ReadableTestExecution execution) {
- if (execution != null) {
- String outFile = Controller.getInstance().saveFile(
- LocaleHandler.getInstance().getMessage("FILE_EXPORT_TITLE"),
- new String[][] { new String[] { "pdf" } },
- new String[] { LocaleHandler.getInstance().getMessage(
- "PDF_FILE_EXTENSION_NAME") });
+ if (execution != null && execution instanceof TestExecution) {
+ String outFile = Controller.getInstance()
+ .saveFile(
+ LocaleHandler.getInstance().getMessage(
+ "FILE_EXPORT_TITLE"),
+ new String[][] { new String[] { "pdf" } },
+ new String[] { LocaleHandler.getInstance()
+ .getMessage("PDF_FILE_EXTENSION_NAME") });
if (outFile != null && !outFile.equals("")) {
-
try {
-
ReportGenerator.toPDF((TestExecution) execution, Controller
.getInstance().testProject.getName(), outFile);
// everything ok
@@ -182,23 +178,23 @@
.getInstance().getMessage("PDF_EXPORT_SUCCESSFUL"),
LocaleHandler.getInstance().getMessage(
"PRINT_AS_PDF"));
-
} catch (FileNotFoundException e) {
- Controller.getInstance().viewLink.notify(LocaleHandler
+ e.printStackTrace();
+ Controller.getInstance().viewLink.error(LocaleHandler
.getInstance().getMessage("ERROR_FILE_EXPORT"),
LocaleHandler.getInstance().getMessage(
"PRINT_AS_PDF"));
} catch (Exception e) {
- Controller.getInstance().viewLink.notify(LocaleHandler
+ e.printStackTrace();
+ Controller.getInstance().viewLink.error(LocaleHandler
.getInstance().getMessage("ERROR_DOCUMENT_EXPORT",
e.getLocalizedMessage()), LocaleHandler
.getInstance().getMessage("PRINT_AS_PDF"));
}
-
}
} else {
- Controller.getInstance().viewLink.notify(LocaleHandler
- .getInstance().getMessage("PLEASE_CHOOSE_AN_EXECUTION"), LocaleHandler
+ Controller.getInstance().viewLink.error(LocaleHandler.getInstance()
+ .getMessage("PLEASE_CHOOSE_AN_EXECUTION"), LocaleHandler
.getInstance().getMessage("PRINT_AS_PDF"));
}
}
Modified: trunk/src/de/sopra/controller/ConfigurationParser.java
===================================================================
--- trunk/src/de/sopra/controller/ConfigurationParser.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/ConfigurationParser.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,30 +2,27 @@
* ConfigurationParser.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: May 23, 2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
package de.sopra.controller;
-import de.sopra.exceptions.ConfigFileIOException;
-import de.sopra.exceptions.InvalidDefaultConfigFileException;
-
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
@@ -40,10 +37,13 @@
import java.util.LinkedList;
import java.util.Properties;
+import de.sopra.exceptions.ConfigFileIOException;
+import de.sopra.exceptions.InvalidDefaultConfigFileException;
+
/**
* This class handles the access to the configuration file of TOM. It uses the
* singleton pattern so an instance may only be gotten via getInstance().
- *
+ *
* @author Falko Kötter
*/
public class ConfigurationParser {
@@ -74,7 +74,7 @@
* A <code>{@link File}</code> constant containing the default config
* file.
*/
- private static final InputStream DEFAULT_CONFIG = new Object().getClass()
+ private static final InputStream DEFAULT_CONFIG = ConfigurationParser.class
.getResourceAsStream(DEFAULT_CONFIG_PATH);
/**
@@ -124,8 +124,9 @@
try {
String readLine;
confFile.createNewFile();
- stdStream = new BufferedReader(new InputStreamReader(getClass()
- .getResourceAsStream(DEFAULT_CONFIG_PATH)));
+ stdStream = new BufferedReader(new InputStreamReader(
+ ConfigurationParser.class
+ .getResourceAsStream(DEFAULT_CONFIG_PATH)));
writeStream = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(confFile)));
readLine = stdStream.readLine();
@@ -176,7 +177,7 @@
*/
private void initConfig() {
Properties defaultProperty = new Properties();
- InputStream config;
+ InputStream config = null;
boolean goodVersion;
confFile = new File(CONFIG_PATH);
@@ -208,6 +209,12 @@
configProperties.load(config);
} catch (IOException e) {
throw new ConfigFileIOException("Illegal config file.", e);
+ } finally {
+ try {
+ config.close();
+ } catch (Exception ex) {
+ // Ignore exception since this is a last resort type of action
+ }
}
if (!goodVersion) {
@@ -219,16 +226,18 @@
/**
* Makes sure the config file version is correct.
- *
+ *
* @return <code>true</code>, if the version is fine or appropriate
* measures could be taken, <code>false</code> if something is
* seriously wrong.
*/
private boolean checkVersion() {
Properties checkProperty = new Properties();
+ FileInputStream checkedStream = null;
try {
- checkProperty.load(new FileInputStream(confFile));
+ checkedStream = new FileInputStream(confFile);
+ checkProperty.load(checkedStream);
} catch (FileNotFoundException e) {
// can't actuall happen, as it must have happened before
throw new ConfigFileIOException("Config file cannot be opened.", e);
@@ -239,6 +248,12 @@
} catch (IOException e) {
// can't actuall happen, as it must have happened before
throw new ConfigFileIOException("Illegal config file.", e);
+ } finally {
+ try {
+ checkedStream.close();
+ } catch (Exception e) {
+ // Ignore exception since this is a last resort type of action
+ }
}
if (checkProperty.getProperty("version") == null) {
Modified: trunk/src/de/sopra/controller/Controller.java
===================================================================
--- trunk/src/de/sopra/controller/Controller.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/Controller.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,21 +2,21 @@
* Controller.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: Apr 30, 2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
@@ -42,9 +42,9 @@
* <code>{@link ExecutionHandler}</code>, <code>{@link MainHandler}</code>,
* <code>{@link PreparationHandler}</code> and
* <code>{@link UserHandler}</code>.
- *
+ *
* @author Jens Müller
- *
+ *
* @see <a href="http://en.wikipedia.org/wiki/Model-view-controller">Wikipedia
* article about the MVC pattern</a>
*/
@@ -57,7 +57,7 @@
/**
* Singleton handling method.
- *
+ *
* @return Existing or newly created singleton instance.
*/
public static Controller getInstance() {
@@ -194,7 +194,6 @@
public void changeDisplayedTestElement(ReadableTestElement element) {
switch (activePerspective) {
-
case PREPARATION:
preparationHandler.changeDisplayedTestElement(element);
break;
@@ -361,7 +360,7 @@
/**
* Creates the default test sequences when creating a new project.
- *
+ *
* @see MainHandler#createDefaultTestSequences()
*/
protected void createDefaultTestSequences() {
@@ -556,7 +555,7 @@
/**
* Requests a file name from the GUI. The dialog for opening a file is used.
- *
+ *
* @param title
* The title of the dialog.
* @param extensions
@@ -580,7 +579,7 @@
/**
* Open a project from the specified file name.
- *
+ *
* @param filename
* The path to the project to open.
*/
@@ -640,7 +639,7 @@
/**
* Requests a filename from the GUI. The dialog for saving a file is used.
- *
+ *
* @param title
* The title of the dialog.
* @param extensions
Modified: trunk/src/de/sopra/controller/ExecutionHandler.java
===================================================================
--- trunk/src/de/sopra/controller/ExecutionHandler.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/ExecutionHandler.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,21 +2,21 @@
* ExecutionHandler.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: 05.05.2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
@@ -48,8 +48,8 @@
/**
* The part of the controller that handles events coming from the view which are
* related to the execution perspective.
- *
- *
+ *
+ *
* @author Reinhold Rumberger
*/
public class ExecutionHandler implements HandlerInterface {
@@ -59,14 +59,14 @@
* level, combining the current sequence of the data model, the current
* iterator throught its childs and the newly created
* <code>{@link ExecutedTestSequence}</code>.
- *
+ *
* Objects of this class will be in a stack during execution, representing
* the level of the tree of executions.
- *
+ *
* @author Jens Müller
- *
+ *
*/
- final class CurrentExecutionLevel {
+ static final class CurrentExecutionLevel {
/**
* Points to the test sequence of the current level of execution.
@@ -97,23 +97,23 @@
* State when the execution is currently not started but the starting screen
* is displayed.
*/
- private final short DEFAULT_STATE = 0;
+ private static final short DEFAULT_STATE = 0;
/**
* State when the execution has currently arrived at a test sequence.
*/
- private final short SEQUENCE_STATE = 1;
+ private static final short SEQUENCE_STATE = 1;
/**
* State when the execution has currently arrived at a test case.
*/
- private final short CASE_STATE = 2;
+ private static final short CASE_STATE = 2;
/**
* State when the execution has currently finished and the final screen is
* displayed.
*/
- private final short FINISH_STATE = 3;
+ private static final short FINISH_STATE = 3;
/**
* Representing the state of this sub controller.
@@ -151,7 +151,7 @@
* Allows to set an implementation of
* <code>{@link ExecutionInterface}</code> for communication with the
* view.
- *
+ *
* @param view
* The new view.
*/
@@ -436,13 +436,13 @@
* This should only be called by
* <code>{@link MainHandler#autoSaveProject()}</code>, as you need to
* make sure that the author references are ok.
- *
+ *
* @return The unfinished execution with all the data.
*/
public TestExecution getUnfinishedExecution() {
// no execution started yet
if (state == DEFAULT_STATE) return null;
-
+
TestExecution unfinishedExecution = new TestExecution();
// Author's references are incremented here. After using this unfinished
@@ -514,7 +514,7 @@
/**
* Asks the handler if it allows to exit the current perspective.
- *
+ *
* @return <code>true</code> if perspective may be changed.
*/
public boolean allowExit() {
@@ -531,7 +531,7 @@
/**
* Asks the handler if it allows to exit the program.
- *
+ *
* @return <code>true</code> if program may be closed.
*/
public boolean allowProgramClose() {
@@ -562,7 +562,7 @@
/**
* Display the selected {@link TestElement} if it is a {@link TestSequence}.
- *
+ *
* @param element
* The <code>TestElement</code> which is to be displayed.
*/
Modified: trunk/src/de/sopra/controller/LocaleHandler.java
===================================================================
--- trunk/src/de/sopra/controller/LocaleHandler.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/LocaleHandler.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,21 +2,21 @@
* LocaleHandler.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: 25.04.2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
@@ -30,12 +30,13 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Locale;
import java.util.Properties;
/**
* This class provides a singleton instance to handle the translation of
* internal <code>{@link String Strings}</code> to localized versions.
- *
+ *
* @author Reinhold Rumberger
*/
public class LocaleHandler {
@@ -98,7 +99,7 @@
/**
* Loads a language to be used by
* <code>{@link #getMessage(String, String[])}</code>.
- *
+ *
* @throws PropertiesNotLoadedException
* Thrown whenever one of the locales could not be loaded.
*/
@@ -127,7 +128,7 @@
/**
* Resets the locale to <code>{@link #DEFAULT_LOCALE}</code>.
- *
+ *
* @throws PropertiesNotLoadedException
* Thrown if the
* <code>{@link #DEFAULT_LOCALE default locale}</code> could
@@ -142,7 +143,7 @@
* <code>{@link #DEFAULT_LOCALE}</code> as default, i.e. it's used
* whenever a <code>{@link String}</code> isn't found in the passed locale
* file.
- *
+ *
* @param newLocale
* The <code>{@link File}</code> containing the locale data.
* @throws PropertiesNotLoadedException
@@ -167,7 +168,7 @@
/**
* Calls <code>{@link #setLocale(File)}</code> with a
* <code>{@link File}</code> initialized with the parameter.
- *
+ *
* @param localepath
* The path of the <code>{@link File}</code> containing the
* locale data.
@@ -195,7 +196,7 @@
* handles incorrect input gracefully. It returns either "NULL" or prints a
* message to <code>{@link System#err}</code>, if msg couldn't be found
* as a key in either the default or the selected locale.
- *
+ *
* @param msg
* A String selector for the message to be returned.
* @param insertationStrings
@@ -222,7 +223,7 @@
if (ret == null) {
System.err.println("Couldn't find message: " + msg);
- return msg.toUpperCase();
+ return msg.toUpperCase(Locale.getDefault());
} else {
return String.format(removeMnemonic(ret),
(Object[]) insertationStrings);
@@ -231,7 +232,7 @@
/**
* Does the actual loading of the localized string.
- *
+ *
* @param msg
* A <code>{@link String}</code> selector for the message to be
* returned.
@@ -258,7 +259,7 @@
* Tries to remove the first unescaped mnemonic character from the localized
* representation of the passed string. Also removes escapes from escaped
* mnemonics.
- *
+ *
* @param withMnemonic
* The <code>{@link String}</code> potentially containing the
* mnemonic.
@@ -323,7 +324,7 @@
/**
* Extracts the mnemonic character from the localized version of the passed
* <code>{@link String}</code>.
- *
+ *
* @param msg
* A <code>{@link String}</code> selector for localized
* <code>{@link String}</code> who's mnemonic should be
Modified: trunk/src/de/sopra/controller/MainHandler.java
===================================================================
--- trunk/src/de/sopra/controller/MainHandler.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/MainHandler.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,21 +2,21 @@
* MainHandler.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: 05.05.2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
@@ -39,13 +39,14 @@
import java.awt.Desktop;
import java.io.File;
import java.util.Calendar;
+import java.util.Locale;
import javax.swing.JOptionPane;
/**
* The part of the controller which handles events coming to the view that do
* not belong to a specific perspective but to the project in general.
- *
+ *
* @author Reinhold Rumberger
*/
public class MainHandler implements HandlerInterface {
@@ -69,7 +70,7 @@
/**
* Allows to set an implementation of <code>{@link MainInterface}</code>
* for communication with the view.
- *
+ *
* @param view
* The new view.
*/
@@ -298,7 +299,7 @@
/**
* Open a project from the specified file name.
- *
+ *
* @param fileName
* The path to the project to open.
* @see de.sopra.controller.facade.ControllerInterface#openProject()
@@ -361,6 +362,7 @@
/**
* @see ControllerInterface#help()
*/
+ // FIXME: This code is not only ugly but also rather buggy
public void help() {
try {
// If the jar is launched with a working directory which is not the
@@ -392,7 +394,8 @@
fileName = fileName.substring(5);
// get the path to the .jar
- int pos = fileName.toLowerCase().indexOf(".jar!");
+ int pos = fileName.toLowerCase(Locale.getDefault()).indexOf(
+ ".jar!");
if (pos != -1) {
@@ -405,7 +408,6 @@
fileName = fileName.substring(0, pos + 1);
pathSuccess = true;
}
-
}
}
@@ -435,7 +437,7 @@
/**
* Asks the handler if it allows to exit the current perspective.
- *
+ *
* @return <code>true</code> if perspective may be changed.
*/
public boolean allowExit() {
@@ -444,7 +446,7 @@
/**
* Asks the handler if it allows to exit the program.
- *
+ *
* @return <code>true</code> if program may be closed.
*/
public boolean allowProgramClose() {
@@ -469,7 +471,7 @@
/**
* Requests a file name from the GUI. The dialog for opening a file is used.
- *
+ *
* @param title
* The title of the dialog.
* @param extensions
@@ -502,7 +504,7 @@
/**
* Requests a filename from the GUI. The dialog for saving a file is used.
- *
+ *
* @param title
* The title of the dialog.
* @param extensions
Modified: trunk/src/de/sopra/controller/PreparationHandler.java
===================================================================
--- trunk/src/de/sopra/controller/PreparationHandler.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/PreparationHandler.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,21 +2,21 @@
* PreparationHandler.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: 05.05.2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
@@ -44,6 +44,7 @@
import de.sopra.view.facade.PreparationInterface;
import java.text.ParseException;
+import java.util.Locale;
import java.util.TreeSet;
import javax.swing.JOptionPane;
@@ -54,18 +55,18 @@
* finite state machine (see constants for the single states). Additionally it
* remembers the displayed element and (in case of a newly created element) the
* parent.
- *
+ *
* Cut and Paste is handled by a separate condition and a buffer. Notice that
* the buffer is cleared when a change of perspective occurs. This is due to
* maintaining author references.
- *
+ *
* If data was changed by the user a decision about the changes is forced before
* he can use any other part of the application. Due to defensive programming,
* some of the conditions or exceptions may never be met if a specific view is
* used. However, they are implemented so that views may be easily exchanged.
- *
+ *
* @author Falko Kötter
- *
+ *
*/
public class PreparationHandler implements HandlerInterface {
@@ -151,7 +152,7 @@
* Allows to set an implementation of
* <code>{@link PreparationInterface}</code> for communication with the
* view.
- *
+ *
* @param view
* The new view.
*/
@@ -197,7 +198,7 @@
/**
* Forces the user to decide what is going to happen with the changes he
* made.
- *
+ *
* @return <code>true</code> if a decision has been made.
*/
private boolean forceDecision() {
@@ -220,7 +221,7 @@
/**
* Asks the handler if it allows to exit the current perspective.
- *
+ *
* @return <code>true</code> if perspective may be changed.
*/
public boolean allowExit() {
@@ -229,7 +230,7 @@
/**
* Asks the handler if it allows to exit the program.
- *
+ *
* @return <code>true</code> if program may be closed.
*/
public boolean allowProgramClose() {
@@ -357,7 +358,7 @@
* The <code>{@link TestElement}</code> to be moved.
* @param index
* The position in the new parent element.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#changePosition(ReadableElementContainer,
* ReadableElementContainer, ReadableTestElement, int)
*/
@@ -440,7 +441,7 @@
/**
* Confirmation of modification/creation of a test case/sequence.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#confirm()
*/
public void confirm() {
@@ -505,7 +506,7 @@
/**
* Signals that the user wants to copy the selected element.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#copy()
*/
public void copy() {
@@ -556,7 +557,7 @@
* The <code>{@link ElementContainer}</code> acting as a parent
* to the new <code>{@link TestSequence}</code>. If parent is
* <code>null</code>, nothing should happen.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#createNewSequence(ReadableElementContainer)
*/
public void createNewSequence(ReadableElementContainer parent) {
@@ -595,7 +596,7 @@
* to the new <code>{@link TestCase}</code>. If
* <code>parent</code> is <code>null</code>, nothing should
* happen.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#createNewTestCase(ReadableElementContainer)
*/
public void createNewTestCase(ReadableElementContainer parent) {
@@ -636,7 +637,7 @@
/**
* Signals that the user wants to cut the selected element.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#cut()
*/
public void cut() {
@@ -690,7 +691,7 @@
/**
* @param sequence
* The <code>{@link TestSequence}</code> to be exported.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#exportTestSequence(ReadableTestSequence)
*/
public void exportTestSequence(ReadableTestSequence sequence) {
@@ -787,7 +788,7 @@
if (element instanceof ReadableTestSequence
&& ((ReadableTestSequence) element).isDefault()) {
defaultSequenceNames.add(((ReadableTestSequence) element)
- .getName().toLowerCase());
+ .getName().toLowerCase(Locale.getDefault()));
}
}
@@ -796,7 +797,7 @@
// contained
// => it must have been the name of a default TestSequence
merge = !defaultSequenceNames.add(importedSequence.getName()
- .toLowerCase());
+ .toLowerCase(Locale.getDefault()));
// ...and insert the sequence into it, if appropriate
if (merge) {
@@ -922,7 +923,7 @@
/**
* @param element
* The <code>{@link TestElement}</code> to be deleted.
- *
+ *
* @see de.sopra.controller.facade.ControllerInterface#removeElement(ReadableTestElement)
*/
public void removeElement(ReadableTestElement element) {
@@ -971,7 +972,7 @@
/**
* Validates the data the user has entered in the view and tells the view to
* notify the user of any errors.
- *
+ *
* @return True If the data the users has entered is in correct format.
*/
private boolean validate() {
@@ -1110,7 +1111,7 @@
/**
* Apply the changes the user has made in the view. changes are only applied
* if they conatin no errors in format.
- *
+ *
* @return True If the changes could be applied.
*/
private boolean applyChanges() {
@@ -1193,7 +1194,7 @@
/**
* Removes an element from the tree and does all necessary updates.
- *
+ *
* @param element
* The element which is to be removed.
*/
@@ -1235,4 +1236,4 @@
void returnToDefaultMode() {
insertionMode = DEFAULT_MODE;
}
-}
\ No newline at end of file
+}
Modified: trunk/src/de/sopra/controller/TOM.java
===================================================================
--- trunk/src/de/sopra/controller/TOM.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/TOM.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,21 +2,21 @@
* TOM.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: Apr 26, 2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
@@ -36,7 +36,7 @@
/**
* Starting class of the software. Used for initialization of Model, Controller
* and View.
- *
+ *
* @author Jens Müller
*/
public class TOM {
@@ -45,7 +45,7 @@
* Representation of the version of the software, allowing comparison and
* other comforts.
*/
- public static final TOMVersion VERSION = new TOMVersion(1, 0, 0);
+ public static final TOMVersion VERSION = new TOMVersion(1, 0, 1);
/**
* A string representation of TOM's version.<br>
@@ -64,7 +64,7 @@
TOMFrame tomFrame = null;
String openFile = null;
-
+
if (args.length > 0) {
openFile = args[0];
}
@@ -81,7 +81,7 @@
tomFrame = new TOMFrame();
Controller.getInstance().changePerspective(PerspectiveEnum.WELCOME);
-
+
if (openFile != null) {
Controller.getInstance().openProject(openFile);
}
Modified: trunk/src/de/sopra/controller/pdf/ReportGenerator.java
===================================================================
--- trunk/src/de/sopra/controller/pdf/ReportGenerator.java 2007-08-27 07:07:35 UTC (rev 4)
+++ trunk/src/de/sopra/controller/pdf/ReportGenerator.java 2007-09-10 05:58:46 UTC (rev 5)
@@ -2,37 +2,27 @@
* ReportGenerator.java
*
* Project: TOM
- * Version: 1.0.0
+ * Version: 1.0.1
* Created: Apr 27, 2007
- *
*
+ *
* copyright 2007 by Falko Kötter, Jens Müller and Reinhold Rumberger
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
package de.sopra.controller.pdf;
-import de.sopra.controller.LocaleHandler;
-import de.sopra.controller.TOM;
-import de.sopra.controller.Visitor;
-import de.sopra.model.execution.ExecutedTestCase;
-import de.sopra.model.execution.ExecutedTestSequence;
-import de.sopra.model.execution.ReadableExecutedTestCase;
-import de.sopra.model.execution.ReadableExecutedTestSequence;
-import de.sopra.model.execution.TestExecution;
-import de.sopra.model.preparation.TestElement;
-
import java.awt.Color;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -56,11 +46,21 @@
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
+import de.sopra.controller.LocaleHandler;
+import de.sopra.controller.TOM;
+import de.sopra.controller.Visitor;
+import de.sopra.model.execution.ExecutedTestCase;
+import de.sopra.model.execution.ExecutedTestSequence;
+import de.sopra.model.execution.ReadableExecutedTestCase;
+import de.sopra.model.execution.ReadableExecutedTestSequence;
+import de.sopra.model.execution.TestExecution;
+import de.sopra.model.preparation.TestElement;
+
/**
* Creates reports for <code>{@link TestExecution TestExecutions}</code>,
* including a table of contents (TOC) and detailed information about every
* executed test element.
- *
+ *
* @author Jens Müller
*/
public class ReportGenerator extends Visitor {
@@ -71,45 +71,6 @@
private static ReportGenerator theInstance;
/**
- * Singleton handling method.
- *
- * @return Existing or newly created singleton instance.
- */
- public static ReportGenerator getInstance() {
-
- if (theInstance == null) {
- theInstance = new ReportGenerator();
- }
-
- return theInstance;
- }
-
- /**
- * Converts a length in centimeters to a length in points. It is assumed
- * that the PDF is rendered with 72 dpi.
- *
- * @param cm
- * to convert to centimeter
- * @return centimeteras length in points.
- */
- public static float cmToPt(float cm) {
- return ((cm / 2.54f) * 72.0f);
- }
-
- /**
- * Converts a length given in pt to cm. The conversion assumes that 72 dpi
- * are used for rendering.
- *
- * @param pt
- * to convert to cm
- * @return pt length in cm
- */
- public static float ptToCm(float pt) {
- // 72 pt = 1 inch = 2.54 cm
- return ((pt / 72.0f) * 2.54f);
- }
-
- /**
* Font used for the main heading
*/
private static Font headingFont;
@@ -135,14 +96,9 @@
private static Font boldFont;
/**
- * Total height of one page.
- */
- public static float pageHeight;
-
- /**
* Total width of one page.
*/
- public static float pageWidth;
+ static float pageWidth;
/**
* Color used for highlighting success OK in the export document.
@@ -198,18 +154,209 @@
* <code>{@link PageDecorator#onStartPage(PdfWriter, Document)}</code>
* then.
*/
- protected static boolean isTOCPages;
+ static boolean isTOCPages;
/**
- * Do not allow external instantiation.
+ * Adds an executed test case to the table of contents.
+ *
+ * @param el
+ * Element for which the entry in the TOC is to be created.
+ * @param toc
+ * Table to add the cells to.
+ * @param depth
+ * Depth in the tree.
*/
- private ReportGenerator() {
- // do nothing
+ private static void addTocElement(ReadableExecutedTestCase el,
+ PdfPTable toc, int depth) {
+
+ PdfPCell idCell = new PdfPCell(new Phrase(el.getId() + ""));
+
+ PdfPCell nameOfElement = new PdfPCell(new Phrase(el.getName()));
+
+ // do not indent more than 5 times, otherwise, sooner or later it will
+ // need two lines
+ nameOfElement.setPaddingLeft(depth < 5 ? TOC_INDENTATION * depth
+ : TOC_INDENTATION * 5);
+
+ PdfPCell success = new PdfPCell();
+
+ Chunk pageNumber = new Chunk("" + pageMapping.get(el.getId()));
+
+ pageNumber.setLocalGoto("elementnav" + el.getId());
+
+ PdfPCell page = new PdfPCell(new Phrase(pageNumber));
+ page.setHorizontalAlignment(Element.ALIGN_RIGHT);
+
+ idCell.setBorder(0);
+ nameOfElement.setBorder(0);
+ success.setBorder(0);
+ page.setBorder(0);
+
+ Chunk successChunk;
+ switch (((ExecutedTestCase) el).getSuccess()) {
+ case ExecutedTestCase.SUCCESS_OK:
+ successChunk = new Chunk(lH.getMessage("EXP_TOC_OK"));
+ successChunk.setBackground(okColor);
+ break;
+ case ExecutedTestCase.SUCCESS_OK_COMMENT:
+ successChunk = new Chunk(lH.getMessage("EXP_TOC_OK_COMMENT"));
+ successChunk.setBackground(okCommentColor);
+ break;
+ case ExecutedTestCase.SUCCESS_NOT_OK:
+ successChunk = new Chunk(lH.getMessage("EXP_TOC_NOT_OK"));
+ successChunk.setBackground(notOkColor);
+ break;
+ default:
+ successChunk = new Chunk(lH.getMessage("EXP_TOC_NOT_SET"));
+ break;
+ }
+
+ success.setPhrase(new Phrase(successChunk));
+ toc.addCell(idCell);
+ toc.addCell(nameOfElement);
+ toc.addCell(success);
+ toc.addCell(page);
+
}
/**
+ * Adds an executed test sequence to the table of contents.
+ *
+ * @param executedTestSequence
+ * Element for which the entry in the TOC is to be created.
+ * @param toc
+ * Table to add the cells to.
+ * @param depth
+ * Depth in the tree.
+ */
+ private static void addTocElement(
+ ReadableExecutedTestSequence executedTestSequence, PdfPTable toc,
+ int depth) {
+
+ PdfPCell idCell = new PdfPCell(new Phrase(executedTestSequence.getId()
+ + ""));
+
+ PdfPCell nameOfElement = new PdfPCell(new Phrase(executedTestSequence
+ .getName(), boldFont));
+ nameOfElement.setPaddingLeft(depth < 5 ? TOC_INDENTATION * depth
+ : TOC_INDENTATION * 5);
+
+ // empty here, but needed to remove the border
+ PdfPCell success = new PdfPCell(new Phrase(""));
+
+ Chunk pageNumber = new Chunk(""
+ + pageMapping.get(executedTestSequence.getId()));
+
+ pageNumber.setLocalGoto("elementnav" + executedTestSequence.getId());
+
+ PdfPCell page = new PdfPCell(new Phrase(pageNumber));
+ page.setHorizontalAlignment(Element.ALIGN_RIGHT);
+
+ idCell.setBorder(0);
+ nameOfElement.setBorder(0);
+ success.setBorder(0);
+ page.setBorder(0);
+
+ toc.addCell(idCell);
+ toc.addCell(nameOfElement);
+ toc.addCell(success);
+ toc.addCell(page);
+
+ for (TestElement el : (ExecutedTestSequence) executedTestSequence) {
+ if (el instanceof ExecutedTestSequence) {
+ addTocElement((ReadableExecutedTestSequence) el, toc, depth + 1);
+ } else if (el instanceof ExecutedTestCase) {
+ addTocElement((ExecutedTestCase) el, toc, depth + 1);
+ }
+ }
+ }
+
+ /**
+ * Converts a length in centimeters to a length in points. It is assumed
+ * that the PDF is rendered with 72 dpi.
+ *
+ * @param cm
+ * to convert to centimeter
+ * @return centimeteras length in points.
+ */
+ public static float cmToPt(float cm) {
+ return ((cm / 2.54f) * 72.0f);
+ }
+
+ /**
+ * Creates a table of contents for an execution.
+ *
+ * @param execution
+ * The execution that is exported.
+ * @param doc
+ * Document in which to add the TOC.
+ */
+ private static void createTableOfContents(TestExecution execution,
+ Document doc) {
+
+ // percentages for column widths
+ float[] widths = { 0.15f, 0.5f, 0.25f, 0.1f };
+ PdfPTable TOC = new PdfPTable(widths);
+
+ PdfPCell idCell = new PdfPCell(new Phrase(lH.getMessage("EXP_TOC_ID")));
+ PdfPCell nameOfElement = new PdfPCell(new Phrase(lH
+ .getMessage("EXP_TOC_NAME")));
+ PdfPCell success = new PdfPCell(new Phrase(lH
+ .getMessage("EXP_TOC_SUCCESS")));
+
+ PdfPCell page = new PdfPCell(new Phrase(lH.getMessage("EXP_TOC_PAGE")));
+ page.setHorizontalAlignment(Element.ALIGN_RIGHT);
+
+ idCell.disableBorderSide(Rectangle.TOP | Rectangle.LEFT);
+ nameOfElement.disableBorderSide(Rectangle.TOP);
+ success.disableBorderSide(Rectangle.TOP);
+ page.disableBorderSide(Rectangle.TOP | Rectangle.RIGHT);
+
+ TOC.addCell(idCell);
+ TOC.addCell(nameOfElement);
+ TOC.addCell(success);
+ TOC.addCell(page);
+
+ addTocElement(execution.getExecutedTestSequence(), TOC, 0);
+
+ try {
+ doc.add(TOC);
+ } catch (DocumentException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Singleton handling method.
+ *
+ * @return Existing or newly created singleton instance.
+ */
+ public static ReportGenerator getInstance() {
+
+ if (theInstance == null) {
+ theInstance = new ReportGenerator();
+ }
+
+ return theInstance;
+ }
+
+ /**
+ * Converts a length given in pt to cm. The conversion assumes that 72 dpi
+ * are used for rendering.
+ *
+ * @param pt
+ * to convert to cm
+ * @return pt length in cm
+ */
+ public static float ptToCm(float pt) {
+ // 72 pt = 1 inch = 2.54 cm
+ return ((pt / 72.0f) * 2.54f);
+ }
+
+ /**
* Exports a <code>{@link TestExecution}</code> to PDF.
- *
+ *
* @param execution
* The execution to be exported.
* @param projectName
@@ -226,7 +373,6 @@
Document doc = new Document(PageSize.A4, 62f, 36f, 56f, 70f);
try {
-
pageMapping.clear();
isTOCPages = false;
@@ -245,7 +391,6 @@
Rectangle pageRect = doc.getPageSize();
- pageHeight = ptToCm(pageRect.getHeight());
pageWidth = ptToCm(pageRect.getWidth());
// Creating some fonts used for headings
@@ -327,7 +472,7 @@
int lenOfTOC = totalPages - beforeTableIndex;
// CAUTION:
- // Base of array stats with 0,
+ // Base of array starts with 0,
// but array as pointer starts with page 1.
int[] reorder = new int[totalPages];
@@ -349,172 +494,20 @@
} catch (FileNotFoundException e) {
throw e;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
}
/**
- * Creates a table of contents for an execution.
- *
- * @param execution
- * The execution that is exported.
- * @param doc
- * Document in which to add the TOC.
+ *...
[truncated message content] |